aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi.c
diff options
context:
space:
mode:
authorBryan Freed <bfreed@chromium.org>2013-03-13 14:17:40 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-01 09:22:59 -0400
commitb0b36b861e434ee1c1a64cb39259e262f79af62e (patch)
tree57c741bdba95e18eab28fe82c2396b7b959c0f2a /drivers/spi/spi.c
parent375981f2e14868be16cafbffd34a4f16a6ee01c6 (diff)
spi: Unlock a spinlock before calling into the controller driver.
spi_pump_messages() calls into a controller driver with unprepare_transfer_hardware() which is documented as "This may sleep". As in the prepare_transfer_hardware() call below, we should release the queue_lock spinlock before making the call. Rework the logic a bit to hold queue_lock to protect the 'busy' flag, then release it to call unprepare_transfer_hardware(). Signed-off-by: Bryan Freed <bfreed@chromium.org> Reviewed-by: Doug Anderson <dianders@chromium.org> Signed-off-by: Doug Anderson <dianders@chromium.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r--drivers/spi/spi.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index f996c600eb8c..5b96250b0628 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -543,17 +543,16 @@ static void spi_pump_messages(struct kthread_work *work)
543 /* Lock queue and check for queue work */ 543 /* Lock queue and check for queue work */
544 spin_lock_irqsave(&master->queue_lock, flags); 544 spin_lock_irqsave(&master->queue_lock, flags);
545 if (list_empty(&master->queue) || !master->running) { 545 if (list_empty(&master->queue) || !master->running) {
546 if (master->busy && master->unprepare_transfer_hardware) { 546 if (!master->busy) {
547 ret = master->unprepare_transfer_hardware(master); 547 spin_unlock_irqrestore(&master->queue_lock, flags);
548 if (ret) { 548 return;
549 spin_unlock_irqrestore(&master->queue_lock, flags);
550 dev_err(&master->dev,
551 "failed to unprepare transfer hardware\n");
552 return;
553 }
554 } 549 }
555 master->busy = false; 550 master->busy = false;
556 spin_unlock_irqrestore(&master->queue_lock, flags); 551 spin_unlock_irqrestore(&master->queue_lock, flags);
552 if (master->unprepare_transfer_hardware &&
553 master->unprepare_transfer_hardware(master))
554 dev_err(&master->dev,
555 "failed to unprepare transfer hardware\n");
557 return; 556 return;
558 } 557 }
559 558