[PATCH 0/3] HID: Add HID_CLAIMED_OTHER device flag

STALE5208d

4 messages, 1 author, 2012-07-15 · open the first message on its own page

[PATCH 0/3] HID: Add HID_CLAIMED_OTHER device flag

From: David Herrmann <hidden>
Date: 2012-07-15 18:22:15

Hi

Drivers like picolcd and wiimote work without the generic hid drivers (hidinput,
hidraw, hiddev). Therefore, we need to make sure that the hid-core does not drop
the device when no driver claimed it.

This introduces the HID_CLAIMED_OTHER flag which can be set by said drivers to
tell hid-core to allow the device without a generic driver loaded.

Patch 2 and 3 convert picolcd and wiimote to use this new flag.

Regards
David

David Herrmann (3):
  HID: Add HID_CLAIMED_OTHER for non-generic drivers
  HID: picolcd: explicitly claim hid devices with HID_CLAIMED_OTHER
  HID: wiimote: explicitly claim hid devices with HID_CLAIMED_OTHER

 drivers/hid/hid-core.c         | 2 ++
 drivers/hid/hid-picolcd.c      | 7 +++----
 drivers/hid/hid-wiimote-core.c | 1 +
 include/linux/hid.h            | 1 +
 4 files changed, 7 insertions(+), 4 deletions(-)

-- 
1.7.11.2

[PATCH 1/3] HID: Add HID_CLAIMED_OTHER for non-generic drivers

From: David Herrmann <hidden>
Date: 2012-07-15 18:22:16

All normal devices that correctly conform to the HID specs are handled by
the hid-input driver. However, for non-standard drivers we often don't
want hid-input to handle them but rather use specific hid drivers. But
hid_connect() requires at least one generic driver to claim the devices.
As hid_hw_start() calls hid_connect() we currently use an ugly workaround
by adding HID_CLAIMED_INPUT to hid->claimed and clear it after
hid_hw_start() again (see hid-picolcd.c for examples).

This adds the HID_CLAIMED_OTHER flag which can be set by device drivers to
tell the hid-core that they handle the device without the need of any
generic driver like hidinput, hiddev or hidraw.

Signed-off-by: David Herrmann <redacted>
---
 drivers/hid/hid-core.c | 2 ++
 include/linux/hid.h    | 1 +
 2 files changed, 3 insertions(+)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 9cdc74e..2039f32 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1391,6 +1391,8 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 	if (hdev->claimed & HID_CLAIMED_HIDRAW)
 		len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
 				((struct hidraw *)hdev->hidraw)->minor);
+	if (hdev->claimed & HID_CLAIMED_OTHER)
+		len += sprintf(buf + len, "%sother", len ? "," : "");
 
 	type = "Device";
 	for (i = 0; i < hdev->maxcollection; i++) {
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 449fa38..26b336a 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -452,6 +452,7 @@ struct hid_output_fifo {
 #define HID_CLAIMED_INPUT	1
 #define HID_CLAIMED_HIDDEV	2
 #define HID_CLAIMED_HIDRAW	4
+#define HID_CLAIMED_OTHER	8
 
 #define HID_STAT_ADDED		1
 #define HID_STAT_PARSED		2
-- 
1.7.11.2

[PATCH 2/3] HID: picolcd: explicitly claim hid devices with HID_CLAIMED_OTHER

From: David Herrmann <hidden>
Date: 2012-07-15 18:22:18

Instead of using an ugly workaround to make hid_hw_start() correctly
initialize the device, we now explicitely set HID_CLAIMED_OTHER before
initializing the hid device. This tells the hid-core to accept the device
even if no generic hid driver gets loaded.

Signed-off-by: David Herrmann <redacted>
---
 drivers/hid/hid-picolcd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c
index 45c3433..36a11a8 100644
--- a/drivers/hid/hid-picolcd.c
+++ b/drivers/hid/hid-picolcd.c
@@ -2613,11 +2613,10 @@ static int picolcd_probe(struct hid_device *hdev,
 		goto err_cleanup_data;
 	}
 
-	/* We don't use hidinput but hid_hw_start() fails if nothing is
-	 * claimed. So spoof claimed input. */
-	hdev->claimed = HID_CLAIMED_INPUT;
+	/* Tell hid-core that we handle the device without the need of any
+	 * generic hid-driver by setting the HID_CLAIMED_OTHER flag. */
+	hdev->claimed |= HID_CLAIMED_OTHER;
 	error = hid_hw_start(hdev, 0);
-	hdev->claimed = 0;
 	if (error) {
 		hid_err(hdev, "hardware start failed\n");
 		goto err_cleanup_data;
-- 
1.7.11.2

[PATCH 3/3] HID: wiimote: explicitly claim hid devices with HID_CLAIMED_OTHER

From: David Herrmann <hidden>
Date: 2012-07-15 18:22:19

We allow hidraw to be loaded on wiimote devices but if a kernel is
compiled without hidraw, calling hid_hw_start() will always fail as no
driver claims the device. Therefore, we now explicitly set
HID_CLAIMED_OTHER so the hid-core will allow loading the device even if no
generic driver claimed it. The wiimote driver will correctly handle the
device, anyway.

Signed-off-by: David Herrmann <redacted>
---
 drivers/hid/hid-wiimote-core.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index 84e2fbe..39154ff9 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -1189,6 +1189,7 @@ static int wiimote_hid_probe(struct hid_device *hdev,
 		goto err;
 	}
 
+	hdev->claimed |= HID_CLAIMED_OTHER;
 	ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
 	if (ret) {
 		hid_err(hdev, "HW start failed\n");
-- 
1.7.11.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help