Re: Quirky Perixx Periboard-520 USB keyboard + trackball

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

This is a followup from my earlier post from january:
https://www.spinics.net/lists/linux-input/msg76463.html

I tracked down the problem to the reported number of descriptors being wrong:
bNumDescriptors == 0

With the attached patch (which is only a dirty workaround), the keyboard and
trackball are both working.

Now, does a proper fix would be interesting for upstream ?
Any help as to how I can do that right (maybe a quirk matching on usb ID) ?

Regards

Here it is inline & probably mangled:

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 4490e2f7252a..3d62c6e2abde 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1017,8 +1017,11 @@ static int usbhid_parse(struct hid_device *hid)
        hid->version = le16_to_cpu(hdesc->bcdHID);
        hid->country = hdesc->bCountryCode;

-       num_descriptors = min_t(int, hdesc->bNumDescriptors,
-              (hdesc->bLength - offset) / sizeof(struct hid_class_descriptor));
+       num_descriptors = (hdesc->bLength - offset) / sizeof(struct
hid_class_descriptor);
+       if (hdesc->bNumDescriptors == 0)
+               dbg_hid("working around the number of report
descriptors being zero\n");
+       else
+               num_descriptors = min_t(int, hdesc->bNumDescriptors,
num_descriptors);

        for (n = 0; n < num_descriptors; n++)
                if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT)

-- 
Vincent Legoll
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 4490e2f7252a..3d62c6e2abde 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1017,8 +1017,11 @@ static int usbhid_parse(struct hid_device *hid)
 	hid->version = le16_to_cpu(hdesc->bcdHID);
 	hid->country = hdesc->bCountryCode;
 
-	num_descriptors = min_t(int, hdesc->bNumDescriptors,
-	       (hdesc->bLength - offset) / sizeof(struct hid_class_descriptor));
+	num_descriptors = (hdesc->bLength - offset) / sizeof(struct hid_class_descriptor);
+	if (hdesc->bNumDescriptors == 0)
+		dbg_hid("working around the number of report descriptors being zero\n");
+	else
+		num_descriptors = min_t(int, hdesc->bNumDescriptors, num_descriptors);
 
 	for (n = 0; n < num_descriptors; n++)
 		if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT)

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux