Skip to content

Commit feed9ba

Browse files
Kalle ValoLinus Torvalds
authored andcommitted
spi: omap2_mcspi PIO RX fix
Before transmission of the last word in PIO RX_ONLY mode rx+tx mode is enabled: /* prevent last RX_ONLY read from triggering * more word i/o: switch to rx+tx */ if (c == 0 && tx == NULL) mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCONF0, l); But because c is decremented after the test, c will never be zero and rx+tx will not be enabled. This breaks RX_ONLY mode PIO transfers. Fix it by decrementing c in the beginning of the various I/O loops. Signed-off-by: Kalle Valo <[email protected]> Signed-off-by: David Brownell <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent dbcc2ec commit feed9ba

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/spi/omap2_mcspi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
350350
tx = xfer->tx_buf;
351351

352352
do {
353+
c -= 1;
353354
if (tx != NULL) {
354355
if (mcspi_wait_for_reg_bit(chstat_reg,
355356
OMAP2_MCSPI_CHSTAT_TXS) < 0) {
@@ -380,7 +381,6 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
380381
word_len, *(rx - 1));
381382
#endif
382383
}
383-
c -= 1;
384384
} while (c);
385385
} else if (word_len <= 16) {
386386
u16 *rx;
@@ -389,6 +389,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
389389
rx = xfer->rx_buf;
390390
tx = xfer->tx_buf;
391391
do {
392+
c -= 2;
392393
if (tx != NULL) {
393394
if (mcspi_wait_for_reg_bit(chstat_reg,
394395
OMAP2_MCSPI_CHSTAT_TXS) < 0) {
@@ -419,7 +420,6 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
419420
word_len, *(rx - 1));
420421
#endif
421422
}
422-
c -= 2;
423423
} while (c);
424424
} else if (word_len <= 32) {
425425
u32 *rx;
@@ -428,6 +428,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
428428
rx = xfer->rx_buf;
429429
tx = xfer->tx_buf;
430430
do {
431+
c -= 4;
431432
if (tx != NULL) {
432433
if (mcspi_wait_for_reg_bit(chstat_reg,
433434
OMAP2_MCSPI_CHSTAT_TXS) < 0) {
@@ -458,7 +459,6 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
458459
word_len, *(rx - 1));
459460
#endif
460461
}
461-
c -= 4;
462462
} while (c);
463463
}
464464

0 commit comments

Comments
 (0)