Commit a199f0ff authored by Andrew Morton's avatar Andrew Morton Committed by Greg Kroah-Hartman

[PATCH] USB: Logitech Cordeless Desktop Keyboard fails to report class descriptor

From: Nico Huber <nico.h@gmx.de>

The receiver of my Logitech Cordeless Desktop fails to report the
keyboard's class descriptor most times I insert the usb-hid module since I
changed to linux 2.6.  The modell of the receiver is C-BD9-DUAL REV C.  The
request seems not to fail but the count of received characters is zero.

As I said it only fails most times, I worked around making the following
changes in drivers/usb/input/hid-core.c from linux-2.6.11-rc2:

Following the good example of drivers/usb/core/message.c line 575, I
initialized the buffer in hid_get_class_descriptor() to zero.  In the loop
of hid_get_class_descriptor() not waiting for any result but waiting for a
result wich is lower the requested size of the class descriptor (line
1290).  usb_hid_configure() should not try to parse the expected length but
the received (line 1653).

Attached is a patch with these changes
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 672bbf00
...@@ -1295,12 +1295,15 @@ static int hid_get_class_descriptor(struct usb_device *dev, int ifnum, ...@@ -1295,12 +1295,15 @@ static int hid_get_class_descriptor(struct usb_device *dev, int ifnum,
unsigned char type, void *buf, int size) unsigned char type, void *buf, int size)
{ {
int result, retries = 4; int result, retries = 4;
memset(buf,0,size); // Make sure we parse really received data
do { do {
result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
USB_REQ_GET_DESCRIPTOR, USB_RECIP_INTERFACE | USB_DIR_IN, USB_REQ_GET_DESCRIPTOR, USB_RECIP_INTERFACE | USB_DIR_IN,
(type << 8), ifnum, buf, size, HZ * USB_CTRL_GET_TIMEOUT); (type << 8), ifnum, buf, size, HZ * USB_CTRL_GET_TIMEOUT);
retries--; retries--;
} while (result < 0 && retries); } while (result < size && retries);
return result; return result;
} }
...@@ -1663,7 +1666,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf) ...@@ -1663,7 +1666,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
printk("\n"); printk("\n");
#endif #endif
if (!(hid = hid_parse_report(rdesc, rsize))) { if (!(hid = hid_parse_report(rdesc, n))) {
dbg("parsing report descriptor failed"); dbg("parsing report descriptor failed");
kfree(rdesc); kfree(rdesc);
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment