Skip to content

Commit d0754db

Browse files
antheasgregkh
authored andcommitted
HID: asus: simplify RGB init sequence
[ Upstream commit 56d1b33 ] 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> Stable-dep-of: 02bf61d ("HID: asus: fix missing hid_is_usb() check") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 70589b0 commit d0754db

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
@@ -638,48 +638,40 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
638638
unsigned char kbd_func;
639639
int ret;
640640

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

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

652659
ret = asus_kbd_init(hdev, FEATURE_KBD_LED_REPORT_ID2);
653660
if (ret < 0)
654661
return ret;
662+
}
655663

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

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

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

0 commit comments

Comments
 (0)