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

HID: uclogic: Refactor UGEEv2 probe magic data

A fututure patch will need to use the array of magic data that the
UGEEv2 devices expect on probe and the endpoint number. Move them to a
common place.

Refactor, no functional changes.

Tested-by: Mia Kanashi <chad@redpilled.dev>
Tested-by: Andreas Grosse <andig.mail@t-online.de>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

José Expósito and committed by
Jiri Kosina
bd85c131 f60c377f

+16 -6
+5 -6
drivers/hid/hid-uclogic-params.c
··· 1021 1021 * Returns: 1022 1022 * Zero, if successful. A negative errno code on error. 1023 1023 */ 1024 - static int uclogic_probe_interface(struct hid_device *hdev, u8 *magic_arr, 1025 - int magic_size, int endpoint) 1024 + static int uclogic_probe_interface(struct hid_device *hdev, const u8 *magic_arr, 1025 + size_t magic_size, int endpoint) 1026 1026 { 1027 1027 struct usb_device *udev; 1028 1028 unsigned int pipe = 0; ··· 1311 1311 __u8 *rdesc_pen = NULL; 1312 1312 s32 desc_params[UCLOGIC_RDESC_PH_ID_NUM]; 1313 1313 enum uclogic_params_frame_type frame_type; 1314 - __u8 magic_arr[] = { 1315 - 0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 1316 - }; 1317 1314 /* The resulting parameters (noop) */ 1318 1315 struct uclogic_params p = {0, }; 1319 1316 ··· 1341 1344 * The specific data was discovered by sniffing the Windows driver 1342 1345 * traffic. 1343 1346 */ 1344 - rc = uclogic_probe_interface(hdev, magic_arr, sizeof(magic_arr), 0x03); 1347 + rc = uclogic_probe_interface(hdev, uclogic_ugee_v2_probe_arr, 1348 + uclogic_ugee_v2_probe_size, 1349 + uclogic_ugee_v2_probe_endpoint); 1345 1350 if (rc) { 1346 1351 uclogic_params_init_invalid(&p); 1347 1352 goto output;
+6
drivers/hid/hid-uclogic-rdesc.c
··· 859 859 const size_t uclogic_rdesc_v2_frame_dial_size = 860 860 sizeof(uclogic_rdesc_v2_frame_dial_arr); 861 861 862 + const __u8 uclogic_ugee_v2_probe_arr[] = { 863 + 0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 864 + }; 865 + const size_t uclogic_ugee_v2_probe_size = sizeof(uclogic_ugee_v2_probe_arr); 866 + const int uclogic_ugee_v2_probe_endpoint = 0x03; 867 + 862 868 /* Fixed report descriptor template for UGEE v2 pen reports */ 863 869 const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[] = { 864 870 0x05, 0x0d, /* Usage Page (Digitizers), */
+5
drivers/hid/hid-uclogic-rdesc.h
··· 164 164 /* Report ID for tweaked UGEE v2 battery reports */ 165 165 #define UCLOGIC_RDESC_UGEE_V2_BATTERY_ID 0xba 166 166 167 + /* Magic data expected by UGEEv2 devices on probe */ 168 + extern const __u8 uclogic_ugee_v2_probe_arr[]; 169 + extern const size_t uclogic_ugee_v2_probe_size; 170 + extern const int uclogic_ugee_v2_probe_endpoint; 171 + 167 172 /* Fixed report descriptor template for UGEE v2 pen reports */ 168 173 extern const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[]; 169 174 extern const size_t uclogic_rdesc_ugee_v2_pen_template_size;