don't let init fail if usb_set_configuration() fails; be more verbose in USB init

This commit is contained in:
marschap
2008-09-22 19:24:12 +00:00
parent 58499eab8d
commit 48cbc7d2d9
2 changed files with 27 additions and 7 deletions
+15 -2
View File
@@ -148,17 +148,30 @@ hd_init_bwct_usb(Driver *drvthis)
if (p->usbHandle != NULL) {
debug(RPT_DEBUG, "hd_init_bwct_usb: opening device succeeded");
errno = 0;
if (usb_set_configuration(p->usbHandle, p->usbIndex) < 0) {
report(RPT_WARNING, "hd_init_bwct_usb: unable to set configuration: %s",
strerror(errno));
}
errno = 0;
if (usb_claim_interface(p->usbHandle, p->usbIndex) < 0) {
#if defined(LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP)
report(RPT_WARNING, "hd_init_bwct_usb: interface may be claimed by "
"kernel driver, attempting to detach it");
errno = 0;
if ((usb_detach_kernel_driver_np(p->usbHandle, p->usbIndex) < 0) ||
(usb_claim_interface(p->usbHandle, p->usbIndex) < 0)) {
report(RPT_ERR, "hd_init_bwct_usb: unable to re-claim interface: %s",
strerror(errno));
usb_close(p->usbHandle);
report(RPT_ERR, "hd_init_bwct_usb: unable to re-claim interface");
return -1;
}
#else
report(RPT_ERR, "hd_init_bwct_usb: unable to claim interface: %s",
strerror(errno));
usb_close(p->usbHandle);
report(RPT_ERR, "hd_init_bwct_usb: unable to claim interface");
return -1;
#endif
}