From: Axel Lin Date: Thu, 2 Jan 2014 07:16:40 +0000 (+0800) Subject: spi: core: Use list_first_entry_or_null() instead of open-coded X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=1cfd97f93e36b3f8b5d2a26147aaccae0c847a9c;p=linux-beck.git spi: core: Use list_first_entry_or_null() instead of open-coded Use list_first_entry_or_null() to save a few lines. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 2cd9fdc9c7f9..401cd66770f9 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -791,11 +791,8 @@ struct spi_message *spi_get_next_queued_message(struct spi_master *master) /* get a pointer to the next message, if any */ spin_lock_irqsave(&master->queue_lock, flags); - if (list_empty(&master->queue)) - next = NULL; - else - next = list_entry(master->queue.next, - struct spi_message, queue); + next = list_first_entry_or_null(&master->queue, struct spi_message, + queue); spin_unlock_irqrestore(&master->queue_lock, flags); return next;