Linux LED subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nikolay Plastinin" <plaztininikolai@gmail.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH v5] leds: trigger: input-events: Restore previous brightness on input
Date: Sun, 01 Nov 2026 07:26:47 +0000	[thread overview]
Message-ID: <sashiko-outbox-192307@kernel.org> (raw)
In-Reply-To: <20261101-leds-input-events-brightness-v5-1-d5296b1957dc@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] leds: trigger: input-events: direct traversal of internal led_cdevs list
--

commit 72651dfe13f897594e567a9427807c1d263125a5
Author: Nikolay Plastinin <plaztininikolai@gmail.com>

leds: trigger: input-events: Restore previous brightness on input

This commit converts the input-events LED trigger from a simple trigger to a
regular trigger that saves each LED's brightness before turning it off on idle
and restores that brightness on the next input event.

> diff --git a/drivers/leds/trigger/ledtrig-input-events.c b/drivers/leds/trigger/ledtrig-input-events.c
> index d057b2a239672..5fbd3e85399f4 100644
> --- a/drivers/leds/trigger/ledtrig-input-events.c
> +++ b/drivers/leds/trigger/ledtrig-input-events.c
[ ... ]
> @@ -28,7 +29,70 @@ static struct input_events_data {
>  	unsigned long led_off_time;
>  } input_events_data;
>  
> -static struct led_trigger *input_events_led_trigger;
[ ... ]
> +/* Must be called with input_events_data.lock held */
> +static void input_events_set_leds(bool on)
> +{
> +	struct led_classdev *led_cdev;
> +
> +	guard(rcu)();
> +	list_for_each_entry_rcu(led_cdev, &input_events_led_trigger.led_cdevs,
> +				trig_list) {
> +		struct input_events_led *led = led_get_trigger_data(led_cdev);
> +
> +		/* Not yet activated, or already deactivated during error unwind */
> +		if (!led)
> +			continue;

[Severity: Medium]
As reported by Lee Jones on v1 [1], should drivers/leds/trigger/ledtrig-input-events.c
avoid accessing led_cdevs and trig_list directly from outside the LED core?

In include/linux/leds.h, struct led_trigger defines led_cdevs as the list
managed by the LED core for simple triggers:

include/linux/leds.h:
struct led_trigger {
	...
	/* LEDs under control by this trigger (for simple triggers) */
	spinlock_t	  leddev_list_lock;
	struct list_head  led_cdevs;
};

Because led_trigger_set() in drivers/leds/led-triggers.c links
led_cdev->trig_list into trig->led_cdevs before calling trig->activate() and
unlinks it after calling trig->deactivate() on the device_add_groups() error
path, walking input_events_led_trigger.led_cdevs directly in
input_events_set_leds() exposes partially activated or already deactivated
LEDs to the trigger driver, requiring input_events_set_leds() and
input_events_deactivate() to work around LED core list ordering.

Would it be cleaner to either provide a helper in drivers/leds/led-triggers.c
as requested on v1, or maintain a driver-internal list of struct
input_events_led instances (similar to other non-simple triggers such as
drivers/leds/trigger/ledtrig-backlight.c)?

[1] https://lore.kernel.org/r/20260929091141.GD2112133@google.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261101-leds-input-events-brightness-v5-1-d5296b1957dc@gmail.com?part=1

  reply	other threads:[~2026-11-01  7:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01  7:19 [PATCH v5] leds: trigger: input-events: Restore previous brightness on input Nikolay Plastinin via B4 Relay
2026-11-01  7:26 ` sashiko-bot [this message]
2026-11-01 13:12 ` Greg Kroah-Hartman

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-192307@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=plaztininikolai@gmail.com \
    --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