[PATCH 11/15] HID: uhid: add and set HID_TYPE_UHID for uhid devices

From: Benjamin Tissoires
Date: Mon Jun 30 2014 - 17:28:44 EST


Some wacom devices checks on the .type field of hid_device. However,
uhid never set it, and as a result, we can not use uhid with some of
the wacom tablets.

Create a HID type HID_TYPE_UHID which is set by uhid and taken into
account by wacom.ko.

With this patch, the wacom.ko driver is completely agnostic of the
USB layer, except for the Wireless Receiver. That means that starting
from now, we can check every changes through uhis and comparing the
resulting kernel device.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@xxxxxxxxxx>
---
drivers/hid/uhid.c | 2 ++
drivers/input/tablet/wacom_sys.c | 3 ++-
include/linux/hid.h | 3 ++-
3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index 0cb92e3..6dbe2e0 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -407,6 +407,7 @@ static int uhid_dev_create(struct uhid_device *uhid,
hid->country = ev->u.create.country;
hid->driver_data = uhid;
hid->dev.parent = uhid_misc.this_device;
+ hid->type = HID_TYPE_UHID;

uhid->hid = hid;
uhid->running = true;
@@ -467,6 +468,7 @@ static int uhid_dev_create2(struct uhid_device *uhid,
hid->country = ev->u.create2.country;
hid->driver_data = uhid;
hid->dev.parent = uhid_misc.this_device;
+ hid->type = HID_TYPE_UHID;

uhid->hid = hid;
uhid->running = true;
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 2208b4a..065c6d5 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -1261,7 +1261,8 @@ static int wacom_probe(struct hid_device *hdev,
goto fail1;
}

- if (features->check_for_hid_type && features->hid_type != hdev->type) {
+ if (hdev->type != HID_TYPE_UHID &&
+ features->check_for_hid_type && features->hid_type != hdev->type) {
error = -ENODEV;
goto fail1;
}
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 9732299..df3c103 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -448,7 +448,8 @@ struct hid_input {
enum hid_type {
HID_TYPE_OTHER = 0,
HID_TYPE_USBMOUSE,
- HID_TYPE_USBNONE
+ HID_TYPE_USBNONE,
+ HID_TYPE_UHID
};

struct hid_driver;
--
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/