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

Configure Feed

Select the types of activity you want to include in your feed.

HID: asus: move vendor initialization to probe

ROG NKEY devices have multiple HID endpoints, around 3-4. One of those
endpoints has a usage page of 0xff31, and is the one that emits keyboard
shortcuts and controls RGB/backlight. Currently, this driver places
the usage page check under asus_input_mapping and then inits backlight
in asus_input_configured which is unnecessarily complicated and prevents
probe from performing customizations on the vendor endpoint.

Simplify the logic by introducing an is_vendor variable into probe that
checks for usage page 0xff31. Then, use this variable to move backlight
initialization into probe instead of asus_input_configured, and remove
the backlight check from asus_input_mapping.

Acked-by: Benjamin Tissoires <bentiss@kernel.org>
Reviewed-by: Denis Benato <benato.denis96@gmail.com>
Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev>
Link: https://patch.msgid.link/20260122075044.5070-6-lkml@antheas.dev
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Antheas Kapenekakis and committed by
Ilpo Järvinen
2b92b797 e82ae34a

+18 -17
+18 -17
drivers/hid/hid-asus.c
··· 48 48 #define T100CHI_MOUSE_REPORT_ID 0x06 49 49 #define FEATURE_REPORT_ID 0x0d 50 50 #define INPUT_REPORT_ID 0x5d 51 + #define HID_USAGE_PAGE_VENDOR 0xff310000 51 52 #define FEATURE_KBD_REPORT_ID 0x5a 52 53 #define FEATURE_KBD_REPORT_SIZE 64 53 54 #define FEATURE_KBD_LED_REPORT_ID1 0x5d ··· 128 127 struct input_dev *tp_kbd_input; 129 128 struct asus_kbd_leds *kbd_backlight; 130 129 const struct asus_touchpad_info *tp; 131 - bool enable_backlight; 132 130 struct power_supply *battery; 133 131 struct power_supply_desc battery_desc; 134 132 int battery_capacity; ··· 318 318 static int asus_event(struct hid_device *hdev, struct hid_field *field, 319 319 struct hid_usage *usage, __s32 value) 320 320 { 321 - if ((usage->hid & HID_USAGE_PAGE) == 0xff310000 && 321 + if ((usage->hid & HID_USAGE_PAGE) == HID_USAGE_PAGE_VENDOR && 322 322 (usage->hid & HID_USAGE) != 0x00 && 323 323 (usage->hid & HID_USAGE) != 0xff && !usage->type) { 324 324 hid_warn(hdev, "Unmapped Asus vendor usagepage code 0x%02x\n", ··· 938 938 939 939 drvdata->input = input; 940 940 941 - if (drvdata->enable_backlight && 942 - !asus_kbd_wmi_led_control_present(hdev) && 943 - asus_kbd_register_leds(hdev)) 944 - hid_warn(hdev, "Failed to initialize backlight.\n"); 945 - 946 941 return 0; 947 942 } 948 943 ··· 1009 1014 * as some make the keyboard appear as a pointer device. */ 1010 1015 return -1; 1011 1016 } 1012 - 1013 - /* 1014 - * Check and enable backlight only on devices with UsagePage == 1015 - * 0xff31 to avoid initializing the keyboard firmware multiple 1016 - * times on devices with multiple HID descriptors but same 1017 - * PID/VID. 1018 - */ 1019 - if (drvdata->quirks & QUIRK_USE_KBD_BACKLIGHT) 1020 - drvdata->enable_backlight = true; 1021 1017 1022 1018 set_bit(EV_REP, hi->input->evbit); 1023 1019 return 1; ··· 1126 1140 1127 1141 static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id) 1128 1142 { 1129 - int ret; 1143 + struct hid_report_enum *rep_enum; 1130 1144 struct asus_drvdata *drvdata; 1145 + struct hid_report *rep; 1146 + bool is_vendor = false; 1147 + int ret; 1131 1148 1132 1149 drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL); 1133 1150 if (drvdata == NULL) { ··· 1214 1225 return ret; 1215 1226 } 1216 1227 1228 + /* Check for vendor for RGB init and handle generic devices properly. */ 1229 + rep_enum = &hdev->report_enum[HID_INPUT_REPORT]; 1230 + list_for_each_entry(rep, &rep_enum->report_list, list) { 1231 + if ((rep->application & HID_USAGE_PAGE) == HID_USAGE_PAGE_VENDOR) 1232 + is_vendor = true; 1233 + } 1234 + 1217 1235 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 1218 1236 if (ret) { 1219 1237 hid_err(hdev, "Asus hw start failed: %d\n", ret); 1220 1238 return ret; 1221 1239 } 1240 + 1241 + if (is_vendor && (drvdata->quirks & QUIRK_USE_KBD_BACKLIGHT) && 1242 + !asus_kbd_wmi_led_control_present(hdev) && 1243 + asus_kbd_register_leds(hdev)) 1244 + hid_warn(hdev, "Failed to initialize backlight.\n"); 1222 1245 1223 1246 /* 1224 1247 * Check that input registration succeeded. Checking that