]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/spi/spidev.c
Merge remote-tracking branches 'spi/topic/sirf', 'spi/topic/spidev' and 'spi/topic...
[karo-tx-linux.git] / drivers / spi / spidev.c
index 92c909eed6b504b01086e4775143128069f33261..dd616ff0ffc52542c3c8f8aaaf7c7d30bb9fd219 100644 (file)
@@ -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;
 }
 
@@ -647,7 +635,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;
@@ -676,7 +663,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 = {