add GPL v2+ SPDX header
[project/usbmode.git] / switch.c
index cc0423702398858a4d570d330ce4e30f7bd8d255..3716bb77506d58947e37681c5025da558c060532 100644 (file)
--- a/switch.c
+++ b/switch.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 #include <unistd.h>
 #include "switch.h"
 
@@ -520,8 +521,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]) {