spi: mxic: Fix transmit path
Subsystems (2)
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")
Suggested-by Mason Yang <[email protected]>
Signed-off-by Miquel Raynal <[email protected]>
--- drivers/spi/spi-mxic.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/spi/spi-mxic.c +12 -16
@@ -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
Mark Brown
maintainerQuoted 3 lines · Miquel Raynal
In certain circumstances, it is needed to check
INT_TX_EMPTYandINT_RX_NOT_EMPTYin 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?