[PATCH] usbmode: add config #0 and delay before actual config

Henrik Ginstmark henrik at ginstmark.se
Mon Feb 7 13:30:40 PST 2022


Add config #0 and a 100milliseconds delay before switching to actual config.
Like in USB_ModeSwitch,
https://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=4&t=2710&sid=505ed44b4064fef7009f0c26aac085e2&start=15

Signed-off-by: Henrik Ginstmark <henrik at ginstmark.se>
---
 usbmode/src/switch.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/usbmode/src/switch.c b/usbmode/src/switch.c
index cc04237..6285c7c 100644
--- a/usbmode/src/switch.c
+++ b/usbmode/src/switch.c
@@ -520,8 +520,11 @@ void handle_switch(struct usbdev_data *data)

                config_new = blobmsg_get_u32(tb[DATA_CONFIG]);
                if (libusb_get_configuration(data->devh, &config) ||
-                   config != config_new)
+                   config != config_new) {
+                       libusb_set_configuration(data->devh, 0);
+                       usleep(100000);
                        libusb_set_configuration(data->devh, config_new);
+               }
        }

        if (tb[DATA_ALT]) {
--
2.34.1



More information about the openwrt-devel mailing list