diff options
author | Henrik Rydberg <rydberg@euromail.se> | 2013-02-25 05:31:43 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-02-25 07:26:39 -0500 |
commit | e90a6df80dc45ab53d2f4f4db297434e48c0208e (patch) | |
tree | c2758516b5a1d387ac81017de45adde6f19f622a | |
parent | 48a732dfaa77a4dfec803aa8f248373998704f76 (diff) |
HID: Extend the interface with report requests
Some drivers send reports directly to underlying device, creating an
unwanted dependency on the underlying transport layer. This patch adds
hid_hw_request() to the interface, thereby removing usbhid from the
lion share of the drivers.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | drivers/hid/usbhid/hid-core.c | 13 | ||||
-rw-r--r-- | include/linux/hid.h | 20 |
2 files changed, 33 insertions, 0 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 8e0c4bf94ebc..366fd09d257d 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
@@ -1243,6 +1243,18 @@ static int usbhid_power(struct hid_device *hid, int lvl) | |||
1243 | return r; | 1243 | return r; |
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | static void usbhid_request(struct hid_device *hid, struct hid_report *rep, int reqtype) | ||
1247 | { | ||
1248 | switch (reqtype) { | ||
1249 | case HID_REQ_GET_REPORT: | ||
1250 | usbhid_submit_report(hid, rep, USB_DIR_IN); | ||
1251 | break; | ||
1252 | case HID_REQ_SET_REPORT: | ||
1253 | usbhid_submit_report(hid, rep, USB_DIR_OUT); | ||
1254 | break; | ||
1255 | } | ||
1256 | } | ||
1257 | |||
1246 | static struct hid_ll_driver usb_hid_driver = { | 1258 | static struct hid_ll_driver usb_hid_driver = { |
1247 | .parse = usbhid_parse, | 1259 | .parse = usbhid_parse, |
1248 | .start = usbhid_start, | 1260 | .start = usbhid_start, |
@@ -1251,6 +1263,7 @@ static struct hid_ll_driver usb_hid_driver = { | |||
1251 | .close = usbhid_close, | 1263 | .close = usbhid_close, |
1252 | .power = usbhid_power, | 1264 | .power = usbhid_power, |
1253 | .hidinput_input_event = usb_hidinput_input_event, | 1265 | .hidinput_input_event = usb_hidinput_input_event, |
1266 | .request = usbhid_request, | ||
1254 | }; | 1267 | }; |
1255 | 1268 | ||
1256 | static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id) | 1269 | static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id) |
diff --git a/include/linux/hid.h b/include/linux/hid.h index e14b465b1146..261c713d4842 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h | |||
@@ -662,6 +662,7 @@ struct hid_driver { | |||
662 | * @hidinput_input_event: event input event (e.g. ff or leds) | 662 | * @hidinput_input_event: event input event (e.g. ff or leds) |
663 | * @parse: this method is called only once to parse the device data, | 663 | * @parse: this method is called only once to parse the device data, |
664 | * shouldn't allocate anything to not leak memory | 664 | * shouldn't allocate anything to not leak memory |
665 | * @request: send report request to device (e.g. feature report) | ||
665 | */ | 666 | */ |
666 | struct hid_ll_driver { | 667 | struct hid_ll_driver { |
667 | int (*start)(struct hid_device *hdev); | 668 | int (*start)(struct hid_device *hdev); |
@@ -676,6 +677,10 @@ struct hid_ll_driver { | |||
676 | unsigned int code, int value); | 677 | unsigned int code, int value); |
677 | 678 | ||
678 | int (*parse)(struct hid_device *hdev); | 679 | int (*parse)(struct hid_device *hdev); |
680 | |||
681 | void (*request)(struct hid_device *hdev, | ||
682 | struct hid_report *report, int reqtype); | ||
683 | |||
679 | }; | 684 | }; |
680 | 685 | ||
681 | #define PM_HINT_FULLON 1<<5 | 686 | #define PM_HINT_FULLON 1<<5 |
@@ -883,6 +888,21 @@ static inline int hid_hw_power(struct hid_device *hdev, int level) | |||
883 | return hdev->ll_driver->power ? hdev->ll_driver->power(hdev, level) : 0; | 888 | return hdev->ll_driver->power ? hdev->ll_driver->power(hdev, level) : 0; |
884 | } | 889 | } |
885 | 890 | ||
891 | |||
892 | /** | ||
893 | * hid_hw_request - send report request to device | ||
894 | * | ||
895 | * @hdev: hid device | ||
896 | * @report: report to send | ||
897 | * @reqtype: hid request type | ||
898 | */ | ||
899 | static inline void hid_hw_request(struct hid_device *hdev, | ||
900 | struct hid_report *report, int reqtype) | ||
901 | { | ||
902 | if (hdev->ll_driver->request) | ||
903 | hdev->ll_driver->request(hdev, report, reqtype); | ||
904 | } | ||
905 | |||
886 | int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, | 906 | int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, |
887 | int interrupt); | 907 | int interrupt); |
888 | 908 | ||