From: David Brownell Make spi_write_then_read() use a mutex not a binary semaphore. Signed-off-by: David Brownell Signed-off-by: Andrew Morton --- drivers/spi/spi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff -puN drivers/spi/spi.c~spi-use-mutex-not-semaphore drivers/spi/spi.c --- a/drivers/spi/spi.c~spi-use-mutex-not-semaphore +++ a/drivers/spi/spi.c @@ -588,7 +588,7 @@ int spi_write_then_read(struct spi_devic 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; @@ -614,7 +614,7 @@ int spi_write_then_read(struct spi_devic } /* ... 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; @@ -633,7 +633,7 @@ int spi_write_then_read(struct spi_devic } if (x[0].tx_buf == buf) - up(&lock); + mutex_unlock(&lock); else kfree(local_buf); _