diff options
Diffstat (limited to 'drivers/spi')
-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 | ||