From patchwork Thu Jan 2 07:16:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3423871 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E07839F374 for ; Thu, 2 Jan 2014 07:16:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 204E820131 for ; Thu, 2 Jan 2014 07:16:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BCC22012F for ; Thu, 2 Jan 2014 07:16:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751975AbaABHQr (ORCPT ); Thu, 2 Jan 2014 02:16:47 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:38567 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751973AbaABHQp (ORCPT ); Thu, 2 Jan 2014 02:16:45 -0500 Received: by mail-pa0-f43.google.com with SMTP id bj1so14204011pad.16 for ; Wed, 01 Jan 2014 23:16:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=DZ8iJRmoDnhELrVF0DQzFBtlkRZDIYlGmXuu5U1mT0I=; b=KKpKGC/05sBinTB/7Vzstu7zbGH59xK8iEVOliUguuR/DtbVyvdanWlV9TaMpTS8n4 4SveZSFgaZ15kECLICbpMsYhFZNoMw6FaPhL2W5jpadiyY2q9ijV+OjPn81uWKrC6YmR /OXgaaywz0UqHnM9THwl5PRACOr1xJFt3daOVxKhAUIlrw4diDAlllt9OfKdSgfBVDrC px4yZGbxhx79NQ21RbxTPWPUQxGzrS4m7N8SocvUzdhhtB5lvXdpYLSISRQAaC0JbWJ4 RYCICnJ8XYiyx+N8rAzoorLjKkQYmDPN+bs8G1fn0V8CC+KcRkI3mdBamXfyv48RFwCy oQvg== X-Gm-Message-State: ALoCoQkCQdNk6bK0r/wG5Qz8VUwMy5HGDs3FFXoH27Os+hUinevhSA/rRkR8AT3cnCCCQsZ/O3EX X-Received: by 10.68.201.226 with SMTP id kd2mr997769pbc.157.1388647004927; Wed, 01 Jan 2014 23:16:44 -0800 (PST) Received: from [192.168.0.102] (218-164-129-204.dynamic.hinet.net. [218.164.129.204]) by mx.google.com with ESMTPSA id i10sm130589754pat.11.2014.01.01.23.16.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 01 Jan 2014 23:16:43 -0800 (PST) Message-ID: <1388647000.28565.1.camel@phoenix> Subject: [PATCH] spi: core: Use list_first_entry_or_null() instead of open-coded From: Axel Lin To: Mark Brown Cc: linux-spi@vger.kernel.org Date: Thu, 02 Jan 2014 15:16:40 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use list_first_entry_or_null() to save a few lines. Signed-off-by: Axel Lin --- drivers/spi/spi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 98f4b77..a1a7f78 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;