Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spi_bitbang: short transfer status fix

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]
Signed-off-by: Jan Nikitenko <jan.nikitenko@gmail.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jan Nikitenko and committed by
Linus Torvalds
2cfb8ce8 40369e1c

+5 -3
+5 -3
drivers/spi/spi_bitbang.c
··· 344 344 t->rx_dma = t->tx_dma = 0; 345 345 status = bitbang->txrx_bufs(spi, t); 346 346 } 347 + if (status > 0) 348 + m->actual_length += status; 347 349 if (status != t->len) { 348 - if (status > 0) 349 - status = -EMSGSIZE; 350 + /* always report some kind of error */ 351 + if (status >= 0) 352 + status = -EREMOTEIO; 350 353 break; 351 354 } 352 - m->actual_length += status; 353 355 status = 0; 354 356 355 357 /* protocol tweaks before next transfer */