Skip to contentSkip to conversation

usb: host: Initiate urb ep with udev ep0

PATCH In review Khalid Masum 2 participants 2 messages Aug 24, 2022 – Aug 25, 2022 USB

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: host: Initiate urb ep with udev ep0

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.

---
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/[email protected]/

 drivers/usb/core/hcd.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/usb/core/hcd.c +1 -8
index 94b305bbd621..05f30ae5570b 100644
@@ -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;
Signature · 6 lines
2.37.1

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Acked-by on v2 1/1
#1 lore raw
Quoted 34 lines · Khalid Masum

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.

---
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/[email protected]/

 drivers/usb/core/hcd.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/usb/core/hcd.c +0 -3
index 94b305bbd621..05f30ae5570b 100644
@@ -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)];

drivers/usb/core/hcd.c static struct urb *request_single_step_set_feature_urb( · line 2171

Quoted 10 lines
drivers/usb/core/hcd.c +1 -5
-	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;

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees