Skip to content

Commit cbebac2

Browse files
chenhuacaiKexyBiscuit
authored andcommitted
AOSCOS: Retry to configure USB device if needed
[Mingcong Bai: Resolved a minor merge conflict in drivers/usb/core/message.c.] Signed-off-by: Huacai Chen <chenhc@lemote.com> Signed-off-by: Kexy Biscuit <kexybiscuit@aosc.io>
1 parent a1a27f8 commit cbebac2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/usb/core/message.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1999,7 +1999,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
19991999
struct usb_host_config *cp = NULL;
20002000
struct usb_interface **new_interfaces = NULL;
20012001
struct usb_hcd *hcd = bus_to_hcd(dev->bus);
2002-
int n, nintf;
2002+
int n, nintf, retried = 0;
20032003

20042004
if (dev->authorized == 0 || configuration == -1)
20052005
configuration = 0;
@@ -2148,6 +2148,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
21482148
}
21492149
kfree(new_interfaces);
21502150

2151+
retry:
21512152
ret = usb_control_msg_send(dev, 0, USB_REQ_SET_CONFIGURATION, 0,
21522153
configuration, 0, NULL, 0,
21532154
USB_CTRL_SET_TIMEOUT, GFP_NOIO);
@@ -2156,6 +2157,12 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
21562157
* All the old state is gone, so what else can we do?
21572158
* The device is probably useless now anyway.
21582159
*/
2160+
if (!retried) {
2161+
retried = 1;
2162+
printk("Retry to configure %d-%s!\n", dev->bus->busnum, dev->devpath);
2163+
goto retry;
2164+
}
2165+
21592166
usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
21602167
for (i = 0; i < nintf; ++i) {
21612168
usb_disable_interface(dev, cp->interface[i], true);

0 commit comments

Comments
 (0)