From 4d02c58eb1f19433cb852b2bde41c44849691614 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Dec 2012 15:26:55 -0700 Subject: HID: introduce helper for hid_driver boilerplate Introduce the module_hid_driver macro which is a convenience macro for HID driver modules similar to module_usb_driver. It is intended to be used by drivers with init/exit sections that do nothing but register/unregister the HID driver. Signed-off-by: H Hartley Sweeten Signed-off-by: Jiri Kosina --- include/linux/hid.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index 7330a0fef0c0..d6c71a674310 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -700,6 +700,18 @@ extern int __must_check __hid_register_driver(struct hid_driver *, extern void hid_unregister_driver(struct hid_driver *); +/** + * module_hid_driver() - Helper macro for registering a HID driver + * @__hid_driver: hid_driver struct + * + * Helper macro for HID drivers which do not do anything special in module + * init/exit. This eliminates a lot of boilerplate. Each module may only + * use this macro once, and calling it replaces module_init() and module_exit() + */ +#define module_hid_driver(__hid_driver) \ + module_driver(__hid_driver, hid_register_driver, \ + hid_unregister_driver) + extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report); extern int hidinput_connect(struct hid_device *hid, unsigned int force); -- cgit v1.2.3 From d463f4719a2fa883bc0bb1fb67e6fea2307aa6df Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 17 Dec 2012 15:27:33 -0700 Subject: HID: hid.h: remove unused hid_generic_{init,exit} prototypes These functions are not defined. Remove the extern declarations. Signed-off-by: H Hartley Sweeten Signed-off-by: Jiri Kosina --- include/linux/hid.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index d6c71a674310..828726c70503 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -884,9 +884,6 @@ static inline int hid_hw_power(struct hid_device *hdev, int level) int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, int interrupt); -extern int hid_generic_init(void); -extern void hid_generic_exit(void); - /* HID quirks API */ u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct); int usbhid_quirks_init(char **quirks_param); -- cgit v1.2.3 From fee5dfecb0c74c9eab475a2a20d7a5ababe2f8e6 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Mon, 17 Dec 2012 13:20:43 +0100 Subject: HID: uhid: use __packed__ for uhid_feature_answer_req We use __packed__ for all API structures so we can extend them without breaking alignment rules. We do try to explicitly align the structures, but to be safe we also use __packed__. uhid_feature_answer_req is already 64bit aligned so we can add __packed__ without breaking ABI. Signed-off-by: David Herrmann Signed-off-by: Jiri Kosina --- include/uapi/linux/uhid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/uapi/linux/uhid.h b/include/uapi/linux/uhid.h index 9c6974f16966..e9ed951e2b09 100644 --- a/include/uapi/linux/uhid.h +++ b/include/uapi/linux/uhid.h @@ -86,7 +86,7 @@ struct uhid_feature_answer_req { __u16 err; __u16 size; __u8 data[UHID_DATA_MAX]; -}; +} __attribute__((__packed__)); struct uhid_event { __u32 type; -- cgit v1.2.3 From 6d85d037d6247b06e1060b5e5ad0e4854a7d1e3b Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Thu, 31 Jan 2013 17:22:23 +0100 Subject: HID: core: add "report" hook, called once the report has been parsed This callback is called when the parsing of the report has been done by hid-core (so after the calls to .event). The hid drivers can now have access to the whole report by relying on the values stored in the different fields. Signed-off-by: Benjamin Tissoires Signed-off-by: Jiri Kosina --- include/linux/hid.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/hid.h b/include/linux/hid.h index 7330a0fef0c0..9f56e9040f66 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -589,6 +589,7 @@ struct hid_usage_id { * @raw_event: if report in report_table, this hook is called (NULL means nop) * @usage_table: on which events to call event (NULL means all) * @event: if usage in usage_table, this hook is called (NULL means nop) + * @report: this hook is called after parsing a report (NULL means nop) * @report_fixup: called before report descriptor parsing (NULL means nop) * @input_mapping: invoked on input registering before mapping an usage * @input_mapped: invoked on input registering after mapping an usage @@ -627,6 +628,7 @@ struct hid_driver { const struct hid_usage_id *usage_table; int (*event)(struct hid_device *hdev, struct hid_field *field, struct hid_usage *usage, __s32 value); + void (*report)(struct hid_device *hdev, struct hid_report *report); __u8 *(*report_fixup)(struct hid_device *hdev, __u8 *buf, unsigned int *size); -- cgit v1.2.3