From: Nikolay Plastinin via B4 Relay <devnull+plaztininikolai.gmail.com@kernel.org>
To: Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>
Cc: Hans de Goede <hansg@kernel.org>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
Nikolay Plastinin <plaztininikolai@gmail.com>
Subject: [PATCH v3 0/2] leds: trigger: input-events: Restore previous brightness on input
Date: Fri, 16 Oct 2026 02:56:48 +0800 [thread overview]
Message-ID: <20261016-leds-input-events-brightness-v3-0-2c462cafe020@gmail.com> (raw)
The input-events trigger turns LEDs back on with LED_FULL, so a keyboard
backlight with several levels always comes back at maximum after being
idle. This series restores the level the user picked instead.
Patch 1 adds led_trigger_for_each_led(), an RCU list iterator in leds.h.
Patch 2 uses it to save and restore each LED's brightness in one loop,
with per-LED state allocated in activate() and freed in deactivate().
There is no new exported function or callback API.
This came up while looking at a keyboard backlight idle timeout for ASUS
laptops in asusctl:
https://github.com/OpenGamingCollective/asusctl/issues/98
Tested on an ASUS ROG Flow X13 GV302XV (asus::kbd_backlight, 3 levels).
The trigger was built out of tree against Fedora 7.2.9-200.fc44.x86_64
with the modified leds.h and W=1. Brightness levels 1 and 2 were restored
after idle timeout and keyboard input. Twenty activate/deactivate cycles
completed, and no kernel messages appeared during the test. This was
not a full kernel build or a leak test.
LLM assistance was used to implement the review changes, prepare the
hardware test script, and draft the commit messages and this letter.
The hardware test was run locally by the submitter.
---
Changes in v3:
- Replace led_trigger_walk_leds() with led_trigger_for_each_led(), an
RCU list iterator in include/linux/leds.h, as suggested by Lee Jones.
- Remove the exported helper, callback typedef, and void-pointer argument.
- Keep saving and restoring brightness in input_events_set_leds(), using
guard(rcu)() and a single loop for both the on and off paths.
- Link to v2: https://lore.kernel.org/r/20260930-leds-input-events-brightness-v2-0-3948d3cddd83@gmail.com
Changes in v2:
- Keep the saved brightness in a per-LED struct allocated in activate()
and freed in deactivate(), stored in led_cdev->trigger_data, instead of
overloading blink_brightness (Lee Jones).
- Add led_trigger_walk_leds() to led-triggers.c and use it instead of
walking led_cdevs/trig_list from the trigger (Lee Jones).
- Use the Assisted-by tag format from coding-assistants.rst.
- Link to v1: https://lore.kernel.org/r/20260924-leds-input-events-brightness-v1-1-b0ceff3a2343@gmail.com
---
Nikolay Plastinin (2):
leds: triggers: Add led_trigger_for_each_led()
leds: trigger: input-events: Restore previous brightness on input
drivers/leds/trigger/ledtrig-input-events.c | 70 ++++++++++++++++++++++++++---
include/linux/leds.h | 12 +++++
2 files changed, 76 insertions(+), 6 deletions(-)
---
base-commit: f475845eaf3d749114a63270bf2efea459e14dd2
change-id: 20260924-leds-input-events-brightness-a76ae9a77b85
Best regards,
--
Nikolay Plastinin <plaztininikolai@gmail.com>
next reply other threads:[~2026-10-15 18:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 18:56 Nikolay Plastinin via B4 Relay [this message]
2026-10-15 18:56 ` [PATCH v3 1/2] leds: triggers: Add led_trigger_for_each_led() Nikolay Plastinin via B4 Relay
2026-10-15 18:56 ` [PATCH v3 2/2] leds: trigger: input-events: Restore previous brightness on input Nikolay Plastinin via B4 Relay
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=20261016-leds-input-events-brightness-v3-0-2c462cafe020@gmail.com \
--to=devnull+plaztininikolai.gmail.com@kernel.org \
--cc=hansg@kernel.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=plaztininikolai@gmail.com \
/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
all inboxes | Powered by JetHome®