1 From: Mark Brown <broonie@kernel.org>
2 Date: Tue, 9 Dec 2014 19:46:56 +0000
3 Subject: [PATCH] spi: Check to see if the device is processing a message
6 cur_msg is updated under the queue lock and holds the message we are
7 currently processing. Since currently we only ever do removals in the
8 pump kthread it doesn't matter in what order we do things but we want
9 to be able to push things out from the submitting thread so pull the
10 check to see if we're currently handling a message before we check to
11 see if the queue is idle.
13 Signed-off-by: Mark Brown <broonie@kernel.org>
16 --- a/drivers/spi/spi.c
17 +++ b/drivers/spi/spi.c
18 @@ -891,8 +891,16 @@ static void spi_pump_messages(struct kth
19 bool was_busy = false;
22 - /* Lock queue and check for queue work */
24 spin_lock_irqsave(&master->queue_lock, flags);
26 + /* Make sure we are not already running a message */
27 + if (master->cur_msg) {
28 + spin_unlock_irqrestore(&master->queue_lock, flags);
32 + /* Check if the queue is idle */
33 if (list_empty(&master->queue) || !master->running) {
35 spin_unlock_irqrestore(&master->queue_lock, flags);
36 @@ -916,11 +924,6 @@ static void spi_pump_messages(struct kth
40 - /* Make sure we are not already running a message */
41 - if (master->cur_msg) {
42 - spin_unlock_irqrestore(&master->queue_lock, flags);
45 /* Extract head of queue */
47 list_first_entry(&master->queue, struct spi_message, queue);