diff options
| -rw-r--r-- | drivers/spi/amba-pl022.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c index 4b618f0e44dd..a2a5921c730a 100644 --- a/drivers/spi/amba-pl022.c +++ b/drivers/spi/amba-pl022.c | |||
| @@ -253,11 +253,6 @@ | |||
| 253 | #define STATE_ERROR ((void *) -1) | 253 | #define STATE_ERROR ((void *) -1) |
| 254 | 254 | ||
| 255 | /* | 255 | /* |
| 256 | * Queue State | ||
| 257 | */ | ||
| 258 | #define QUEUE_RUNNING (0) | ||
| 259 | #define QUEUE_STOPPED (1) | ||
| 260 | /* | ||
| 261 | * SSP State - Whether Enabled or Disabled | 256 | * SSP State - Whether Enabled or Disabled |
| 262 | */ | 257 | */ |
| 263 | #define SSP_DISABLED (0) | 258 | #define SSP_DISABLED (0) |
| @@ -344,7 +339,7 @@ struct vendor_data { | |||
| 344 | * @lock: spinlock to syncronise access to driver data | 339 | * @lock: spinlock to syncronise access to driver data |
| 345 | * @workqueue: a workqueue on which any spi_message request is queued | 340 | * @workqueue: a workqueue on which any spi_message request is queued |
| 346 | * @busy: workqueue is busy | 341 | * @busy: workqueue is busy |
| 347 | * @run: workqueue is running | 342 | * @running: workqueue is running |
| 348 | * @pump_transfers: Tasklet used in Interrupt Transfer mode | 343 | * @pump_transfers: Tasklet used in Interrupt Transfer mode |
| 349 | * @cur_msg: Pointer to current spi_message being processed | 344 | * @cur_msg: Pointer to current spi_message being processed |
| 350 | * @cur_transfer: Pointer to current spi_transfer | 345 | * @cur_transfer: Pointer to current spi_transfer |
| @@ -370,7 +365,7 @@ struct pl022 { | |||
| 370 | spinlock_t queue_lock; | 365 | spinlock_t queue_lock; |
| 371 | struct list_head queue; | 366 | struct list_head queue; |
| 372 | bool busy; | 367 | bool busy; |
| 373 | int run; | 368 | bool running; |
| 374 | /* Message transfer pump */ | 369 | /* Message transfer pump */ |
| 375 | struct tasklet_struct pump_transfers; | 370 | struct tasklet_struct pump_transfers; |
| 376 | struct spi_message *cur_msg; | 371 | struct spi_message *cur_msg; |
| @@ -1460,7 +1455,7 @@ static void pump_messages(struct work_struct *work) | |||
| 1460 | 1455 | ||
| 1461 | /* Lock queue and check for queue work */ | 1456 | /* Lock queue and check for queue work */ |
| 1462 | spin_lock_irqsave(&pl022->queue_lock, flags); | 1457 | spin_lock_irqsave(&pl022->queue_lock, flags); |
| 1463 | if (list_empty(&pl022->queue) || pl022->run == QUEUE_STOPPED) { | 1458 | if (list_empty(&pl022->queue) || !pl022->running) { |
| 1464 | pl022->busy = false; | 1459 | pl022->busy = false; |
| 1465 | spin_unlock_irqrestore(&pl022->queue_lock, flags); | 1460 | spin_unlock_irqrestore(&pl022->queue_lock, flags); |
| 1466 | return; | 1461 | return; |
| @@ -1507,7 +1502,7 @@ static int __init init_queue(struct pl022 *pl022) | |||
| 1507 | INIT_LIST_HEAD(&pl022->queue); | 1502 | INIT_LIST_HEAD(&pl022->queue); |
| 1508 | spin_lock_init(&pl022->queue_lock); | 1503 | spin_lock_init(&pl022->queue_lock); |
| 1509 | 1504 | ||
| 1510 | pl022->run = QUEUE_STOPPED; | 1505 | pl022->running = false; |
| 1511 | pl022->busy = false; | 1506 | pl022->busy = false; |
| 1512 | 1507 | ||
| 1513 | tasklet_init(&pl022->pump_transfers, | 1508 | tasklet_init(&pl022->pump_transfers, |
| @@ -1529,12 +1524,12 @@ static int start_queue(struct pl022 *pl022) | |||
| 1529 | 1524 | ||
| 1530 | spin_lock_irqsave(&pl022->queue_lock, flags); | 1525 | spin_lock_irqsave(&pl022->queue_lock, flags); |
| 1531 | 1526 | ||
| 1532 | if (pl022->run == QUEUE_RUNNING || pl022->busy) { | 1527 | if (pl022->running || pl022->busy) { |
| 1533 | spin_unlock_irqrestore(&pl022->queue_lock, flags); | 1528 | spin_unlock_irqrestore(&pl022->queue_lock, flags); |
| 1534 | return -EBUSY; | 1529 | return -EBUSY; |
| 1535 | } | 1530 | } |
| 1536 | 1531 | ||
| 1537 | pl022->run = QUEUE_RUNNING; | 1532 | pl022->running = true; |
| 1538 | pl022->cur_msg = NULL; | 1533 | pl022->cur_msg = NULL; |
| 1539 | pl022->cur_transfer = NULL; | 1534 | pl022->cur_transfer = NULL; |
| 1540 | pl022->cur_chip = NULL; | 1535 | pl022->cur_chip = NULL; |
| @@ -1566,7 +1561,8 @@ static int stop_queue(struct pl022 *pl022) | |||
| 1566 | 1561 | ||
| 1567 | if (!list_empty(&pl022->queue) || pl022->busy) | 1562 | if (!list_empty(&pl022->queue) || pl022->busy) |
| 1568 | status = -EBUSY; | 1563 | status = -EBUSY; |
| 1569 | else pl022->run = QUEUE_STOPPED; | 1564 | else |
| 1565 | pl022->running = false; | ||
| 1570 | 1566 | ||
| 1571 | spin_unlock_irqrestore(&pl022->queue_lock, flags); | 1567 | spin_unlock_irqrestore(&pl022->queue_lock, flags); |
| 1572 | 1568 | ||
| @@ -1684,7 +1680,7 @@ static int pl022_transfer(struct spi_device *spi, struct spi_message *msg) | |||
| 1684 | 1680 | ||
| 1685 | spin_lock_irqsave(&pl022->queue_lock, flags); | 1681 | spin_lock_irqsave(&pl022->queue_lock, flags); |
| 1686 | 1682 | ||
| 1687 | if (pl022->run == QUEUE_STOPPED) { | 1683 | if (!pl022->running) { |
| 1688 | spin_unlock_irqrestore(&pl022->queue_lock, flags); | 1684 | spin_unlock_irqrestore(&pl022->queue_lock, flags); |
| 1689 | return -ESHUTDOWN; | 1685 | return -ESHUTDOWN; |
| 1690 | } | 1686 | } |
| @@ -1693,7 +1689,7 @@ static int pl022_transfer(struct spi_device *spi, struct spi_message *msg) | |||
| 1693 | msg->state = STATE_START; | 1689 | msg->state = STATE_START; |
| 1694 | 1690 | ||
| 1695 | list_add_tail(&msg->queue, &pl022->queue); | 1691 | list_add_tail(&msg->queue, &pl022->queue); |
| 1696 | if (pl022->run == QUEUE_RUNNING && !pl022->busy) | 1692 | if (pl022->running && !pl022->busy) |
| 1697 | queue_work(pl022->workqueue, &pl022->pump_messages); | 1693 | queue_work(pl022->workqueue, &pl022->pump_messages); |
| 1698 | 1694 | ||
| 1699 | spin_unlock_irqrestore(&pl022->queue_lock, flags); | 1695 | spin_unlock_irqrestore(&pl022->queue_lock, flags); |
