Skip to content

Commit

Permalink
spi_bitbang: short transfer status fix
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jan Nikitenko authored and Linus Torvalds committed Mar 13, 2008
1 parent 40369e1 commit 2cfb8ce
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/spi/spi_bitbang.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,14 @@ static void bitbang_work(struct work_struct *work)
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 */
Expand Down

0 comments on commit 2cfb8ce

Please sign in to comment.