Fix hiddev's use of usb_find_interface
PATCH 1/1 Fix hiddev's use of usb_find_interface
My macbook infrared remote control was broken by commit bd25f4dd6972755579d0ea50d1a5ace2e9b00d1a:
HID: hiddev: use usb_find_interface, get rid of BKL
This device appears in dmesg as:
apple 0003:05AC:8242.0001: hiddev0,hidraw0: USB HID v1.11 Device [Apple Computer, Inc. IR Receiver] on usb-0000:00:1d.2-1/input0
It stopped working as lircd was getting ENODEV when opening /dev/usb/hiddev0.
AFAICS hiddev_driver is a dummy driver so usb_find_interface(&hiddev_driver) does not find anything.
The device is associated with the usbhid driver, so let's do usb_find_interface(&hid_driver) instead.
$ ls -l /sys/devices/pci0000:00/0000:00:1d.2/usb7/7-1/7-1:1.0/usb/hiddev0/device/driver lrwxrwxrwx 1 root root 0 2010-09-12 16:28 /sys/devices/pci0000:00/0000:00:1d.2/usb7/7-1/7-1:1.0/usb/hiddev0/device/driver -> ../../../../../../bus/usb/drivers/usbhid
--- drivers/hid/usbhid/hid-core.c | 5 +++++ drivers/hid/usbhid/hiddev.c | 2 +- drivers/hid/usbhid/usbhid.h | 1 + 3 files changed, 7 insertions(+), 1 deletions(-)
drivers/hid/usbhid/hid-core.c +5 -0
@@ -1445,6 +1445,11 @@ static const struct hid_device_id hid_usb_table[] = { { } }; +struct usb_interface *usbhid_find_interface (int minor) +{ +return usb_find_interface (&hid_driver, minor); +} +static struct hid_driver hid_usb_driver = { .name ="generic-usb" , .id_table = hid_usb_table,
drivers/hid/usbhid/hiddev.c +1 -1
@@ -270,7 +270,7 @@ static int hiddev_open(struct inode *inode, struct file *file)struct hiddev *hiddev;int res; - intf =usb_find_interface (&hiddev_driver,iminor (inode)); + intf =usbhid_find_interface (iminor (inode));if (!intf)return -ENODEV ; hid =usb_get_intfdata (intf);
drivers/hid/usbhid/usbhid.h +1 -0
@@ -42,6 +42,7 @@ void usbhid_submit_report (struct hid_device *hid, struct hid_report *report, unsigned char dir);int usbhid_get_power (struct hid_device *hid);void usbhid_put_power (struct hid_device *hid); +struct usb_interface *usbhid_find_interface (int minor);/* iofl flags */ #define HID_CTRL_RUNNING 1
Signature · 1 line
1.7.0.4
Quoted 3 lines · Guillaume Chazarain
My macbook infrared remote control was broken by commit
bd25f4dd6972755579d0ea50d1a5ace2e9b00d1a:
HID: hiddev: useusb_find_interface, get rid of BKL
Right, my bug. Sorry for the trouble you went through.
A few other people have reported the same and Jiri has done a fix that was merged in 2.6.36-rc2.
Arnd
Quoted 8 lines · Arnd Bergmann
Quoted 3 lines
My macbook infrared remote control was broken by commit
bd25f4dd6972755579d0ea50d1a5ace2e9b00d1a:
HID: hiddev: useusb_find_interface, get rid of BKLRight, my bug. Sorry for the trouble you went through.
A few other people have reported the same and Jiri has done a fix that was merged in 2.6.36-rc2.
Yeah -- Guillaume, I think that you are actually seeing symptoms of intfdata being bogus. Could you please try with any kernel with commit 9c9e54a8df0be48 ("HID: hiddev: fix memory corruption due to invalid intfdata") applied (which is the one Arnd is talking about) and report back whether the problem is fixed by it?
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.
Quoted 5 lines · Jiri Kosina
Yeah -- Guillaume, I think that you are actually seeing symptoms of intfdata being bogus. Could you please try with any kernel with commit
9c9e54a8df0be48("HID: hiddev: fix memory corruption due to invalid intfdata") applied (which is the one Arnd is talking about) and report back whether the problem is fixed by it?
I also saw the problem with 2.6.36-rc3. My problem is with usb_find_interface(&hiddev_driver) not finding anything and 9c9e54a8df0be48aa359744f412377cc55c3b7d2 did not change this line.
In its current state I don't understand how hiddev_open() can possibly work. I see people reporting suspend issues and stack traces in dmesg but nobody reporting the driver being non-functioning, which is what I'm doing here.
Thanks.
Signature · 1 line
Guillaume
Quoted 1 line · Guillaume Chazarain
I also saw the problem with 2.6.36-rc3.
For completeness, I also reproduced the problem with 2.6.36-rc4. Not being familiar with the driver model, I'm not attached to the approach I took in the patch, but it solves a real regression: hiddev not working.
Signature · 1 line
Guillaume
Quoted 6 lines · Guillaume Chazarain
Quoted 5 lines
Yeah -- Guillaume, I think that you are actually seeing symptoms of intfdata being bogus. Could you please try with any kernel with commit
9c9e54a8df0be48("HID: hiddev: fix memory corruption due to invalid intfdata") applied (which is the one Arnd is talking about) and report back whether the problem is fixed by it?
Quoted 8 lines
I also saw the problem with 2.6.36-rc3. My problem is with
usb_find_interface(&hiddev_driver)not finding anything and9c9e54a8df0be48aa359744f412377cc55c3b7d2did not change this line.In its current state I don't understand how
hiddev_open()can possibly work. I see people reporting suspend issues and stack traces in dmesg but nobody reporting the driver being non-functioning, which is what I'm doing here.
You are right. I have now applied your patch, thanks a lot for tracking it down.
Signature · 2 lines
Jiri Kosina SUSE Labs, Novell Inc.