Skip to content

Commit b7c35fb

Browse files
decsnynashif
authored andcommitted
drivers: spi_mcux_lpspi: Remove rtio prepare_start
Remove unneeded prepare_start function since all uses of it are paired with the start function. Also, probably should not mess with chip select before deciding to do the transfer. And just return on some error like the rest of the driver does instead of assert. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
1 parent d6a6b11 commit b7c35fb

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

drivers/spi/spi_mcux_lpspi.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -527,20 +527,6 @@ static int transceive_dma(const struct device *dev, const struct spi_config *spi
527527
#endif /* CONFIG_SPI_MCUX_LPSPI_DMA */
528528

529529
#ifdef CONFIG_SPI_RTIO
530-
static inline void spi_mcux_iodev_prepare_start(const struct device *dev)
531-
{
532-
struct spi_mcux_data *data = dev->data;
533-
struct spi_rtio *rtio_ctx = data->rtio_ctx;
534-
struct spi_dt_spec *spi_dt_spec = rtio_ctx->txn_curr->sqe.iodev->data;
535-
struct spi_config *spi_config = &spi_dt_spec->config;
536-
int err;
537-
538-
err = spi_mcux_configure(dev, spi_config);
539-
__ASSERT(!err, "%d", err);
540-
541-
spi_context_cs_control(&data->ctx, true);
542-
}
543-
544530
static void spi_mcux_iodev_start(const struct device *dev)
545531
{
546532
struct spi_mcux_data *data = dev->data;
@@ -552,6 +538,12 @@ static void spi_mcux_iodev_start(const struct device *dev)
552538
lpspi_transfer_t transfer;
553539
status_t status;
554540

541+
status = spi_mcux_configure(dev, spi_cfg);
542+
if (status) {
543+
LOG_ERR("Error configuring lpspi");
544+
return;
545+
}
546+
555547
transfer.configFlags = LPSPI_MASTER_XFER_CFG_FLAGS(spi_cfg->slave);
556548

557549
switch (sqe->op) {
@@ -583,6 +575,8 @@ static void spi_mcux_iodev_start(const struct device *dev)
583575

584576
data->transfer_len = transfer.dataSize;
585577

578+
spi_context_cs_control(&data->ctx, true);
579+
586580
status = LPSPI_MasterTransferNonBlocking(base, &data->handle, &transfer);
587581
if (status != kStatus_Success) {
588582
LOG_ERR("Transfer could not start on %s: %d", dev->name, status);
@@ -605,7 +599,6 @@ static void spi_mcux_iodev_complete(const struct device *dev, int status)
605599
spi_context_cs_control(&data->ctx, false);
606600

607601
if (spi_rtio_complete(rtio_ctx, status)) {
608-
spi_mcux_iodev_prepare_start(dev);
609602
spi_mcux_iodev_start(dev);
610603
}
611604
}
@@ -616,7 +609,6 @@ static void spi_mcux_iodev_submit(const struct device *dev, struct rtio_iodev_sq
616609
struct spi_rtio *rtio_ctx = data->rtio_ctx;
617610

618611
if (spi_rtio_submit(rtio_ctx, iodev_sqe)) {
619-
spi_mcux_iodev_prepare_start(dev);
620612
spi_mcux_iodev_start(dev);
621613
}
622614
}

0 commit comments

Comments
 (0)