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>
This commit is contained in:
parent
ab09e0406f
commit
f4f50c3ff7
@ -41,8 +41,6 @@ MODULE_LICENSE("GPL");
|
||||
#define RUNNING_STATE ((void *)1)
|
||||
#define DONE_STATE ((void *)2)
|
||||
#define ERROR_STATE ((void *)-1)
|
||||
#define QUEUE_RUNNING 0
|
||||
#define QUEUE_STOPPED 1
|
||||
|
||||
struct driver_data {
|
||||
/* Driver model hookup */
|
||||
@ -66,7 +64,7 @@ struct driver_data {
|
||||
spinlock_t lock;
|
||||
struct list_head queue;
|
||||
int busy;
|
||||
int run;
|
||||
bool running;
|
||||
|
||||
/* Message Transfer pump */
|
||||
struct tasklet_struct pump_transfers;
|
||||
@ -871,7 +869,7 @@ static void bfin_spi_pump_messages(struct work_struct *work)
|
||||
|
||||
/* Lock queue and check for queue work */
|
||||
spin_lock_irqsave(&drv_data->lock, flags);
|
||||
if (list_empty(&drv_data->queue) || drv_data->run == QUEUE_STOPPED) {
|
||||
if (list_empty(&drv_data->queue) || !drv_data->running) {
|
||||
/* pumper kicked off but no work to do */
|
||||
drv_data->busy = 0;
|
||||
spin_unlock_irqrestore(&drv_data->lock, flags);
|
||||
@ -926,7 +924,7 @@ static int bfin_spi_transfer(struct spi_device *spi, struct spi_message *msg)
|
||||
|
||||
spin_lock_irqsave(&drv_data->lock, flags);
|
||||
|
||||
if (drv_data->run == QUEUE_STOPPED) {
|
||||
if (!drv_data->running) {
|
||||
spin_unlock_irqrestore(&drv_data->lock, flags);
|
||||
return -ESHUTDOWN;
|
||||
}
|
||||
@ -938,7 +936,7 @@ static int bfin_spi_transfer(struct spi_device *spi, struct spi_message *msg)
|
||||
dev_dbg(&spi->dev, "adding an msg in transfer() \n");
|
||||
list_add_tail(&msg->queue, &drv_data->queue);
|
||||
|
||||
if (drv_data->run == QUEUE_RUNNING && !drv_data->busy)
|
||||
if (drv_data->running && !drv_data->busy)
|
||||
queue_work(drv_data->workqueue, &drv_data->pump_messages);
|
||||
|
||||
spin_unlock_irqrestore(&drv_data->lock, flags);
|
||||
@ -1177,7 +1175,7 @@ static inline int bfin_spi_init_queue(struct driver_data *drv_data)
|
||||
INIT_LIST_HEAD(&drv_data->queue);
|
||||
spin_lock_init(&drv_data->lock);
|
||||
|
||||
drv_data->run = QUEUE_STOPPED;
|
||||
drv_data->running = false;
|
||||
drv_data->busy = 0;
|
||||
|
||||
/* init transfer tasklet */
|
||||
@ -1200,12 +1198,12 @@ static inline int bfin_spi_start_queue(struct driver_data *drv_data)
|
||||
|
||||
spin_lock_irqsave(&drv_data->lock, flags);
|
||||
|
||||
if (drv_data->run == QUEUE_RUNNING || drv_data->busy) {
|
||||
if (drv_data->running || drv_data->busy) {
|
||||
spin_unlock_irqrestore(&drv_data->lock, flags);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
drv_data->run = QUEUE_RUNNING;
|
||||
drv_data->running = true;
|
||||
drv_data->cur_msg = NULL;
|
||||
drv_data->cur_transfer = NULL;
|
||||
drv_data->cur_chip = NULL;
|
||||
@ -1230,7 +1228,7 @@ static inline int bfin_spi_stop_queue(struct driver_data *drv_data)
|
||||
* execution path (pump_messages) would be required to call wake_up or
|
||||
* friends on every SPI message. Do this instead
|
||||
*/
|
||||
drv_data->run = QUEUE_STOPPED;
|
||||
drv_data->running = false;
|
||||
while (!list_empty(&drv_data->queue) && drv_data->busy && limit--) {
|
||||
spin_unlock_irqrestore(&drv_data->lock, flags);
|
||||
msleep(10);
|
||||
|
Loading…
Reference in New Issue
Block a user