Linux LED subsystem development
 help / color / mirror / Atom feed
From: Rong Zhang <i@rong.moe>
To: lee@kernel.org, sashiko-reviews@lists.linux.dev
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	linux-leds@vger.kernel.org,
	platform-driver-x86 <platform-driver-x86@vger.kernel.org>
Subject: Re: [PATCH v6 11/12] platform/x86: ideapad-laptop: Decouple hardware & classdev brightness for keyboard backlight
Date: Thu, 03 Sep 2026 03:15:44 +0800	[thread overview]
Message-ID: <8fd61cb314df880cd70d4fdd30642ed58af38c2b.camel@rong.moe> (raw)
In-Reply-To: <20260902181558.5FAD11F000E9@smtp.kernel.org>

Hi Lee,

On Wed, 2026-09-02 at 18:15 +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> 
> New issues:
> - [Low] Incorrect format string `%d` used for `unsigned int hw_brightness` in `dev_warn`.

Well, let me fix it in the next revision.

> 
> Pre-existing issues:
> - [High] The driver uses the unmanaged `led_classdev_register` API instead of the managed `devm_led_classdev_register` API.

This is yet another LLM hallucination. The driver needs to manage LED
unregistration itself to coordinate with ACPI notification handling.

Sashiko's concerns on other patches in the series are either pre-existing
issues that are out of the scope of the series, or LLM hallucinations.

Lee, I believe the series is ready for your review. Could you kindly
shine some light on the series? If you decide to apply PATCH v6 1-9 to
the LED tree, I will send a v7 solely for pdx86. Otherwise I will refresh
the whole series according to your insights.

Thanks,
Rong

> --
> 
> commit 227fca9f070999fc85599521adcec4975c6e441e
> Author: Rong Zhang <i@rong.moe>
> 
> platform/x86: ideapad-laptop: Decouple hardware & classdev brightness for keyboard backlight
> 
> This commit decouples hardware brightness from LED classdev brightness to
> better support models with an ambient light sensor (ALS). It also introduces
> a refactor of the initialization path to prepare for exposing the auto
> brightness mode.
> 
> > diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c
> > index 684421ba53cbc..712999b6900df 100644
> > --- a/drivers/platform/x86/lenovo/ideapad-laptop.c
> > +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c
> 
> [ ... ]
> 
> > @@ -1594,7 +1619,24 @@ static int ideapad_kbd_bl_check_tristate(int type)
> >  	return (type == KBD_BL_TRISTATE) || (type == KBD_BL_TRISTATE_AUTO);
> >  }
> >  
> > -static int ideapad_kbd_bl_brightness_get(struct ideapad_private *priv)
> > +static int ideapad_kbd_bl_brightness_parse(struct ideapad_private *priv, unsigned int hw_brightness)
> > +{
> > +	/* Off, low or high */
> > +	if (hw_brightness <= priv->kbd_bl.led.max_brightness)
> > +		return hw_brightness;
> > +
> > +	/* Auto (controlled by EC according to ALS), report as off */
> > +	if (priv->kbd_bl.type == KBD_BL_TRISTATE_AUTO &&
> > +	    hw_brightness == KBD_BL_AUTO_MODE_HW_BRIGHTNESS)
> > +		return 0;
> > +
> > +	/* Unknown value */
> > +	dev_warn(&priv->platform_device->dev,
> > +		 "Unknown keyboard backlight value: %d", hw_brightness);
> 
> [Severity: Low]
> Does this dev_warn() use the correct format string for its argument?
> The hw_brightness variable is passed as an unsigned int, but the format
> string uses %d which expects a signed int.
> 
> > +	return -EINVAL;
> > +}
> 
> [ ... ]
> 
> > @@ -1710,21 +1758,35 @@ static int ideapad_kbd_bl_init(struct ideapad_private *priv)
> >  	if (err)
> >  		return err;
> 
> [ ... ]
> 
> > +	/* Reject insane values. */
> > +	err = ideapad_kbd_bl_brightness_parse(priv, hw_brightness);
> > +	if (err < 0)
> > +		return err;
> > +
> >  	err = led_classdev_register(&priv->platform_device->dev, &priv->kbd_bl.led);
> 
> [Severity: High]
> This isn't a bug introduced by this patch, but should this use the managed
> devm_led_classdev_register() API instead?
> 
> The LED subsystem guidelines mandate using managed registration APIs to
> prevent resource leaks and use-after-free hazards during driver removal.
> 
> >  	if (err)
> >  		return err;

  reply	other threads:[~2026-09-02 19:21 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 18:09 [PATCH v6 00/12] leds: Add support for hardware-initiated hardware control trigger transition Rong Zhang
2026-09-01 18:09 ` [PATCH v6 01/12] leds: class: Always protect brightness_show() with led_access Rong Zhang
2026-09-02 18:15   ` sashiko-bot
2026-09-01 18:09 ` [PATCH v6 02/12] leds: Move led_trigger_is_hw_controlled() to the right place Rong Zhang
2026-09-02 18:15   ` sashiko-bot
2026-09-01 18:09 ` [PATCH v6 03/12] leds: class: Remove hardware control trigger when writing brightness Rong Zhang
2026-09-02 18:15   ` sashiko-bot
2026-09-01 18:09 ` [PATCH v6 04/12] leds: trigger: Add offloaded() callback and provide trigger_may_offload attribute Rong Zhang
2026-09-02 18:15   ` sashiko-bot
2026-09-01 18:09 ` [PATCH v6 05/12] leds: cros_ec: Implement offloaded() trigger callback Rong Zhang
2026-09-02 18:15   ` sashiko-bot
2026-09-02 18:45     ` Rong Zhang
2026-09-01 18:09 ` [PATCH v6 06/12] leds: turris-omnia: Implement offloaded() trigger callback and declare hw_control_trigger Rong Zhang
2026-09-02 18:15   ` sashiko-bot
2026-09-02 18:46     ` Rong Zhang
2026-09-01 18:09 ` [PATCH v6 07/12] leds: trigger: netdev: Implement offloaded() callback Rong Zhang
2026-09-02 18:15   ` sashiko-bot
2026-09-02 18:47     ` Rong Zhang
2026-09-01 18:09 ` [PATCH v6 08/12] leds: trigger: Enforce strict checks in led_trigger_is_hw_controlled() Rong Zhang
2026-09-02 18:15   ` sashiko-bot
2026-09-01 18:09 ` [PATCH v6 09/12] leds: trigger: Add led_trigger_notify_hw_control_changed() interface Rong Zhang
2026-09-02 18:15   ` sashiko-bot
2026-09-02 18:56     ` Rong Zhang
2026-09-01 18:09 ` [PATCH v6 10/12] platform/x86: ideapad-laptop: Serialize keyboard backlight tracking Rong Zhang
2026-09-02 18:15   ` sashiko-bot
2026-09-01 18:09 ` [PATCH v6 11/12] platform/x86: ideapad-laptop: Decouple hardware & classdev brightness for keyboard backlight Rong Zhang
2026-09-02 18:15   ` sashiko-bot
2026-09-02 19:15     ` Rong Zhang [this message]
2026-09-01 18:09 ` [PATCH v6 12/12] platform/x86: ideapad-laptop: Fully support auto " Rong Zhang
2026-09-02 18:15   ` 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=8fd61cb314df880cd70d4fdd30642ed58af38c2b.camel@rong.moe \
    --to=i@rong.moe \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=lee@kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=platform-driver-x86@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