Commit 068f4070 authored by David Brownell's avatar David Brownell Committed by Linus Torvalds

SPI: use mutex not semaphore

Make spi_write_then_read() use a mutex not a binary semaphore.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f8fcc933
...@@ -589,7 +589,7 @@ int spi_write_then_read(struct spi_device *spi, ...@@ -589,7 +589,7 @@ int spi_write_then_read(struct spi_device *spi,
const u8 *txbuf, unsigned n_tx, const u8 *txbuf, unsigned n_tx,
u8 *rxbuf, unsigned n_rx) u8 *rxbuf, unsigned n_rx)
{ {
static DECLARE_MUTEX(lock); static DEFINE_MUTEX(lock);
int status; int status;
struct spi_message message; struct spi_message message;
...@@ -615,7 +615,7 @@ int spi_write_then_read(struct spi_device *spi, ...@@ -615,7 +615,7 @@ int spi_write_then_read(struct spi_device *spi,
} }
/* ... unless someone else is using the pre-allocated buffer */ /* ... unless someone else is using the pre-allocated buffer */
if (down_trylock(&lock)) { if (!mutex_trylock(&lock)) {
local_buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL); local_buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL);
if (!local_buf) if (!local_buf)
return -ENOMEM; return -ENOMEM;
...@@ -634,7 +634,7 @@ int spi_write_then_read(struct spi_device *spi, ...@@ -634,7 +634,7 @@ int spi_write_then_read(struct spi_device *spi,
} }
if (x[0].tx_buf == buf) if (x[0].tx_buf == buf)
up(&lock); mutex_unlock(&lock);
else else
kfree(local_buf); kfree(local_buf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment