]> err.no Git - linux-2.6/commitdiff
SPI: use mutex not semaphore
authorDavid Brownell <david-b@pacbell.net>
Wed, 5 Dec 2007 07:45:09 +0000 (23:45 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 5 Dec 2007 17:21:18 +0000 (09:21 -0800)
Make spi_write_then_read() use a mutex not a binary semaphore.

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>
drivers/spi/spi.c

index b31f4431849b25e771d301f956b3afd31b00d2bf..6ca07c9929e6cef3e84c46333a81cd045bfc1a17 100644 (file)
@@ -589,7 +589,7 @@ int spi_write_then_read(struct spi_device *spi,
                const u8 *txbuf, unsigned n_tx,
                u8 *rxbuf, unsigned n_rx)
 {
-       static DECLARE_MUTEX(lock);
+       static DEFINE_MUTEX(lock);
 
        int                     status;
        struct spi_message      message;
@@ -615,7 +615,7 @@ int spi_write_then_read(struct spi_device *spi,
        }
 
        /* ... unless someone else is using the pre-allocated buffer */
-       if (down_trylock(&lock)) {
+       if (!mutex_trylock(&lock)) {
                local_buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL);
                if (!local_buf)
                        return -ENOMEM;
@@ -634,7 +634,7 @@ int spi_write_then_read(struct spi_device *spi,
        }
 
        if (x[0].tx_buf == buf)
-               up(&lock);
+               mutex_unlock(&lock);
        else
                kfree(local_buf);