linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] usb: host: Initiate urb ep with udev ep0
@ 2022-08-24 20:31 Khalid Masum
  2022-08-25 14:19 ` Alan Stern
  0 siblings, 1 reply; 2+ messages in thread
From: Khalid Masum @ 2022-08-24 20:31 UTC (permalink / raw)
  To: Alan Stern, linux-kernel, linux-kernel-mentees
  Cc: Sergey Shtylyov, Arnd Bergmann, linux-usb,
	Kishon Vijay Abraham I, Matthias Kaehlcke, Weitao Wang

Currently we look up for endpoint in a table and initate urb endpoint
with it. This is unnecessary because the lookup will always result in
endpoint 0.

Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Khalid Masum <khalid.masum.92@gmail.com>
---
Changes since v1:
 - Remove endpoint lookup and NULL check
 - Remove unnecessary variable *ep
 - Initiate urb ep with udev ep0
 - Update commit message
 - v1 Link: https://lore.kernel.org/lkml/20220824130702.10912-1-khalid.masum.92@gmail.com/ 

 drivers/usb/core/hcd.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 94b305bbd621..05f30ae5570b 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2158,21 +2158,14 @@ static struct urb *request_single_step_set_feature_urb(
 {
 	struct urb *urb;
 	struct usb_hcd *hcd = bus_to_hcd(udev->bus);
-	struct usb_host_endpoint *ep;
 
 	urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (!urb)
 		return NULL;
 
 	urb->pipe = usb_rcvctrlpipe(udev, 0);
-	ep = (usb_pipein(urb->pipe) ? udev->ep_in : udev->ep_out)
-				[usb_pipeendpoint(urb->pipe)];
-	if (!ep) {
-		usb_free_urb(urb);
-		return NULL;
-	}
 
-	urb->ep = ep;
+	urb->ep = &udev->ep0;
 	urb->dev = udev;
 	urb->setup_packet = (void *)dr;
 	urb->transfer_buffer = buf;
-- 
2.37.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [PATCH v2] usb: host: Initiate urb ep with udev ep0
  2022-08-24 20:31 [PATCH v2] usb: host: Initiate urb ep with udev ep0 Khalid Masum
@ 2022-08-25 14:19 ` Alan Stern
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Stern @ 2022-08-25 14:19 UTC (permalink / raw)
  To: Khalid Masum
  Cc: Sergey Shtylyov, Arnd Bergmann, linux-usb, linux-kernel,
	Kishon Vijay Abraham I, Matthias Kaehlcke, Weitao Wang,
	linux-kernel-mentees

On Thu, Aug 25, 2022 at 02:31:07AM +0600, Khalid Masum wrote:
> Currently we look up for endpoint in a table and initate urb endpoint
> with it. This is unnecessary because the lookup will always result in
> endpoint 0.
> 
> Suggested-by: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: Khalid Masum <khalid.masum.92@gmail.com>
> ---
> Changes since v1:
>  - Remove endpoint lookup and NULL check
>  - Remove unnecessary variable *ep
>  - Initiate urb ep with udev ep0
>  - Update commit message
>  - v1 Link: https://lore.kernel.org/lkml/20220824130702.10912-1-khalid.masum.92@gmail.com/ 
> 
>  drivers/usb/core/hcd.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 94b305bbd621..05f30ae5570b 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -2158,21 +2158,14 @@ static struct urb *request_single_step_set_feature_urb(
>  {
>  	struct urb *urb;
>  	struct usb_hcd *hcd = bus_to_hcd(udev->bus);
> -	struct usb_host_endpoint *ep;
>  
>  	urb = usb_alloc_urb(0, GFP_KERNEL);
>  	if (!urb)
>  		return NULL;
>  
>  	urb->pipe = usb_rcvctrlpipe(udev, 0);
> -	ep = (usb_pipein(urb->pipe) ? udev->ep_in : udev->ep_out)
> -				[usb_pipeendpoint(urb->pipe)];
> -	if (!ep) {
> -		usb_free_urb(urb);
> -		return NULL;
> -	}
>  
> -	urb->ep = ep;
> +	urb->ep = &udev->ep0;
>  	urb->dev = udev;
>  	urb->setup_packet = (void *)dr;
>  	urb->transfer_buffer = buf;

Acked-by: Alan Stern <stern@rowland.harvard.edu>
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

end of thread, other threads:[~2022-08-25 14:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-24 20:31 [PATCH v2] usb: host: Initiate urb ep with udev ep0 Khalid Masum
2022-08-25 14:19 ` Alan Stern

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).