From 98d6f479580013b42d179c30ff39107b6728ed82 Mon Sep 17 00:00:00 2001 From: Martin Sperl Date: Thu, 23 Apr 2015 07:56:01 +0000 Subject: 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 Signed-off-by: Mark Brown --- drivers/spi/spidev.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'drivers/spi/spidev.c') diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 4eb7a98..eb0a075 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; } -- cgit v1.1 From 99472cc08a8bda2c56bceec3693193cc87a33ef1 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sat, 9 May 2015 12:57:19 -0300 Subject: spi: spidev: Remove unneeded variable Remove unneeded variable used to store return value. The semantic patch that makes this change is available in scripts/coccinelle/misc/returnvar.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- drivers/spi/spidev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/spi/spidev.c') diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index eb0a075..dba7b462 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -616,7 +616,6 @@ err_find_dev: static int spidev_release(struct inode *inode, struct file *filp) { struct spidev_data *spidev; - int status = 0; mutex_lock(&device_list_lock); spidev = filp->private_data; @@ -645,7 +644,7 @@ static int spidev_release(struct inode *inode, struct file *filp) } mutex_unlock(&device_list_lock); - return status; + return 0; } static const struct file_operations spidev_fops = { -- cgit v1.1