Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1485851

[PATCH v2 1/3] usb: dwc2: cleanup with list_first_entry_or_null()

Path csiph.com!goblin3!goblin2!goblin.stu.neva.ru!gothmog.csi.it!bofh.it!news.nic.it!robomod
From Masahiro Yamada <yamada.masahiro@socionext.com>
Newsgroups linux.kernel
Subject [PATCH v2 1/3] usb: dwc2: cleanup with list_first_entry_or_null()
Date Sun, 18 Sep 2016 18:10:01 +0200
Message-ID <siMPf-1Ng-13@gated-at.bofh.it> (permalink)
References <siMPf-1Ng-3@gated-at.bofh.it>
X-Original-To linux-usb@vger.kernel.org
Dkim-Filter OpenDKIM Filter v2.10.3 conuserg-10.nifty.com u8IG3LfX028491
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1474214607; bh=nnLYV0ombgF0pgYl832XW0x2GGkPmHmztGErzWnnVkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ejpkFfN0ry0j3h6m683GEhehBx556fThgudd+Z2ALQXyWyGYYYJBK7N4954n3cujs XmndUsxiClUgg3v/bCJk5SoYOhSy3vZOindiKIyntqqh/HVkSqpIIw4ZiPPB4j9FG1 hJTkMVKnX1jxBlI/I+1B06wt+8e1JRFjYIoIClFAb9AUDCFJJhJzfCWnVvDHVhRikB 8wNzWHMxKKv+fS5K+G61V+qdqHzOSCm2YmtQLj/G9k7lNcWvDTtMMfMFk9TNwX49bF EEuZPoK9ijzhxJahqUmGzyybMNt7nVNl4YHmhQClMrzhstKnAS1R/Oo+zuHVjsrMfb EwWL34BPvKaZg==
X-Nifty-Srcip [111.169.71.157]
X-Mailer git-send-email 1.9.1
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 29
Organization linux.* mail to news gateway
X-Original-Cc Felipe Balbi <balbi@kernel.org>, Masahiro Yamada <yamada.masahiro@socionext.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, John Youn <johnyoun@synopsys.com>, linux-kernel@vger.kernel.org
X-Original-Date Mon, 19 Sep 2016 01:03:13 +0900
X-Original-Message-ID <1474214595-9349-2-git-send-email-yamada.masahiro@socionext.com>
X-Original-References <1474214595-9349-1-git-send-email-yamada.masahiro@socionext.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1485851

Show key headers only | View raw


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 <yamada.masahiro@socionext.com>
Acked-by: John Youn <johnyoun@synopsys.com>
---

 drivers/usb/dwc2/gadget.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

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);
 }
 
 /**
-- 
1.9.1

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/3] usb: trivial cleanups with list_first_entry_or_null() Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-09-18 18:10 +0200
  [PATCH v2 3/3] usb: renesas_usbhs: cleanup with list_first_entry_or_null() Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-09-18 18:10 +0200
  [PATCH v2 1/3] usb: dwc2: cleanup with list_first_entry_or_null() Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-09-18 18:10 +0200

csiph-web