Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: convert defines of HID class requests into a proper enum

This allows to export the type in BTF and so in the automatically
generated vmlinux.h. It will also add some static checks on the users
when we change the ll driver API (see not below).

Note that we need to also do change in the ll_driver API, but given
that this will have a wider impact outside of this tree, we leave this
as a TODO for the future.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20220902132938.2409206-11-benjamin.tissoires@redhat.com

+16 -13
+3 -3
drivers/hid/hid-core.c
··· 1921 1921 * DO NOT USE in hid drivers directly, but through hid_hw_request instead. 1922 1922 */ 1923 1923 int __hid_request(struct hid_device *hid, struct hid_report *report, 1924 - int reqtype) 1924 + enum hid_class_request reqtype) 1925 1925 { 1926 1926 char *buf; 1927 1927 int ret; ··· 2353 2353 * @reqtype: hid request type 2354 2354 */ 2355 2355 void hid_hw_request(struct hid_device *hdev, 2356 - struct hid_report *report, int reqtype) 2356 + struct hid_report *report, enum hid_class_request reqtype) 2357 2357 { 2358 2358 if (hdev->ll_driver->request) 2359 2359 return hdev->ll_driver->request(hdev, report, reqtype); ··· 2378 2378 */ 2379 2379 int hid_hw_raw_request(struct hid_device *hdev, 2380 2380 unsigned char reportnum, __u8 *buf, 2381 - size_t len, enum hid_report_type rtype, int reqtype) 2381 + size_t len, enum hid_report_type rtype, enum hid_class_request reqtype) 2382 2382 { 2383 2383 if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf) 2384 2384 return -EINVAL;
+5 -4
include/linux/hid.h
··· 923 923 unsigned int hidinput_count_leds(struct hid_device *hid); 924 924 __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code); 925 925 void hid_output_report(struct hid_report *report, __u8 *data); 926 - int __hid_request(struct hid_device *hid, struct hid_report *rep, int reqtype); 926 + int __hid_request(struct hid_device *hid, struct hid_report *rep, enum hid_class_request reqtype); 927 927 u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags); 928 928 struct hid_device *hid_allocate_device(void); 929 929 struct hid_report *hid_register_report(struct hid_device *device, ··· 1100 1100 int __must_check hid_hw_open(struct hid_device *hdev); 1101 1101 void hid_hw_close(struct hid_device *hdev); 1102 1102 void hid_hw_request(struct hid_device *hdev, 1103 - struct hid_report *report, int reqtype); 1103 + struct hid_report *report, enum hid_class_request reqtype); 1104 1104 int hid_hw_raw_request(struct hid_device *hdev, 1105 1105 unsigned char reportnum, __u8 *buf, 1106 - size_t len, enum hid_report_type rtype, int reqtype); 1106 + size_t len, enum hid_report_type rtype, 1107 + enum hid_class_request reqtype); 1107 1108 int hid_hw_output_report(struct hid_device *hdev, __u8 *buf, size_t len); 1108 1109 1109 1110 /** ··· 1132 1131 * @reqtype: hid request type 1133 1132 */ 1134 1133 static inline int hid_hw_idle(struct hid_device *hdev, int report, int idle, 1135 - int reqtype) 1134 + enum hid_class_request reqtype) 1136 1135 { 1137 1136 if (hdev->ll_driver->idle) 1138 1137 return hdev->ll_driver->idle(hdev, report, idle, reqtype);
+8 -6
include/uapi/linux/hid.h
··· 58 58 * HID class requests 59 59 */ 60 60 61 - #define HID_REQ_GET_REPORT 0x01 62 - #define HID_REQ_GET_IDLE 0x02 63 - #define HID_REQ_GET_PROTOCOL 0x03 64 - #define HID_REQ_SET_REPORT 0x09 65 - #define HID_REQ_SET_IDLE 0x0A 66 - #define HID_REQ_SET_PROTOCOL 0x0B 61 + enum hid_class_request { 62 + HID_REQ_GET_REPORT = 0x01, 63 + HID_REQ_GET_IDLE = 0x02, 64 + HID_REQ_GET_PROTOCOL = 0x03, 65 + HID_REQ_SET_REPORT = 0x09, 66 + HID_REQ_SET_IDLE = 0x0A, 67 + HID_REQ_SET_PROTOCOL = 0x0B, 68 + }; 67 69 68 70 /* 69 71 * HID class descriptor types