drivers: spi_mcux_lpspi: Minor RTIO cleanup

Add closing comment for #ifdef and remove unnecessary
indentation of an else block. Also move the transcieve_rtio
function to be near the other rtio functions. And move function
prototypes to top of file.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
This commit is contained in:
Declan Snyder 2024-09-20 15:51:09 -05:00 committed by Anas Nashif
commit e21bf37f13

View file

@ -85,6 +85,13 @@ struct spi_mcux_data {
#endif #endif
}; };
#ifdef CONFIG_SPI_RTIO
static void spi_mcux_iodev_complete(const struct device *dev, int status);
static inline int transceive_rtio(const struct device *dev, const struct spi_config *spi_cfg,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs);
#endif
static int spi_mcux_transfer_next_packet(const struct device *dev) static int spi_mcux_transfer_next_packet(const struct device *dev)
{ {
/* const struct spi_mcux_config *config = dev->config; */ /* const struct spi_mcux_config *config = dev->config; */
@ -161,10 +168,6 @@ static void spi_mcux_isr(const struct device *dev)
#endif #endif
} }
#ifdef CONFIG_SPI_RTIO
static void spi_mcux_iodev_complete(const struct device *dev, int status);
#endif
static void spi_mcux_master_transfer_callback(LPSPI_Type *base, lpspi_master_handle_t *handle, static void spi_mcux_master_transfer_callback(LPSPI_Type *base, lpspi_master_handle_t *handle,
status_t status, void *userData) status_t status, void *userData)
{ {
@ -557,27 +560,6 @@ out:
#define lpspi_inst_has_dma(arg) arg != arg #define lpspi_inst_has_dma(arg) arg != arg
#endif /* CONFIG_SPI_MCUX_LPSPI_DMA */ #endif /* CONFIG_SPI_MCUX_LPSPI_DMA */
#ifdef CONFIG_SPI_RTIO
static inline int transceive_rtio(const struct device *dev, const struct spi_config *spi_cfg,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs)
{
struct spi_mcux_data *data = dev->data;
struct spi_rtio *rtio_ctx = data->rtio_ctx;
int ret;
spi_context_lock(&data->ctx, false, NULL, NULL, spi_cfg);
ret = spi_rtio_transceive(rtio_ctx, spi_cfg, tx_bufs, rx_bufs);
spi_context_release(&data->ctx, ret);
return ret;
}
#endif /* CONFIG_SPI_RTIO */
static int transceive(const struct device *dev, const struct spi_config *spi_cfg, static int transceive(const struct device *dev, const struct spi_config *spi_cfg,
const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs,
bool asynchronous, spi_callback_t cb, void *userdata) bool asynchronous, spi_callback_t cb, void *userdata)
@ -614,7 +596,6 @@ static int spi_mcux_transceive(const struct device *dev, const struct spi_config
#ifdef CONFIG_SPI_RTIO #ifdef CONFIG_SPI_RTIO
return transceive_rtio(dev, spi_cfg, tx_bufs, rx_bufs); return transceive_rtio(dev, spi_cfg, tx_bufs, rx_bufs);
#endif /* CONFIG_SPI_RTIO */ #endif /* CONFIG_SPI_RTIO */
#ifdef CONFIG_SPI_MCUX_LPSPI_DMA #ifdef CONFIG_SPI_MCUX_LPSPI_DMA
const struct spi_mcux_data *data = dev->data; const struct spi_mcux_data *data = dev->data;
@ -656,6 +637,22 @@ static int spi_mcux_release(const struct device *dev, const struct spi_config *s
} }
#ifdef CONFIG_SPI_RTIO #ifdef CONFIG_SPI_RTIO
static inline int transceive_rtio(const struct device *dev, const struct spi_config *spi_cfg,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs)
{
struct spi_mcux_data *data = dev->data;
struct spi_rtio *rtio_ctx = data->rtio_ctx;
int ret;
spi_context_lock(&data->ctx, false, NULL, NULL, spi_cfg);
ret = spi_rtio_transceive(rtio_ctx, spi_cfg, tx_bufs, rx_bufs);
spi_context_release(&data->ctx, ret);
return ret;
}
static inline void spi_mcux_iodev_prepare_start(const struct device *dev) static inline void spi_mcux_iodev_prepare_start(const struct device *dev)
{ {
@ -741,18 +738,18 @@ static void spi_mcux_iodev_complete(const struct device *dev, int status)
if (!status && rtio_ctx->txn_curr->sqe.flags & RTIO_SQE_TRANSACTION) { if (!status && rtio_ctx->txn_curr->sqe.flags & RTIO_SQE_TRANSACTION) {
rtio_ctx->txn_curr = rtio_txn_next(rtio_ctx->txn_curr); rtio_ctx->txn_curr = rtio_txn_next(rtio_ctx->txn_curr);
spi_mcux_iodev_start(dev); spi_mcux_iodev_start(dev);
} else { return;
/** De-assert CS-line to space from next transaction */ }
spi_context_cs_control(&data->ctx, false);
if (spi_rtio_complete(rtio_ctx, status)) { /** De-assert CS-line to space from next transaction */
spi_mcux_iodev_prepare_start(dev); spi_context_cs_control(&data->ctx, false);
spi_mcux_iodev_start(dev);
} if (spi_rtio_complete(rtio_ctx, status)) {
spi_mcux_iodev_prepare_start(dev);
spi_mcux_iodev_start(dev);
} }
} }
#endif /* CONFIG_SPI_RTIO */
#endif
#if defined(CONFIG_SPI_MCUX_LPSPI_DMA) #if defined(CONFIG_SPI_MCUX_LPSPI_DMA)
static int lpspi_dma_dev_ready(const struct device *dma_dev) static int lpspi_dma_dev_ready(const struct device *dma_dev)