2013-04-18 16:55:57

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH] HID: core: dump events in hidraw even if raw_event() returns > 0

If raw_events() returns a value not equal to 0, the processing stops.
However, I think we should still forward the events to the hidraw node,
unless there is an error in raw_event() marked by a negative value.

For instance, hid-magicmouse stops the processing because the device
use a hidden collection (not declared in hid reports descriptor), making
hid-core lost when dealing with it. However, forwarding it to the
user-space through hidraw is harmless and can help debugging the driver.

Of course, hid debugfs can be used, but there is currently a problem with
the output beeing too small for some devices and it adds processing in the
kernel because debugfs returns human readable strings outputs.

Signed-off-by: Benjamin Tissoires <[email protected]>
---

Hi Jiri,

well, this is the patch I mentioned earlier.
I don't think it will break anything, but I don't know how many applications
use hidraw and will be hurt by receiving more events. I did a quick review
of all hid drivers, and some of them are returning 1 in their raw_event().
The only problematic one is hid-primax, which manually calls
hid_report_raw_event() before returning 1... which is... weird.

Anyway, I would like your advice on this, if you think it's valuable or if
we should drop it and continue with the current implementation.

Cheers,
Benjamin

drivers/hid/hid-core.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 1129f49..e0b8175 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1315,6 +1315,8 @@ nomem:
if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) {
ret = hdrv->raw_event(hid, report, data, size);
if (ret != 0) {
+ if (ret > 0 && (hid->claimed & HID_CLAIMED_HIDRAW))
+ ret = hidraw_report_event(hid, data, size);
ret = ret < 0 ? ret : 0;
goto unlock;
}
--
1.8.1.4