HID: Allow drivers without listeners to remain on the bus
Subsystems (2)
PATCH 1/1 HID: Allow drivers without listeners to remain on the bus
hid-picolcd and hid-wiimote do not allow any of hidinput, hiddev or hidraw to claim the device but still want to remain on the bus. Hence, if a driver uses the raw_event callback but no listener claimed the device, we still leave it on the bus as the driver probably handles everything by itself.
Under some circumstances (eg., hidinput_connect() fails and raw_event set) a device may not be left on the bus even though it has no listeners. But then if hidinput_connect() fails there are bigger issues than a device that is left unhandled. So we can safely use this heuristic to avoid adding another flag for special devices like hid-picolcd and hid-wiimote.
This also removes the ugly hack from hid-picolcd as this is no longer required.
---
Hi Jiri
I posted another patchset that introduced HID_CLAIMED_OTHER to avoid this heuristic but Henrik convinced me that this trivial check is the cleaner and less intrusive implementation. If you're interested, the old patchset was here:
http://thread.gmane.org/gmane.linux.kernel.input/25945
Henrik, can you add your signed-off-by as this was your idea?
Thanks
David
drivers/hid/hid-core.c | 8 ++++++-- drivers/hid/hid-picolcd.c | 4 ---- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/hid/hid-core.c +6 -2
@@ -1373,8 +1373,12 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)if ((connect_mask &HID_CONNECT_HIDRAW ) && !hidraw_connect (hdev)) hdev->claimed |=HID_CLAIMED_HIDRAW ; -if (!hdev->claimed) { -hid_err (hdev,"claimed by neither input, hiddev nor hidraw\n" ); +/* There are device drivers that do not allow hidinput, hiddev or +* hidraw to be connected but still want to remain on the bus. We +* require that these devices use the raw_event callback. Otherwise, we +* simply remove them from the bus if no listener claimed them. */ +if (!hdev->claimed && !hdev->driver->raw_event) { +hid_err (hdev,"device has no listeners, quitting\n" );return -ENODEV ; }
drivers/hid/hid-picolcd.c +0 -4
@@ -2613,11 +2613,7 @@ 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 ; error =hid_hw_start (hdev,0 ); - hdev->claimed =0 ;if (error) {hid_err (hdev,"hardware start failed\n" ); goto err_cleanup_data;
Signature · 1 line
1.7.11.2
Hi David,
Quoted 19 lines
hid-picolcd and hid-wiimote do not allow any of hidinput, hiddev or hidraw to claim the device but still want to remain on the bus. Hence, if a driver uses the
raw_eventcallback but no listener claimed the device, we still leave it on the bus as the driver probably handles everything by itself.Under some circumstances (eg.,
hidinput_connect()fails andraw_eventset) a device may not be left on the bus even though it has no listeners. But then ifhidinput_connect()fails there are bigger issues than a device that is left unhandled. So we can safely use this heuristic to avoid adding another flag for special devices like hid-picolcd and hid-wiimote.This also removes the ugly hack from hid-picolcd as this is no longer required.
Signed-off-by David Herrmann <[email protected]>---
Hi Jiri
Quoted 6 lines
I posted another patchset that introduced
HID_CLAIMED_OTHERto avoid this heuristic but Henrik convinced me that this trivial check is the cleaner and less intrusive implementation. If you're interested, the old patchset was here:
http://thread.gmane.org/gmane.linux.kernel.input/25945Henrik, can you add your signed-off-by as this was your idea?
Gladly, but I would like to change the wording slightly, since a driver with raw_event set is a listener, and we are still bailing out if there are no listeners at all. The title is thus misleading.
Quoted 13 lines
Thanks
Daviddrivers/hid/hid-core.c | 8 ++++++-- drivers/hid/hid-picolcd.c | 4 ---- 2 files changed, 6 insertions(+), 6 deletions(-)drivers/hid/hid-core.c +0
-0
drivers/hid/hid-core.c int hid_connect(struct hid_device *hdev, unsigned int connect_mask) · line 1379
Quoted 9 lines
drivers/hid/hid-core.c +4
-2@@ -1373,8 +1373,12 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)if ((connect_mask &HID_CONNECT_HIDRAW ) && !hidraw_connect (hdev)) hdev->claimed |=HID_CLAIMED_HIDRAW ; -if (!hdev->claimed) { -hid_err (hdev,"claimed by neither input, hiddev nor hidraw\n" ); +/* There are device drivers that do not allow hidinput, hiddev or +* hidraw to be connected but still want to remain on the bus. We +* require that these devices use the raw_event callback. Otherwise, we +* simply remove them from the bus if no listener claimed them. */
How about "Drivers using raw_event() are not required to connect to anything else"?
Quoted 24 lines
drivers/hid/hid-core.c +2
-0+if (!hdev->claimed && !hdev->driver->raw_event) { +hid_err (hdev,"device has no listeners, quitting\n" );return -ENODEV ; }drivers/hid/hid-picolcd.c +0
-4@@ -2613,11 +2613,7 @@ 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 ; error =hid_hw_start (hdev,0 ); - hdev->claimed =0 ;if (error) {hid_err (hdev,"hardware start failed\n" ); goto err_cleanup_data;Signature · 1 line
1.7.11.2
Thanks,
Henrik
Quoted 24 lines · Henrik Rydberg
Quoted 24 lines
hid-picolcd and hid-wiimote do not allow any of hidinput, hiddev or hidraw to claim the device but still want to remain on the bus. Hence, if a driver uses the
raw_eventcallback but no listener claimed the device, we still leave it on the bus as the driver probably handles everything by itself.Under some circumstances (eg.,
hidinput_connect()fails andraw_eventset) a device may not be left on the bus even though it has no listeners. But then ifhidinput_connect()fails there are bigger issues than a device that is left unhandled. So we can safely use this heuristic to avoid adding another flag for special devices like hid-picolcd and hid-wiimote.This also removes the ugly hack from hid-picolcd as this is no longer required.
Signed-off-by David Herrmann <[email protected]>---
Hi JiriI posted another patchset that introduced
HID_CLAIMED_OTHERto avoid this heuristic but Henrik convinced me that this trivial check is the cleaner and less intrusive implementation. If you're interested, the old patchset was here:
http://thread.gmane.org/gmane.linux.kernel.input/25945
Quoted 5 lines
Quoted 1 line
Henrik, can you add your signed-off-by as this was your idea?
Gladly, but I would like to change the wording slightly, since a driver with
raw_eventset is a listener, and we are still bailing out if there are no listeners at all. The title is thus misleading.
So could you guys please come up with a revised version of the patch? I like the aproach much more than the previous one, so would like to queue it for 3.6 merge window.
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs