arch/xtensa/esp32: style fixes in SPI driver

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
Petro Karashchenko
2023-01-25 23:00:01 +02:00
committed by Xiang Xiao
parent e3a8e1e3ef
commit c415ce518f
2 changed files with 65 additions and 60 deletions
+59 -53
View File
@@ -295,9 +295,9 @@ static const struct spi_ops_s esp32_spi2_ops =
static struct esp32_spi_priv_s esp32_spi2_priv = static struct esp32_spi_priv_s esp32_spi2_priv =
{ {
.spi_dev = .spi_dev =
{ {
.ops = &esp32_spi2_ops .ops = &esp32_spi2_ops
}, },
.config = &esp32_spi2_config, .config = &esp32_spi2_config,
.lock = NXMUTEX_INITIALIZER, .lock = NXMUTEX_INITIALIZER,
.sem_isr = SEM_INITIALIZER(0), .sem_isr = SEM_INITIALIZER(0),
@@ -372,9 +372,9 @@ static const struct spi_ops_s esp32_spi3_ops =
static struct esp32_spi_priv_s esp32_spi3_priv = static struct esp32_spi_priv_s esp32_spi3_priv =
{ {
.spi_dev = .spi_dev =
{ {
.ops = &esp32_spi3_ops .ops = &esp32_spi3_ops
}, },
.config = &esp32_spi3_config, .config = &esp32_spi3_config,
.lock = NXMUTEX_INITIALIZER, .lock = NXMUTEX_INITIALIZER,
.sem_isr = SEM_INITIALIZER(0), .sem_isr = SEM_INITIALIZER(0),
@@ -563,9 +563,8 @@ static void esp32_spi_select(struct spi_dev_s *dev,
{ {
#ifdef CONFIG_ESP32_SPI_SWCS #ifdef CONFIG_ESP32_SPI_SWCS
struct esp32_spi_priv_s *priv = (struct esp32_spi_priv_s *)dev; struct esp32_spi_priv_s *priv = (struct esp32_spi_priv_s *)dev;
bool value = selected ? false : true;
esp32_gpiowrite(priv->config->cs_pin, value); esp32_gpiowrite(priv->config->cs_pin, !selected);
#endif #endif
spiinfo("devid: %08" PRIx32 " CS: %s\n", spiinfo("devid: %08" PRIx32 " CS: %s\n",
@@ -674,11 +673,11 @@ static uint32_t esp32_spi_setfrequency(struct spi_dev_s *dev,
* Set the SPI mode. * Set the SPI mode.
* *
* Input Parameters: * Input Parameters:
* dev - Device-specific state data * dev - Device-specific state data
* mode - The SPI mode requested * mode - The requested SPI mode
* *
* Returned Value: * Returned Value:
* none * None.
* *
****************************************************************************/ ****************************************************************************/
@@ -753,14 +752,14 @@ static void esp32_spi_setmode(struct spi_dev_s *dev,
* Name: esp32_spi_setbits * Name: esp32_spi_setbits
* *
* Description: * Description:
* Set the number if bits per word. * Set the number of bits per word.
* *
* Input Parameters: * Input Parameters:
* dev - Device-specific state data * dev - Device-specific state data
* nbits - The number of bits in an SPI word. * nbits - The number of bits in an SPI word.
* *
* Returned Value: * Returned Value:
* none * None.
* *
****************************************************************************/ ****************************************************************************/
@@ -816,7 +815,7 @@ static int esp32_spi_hwfeatures(struct spi_dev_s *dev,
* uint16_t's * uint16_t's
* *
* Returned Value: * Returned Value:
* None * None.
* *
****************************************************************************/ ****************************************************************************/
@@ -966,11 +965,11 @@ static void esp32_spi_dma_exchange(struct esp32_spi_priv_s *priv,
* *
* Input Parameters: * Input Parameters:
* priv - SPI private state data * priv - SPI private state data
* wd - The word to send. the size of the data is determined by the * wd - The word to send. The size of the data is determined by the
* number of bits selected for the SPI interface. * number of bits selected for the SPI interface.
* *
* Returned Value: * Returned Value:
* Received value * Received value.
* *
****************************************************************************/ ****************************************************************************/
@@ -997,7 +996,7 @@ static uint32_t esp32_spi_poll_send(struct esp32_spi_priv_s *priv,
val = getreg32(spi_w0_reg); val = getreg32(spi_w0_reg);
spiinfo("send=%x and recv=%x\n", wd, val); spiinfo("send=0x%" PRIx32 " and recv=0x%" PRIx32 "\n", wd, val);
return val; return val;
} }
@@ -1010,11 +1009,11 @@ static uint32_t esp32_spi_poll_send(struct esp32_spi_priv_s *priv,
* *
* Input Parameters: * Input Parameters:
* dev - Device-specific state data * dev - Device-specific state data
* wd - The word to send. the size of the data is determined by the * wd - The word to send. The size of the data is determined by the
* number of bits selected for the SPI interface. * number of bits selected for the SPI interface.
* *
* Returned Value: * Returned Value:
* Received value * Received value.
* *
****************************************************************************/ ****************************************************************************/
@@ -1035,14 +1034,14 @@ static uint32_t esp32_spi_send(struct spi_dev_s *dev, uint32_t wd)
* priv - SPI private state data * priv - SPI private state data
* txbuffer - A pointer to the buffer of data to be sent * txbuffer - A pointer to the buffer of data to be sent
* rxbuffer - A pointer to the buffer in which to receive data * rxbuffer - A pointer to the buffer in which to receive data
* nwords - the length of data that to be exchanged in units of words. * nwords - The length of data that to be exchanged in units of words.
* The wordsize is determined by the number of bits-per-word * The wordsize is determined by the number of bits-per-word
* selected for the SPI interface. If nbits <= 8, the data is * selected for the SPI interface. If nbits <= 8, the data is
* packed into uint8_t's; if nbits >8, the data is packed into * packed into uint8_t's; if nbits >8, the data is packed into
* uint16_t's * uint16_t's
* *
* Returned Value: * Returned Value:
* None * None.
* *
****************************************************************************/ ****************************************************************************/
@@ -1163,14 +1162,14 @@ static void esp32_spi_poll_exchange(struct esp32_spi_priv_s *priv,
* dev - Device-specific state data * dev - Device-specific state data
* txbuffer - A pointer to the buffer of data to be sent * txbuffer - A pointer to the buffer of data to be sent
* rxbuffer - A pointer to the buffer in which to receive data * rxbuffer - A pointer to the buffer in which to receive data
* nwords - the length of data that to be exchanged in units of words. * nwords - The length of data that to be exchanged in units of words.
* The wordsize is determined by the number of bits-per-word * The wordsize is determined by the number of bits-per-word
* selected for the SPI interface. If nbits <= 8, the data is * selected for the SPI interface. If nbits <= 8, the data is
* packed into uint8_t's; if nbits >8, the data is packed into * packed into uint8_t's; if nbits >8, the data is packed into
* uint16_t's * uint16_t's
* *
* Returned Value: * Returned Value:
* None * None.
* *
****************************************************************************/ ****************************************************************************/
@@ -1206,16 +1205,16 @@ static void esp32_spi_exchange(struct spi_dev_s *dev,
* Send a block of data on SPI. * Send a block of data on SPI.
* *
* Input Parameters: * Input Parameters:
* dev - Device-specific state data * dev - Device-specific state data
* buffer - A pointer to the buffer of data to be sent * txbuffer - A pointer to the buffer of data to be sent
* nwords - the length of data to send from the buffer in number of words. * nwords - The length of data to send from the buffer in number of
* The wordsize is determined by the number of bits-per-word * words. The wordsize is determined by the number of
* selected for the SPI interface. If nbits <= 8, the data is * bits-per-word selected for the SPI interface. If nbits <= 8,
* packed into uint8_t's; if nbits >8, the data is packed into * the data is packed into uint8_t's; if nbits >8, the data is
* uint16_t's * packed into uint16_t's
* *
* Returned Value: * Returned Value:
* None * None.
* *
****************************************************************************/ ****************************************************************************/
@@ -1235,16 +1234,16 @@ static void esp32_spi_sndblock(struct spi_dev_s *dev,
* Receive a block of data from SPI. * Receive a block of data from SPI.
* *
* Input Parameters: * Input Parameters:
* dev - Device-specific state data * dev - Device-specific state data
* buffer - A pointer to the buffer in which to receive data * rxbuffer - A pointer to the buffer in which to receive data
* nwords - the length of data that can be received in the buffer in number * nwords - The length of data that can be received in the buffer in
* of words. The wordsize is determined by the number of bits- * number of words. The wordsize is determined by the number of
* per-word selected for the SPI interface. If nbits <= 8, the * bits-per-word selected for the SPI interface. If nbits <= 8,
* data is packed into uint8_t's; if nbits >8, the data is packed * the data is packed into uint8_t's; if nbits >8, the data is
* into uint16_t's * packed into uint16_t's
* *
* Returned Value: * Returned Value:
* None * None.
* *
****************************************************************************/ ****************************************************************************/
@@ -1409,7 +1408,7 @@ static void esp32_spi_init(struct spi_dev_s *dev)
* dev - Device-specific state data * dev - Device-specific state data
* *
* Returned Value: * Returned Value:
* None * None.
* *
****************************************************************************/ ****************************************************************************/
@@ -1436,10 +1435,12 @@ static void esp32_spi_deinit(struct spi_dev_s *dev)
* Name: esp32_spi_interrupt * Name: esp32_spi_interrupt
* *
* Description: * Description:
* Common SPI DMA interrupt handler * Common SPI DMA interrupt handler.
* *
* Input Parameters: * Input Parameters:
* arg - SPI controller private data * irq - Number of the IRQ that generated the interrupt
* context - Interrupt register state save info
* arg - SPI controller private data
* *
* Returned Value: * Returned Value:
* Standard interrupt return value. * Standard interrupt return value.
@@ -1460,13 +1461,13 @@ static int esp32_spi_interrupt(int irq, void *context, void *arg)
* Name: esp32_spibus_initialize * Name: esp32_spibus_initialize
* *
* Description: * Description:
* Initialize the selected SPI bus * Initialize the selected SPI bus.
* *
* Input Parameters: * Input Parameters:
* Port number (for hardware that has multiple SPI interfaces) * port - Port number (for hardware that has multiple SPI interfaces)
* *
* Returned Value: * Returned Value:
* Valid SPI device structure reference on success; a NULL on failure * Valid SPI device structure reference on success; NULL on failure.
* *
****************************************************************************/ ****************************************************************************/
@@ -1492,14 +1493,13 @@ struct spi_dev_s *esp32_spibus_initialize(int port)
return NULL; return NULL;
} }
nxmutex_lock(&priv->lock);
spi_dev = (struct spi_dev_s *)priv; spi_dev = (struct spi_dev_s *)priv;
nxmutex_lock(&priv->lock);
if (priv->refs != 0) if (priv->refs != 0)
{ {
priv->refs++; priv->refs++;
nxmutex_unlock(&priv->lock); nxmutex_unlock(&priv->lock);
return spi_dev; return spi_dev;
} }
@@ -1540,7 +1540,13 @@ struct spi_dev_s *esp32_spibus_initialize(int port)
* Name: esp32_spibus_uninitialize * Name: esp32_spibus_uninitialize
* *
* Description: * Description:
* Uninitialize an SPI bus * Uninitialize an SPI bus.
*
* Input Parameters:
* dev - Device-specific state data
*
* Returned Value:
* Zero (OK) is returned on success. Otherwise -1 (ERROR).
* *
****************************************************************************/ ****************************************************************************/
+6 -7
View File
@@ -39,7 +39,6 @@
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <nuttx/clock.h> #include <nuttx/clock.h>
#include <nuttx/mutex.h> #include <nuttx/mutex.h>
#include <nuttx/semaphore.h>
#include <nuttx/spi/spi.h> #include <nuttx/spi/spi.h>
#include <arch/board/board.h> #include <arch/board/board.h>
@@ -291,9 +290,9 @@ static const struct spi_ops_s esp32s3_spi2_ops =
static struct esp32s3_spi_priv_s esp32s3_spi2_priv = static struct esp32s3_spi_priv_s esp32s3_spi2_priv =
{ {
.spi_dev = .spi_dev =
{ {
.ops = &esp32s3_spi2_ops .ops = &esp32s3_spi2_ops
}, },
.config = &esp32s3_spi2_config, .config = &esp32s3_spi2_config,
.refs = 0, .refs = 0,
.lock = NXMUTEX_INITIALIZER, .lock = NXMUTEX_INITIALIZER,
@@ -366,9 +365,9 @@ static const struct spi_ops_s esp32s3_spi3_ops =
static struct esp32s3_spi_priv_s esp32s3_spi3_priv = static struct esp32s3_spi_priv_s esp32s3_spi3_priv =
{ {
.spi_dev = .spi_dev =
{ {
.ops = &esp32s3_spi3_ops .ops = &esp32s3_spi3_ops
}, },
.config = &esp32s3_spi3_config, .config = &esp32s3_spi3_config,
.refs = 0, .refs = 0,
.lock = NXMUTEX_INITIALIZER, .lock = NXMUTEX_INITIALIZER,