Skip to contentSkip to conversation

usbhid: call report_fixup before comparing descriptors

PATCH In review Kevin Daughtridge 3 participants 4 messages Sep 17, 2012 – Sep 19, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usbhid: call report_fixup before comparing descriptors

hid_post_reset checks the stored report descriptor against what is currently returned by the device. An HID driver's report_fixup method may have changed the stored descriptor, however, creating false positives. These leave some devices nonfunctional after a resume, with a "reset_resume error 1" reported. This patch passes the new descriptor to the driver's report_fixup method, if any, before it is compared to the stored one.

---

drivers/hid/usbhid/hid-core.c 2012-09-16 18:51:45.381868737 -0700 renamed from drivers/hid/usbhid/hid-core.c 2012-08-20 10:17:09.000000000 -0700 +4 -0
@@ -1436,6 +1436,10 @@ static int hid_post_reset(struct usb_int
         kfree(rdesc);
         return 1;
     }
+
+    if (hid->driver && hid->driver->report_fixup)
+        rdesc = hid->driver->report_fixup(hid, rdesc, &status);
+
     status = memcmp(rdesc, hid->rdesc, hid->rsize);
     kfree(rdesc);
     if (status != 0) {

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw

Hello.

Quoted 13 lines · Kevin Daughtridge

hid_post_reset checks the stored report descriptor against what is currently returned by the device. An HID driver's report_fixup method may have changed the stored descriptor, however, creating false positives. These leave some devices nonfunctional after a resume, with a "reset_resume error 1" reported. This patch passes the new descriptor to the driver's report_fixup method, if any, before it is compared to the stored one.

---

drivers/hid/usbhid/hid-core.c 2012-09-16 18:51:45.381868737 -0700 static int hid_post_reset(struct usb_int · line 1442

Quoted 7 lines
drivers/hid/usbhid/hid-core.c 2012-09-16 18:51:45.381868737 -0700 renamed from drivers/hid/usbhid/hid-core.c 2012-08-20 10:17:09.000000000 -0700 +4 -0
@@ -1436,6 +1436,10 @@ static int hid_post_reset(struct usb_int
          kfree(rdesc);
          return 1;
      }
+
+    if (hid->driver && hid->driver->report_fixup)
+        rdesc = hid->driver->report_fixup(hid, rdesc, &status);
+

Your patch is whitespace damaged, i.e. has all tabs replaced by spaces.

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to Kevin Daughtridge

Hi Kevin,

drivers/hid/usbhid/hid-core.c 2012-09-16 18:51:45.381868737 -0700 static int hid_post_reset(struct usb_int · line 1443

Quoted 9 lines
drivers/hid/usbhid/hid-core.c 2012-09-16 18:51:45.381868737 -0700 renamed from drivers/hid/usbhid/hid-core.c 2012-08-20 10:17:09.000000000 -0700 +4 -0
@@ -1436,6 +1436,10 @@ static int hid_post_reset(struct usb_int
         kfree(rdesc);
         return 1;
     }
+
+    if (hid->driver && hid->driver->report_fixup)
+        rdesc = hid->driver->report_fixup(hid, rdesc, &status);
+
     status = memcmp(rdesc, hid->rdesc, hid->rsize);

You can use dev_rdesc here instead.

Thanks,
Henrik

#3 lore raw
Quoted 1 line · Henrik Rydberg

You can use dev_rdesc here instead.

Hi Henrik. Thanks for the tip. I tried comparing rdesc to hid->dev_rdesc without any report_fixup call, but the problem (device nonfunctional with "reset_resume error 1" message) still occurred. Upon looking at hid_open_report, I noticed that it calls report_fixup on dev_rdesc (pointer copied to "start") before it is kmemdup'd to rdesc. For most HID drivers, the report_fixup method directly modifies and returns the passed structure instead of returning a new pointer, so dev_rdesc is also modified. Assuming that dev_rdesc is supposed to be the unmodified data, I moved the report_fixup call in hid_open_report to after the kmemdup. This combination successfully solves the original problem. I'll submit a new patch version presently that addresses both points.

Quoted 1 line · Sergei Shtylyov

Your patch is whitespace damaged, i.e. has all tabs replaced by spaces.

Hi Sergei. Thanks for catching that. The munging problem was supposedly fixed in Thunderbird years ago! I guess I'll just mail the new version from the command line.

-Kevin