Skip to content

Commit 56d1b33

Browse files
antheasij-intel
authored andcommitted
HID: asus: simplify RGB init sequence
Currently, RGB initialization forks depending on whether a device is NKEY. However, in reality both initialization forks are the same, other than the NKEY initialization initializing the LED_REPORT_ID1, LED_REPORT_ID2 endpoints, and the non-NKEY initialization having a functionality check which is skipped for the NKEY path. Therefore, merge the if blocks, gate the ID1/ID2 initializations behind the NKEY quirk instead, and introduce the functionality check for NKEY devices (it is supported by them). There should be no functional change with this patch. Acked-by: Benjamin Tissoires <bentiss@kernel.org> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://patch.msgid.link/20260122075044.5070-2-lkml@antheas.dev Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 8f0b4cc commit 56d1b33

1 file changed

Lines changed: 22 additions & 30 deletions

File tree

drivers/hid/hid-asus.c

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -639,48 +639,40 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
639639
unsigned char kbd_func;
640640
int ret;
641641

642-
if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
643-
/* Initialize keyboard */
644-
ret = asus_kbd_init(hdev, FEATURE_KBD_REPORT_ID);
645-
if (ret < 0)
646-
return ret;
642+
ret = asus_kbd_init(hdev, FEATURE_KBD_REPORT_ID);
643+
if (ret < 0)
644+
return ret;
647645

648-
/* The LED endpoint is initialised in two HID */
646+
/* Get keyboard functions */
647+
ret = asus_kbd_get_functions(hdev, &kbd_func, FEATURE_KBD_REPORT_ID);
648+
if (ret < 0)
649+
return ret;
650+
651+
/* Check for backlight support */
652+
if (!(kbd_func & SUPPORT_KBD_BACKLIGHT))
653+
return -ENODEV;
654+
655+
if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
649656
ret = asus_kbd_init(hdev, FEATURE_KBD_LED_REPORT_ID1);
650657
if (ret < 0)
651658
return ret;
652659

653660
ret = asus_kbd_init(hdev, FEATURE_KBD_LED_REPORT_ID2);
654661
if (ret < 0)
655662
return ret;
663+
}
656664

657-
if (dmi_match(DMI_PRODUCT_FAMILY, "ProArt P16")) {
658-
ret = asus_kbd_disable_oobe(hdev);
659-
if (ret < 0)
660-
return ret;
661-
}
662-
663-
if (drvdata->quirks & QUIRK_ROG_ALLY_XPAD) {
664-
intf = to_usb_interface(hdev->dev.parent);
665-
udev = interface_to_usbdev(intf);
666-
validate_mcu_fw_version(hdev,
667-
le16_to_cpu(udev->descriptor.idProduct));
668-
}
669-
670-
} else {
671-
/* Initialize keyboard */
672-
ret = asus_kbd_init(hdev, FEATURE_KBD_REPORT_ID);
673-
if (ret < 0)
674-
return ret;
675-
676-
/* Get keyboard functions */
677-
ret = asus_kbd_get_functions(hdev, &kbd_func, FEATURE_KBD_REPORT_ID);
665+
if (dmi_match(DMI_PRODUCT_FAMILY, "ProArt P16")) {
666+
ret = asus_kbd_disable_oobe(hdev);
678667
if (ret < 0)
679668
return ret;
669+
}
680670

681-
/* Check for backlight support */
682-
if (!(kbd_func & SUPPORT_KBD_BACKLIGHT))
683-
return -ENODEV;
671+
if (drvdata->quirks & QUIRK_ROG_ALLY_XPAD) {
672+
intf = to_usb_interface(hdev->dev.parent);
673+
udev = interface_to_usbdev(intf);
674+
validate_mcu_fw_version(hdev,
675+
le16_to_cpu(udev->descriptor.idProduct));
684676
}
685677

686678
drvdata->kbd_backlight = devm_kzalloc(&hdev->dev,

0 commit comments

Comments
 (0)