From: sashiko-bot@kernel.org
To: "Rong Zhang" <i@rong.moe>
Cc: lee@kernel.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH RFC v3 09/11] platform/x86: ideapad-laptop: Decouple hardware & classdev brightness for keyboard backlight
Date: Sun, 19 Jul 2026 17:13:05 +0000 [thread overview]
Message-ID: <20260719171306.574BB1F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260719-leds-trigger-hw-changed-v3-9-5fb55722e36e@rong.moe>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The refactored initialization path drops hardware brightness validation, allowing registration of buggy hardware states.
--
--- Patch [9]: [PATCH RFC v3 09/11] platform/x86: ideapad-laptop: Decouple hardware & classdev brightness for keyboard backlight ---
commit c04be41ffaebded5f3d78556c570769ff717d019
Author: Rong Zhang <i@rong.moe>
platform/x86: ideapad-laptop: Decouple hardware & classdev brightness for keyboard backlight
This commit decouples the hardware brightness from the LED classdev
brightness for keyboard backlights. It converts the last hardware
brightness state into an atomic_t to prevent race conditions and refactors
the initialization path.
> diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c
> --- a/drivers/platform/x86/lenovo/ideapad-laptop.c
> +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c
[ ... ]
> @@ -1700,21 +1745,30 @@ static int ideapad_kbd_bl_init(struct ideapad_private *priv)
> if (WARN_ON(priv->kbd_bl.initialized))
> return -EEXIST;
>
> - if (ideapad_kbd_bl_check_tristate(priv->kbd_bl.type))
> - priv->kbd_bl.led.max_brightness = 2;
> - else
> - priv->kbd_bl.led.max_brightness = 1;
> + hw_brightness = ideapad_kbd_bl_hw_brightness_get(priv);
> + if (hw_brightness < 0)
> + return hw_brightness;
>
> - brightness = ideapad_kbd_bl_brightness_get(priv);
> - if (brightness < 0)
> - return brightness;
> + atomic_set(&priv->kbd_bl.last_hw_brightness, hw_brightness);
[Severity: Medium]
Does this refactored initialization path drop the validation of the initial
hardware brightness?
In the old code, ideapad_kbd_bl_brightness_get() validated the brightness
against max_brightness, returning -EINVAL if the firmware returned an invalid
value. This safely aborted the initialization.
In this new flow, ideapad_kbd_bl_hw_brightness_get() just returns the raw
hardware value without validation, because max_brightness is not set until
later in this function, and ideapad_kbd_bl_brightness_parse() is bypassed.
If the firmware boots in a buggy state with an out-of-range brightness, will
this allow the LED class device to register successfully, only to spam dmesg
with "Unknown keyboard backlight value" warnings on every subsequent user-space
read?
> - priv->kbd_bl.last_brightness = brightness;
> priv->kbd_bl.led.name = "platform::" LED_FUNCTION_KBD_BACKLIGHT;
> priv->kbd_bl.led.brightness_get = ideapad_kbd_bl_led_cdev_brightness_get;
> priv->kbd_bl.led.brightness_set_blocking = ideapad_kbd_bl_led_cdev_brightness_set;
> priv->kbd_bl.led.flags = LED_BRIGHT_HW_CHANGED | LED_RETAIN_AT_SHUTDOWN;
>
> + switch (priv->kbd_bl.type) {
> + case KBD_BL_TRISTATE_AUTO:
> + case KBD_BL_TRISTATE:
> + priv->kbd_bl.led.max_brightness = 2;
> + break;
> + case KBD_BL_STANDARD:
> + priv->kbd_bl.led.max_brightness = 1;
> + break;
> + default:
> + /* This has already been validated by ideapad_check_features(). */
> + unreachable();
> + }
> +
> err = led_classdev_register(&priv->platform_device->dev, &priv->kbd_bl.led);
> if (err)
> return err;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260719-leds-trigger-hw-changed-v3-0-5fb55722e36e@rong.moe?part=9
next prev parent reply other threads:[~2026-07-19 17:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-18 17:05 [PATCH RFC v3 00/11] leds: Add support for hardware-initiated hardware control trigger transition Rong Zhang
2026-07-18 17:05 ` [PATCH RFC v3 01/11] leds: Move led_trigger_is_hw_controlled() to the right place Rong Zhang
2026-07-19 17:13 ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 02/11] leds: class: Remove hardware control trigger when writing brightness Rong Zhang
2026-07-19 17:13 ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 03/11] leds: trigger: Add offloaded() callback and provide trigger_may_offload attribute Rong Zhang
2026-07-19 17:13 ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 04/11] leds: cros_ec: trigger: Implement offloaded() callback Rong Zhang
2026-07-19 17:13 ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 05/11] leds: turris-omnia: trigger: Implement offloaded() and declare hw_control_trigger Rong Zhang
2026-07-19 17:13 ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 06/11] leds: trigger: netdev: Implement offloaded() callback Rong Zhang
2026-07-19 17:13 ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 07/11] leds: trigger: Enforce strict checks in led_trigger_is_hw_controlled() Rong Zhang
2026-07-19 17:13 ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 08/11] leds: trigger: Add led_trigger_notify_hw_control_changed() interface Rong Zhang
2026-07-19 17:13 ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 09/11] platform/x86: ideapad-laptop: Decouple hardware & classdev brightness for keyboard backlight Rong Zhang
2026-07-19 17:13 ` sashiko-bot [this message]
2026-07-18 17:05 ` [PATCH RFC v3 10/11] platform/x86: ideapad-laptop: Serialize keyboard backlight notifications Rong Zhang
2026-07-19 17:13 ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 11/11] platform/x86: ideapad-laptop: Fully support auto keyboard backlight Rong Zhang
2026-07-19 17:13 ` sashiko-bot
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=20260719171306.574BB1F00A3E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=i@rong.moe \
--cc=lee@kernel.org \
--cc=linux-leds@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