From: sashiko-bot@kernel.org
To: "Jesper B. Christensen" <jaytersen@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v3] HID: asus: support the Zenbook A14 (UX3407RA) keyboard backlight
Date: Tue, 01 Dec 2026 21:45:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-244290@kernel.org> (raw)
In-Reply-To: <20261201213143.5377-1-jaytersen@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] HID: asus: backlight restore in asus_resume() bypassed on
I2C-HID resume
- [Medium] HID: asus: asus_kbd_set_brightness_cdev() returns byte count
instead of 0
- [Low] HID: asus: unlocked initial brightness set after
led_classdev_register()
--
commit a00a581139058a6387bd604ffc2d0f43de055296
Author: Jesper B. Christensen <jaytersen@gmail.com>
HID: asus: support the Zenbook A14 (UX3407RA) keyboard backlight
This commit adds HID device IDs, report size and OOBE quirks, and direct
LED classdev registration for the ASUS Zenbook A14 (UX3407RA) I2C-HID
keyboard backlight on non-WMI platforms.
> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index 4f5749c9b2dbb..5860f21d002a6 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
[ ... ]
> @@ -706,7 +719,7 @@ static void asus_kbd_set_fn_lock(struct hid_device *hdev, bool enabled)
> hid_err(hdev, "Asus failed to set fn lock: %d\n", ret);
> }
>
> -static void asus_kbd_set_brightness(struct hid_device *hdev, u8 brightness)
> +static int asus_kbd_set_brightness(struct hid_device *hdev, u8 brightness)
> {
> const u8 buf[FEATURE_KBD_REPORT_SIZE] = {
> FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4, brightness
> @@ -716,6 +729,20 @@ static void asus_kbd_set_brightness(struct hid_device *hdev, u8 brightness)
> ret = asus_kbd_set_report(hdev, buf, sizeof(buf));
> if (ret < 0)
> hid_err(hdev, "Asus failed to set keyboard backlight: %d\n", ret);
> +
> + return ret;
> +}
> +
> +static int asus_kbd_set_brightness_cdev(struct led_classdev *led_cdev,
> + enum led_brightness brightness)
> +{
> + struct asus_drvdata *drvdata = container_of(led_cdev, struct asus_drvdata, kbd_led_cdev);
> + u8 level = (u8)brightness;
> +
> + if (level > EC_KBD_MAX_BACKLIGHT)
> + level = EC_KBD_MAX_BACKLIGHT;
> +
> + return asus_kbd_set_brightness(drvdata->hdev, level);
> }
[Severity: Medium]
Should asus_kbd_set_brightness_cdev() return 0 on success instead of the
byte count from asus_kbd_set_report()?
asus_kbd_set_report() returns the result of hid_hw_raw_request(), which is
the number of bytes transferred (FEATURE_KBD_REPORT_SIZE) on success.
Because led_classdev.brightness_set_blocking is expected to return 0 on
success or a negative error code (as asus_xgm_led_set() does in this
driver), callers such as led_set_brightness_sync() will receive 64 instead
of 0.
[ ... ]
> @@ -1012,10 +1039,29 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
> drvdata->listener.brightness_set = asus_kbd_backlight_set;
> ret = asus_hid_register_listener(&drvdata->listener);
> if (ret < 0) {
> - hid_err(hdev, "Unable to register kbd brightness listener: %d\n", ret);
> + if (ret != -ENODEV) {
> + hid_err(hdev, "Unable to register kbd brightness listener: %d\n", ret);
> + }
> drvdata->listener.brightness_set = NULL;
> }
>
> + // Non-x86 architectures do not have WMI, just register a led
> + // device directly
> + if (ret == -ENODEV) {
> + drvdata->kbd_led_cdev.name = "asus::kbd_backlight";
> + drvdata->kbd_led_cdev.brightness = 1;
> + drvdata->kbd_led_cdev.brightness_set_blocking = asus_kbd_set_brightness_cdev;
> + drvdata->kbd_led_cdev.max_brightness = EC_KBD_MAX_BACKLIGHT;
> + ret = led_classdev_register(&hdev->dev, &drvdata->kbd_led_cdev);
> + if (ret < 0) {
> + hid_err(hdev, "Unable to register kbd brightness led: %d\n", ret);
> + drvdata->kbd_led_cdev.brightness_set_blocking = NULL;
> + } else {
> + asus_kbd_set_brightness_cdev(&drvdata->kbd_led_cdev,
> + drvdata->kbd_led_cdev.brightness);
> + }
> + }
> +
> return ret;
> }
[Severity: Low]
Can calling asus_kbd_set_brightness_cdev() after led_classdev_register()
race with userspace brightness updates?
Once led_classdev_register() returns, sysfs is live and userspace (such as
systemd-backlight) can write a new brightness via set_brightness_work.
Because this initial call does not hold led_access, it can run after a
userspace write and overwrite the hardware brightness with the default of
1, leaving the hardware out of sync with kbd_led_cdev.brightness. Setting
the initial hardware brightness before led_classdev_register(), as
asus_xgm_init() does, avoids the race.
> @@ -1499,6 +1545,9 @@ static int __maybe_unused asus_resume(struct hid_device *hdev)
> if (drvdata->listener.brightness_set)
> asus_kbd_backlight_set(&drvdata->listener, drvdata->kbd_backlight_brightness);
>
> + if (drvdata->kbd_led_cdev.brightness_set_blocking)
> + asus_kbd_set_brightness_cdev(&drvdata->kbd_led_cdev, drvdata->kbd_led_cdev.brightness);
> +
> return 0;
> }
[Severity: Medium]
Does restoring drvdata->kbd_led_cdev in asus_resume() ever run on the
Zenbook A14 I2C-HID keyboard?
On system resume, i2c_hid_core_resume() calls hid_driver_reset_resume()
rather than hid_driver_resume(), so asus_reset_resume() runs and
asus_resume() is skipped, leaving the keyboard backlight unrestored after
suspend. Calling asus_kbd_set_brightness_cdev() directly during resume
also bypasses LED core suspend/resume serialization (LED_SUSPENDED,
set_brightness_work, and led_access); setting LED_CORE_SUSPENDRESUME on
drvdata->kbd_led_cdev.flags (as asus_xgm_init() does) would let the LED
core handle suspend and resume regardless of which HID resume callback is
used.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201213143.5377-1-jaytersen@gmail.com?part=1
next prev parent reply other threads:[~2026-12-01 21:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 21:31 [PATCH v3] HID: asus: support the Zenbook A14 (UX3407RA) keyboard backlight Jesper B. Christensen
2026-12-01 21:45 ` sashiko-bot [this message]
2026-12-05 2:12 ` Dr. David Alan Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-244290@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jaytersen@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox