spi: bitbang: Replace spinlock by mutex

chipselect (in the case of spi-gpio: spi_gpio_chipselect, which
calls gpiod_set_raw_value_cansleep) can sleep, so we should not
hold a spinlock while calling it from spi_bitbang_setup.

This issue was introduced by this commit, which converted spi-gpio
to cansleep variants:
d9dda5a191 "spi: spi-gpio: Use 'cansleep' variants to access GPIO"

Replacing the lock variable by a mutex fixes the issue: This is
safe as all instances where the lock is used are called from
contexts that can sleep.

Finally, update spi-ppc4xx and and spi-s3c24xx to use mutex
functions, as they directly hold the lock for similar purpose.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Nicolas Boichat
2015-08-17 11:52:54 +08:00
committed by Mark Brown
parent 6ff33f3902
commit c15f6ed3a1
4 changed files with 12 additions and 15 deletions

View File

@@ -4,7 +4,7 @@
#include <linux/workqueue.h>
struct spi_bitbang {
spinlock_t lock;
struct mutex lock;
u8 busy;
u8 use_dma;
u8 flags; /* extra spi->mode support */