diff options
author | David Brownell <david-b@pacbell.net> | 2007-12-05 02:45:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-12-05 12:21:18 -0500 |
commit | 068f4070868c801c7d7aa1ae1193c1c854193545 (patch) | |
tree | 17167c675c5115653e3f28f8977bdfd43b22ce6a /drivers/spi/spi.c | |
parent | f8fcc93319faa09272185af100fb24e71b02ab03 (diff) |
SPI: use mutex not semaphore
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>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index b31f4431849b..6ca07c9929e6 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -589,7 +589,7 @@ int spi_write_then_read(struct spi_device *spi, | |||
589 | const u8 *txbuf, unsigned n_tx, | 589 | const u8 *txbuf, unsigned n_tx, |
590 | u8 *rxbuf, unsigned n_rx) | 590 | u8 *rxbuf, unsigned n_rx) |
591 | { | 591 | { |
592 | static DECLARE_MUTEX(lock); | 592 | static DEFINE_MUTEX(lock); |
593 | 593 | ||
594 | int status; | 594 | int status; |
595 | struct spi_message message; | 595 | struct spi_message message; |
@@ -615,7 +615,7 @@ int spi_write_then_read(struct spi_device *spi, | |||
615 | } | 615 | } |
616 | 616 | ||
617 | /* ... unless someone else is using the pre-allocated buffer */ | 617 | /* ... unless someone else is using the pre-allocated buffer */ |
618 | if (down_trylock(&lock)) { | 618 | if (!mutex_trylock(&lock)) { |
619 | local_buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL); | 619 | local_buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL); |
620 | if (!local_buf) | 620 | if (!local_buf) |
621 | return -ENOMEM; | 621 | return -ENOMEM; |
@@ -634,7 +634,7 @@ int spi_write_then_read(struct spi_device *spi, | |||
634 | } | 634 | } |
635 | 635 | ||
636 | if (x[0].tx_buf == buf) | 636 | if (x[0].tx_buf == buf) |
637 | up(&lock); | 637 | mutex_unlock(&lock); |
638 | else | 638 | else |
639 | kfree(local_buf); | 639 | kfree(local_buf); |
640 | 640 | ||