diff options
author | Marc Pignat <marc.pignat@hevs.ch> | 2007-12-05 02:45:10 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-12-05 12:21:18 -0500 |
commit | 9b938b749065d6a94172ac24d9748bd66a03da4c (patch) | |
tree | d5f3540224235751a492c8be8003c331263fe51a /drivers/spi/spi.c | |
parent | 3f86f14c0fc9fdb0984e64209df2f47895a07151 (diff) |
spi: simplify spi_sync() calling convention
Simplify spi_sync calling convention, eliminating the need to check both
the return value AND the message->status. In consequence, this corrects
misbehaviours of spi_read and spi_write (which only checked the former) and
their callers.
Signed-off-by: Marc Pignat <marc.pignat@hevs.ch>
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>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 6ca07c9929e6..93e9de46977a 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -541,10 +541,7 @@ static void spi_complete(void *arg) | |||
541 | * Also, the caller is guaranteeing that the memory associated with the | 541 | * Also, the caller is guaranteeing that the memory associated with the |
542 | * message will not be freed before this call returns. | 542 | * message will not be freed before this call returns. |
543 | * | 543 | * |
544 | * The return value is a negative error code if the message could not be | 544 | * It returns zero on success, else a negative error code. |
545 | * submitted, else zero. When the value is zero, then message->status is | ||
546 | * also defined; it's the completion code for the transfer, either zero | ||
547 | * or a negative error code from the controller driver. | ||
548 | */ | 545 | */ |
549 | int spi_sync(struct spi_device *spi, struct spi_message *message) | 546 | int spi_sync(struct spi_device *spi, struct spi_message *message) |
550 | { | 547 | { |
@@ -554,8 +551,10 @@ int spi_sync(struct spi_device *spi, struct spi_message *message) | |||
554 | message->complete = spi_complete; | 551 | message->complete = spi_complete; |
555 | message->context = &done; | 552 | message->context = &done; |
556 | status = spi_async(spi, message); | 553 | status = spi_async(spi, message); |
557 | if (status == 0) | 554 | if (status == 0) { |
558 | wait_for_completion(&done); | 555 | wait_for_completion(&done); |
556 | status = message->status; | ||
557 | } | ||
559 | message->context = NULL; | 558 | message->context = NULL; |
560 | return status; | 559 | return status; |
561 | } | 560 | } |
@@ -628,10 +627,8 @@ int spi_write_then_read(struct spi_device *spi, | |||
628 | 627 | ||
629 | /* do the i/o */ | 628 | /* do the i/o */ |
630 | status = spi_sync(spi, &message); | 629 | status = spi_sync(spi, &message); |
631 | if (status == 0) { | 630 | if (status == 0) |
632 | memcpy(rxbuf, x[1].rx_buf, n_rx); | 631 | memcpy(rxbuf, x[1].rx_buf, n_rx); |
633 | status = message.status; | ||
634 | } | ||
635 | 632 | ||
636 | if (x[0].tx_buf == buf) | 633 | if (x[0].tx_buf == buf) |
637 | mutex_unlock(&lock); | 634 | mutex_unlock(&lock); |