linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usbhid: call report_fixup before comparing descriptors
@ 2012-09-17 20:05 Kevin Daughtridge
  2012-09-18 12:00 ` Sergei Shtylyov
  2012-09-18 16:16 ` Henrik Rydberg
  0 siblings, 2 replies; 4+ messages in thread
From: Kevin Daughtridge @ 2012-09-17 20:05 UTC (permalink / raw)
  To: Jiri Kosina, linux-input; +Cc: linux-usb, linux-kernel

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.

BugLink: http://bugs.launchpad.net/bugs/1049623
Signed-off-by: Kevin Daughtridge <kevin@kdau.com>
---
--- a/drivers/hid/usbhid/hid-core.c    2012-08-20 10:17:09.000000000 -0700
+++ b/drivers/hid/usbhid/hid-core.c    2012-09-16 18:51:45.381868737 -0700
@@ -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) {

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usbhid: call report_fixup before comparing descriptors
  2012-09-17 20:05 [PATCH] usbhid: call report_fixup before comparing descriptors Kevin Daughtridge
@ 2012-09-18 12:00 ` Sergei Shtylyov
  2012-09-18 16:16 ` Henrik Rydberg
  1 sibling, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2012-09-18 12:00 UTC (permalink / raw)
  To: Kevin Daughtridge; +Cc: Jiri Kosina, linux-input, linux-usb, linux-kernel

Hello.

On 18-09-2012 0:05, Kevin Daughtridge wrote:

> 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.

> BugLink: http://bugs.launchpad.net/bugs/1049623
> Signed-off-by: Kevin Daughtridge <kevin@kdau.com>
> ---
> --- a/drivers/hid/usbhid/hid-core.c    2012-08-20 10:17:09.000000000 -0700
> +++ b/drivers/hid/usbhid/hid-core.c    2012-09-16 18:51:45.381868737 -0700
> @@ -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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usbhid: call report_fixup before comparing descriptors
  2012-09-17 20:05 [PATCH] usbhid: call report_fixup before comparing descriptors Kevin Daughtridge
  2012-09-18 12:00 ` Sergei Shtylyov
@ 2012-09-18 16:16 ` Henrik Rydberg
  2012-09-19  2:21   ` Kevin Daughtridge
  1 sibling, 1 reply; 4+ messages in thread
From: Henrik Rydberg @ 2012-09-18 16:16 UTC (permalink / raw)
  To: Kevin Daughtridge; +Cc: Jiri Kosina, linux-input, linux-usb, linux-kernel

Hi Kevin,

> @@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usbhid: call report_fixup before comparing descriptors
  2012-09-18 16:16 ` Henrik Rydberg
@ 2012-09-19  2:21   ` Kevin Daughtridge
  0 siblings, 0 replies; 4+ messages in thread
From: Kevin Daughtridge @ 2012-09-19  2:21 UTC (permalink / raw)
  To: Henrik Rydberg, Sergei Shtylyov
  Cc: Jiri Kosina, linux-input, linux-usb, linux-kernel

On 09/18/12 09:16 N.U., Henrik Rydberg wrote:
> 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.

On 09/18/12 05:00 N.U., Sergei Shtylyov wrote:
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-19  2:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-17 20:05 [PATCH] usbhid: call report_fixup before comparing descriptors Kevin Daughtridge
2012-09-18 12:00 ` Sergei Shtylyov
2012-09-18 16:16 ` Henrik Rydberg
2012-09-19  2:21   ` Kevin Daughtridge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).