Skip to contentSkip to conversation

spi: mxic: Fix transmit path

PATCH In review Miquel Raynal 2 participants 2 messages Sep 19, 2019 – Sep 20, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 spi: mxic: Fix transmit path

In certain circumstances, it is needed to check INT_TX_EMPTY and INT_RX_NOT_EMPTY in the transmit path, not only in the receive path. In both cases, the delay penalty is negligible.

Fixes b942d80b0a39 ("spi: Add MXIC controller driver")
---
 drivers/spi/spi-mxic.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/spi/spi-mxic.c +12 -16
index f48563c09b97..eaa7a6a9044d 100644
@@ -304,25 +304,21 @@ static int mxic_spi_data_xfer(struct mxic_spi *mxic, const void *txbuf,
 
 		writel(data, mxic->regs + TXD(nbytes % 4));
 
+		ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
+					 sts & INT_TX_EMPTY, 0, USEC_PER_SEC);
+		if (ret)
+			return ret;
+
+		ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
+					 sts & INT_RX_NOT_EMPTY, 0,
+					 USEC_PER_SEC);
+		if (ret)
+			return ret;
+
+		data = readl(mxic->regs + RXD);
 		if (rxbuf) {
-			ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
-						 sts & INT_TX_EMPTY, 0,
-						 USEC_PER_SEC);
-			if (ret)
-				return ret;
-
-			ret = readl_poll_timeout(mxic->regs + INT_STS, sts,
-						 sts & INT_RX_NOT_EMPTY, 0,
-						 USEC_PER_SEC);
-			if (ret)
-				return ret;
-
-			data = readl(mxic->regs + RXD);
 			data >>= (8 * (4 - nbytes));
 			memcpy(rxbuf + pos, &data, nbytes);
-			WARN_ON(readl(mxic->regs + INT_STS) & INT_RX_NOT_EMPTY);
-		} else {
-			readl(mxic->regs + RXD);
 		}
 		WARN_ON(readl(mxic->regs + INT_STS) & INT_RX_NOT_EMPTY);
 
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 3 lines · Miquel Raynal

In certain circumstances, it is needed to check INT_TX_EMPTY and INT_RX_NOT_EMPTY in the transmit path, not only in the receive path. In both cases, the delay penalty is negligible.

In which circumstances and why is this required?