From patchwork Mon Sep 12 17:46:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 76016 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp967958qgf; Mon, 12 Sep 2016 10:48:31 -0700 (PDT) X-Received: by 10.66.2.168 with SMTP id 8mr35840537pav.87.1473702511039; Mon, 12 Sep 2016 10:48:31 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zq3si22615331pac.22.2016.09.12.10.48.30; Mon, 12 Sep 2016 10:48:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932809AbcILRsS (ORCPT + 27 others); Mon, 12 Sep 2016 13:48:18 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:29316 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753762AbcILRsG (ORCPT ); Mon, 12 Sep 2016 13:48:06 -0400 Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-11.nifty.com with ESMTP id u8CHkS70009533; Tue, 13 Sep 2016 02:46:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com u8CHkS70009533 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1473702392; bh=NI+LqVl+p7M/GTv2aIQmm1cBXe3NRS6gKh6gYfESuwA=; h=From:To:Cc:Subject:Date:From; b=Hien8WXFD7dKfoGJZl74DnL4ZYl/ZOLiaztHVOVKXTtnfsfQpr0y54ucaBoScZFvC bbsWN1SNEjmf3a6FIQS31DjrcKnzMyuw8p0g+V6zXSnfCPfmcKiaDDrl6+w6JOTfaU L0AWcBhd/qJIQUGZxFZBVLeifsFvJKh8ENSZYbQWwS8eXU6Qm9fzttA0cPO2zYTy+/ Ii0wiVS4ijPNEKdH9AWt7Wh/y0ImZEk+xkJNUyFjEWmFAnuFUm+g7yuCcVUbrup8bC CLgyMzuQZwgMTY7zCS/UQSZGaWe2CMneqZ8gU3MnK0dDV5kj61RMsZJX7JBnCa65oI mn/7oGW/sqw1g== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: linux-usb@vger.kernel.org Cc: Masahiro Yamada , Felipe Balbi , linux-kernel@vger.kernel.org, Yoshihiro Shimoda , Julia Lawall , Greg Kroah-Hartman , John Youn Subject: [PATCH] usb: cleanup with list_first_entry_or_null() Date: Tue, 13 Sep 2016 02:46:23 +0900 Message-Id: <1473702383-16081-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The combo of list_empty() check and return list_first_entry() can be replaced with list_first_entry_or_null(). Signed-off-by: Masahiro Yamada --- drivers/usb/dwc2/gadget.c | 6 ++---- drivers/usb/dwc3/gadget.h | 5 +---- drivers/usb/renesas_usbhs/fifo.c | 5 +---- 3 files changed, 4 insertions(+), 12 deletions(-) -- 1.9.1 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index af46adf..28a250a 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -1098,10 +1098,8 @@ static int dwc2_hsotg_ep_sethalt(struct usb_ep *ep, int value, bool now); */ static struct dwc2_hsotg_req *get_ep_head(struct dwc2_hsotg_ep *hs_ep) { - if (list_empty(&hs_ep->queue)) - return NULL; - - return list_first_entry(&hs_ep->queue, struct dwc2_hsotg_req, queue); + return list_first_entry_or_null(&hs_ep->queue, struct dwc2_hsotg_req, + queue); } /** diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index e4a1d97..3129bcf 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h @@ -62,10 +62,7 @@ struct dwc3; static inline struct dwc3_request *next_request(struct list_head *list) { - if (list_empty(list)) - return NULL; - - return list_first_entry(list, struct dwc3_request, list); + return list_first_entry_or_null(list, struct dwc3_request, list); } static inline void dwc3_gadget_move_started_request(struct dwc3_request *req) diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 857e783..d1af831 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c @@ -100,10 +100,7 @@ static void __usbhsf_pkt_del(struct usbhs_pkt *pkt) static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe) { - if (list_empty(&pipe->list)) - return NULL; - - return list_first_entry(&pipe->list, struct usbhs_pkt, node); + return list_first_entry_or_null(&pipe->list, struct usbhs_pkt, node); } static void usbhsf_fifo_clear(struct usbhs_pipe *pipe,