aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/amba-pl022.c
diff options
context:
space:
mode:
authorVasily Khoruzhick <anarsoul@gmail.com>2011-04-06 10:49:15 -0400
committerGrant Likely <grant.likely@secretlab.ca>2011-04-07 14:17:45 -0400
commit850a28ecd8044ef36b2c7699d2e3736a410b4d0a (patch)
tree42a67f4ca8a624df752ad790fe0614fa584817d6 /drivers/spi/amba-pl022.c
parent454abcc57f1d48a976291bc4af73b5f087e21d70 (diff)
spi: Fix race condition in stop_queue()
There's a race condition in stop_queue() in some drivers - if drv_data->queue is empty, but drv_data->busy is still set (or opposite situation) stop_queue will return -EBUSY. So fix loop condition to check that both drv_data->queue is empty and drv_data->busy is not set. This patch affects following drivers: pxa2xx_spi spi_bfin5xx amba-pl022 dw_spi Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Acked-by: Eric Miao <eric.y.miao@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi/amba-pl022.c')
-rw-r--r--drivers/spi/amba-pl022.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c
index 5a4e0afb9ad6..4b8357b728cb 100644
--- a/drivers/spi/amba-pl022.c
+++ b/drivers/spi/amba-pl022.c
@@ -1555,7 +1555,7 @@ static int stop_queue(struct pl022 *pl022)
1555 * A wait_queue on the pl022->busy could be used, but then the common 1555 * A wait_queue on the pl022->busy could be used, but then the common
1556 * execution path (pump_messages) would be required to call wake_up or 1556 * execution path (pump_messages) would be required to call wake_up or
1557 * friends on every SPI message. Do this instead */ 1557 * friends on every SPI message. Do this instead */
1558 while (!list_empty(&pl022->queue) && pl022->busy && limit--) { 1558 while ((!list_empty(&pl022->queue) || pl022->busy) && limit--) {
1559 spin_unlock_irqrestore(&pl022->queue_lock, flags); 1559 spin_unlock_irqrestore(&pl022->queue_lock, flags);
1560 msleep(10); 1560 msleep(10);
1561 spin_lock_irqsave(&pl022->queue_lock, flags); 1561 spin_lock_irqsave(&pl022->queue_lock, flags);