Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933736AbcKGTGl (ORCPT ); Mon, 7 Nov 2016 14:06:41 -0500 Received: from www.osadl.org ([62.245.132.105]:48052 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932923AbcKGTGi (ORCPT ); Mon, 7 Nov 2016 14:06:38 -0500 From: Nicholas Mc Guire To: John Youn Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] usb: dwc2: gadget: simplify list handling Date: Mon, 7 Nov 2016 20:08:03 +0100 Message-Id: <1478545683-29897-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1085 Lines: 35 The current code is effectively equivalent to list_first_entry_or_null() so simply switch and simplify the code. Fixes: 9c39ddc60ee9 ("USB: s3c-hsotg: Fix stall condition processing") Signed-off-by: Nicholas Mc Guire --- Found by simple coccinelle scanner Compile tested with: x86_64_defconfig + CONFIG_USB_DWC2=m, CONFIG_USB_DWC2_PERIPHERAL=y Patch is against 4.9.0-rc2 (localversion-next is next-20161028) 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 24fbebc..9ac8ca0 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -1099,10 +1099,8 @@ static int dwc2_hsotg_process_req_status(struct dwc2_hsotg *hsotg, */ 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.7.10.4