Skip to content

Commit

Permalink
spi/bfin_spi: convert queue run state to true/false
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mike Frysinger committed Oct 18, 2010
1 parent ab09e04 commit f4f50c3
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions drivers/spi/spi_bfin5xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit f4f50c3

Please sign in to comment.