Skip to content

Commit

Permalink
spi: core: make zero length transfer valid again
Browse files Browse the repository at this point in the history
Zero length transfer becomes invalid since
"spi: core: Validate length of the transfers in message" commit,
but it should be valid to support an odd device, for example, which
requires long delay between chipselect and the first transfer, etc.

Signed-off-by: Atsushi Nemoto <[email protected]>
Tested-by: Thierry Reding <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
atsushi-nemoto authored and broonie committed Mar 4, 2014
1 parent f97b26b commit 6ea3129
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
{
struct spi_master *master = spi->master;
struct spi_transfer *xfer;
int w_size, n_words;
int w_size;

if (list_empty(&message->transfers))
return -EINVAL;
Expand Down Expand Up @@ -1680,9 +1680,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
else
w_size = 4;

n_words = xfer->len / w_size;
/* No partial transfers accepted */
if (!n_words || xfer->len % w_size)
if (xfer->len % w_size)
return -EINVAL;

if (xfer->speed_hz && master->min_speed_hz &&
Expand Down

0 comments on commit 6ea3129

Please sign in to comment.