-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lsusb: detach the kernel driver before claiming the interface #52
Conversation
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay.
What type of side-affect does this cause? I'm leery of changing the way the interaction with the kernel works here, as unbind/bind could cause issues for some devices, right?
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() 3195 } else { 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.. 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: 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
No really necessary. I just want to show a report descriptor from lsusb without any other actions.
@gregkh |
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. |
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