Comment 20 for bug 769816

Revision history for this message
Marius B. Kotsbak (mariusko) wrote :

Hmm, where is this change? In get_current_configuration() there is no "Configuration" variable. Then the "if (Configuration)" doesn't make sense. Do you have a patch against the Ubuntu patched version?

I tried something similar, and then I got: "Error: getting the interface class failed. Aborting."

I then set interface class to 0 in those cases.

The patch of what I did is:

--- usb-modeswitch-1.1.7.orig/usb_modeswitch.c
+++ usb-modeswitch-1.1.7/usb_modeswitch.c
@@ -409,8 +409,8 @@ int main(int argc, char **argv)
        defaultClass = dev->descriptor.bDeviceClass;
        interfaceClass = get_interface0_class(dev, currentConfig);
        if (interfaceClass == -1) {
- fprintf(stderr, "Error: getting the interface class failed. Aborting.\n\n");
- exit(1);
+ fprintf(stderr, "Error: getting the interface class failed. Falling back to assuming it is 0 (Defined at Interface level).\n\n");
+ interfaceClass = 0;
        }

        if (defaultClass == 0)
@@ -1389,8 +1389,8 @@ int get_current_configuration(struct usb
        SHOW_PROGRESS("Getting the current device configuration ...\n");
        ret = usb_control_msg(devh, USB_DIR_IN + USB_TYPE_STANDARD + USB_RECIP_DEVICE, USB_REQ_GET_CONFIGURATION, 0, 0, buffer, 1, 1000);
        if (ret < 0) {
- fprintf(stderr, "Error: getting the current configuration failed (error %d). Aborting.\n\n", ret);
- exit(1);
+ fprintf(stderr, "Error: getting the current configuration failed (error %d). Falling back to configuration 1.\n", ret);
+ return 0;
        } else {
                SHOW_PROGRESS(" OK, got current device configuration (%d)\n", buffer[0]);
                return buffer[0];

Attached the new error log.