summaryrefslogtreecommitdiff
path: root/drivers/spi
diff options
context:
space:
mode:
authorMarc Pignat <marc.pignat@hevs.ch>2007-12-04 23:45:10 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-12-05 09:21:18 -0800
commit9b938b749065d6a94172ac24d9748bd66a03da4c (patch)
treed5f3540224235751a492c8be8003c331263fe51a /drivers/spi
parent3f86f14c0fc9fdb0984e64209df2f47895a07151 (diff)
downloadlinux-stable-9b938b749065d6a94172ac24d9748bd66a03da4c.tar.gz
linux-stable-9b938b749065d6a94172ac24d9748bd66a03da4c.tar.bz2
linux-stable-9b938b749065d6a94172ac24d9748bd66a03da4c.zip
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')
-rw-r--r--drivers/spi/spi.c13
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)
* Also, the caller is guaranteeing that the memory associated with the
* message will not be freed before this call returns.
*
- * The return value is a negative error code if the message could not be
- * submitted, else zero. When the value is zero, then message->status is
- * also defined; it's the completion code for the transfer, either zero
- * or a negative error code from the controller driver.
+ * It returns zero on success, else a negative error code.
*/
int spi_sync(struct spi_device *spi, struct spi_message *message)
{
@@ -554,8 +551,10 @@ int spi_sync(struct spi_device *spi, struct spi_message *message)
message->complete = spi_complete;
message->context = &done;
status = spi_async(spi, message);
- if (status == 0)
+ if (status == 0) {
wait_for_completion(&done);
+ status = message->status;
+ }
message->context = NULL;
return status;
}
@@ -628,10 +627,8 @@ int spi_write_then_read(struct spi_device *spi,
/* do the i/o */
status = spi_sync(spi, &message);
- if (status == 0) {
+ if (status == 0)
memcpy(rxbuf, x[1].rx_buf, n_rx);
- status = message.status;
- }
if (x[0].tx_buf == buf)
mutex_unlock(&lock);