X-Git-Url: https://git.ao2.it/libam7xxx.git/blobdiff_plain/cd64a0277a5ca41122a343b26e4bad98b0377256..361d1aa96547f527f1c60a871db35c943bc07471:/src/am7xxx.c diff --git a/src/am7xxx.c b/src/am7xxx.c index f4203e3..1c3f704 100644 --- a/src/am7xxx.c +++ b/src/am7xxx.c @@ -736,6 +736,15 @@ static int open_device(am7xxx_context *ctx, current_configuration = -1; libusb_get_configuration((*dev)->usb_device, ¤t_configuration); if (current_configuration != (*dev)->desc->configuration) { + /* + * In principle kernel drivers bound to each interface should + * be detached before setting the configuration, but in + * practice this is not necessary for most devices. + * + * For example something like the following function would be + * called: + * libusb_detach_all_kernel_drivers((*dev)->usb_device); + */ ret = libusb_set_configuration((*dev)->usb_device, (*dev)->desc->configuration); if (ret < 0) { @@ -765,9 +774,9 @@ static int open_device(am7xxx_context *ctx, current_configuration = -1; libusb_get_configuration((*dev)->usb_device, ¤t_configuration); if (current_configuration != (*dev)->desc->configuration) { - debug(ctx, "libusb configuration changed\n"); - debug(ctx, "Cannot claim interface %hhu\n", - (*dev)->desc->interface_number); + debug(ctx, "libusb configuration changed (expected: %hhu, current: %hhu\n", + (*dev)->desc->configuration, current_configuration); + ret = -EINVAL; goto out_libusb_close; } out: