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


Groups > linux.kernel > #1485850

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

From Masahiro Yamada <yamada.masahiro@socionext.com>
Newsgroups linux.kernel
Subject [PATCH v2 3/3] usb: renesas_usbhs: cleanup with list_first_entry_or_null()
Date 2016-09-18 18:10 +0200
Message-ID <siMPf-1Ng-7@gated-at.bofh.it> (permalink)
References <siMPf-1Ng-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | 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>
---

 drivers/usb/renesas_usbhs/fifo.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

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,
-- 
1.9.1

Back to linux.kernel | Previous | Next — Previous in thread | Next 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