[PATCH v2 1/6] spi: cadence-xspi: Properly handle errors in .transfer_one_message
From: Paul Cercueil
Date: Wed Nov 11 2026 - 05:41:42 EST
From: Tanmay Jagdale <tanmay@xxxxxxxxxxx>
The cdns_xspi_transfer_one_message_b0() function was not setting
m->status on error, causing it to be stuck at -EINPROGRESS, confusing
the SPI core.
Fixes: 931e389ded0f ("spi: cadence: Add Marvell xfer operation support")
Signed-off-by: Tanmay Jagdale <tanmay@xxxxxxxxxxx>
Co-developed-by: Paul Cercueil <paul.cercueil@xxxxxxxxxxx>
Signed-off-by: Paul Cercueil <paul.cercueil@xxxxxxxxxxx>
---
v2: New patch
---
drivers/spi/spi-cadence-xspi.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index 3687853e4ce4..a584a3c395d0 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -1112,6 +1112,7 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
int current_transfer_len;
int cs = spi_get_chipselect(spi, 0);
int cs_change = 0;
+ int ret = -EIO;
/* Enable xfer state machine */
if (!cdns_xspi->xfer_in_progress) {
@@ -1152,7 +1153,7 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
false, cmd_regs);
cdns_xspi_trigger_command(cdns_xspi, cmd_regs);
if (!cdns_xspi_is_stig_ready(cdns_xspi, true))
- return -EIO;
+ goto out;
} else {
cdns_xspi_prepare_generic(cs, txd, 1, true, cmd_regs);
cdns_xspi_trigger_command(cdns_xspi, cmd_regs);
@@ -1161,11 +1162,11 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
cdns_xspi_trigger_command(cdns_xspi, cmd_regs);
cdns_xspi->sdma_xfer_len = current_transfer_len - 1;
if (!cdns_xspi_is_sdma_ready(cdns_xspi, true))
- return -EIO;
+ goto out;
if (cdns_xspi->sdma_handler(cdns_xspi))
- return -EIO;
+ goto out;
if (!cdns_xspi_is_stig_ready(cdns_xspi, true))
- return -EIO;
+ goto out;
if (rxd)
cdns_xspi->in_buffer += current_transfer_len;
@@ -1202,10 +1203,15 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,
cdns_xspi->xfer_in_progress = false;
}
- m->status = 0;
+ ret = 0;
+
+out:
+ if (m->status == -EINPROGRESS)
+ m->status = ret;
+
spi_finalize_current_message(controller);
- return 0;
+ return ret;
}
#endif
--
2.47.3