diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-09-23 20:41:49 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2010-10-18 02:49:32 -0400 |
commit | f4f50c3ff7815d83dcbb19341f35db2f408ac4f8 (patch) | |
tree | 9897c41c9ddbf63dab5d6d1428e0a46ba528f432 /drivers/spi/spi_bfin5xx.c | |
parent | ab09e0406ffd42d26fc9a6dcbb626f9eb1da9160 (diff) |
spi/bfin_spi: convert queue run state to true/false
No point in creating our own version of true/false defines when there is
already a standard stdbool available to us.
Reported-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'drivers/spi/spi_bfin5xx.c')
-rw-r--r-- | drivers/spi/spi_bfin5xx.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c index 045c82a36164..40d9f64c7fa0 100644 --- a/drivers/spi/spi_bfin5xx.c +++ b/drivers/spi/spi_bfin5xx.c | |||
@@ -41,8 +41,6 @@ MODULE_LICENSE("GPL"); | |||
41 | #define RUNNING_STATE ((void *)1) | 41 | #define RUNNING_STATE ((void *)1) |
42 | #define DONE_STATE ((void *)2) | 42 | #define DONE_STATE ((void *)2) |
43 | #define ERROR_STATE ((void *)-1) | 43 | #define ERROR_STATE ((void *)-1) |
44 | #define QUEUE_RUNNING 0 | ||
45 | #define QUEUE_STOPPED 1 | ||
46 | 44 | ||
47 | struct driver_data { | 45 | struct driver_data { |
48 | /* Driver model hookup */ | 46 | /* Driver model hookup */ |
@@ -66,7 +64,7 @@ struct driver_data { | |||
66 | spinlock_t lock; | 64 | spinlock_t lock; |
67 | struct list_head queue; | 65 | struct list_head queue; |
68 | int busy; | 66 | int busy; |
69 | int run; | 67 | bool running; |
70 | 68 | ||
71 | /* Message Transfer pump */ | 69 | /* Message Transfer pump */ |
72 | struct tasklet_struct pump_transfers; | 70 | struct tasklet_struct pump_transfers; |
@@ -871,7 +869,7 @@ static void bfin_spi_pump_messages(struct work_struct *work) | |||
871 | 869 | ||
872 | /* Lock queue and check for queue work */ | 870 | /* Lock queue and check for queue work */ |
873 | spin_lock_irqsave(&drv_data->lock, flags); | 871 | spin_lock_irqsave(&drv_data->lock, flags); |
874 | if (list_empty(&drv_data->queue) || drv_data->run == QUEUE_STOPPED) { | 872 | if (list_empty(&drv_data->queue) || !drv_data->running) { |
875 | /* pumper kicked off but no work to do */ | 873 | /* pumper kicked off but no work to do */ |
876 | drv_data->busy = 0; | 874 | drv_data->busy = 0; |
877 | spin_unlock_irqrestore(&drv_data->lock, flags); | 875 | spin_unlock_irqrestore(&drv_data->lock, flags); |
@@ -926,7 +924,7 @@ static int bfin_spi_transfer(struct spi_device *spi, struct spi_message *msg) | |||
926 | 924 | ||
927 | spin_lock_irqsave(&drv_data->lock, flags); | 925 | spin_lock_irqsave(&drv_data->lock, flags); |
928 | 926 | ||
929 | if (drv_data->run == QUEUE_STOPPED) { | 927 | if (!drv_data->running) { |
930 | spin_unlock_irqrestore(&drv_data->lock, flags); | 928 | spin_unlock_irqrestore(&drv_data->lock, flags); |
931 | return -ESHUTDOWN; | 929 | return -ESHUTDOWN; |
932 | } | 930 | } |
@@ -938,7 +936,7 @@ static int bfin_spi_transfer(struct spi_device *spi, struct spi_message *msg) | |||
938 | dev_dbg(&spi->dev, "adding an msg in transfer() \n"); | 936 | dev_dbg(&spi->dev, "adding an msg in transfer() \n"); |
939 | list_add_tail(&msg->queue, &drv_data->queue); | 937 | list_add_tail(&msg->queue, &drv_data->queue); |
940 | 938 | ||
941 | if (drv_data->run == QUEUE_RUNNING && !drv_data->busy) | 939 | if (drv_data->running && !drv_data->busy) |
942 | queue_work(drv_data->workqueue, &drv_data->pump_messages); | 940 | queue_work(drv_data->workqueue, &drv_data->pump_messages); |
943 | 941 | ||
944 | spin_unlock_irqrestore(&drv_data->lock, flags); | 942 | spin_unlock_irqrestore(&drv_data->lock, flags); |
@@ -1177,7 +1175,7 @@ static inline int bfin_spi_init_queue(struct driver_data *drv_data) | |||
1177 | INIT_LIST_HEAD(&drv_data->queue); | 1175 | INIT_LIST_HEAD(&drv_data->queue); |
1178 | spin_lock_init(&drv_data->lock); | 1176 | spin_lock_init(&drv_data->lock); |
1179 | 1177 | ||
1180 | drv_data->run = QUEUE_STOPPED; | 1178 | drv_data->running = false; |
1181 | drv_data->busy = 0; | 1179 | drv_data->busy = 0; |
1182 | 1180 | ||
1183 | /* init transfer tasklet */ | 1181 | /* init transfer tasklet */ |
@@ -1200,12 +1198,12 @@ static inline int bfin_spi_start_queue(struct driver_data *drv_data) | |||
1200 | 1198 | ||
1201 | spin_lock_irqsave(&drv_data->lock, flags); | 1199 | spin_lock_irqsave(&drv_data->lock, flags); |
1202 | 1200 | ||
1203 | if (drv_data->run == QUEUE_RUNNING || drv_data->busy) { | 1201 | if (drv_data->running || drv_data->busy) { |
1204 | spin_unlock_irqrestore(&drv_data->lock, flags); | 1202 | spin_unlock_irqrestore(&drv_data->lock, flags); |
1205 | return -EBUSY; | 1203 | return -EBUSY; |
1206 | } | 1204 | } |
1207 | 1205 | ||
1208 | drv_data->run = QUEUE_RUNNING; | 1206 | drv_data->running = true; |
1209 | drv_data->cur_msg = NULL; | 1207 | drv_data->cur_msg = NULL; |
1210 | drv_data->cur_transfer = NULL; | 1208 | drv_data->cur_transfer = NULL; |
1211 | drv_data->cur_chip = NULL; | 1209 | drv_data->cur_chip = NULL; |
@@ -1230,7 +1228,7 @@ static inline int bfin_spi_stop_queue(struct driver_data *drv_data) | |||
1230 | * execution path (pump_messages) would be required to call wake_up or | 1228 | * execution path (pump_messages) would be required to call wake_up or |
1231 | * friends on every SPI message. Do this instead | 1229 | * friends on every SPI message. Do this instead |
1232 | */ | 1230 | */ |
1233 | drv_data->run = QUEUE_STOPPED; | 1231 | drv_data->running = false; |
1234 | while (!list_empty(&drv_data->queue) && drv_data->busy && limit--) { | 1232 | while (!list_empty(&drv_data->queue) && drv_data->busy && limit--) { |
1235 | spin_unlock_irqrestore(&drv_data->lock, flags); | 1233 | spin_unlock_irqrestore(&drv_data->lock, flags); |
1236 | msleep(10); | 1234 | msleep(10); |