2020-05-07 11:11:22

by Jason Yan

[permalink] [raw]
Subject: [PATCH] USB: Remove dead code in usb_choose_configuration()

This code is dead for more than 10 years. Remove it.

Signed-off-by: Jason Yan <[email protected]>
---
drivers/usb/core/generic.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index 4626227a6dd2..1c93192fc136 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -93,12 +93,6 @@ int usb_choose_configuration(struct usb_device *udev)
* be reinstated when device firmwares become more reliable.
* Don't hold your breath.
*/
-#if 0
- /* Rule out self-powered configs for a bus-powered device */
- if (bus_powered && (c->desc.bmAttributes &
- USB_CONFIG_ATT_SELFPOWER))
- continue;
-#endif

/*
* The next test may not be as effective as it should be.
--
2.21.1


2020-05-07 13:34:35

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH] USB: Remove dead code in usb_choose_configuration()

On Thu, 7 May 2020, Jason Yan wrote:

> This code is dead for more than 10 years. Remove it.
>
> Signed-off-by: Jason Yan <[email protected]>
> ---
> drivers/usb/core/generic.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
> index 4626227a6dd2..1c93192fc136 100644
> --- a/drivers/usb/core/generic.c
> +++ b/drivers/usb/core/generic.c
> @@ -93,12 +93,6 @@ int usb_choose_configuration(struct usb_device *udev)
> * be reinstated when device firmwares become more reliable.
> * Don't hold your breath.
> */
> -#if 0
> - /* Rule out self-powered configs for a bus-powered device */
> - if (bus_powered && (c->desc.bmAttributes &
> - USB_CONFIG_ATT_SELFPOWER))
> - continue;
> -#endif

Please don't remove this dead code. But if you insist on removing it
then you should make it part of the preceding comment -- otherwise
people reading the comment won't know what it's talking about.

And I really think removing both the code and the comment would be a
bad idea. If you do that, someday somebody will think that the code is
missing by accident and will add it in, causing problems for many other
people.

Alan Stern