usb: core: replace usb_sndaddr0pipe macro with usb_sndctrlpipe
PATCH 1/1 usb: core: replace usb_sndaddr0pipe macro with usb_sndctrlpipe
From: Stefan Eichenberger <[email protected]>
The usb_sndaddr0pipe macro is only used in the hub_set_address function. Replace it with usb_sndctrlpipe which provides the same functionality but would also consider the endpoint device number.
If the device has not been initialised, it is safe to use usb_sndctrlpipe in this context because udev->devnum is set to 0. Therefore, this change does not affect behaviour, but reduces code complexity by reusing the existing macro.
---
Even though this patch does not fix a bug it is related to the following discussion and addresses the change proposed by Alan:
https://lore.kernel.org/all/[email protected]/
--- drivers/usb/core/hub.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/core/hub.c +1 -3
@@ -4697,8 +4697,6 @@ void usb_ep0_reinit(struct usb_device *udev) }EXPORT_SYMBOL_GPL (usb_ep0_reinit); -#define usb_sndaddr0pipe () (PIPE_CONTROL << 30) -static int hub_set_address (struct usb_device *udev,int devnum) {int retval;
@@ -4722,7 +4720,7 @@ static int hub_set_address(struct usb_device *udev, int devnum)if (hcd->driver->address_device) retval = hcd->driver->address_device (hcd, udev, timeout_ms);else - retval =usb_control_msg (udev,usb_sndaddr0pipe (), + retval =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ),USB_REQ_SET_ADDRESS ,0 , devnum,0 ,NULL ,0 , timeout_ms);if (retval ==0 ) {
Signature · 1 line
2.45.2
Quoted 11 lines · Stefan Eichenberger
From: Stefan Eichenberger <[email protected]>
The
usb_sndaddr0pipemacro is only used in thehub_set_addressfunction. Replace it withusb_sndctrlpipewhich provides the same functionality but would also consider the endpoint device number.If the device has not been initialised, it is safe to use
usb_sndctrlpipein this context becauseudev->devnumis set to 0. Therefore, this change does not affect behaviour, but reduces code complexity by reusing the existing macro.
Quoted 6 lines
Signed-off-by Stefan Eichenberger <[email protected]>---
Even though this patch does not fix a bug it is related to the following discussion and addresses the change proposed by Alan:
https://lore.kernel.org/all/[email protected]/
---
Quoted 28 lines
drivers/usb/core/hub.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/usb/core/hub.c +1
-3@@ -4697,8 +4697,6 @@ void usb_ep0_reinit(struct usb_device *udev) }EXPORT_SYMBOL_GPL (usb_ep0_reinit); -#define usb_sndaddr0pipe () (PIPE_CONTROL << 30) -static int hub_set_address (struct usb_device *udev,int devnum) {int retval;@@ -4722,7 +4720,7 @@ static int hub_set_address(struct usb_device *udev, int devnum)if (hcd->driver->address_device) retval = hcd->driver->address_device (hcd, udev, timeout_ms);else - retval =usb_control_msg (udev,usb_sndaddr0pipe (), + retval =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ),USB_REQ_SET_ADDRESS ,0 , devnum,0 ,NULL ,0 , timeout_ms);if (retval ==0 ) {Signature · 1 line
2.45.2