Skip to content

Commit ab7bd22

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 ad9330f commit ab7bd22

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
@@ -635,48 +635,40 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
635635
unsigned char kbd_func;
636636
int ret;
637637

638-
if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD) {
639-
/* Initialize keyboard */
640-
ret = asus_kbd_init(hdev, FEATURE_KBD_REPORT_ID);
641-
if (ret < 0)
642-
return ret;
638+
ret = asus_kbd_init(hdev, FEATURE_KBD_REPORT_ID);
639+
if (ret < 0)
640+
return ret;
643641

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

649656
ret = asus_kbd_init(hdev, FEATURE_KBD_LED_REPORT_ID2);
650657
if (ret < 0)
651658
return ret;
659+
}
652660

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

677-
/* Check for backlight support */
678-
if (!(kbd_func & SUPPORT_KBD_BACKLIGHT))
679-
return -ENODEV;
667+
if (drvdata->quirks & QUIRK_ROG_ALLY_XPAD) {
668+
intf = to_usb_interface(hdev->dev.parent);
669+
udev = interface_to_usbdev(intf);
670+
validate_mcu_fw_version(hdev,
671+
le16_to_cpu(udev->descriptor.idProduct));
680672
}
681673

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

0 commit comments

Comments
 (0)