summaryrefslogtreecommitdiff
path: root/drivers/spi/spidev.c
diff options
context:
space:
mode:
authorMartin Sperl <kernel@martin.sperl.org>2015-04-23 07:56:01 +0000
committerMark Brown <broonie@kernel.org>2015-04-23 10:34:39 +0100
commit98d6f479580013b42d179c30ff39107b6728ed82 (patch)
tree7b4b69e70c890ef836fb6d6c250234dedc8ef0af /drivers/spi/spidev.c
parentc517d838eb7d07bbe9507871fab3931deccff539 (diff)
spi: spidev: use spi_sync instead of spi_async
This has the benefit that the "optimization" of the framework in regards to spi_sync will also benefit spidev users directly and allow running spi transfers without a necessary context-switch to message-pump. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spidev.c')
-rw-r--r--drivers/spi/spidev.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 4eb7a980e670..eb0a075b23a2 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -95,37 +95,25 @@ MODULE_PARM_DESC(bufsiz, "data bytes in biggest supported SPI message");
/*-------------------------------------------------------------------------*/
-/*
- * We can't use the standard synchronous wrappers for file I/O; we
- * need to protect against async removal of the underlying spi_device.
- */
-static void spidev_complete(void *arg)
-{
- complete(arg);
-}
-
static ssize_t
spidev_sync(struct spidev_data *spidev, struct spi_message *message)
{
DECLARE_COMPLETION_ONSTACK(done);
int status;
-
- message->complete = spidev_complete;
- message->context = &done;
+ struct spi_device *spi;
spin_lock_irq(&spidev->spi_lock);
- if (spidev->spi == NULL)
+ spi = spidev->spi;
+ spin_unlock_irq(&spidev->spi_lock);
+
+ if (spi == NULL)
status = -ESHUTDOWN;
else
- status = spi_async(spidev->spi, message);
- spin_unlock_irq(&spidev->spi_lock);
+ status = spi_sync(spi, message);
+
+ if (status == 0)
+ status = message->actual_length;
- if (status == 0) {
- wait_for_completion(&done);
- status = message->status;
- if (status == 0)
- status = message->actual_length;
- }
return status;
}