From: Stanislav B. <sb...@su...> - 2012-01-04 19:55:59
|
usb_detach_kernel_driver_np() from the compat library returns different error messages than the old libusb0. It causes problems for drivers that expect exact error code. Proposed patch converts libusb1 errors to libusb0 errors. But maybe it is overcomplicated. If we accept that the function was implemented only in Linux (and the same is valid for libusb0), we can just simply return original errno instead of double conversion of errno to libusb1 error code and back to errno. As an alternative, we can check only for -ENODATA condition as libusb-compat does in usb_get_driver_np(). The affected software: lirc-0.8.7/daemons/hw_srm7500libusb.c: srm7500_initialize_usbdongle() The function continues if usb_detach_kernel_driver_np() finishes with no error or if it returns -ENODATA. But the compat layer returns -ENOENT and the driver considers this error as fatal. I am waiting for confirmation of the fix. Downstream bug reference: https://bugzilla.novell.com/show_bug.cgi?id=683307 --- libusb/core.c +++ libusb/core.c @@ -912,6 +912,22 @@ API_EXPORTED int usb_get_driver_np(usb_d API_EXPORTED int usb_detach_kernel_driver_np(usb_dev_handle *dev, int interface) { - return compat_err(libusb_detach_kernel_driver(dev->handle, interface)); + int r = compat_err(libusb_detach_kernel_driver(dev->handle, interface)); + if (r == 0) { + return 0; + } else { + switch (r) { + case LIBUSB_ERROR_NOT_FOUND: + return ENODATA; + case LIBUSB_ERROR_INVALID_PARAM: + return EINVAL; + case LIBUSB_ERROR_NO_DEVICE: + return ENODEV; + case LIBUSB_ERROR_OTHER: + return errno; + default: + return ERANGE; + } + } } -- Best Regards / S pozdravem, Stanislav Brabec software developer --------------------------------------------------------------------- SUSE LINUX, s. r. o. e-mail: sb...@su... Lihovarská 1060/12 tel: +49 911 7405384547 190 00 Praha 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/ |