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

From: Alan Stern
Date: Thu May 07 2020 - 09:32:28 EST


On Thu, 7 May 2020, Jason Yan wrote:

> This code is dead for more than 10 years. Remove it.
>
> Signed-off-by: Jason Yan <yanaijie@xxxxxxxxxx>
> ---
> 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