Closed jazzguitar81 closed 4 years ago
With original source(without my patch), the return value of libusb_claim_interface is -6 which means LIBUSB_ERROR_BUSY if another program or driver has claimed the interface.
To display the report descriptor for HID device, we need to detach the kernel driver or another program. The libusb_set_auto_detach_kernel_driver() makes 'auto_detach_kernel_driver' field from struct libusb_device_handle set as enable.
There is a comment about the fail case about libusb_claim_interface:
static void dump_hid_device() .. snip..
3195 } else { 3196 / recent Linuxes require claim() for RECIP_INTERFACE, 3197 so "rmmod hid" will often make these available. 3198 */ 3199 printf(" Report Descriptors: \n" 3200 " UNAVAILABLE \n"); 3201 }
I don't think this makes the side-effect the HID devices already claimed interface. The only problem is the shortly mouse pointer is stop while detached the HID kernel driver and re-attach the kernel driver if the user run the 'lsusb' command.
Let me think about this for maybe the next release...
Still here.. I'm OK if you drop this patch :)
Anyway, I checked usbhid-dump(dump hid report descriptor) source code and it also detach a hid interface before claim interface. Proceed in the following order: detach --> claim --> releae --> attach interface back
So, the usbhid-dump program also causes the mouse pointer to be briefly interrupted.
On Thu, Feb 14, 2019 at 04:00:52PM +0000, Valerii Zapodovnikov wrote:
@jazzguitar81 @gregkh Maybe I don't understand smth, but is "detach/unbind the kernel driver" really nesessary? One could just use
cat /sys/kernel/debug/hid/*/rdesc
You can read about it there http://www.slashdev.ca/2010/05/08/get-usb-report-descriptor-with-linux/ (first comment).
Only works with HID devices.
And as usbhid-dump comes with usbutils, there's not much more I can do about that :)
@ValZapod Sorry about late response.
@jazzguitar81 @gregkh Maybe I don't understand smth, but is "detach/unbind the kernel driver" really necessary? One could just use
No really necessary. I just want to show a report descriptor from lsusb without any other actions.
cat /sys/kernel/debug/hid/*/rdesc
You can read about it there http://www.slashdev.ca/2010/05/08/get-usb-report-descriptor-with-linux/ (first comment).
@gregkh I still OK if you close this PR.
There's nothing to comment on it. debugfs is accessible only by root, as it is for debugging information only.
I really don't like the unbind/bind method here, as I have stated a number of times already.
And about debug descriptors?
I have no idea what you are referring to with when you say this, sorry, please be more specific.
I really do not like the unbind/bind stuff here, it can cause problems with userspace so I'm going to just close this out, thanks.
To display a report descriptor for HID device, we have to success claim the interface. So, we need to detach the kernel driver before claming the interface.
The libusb_set_auto_detach_kernel_driver() in libusb automatically do detach the kernel driver on an interface when claiming the interface, and attach it when releasing the interface.
Signed-off-by: Jaejoong Kim climbbb.kim@gmail.com