Skip to contentSkip to conversation

spi_bitbang: short transfer status fix

PATCH New David Brownell 1 participant 1 message Mar 11, 2008 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi_bitbang: short transfer status fix

From: Jan Nikitenko <[email protected]>

SPI controller drivers return number of bytes actually transfered from bitbang->txrx_bufs() method. This updates handling of short transfers (where the transfer size is less than requested):

- Even zero byte short transfers should report errors;
- Include short transfers in the total of transferred bytes;
- Use EREMOTEIO (like USB) not EMSGSIZE to report short transfers

Short transfers don't normally mean invalid message sizes, but if the underlying controller driver needs to use EMSGSIZE it can still do so.

[db: fix two more minor issues]
---
 drivers/spi/spi_bitbang.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/spi/spi_bitbang.c +5 -3
@@ -343,12 +343,14 @@ static void bitbang_work(struct work_str
 					t->rx_dma = t->tx_dma = 0;
 				status = bitbang->txrx_bufs(spi, t);
 			}
+			if (status > 0)
+				m->actual_length += status;
 			if (status != t->len) {
-				if (status > 0)
-					status = -EMSGSIZE;
+				/* always report some kind of error */
+				if (status >= 0)
+					status = -EREMOTEIO;
 				break;
 			}
-			m->actual_length += status;
 			status = 0;
 
 			/* protocol tweaks before next transfer */

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/