aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-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)
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 */
549int spi_sync(struct spi_device *spi, struct spi_message *message) 546int 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);