linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: gadget: simplify list handling
@ 2016-11-07 19:08 Nicholas Mc Guire
  2016-11-07 19:16 ` John Youn
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Mc Guire @ 2016-11-07 19:08 UTC (permalink / raw)
  To: John Youn; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, Nicholas Mc Guire

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 <hofrat@osadl.org>
---
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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: dwc2: gadget: simplify list handling
  2016-11-07 19:08 [PATCH] usb: dwc2: gadget: simplify list handling Nicholas Mc Guire
@ 2016-11-07 19:16 ` John Youn
  0 siblings, 0 replies; 2+ messages in thread
From: John Youn @ 2016-11-07 19:16 UTC (permalink / raw)
  To: Nicholas Mc Guire, John Youn
  Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, Felipe Balbi

On 11/7/2016 11:06 AM, Nicholas Mc Guire wrote:
> 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 <hofrat@osadl.org>
> ---
> 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);
>  }
>  
>  /**
> 


Hi,

The same is already queued in Felipe's testing/next.

Regards,
John

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-07 19:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-07 19:08 [PATCH] usb: dwc2: gadget: simplify list handling Nicholas Mc Guire
2016-11-07 19:16 ` John Youn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).