From: Qiling Zhu <kmatzkaczor244@gmail.com>
To: "Mark Pearson" <mpearson-lenovo@squebb.ca>,
"Derek J. Clark" <derekjohn.clark@gmail.com>,
"Rong Zhang" <i@rong.moe>, "Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Henrique de Moraes Holschuh" <hmh@hmh.eng.br>
Cc: Griffin Kroah-Hartman <griffin@kroah.com>,
ibm-acpi-devel@lists.sourceforge.net, Lee Jones <lee@kernel.org>,
linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org,
Pavel Machek <pavel@kernel.org>,
platform-driver-x86@vger.kernel.org, vishnuocv@gmail.com,
vsankar@lenovo.com, Qiling Zhu <kmatzkaczor244@gmail.com>
Subject: [RFC PATCH v2 1/2] platform/x86: thinkpad_acpi: Extract kbdlight_notify_change() helper
Date: Mon, 2 Nov 2026 23:10:18 +0800 [thread overview]
Message-ID: <20261102151211.40701-2-kmatzkaczor244@gmail.com> (raw)
In-Reply-To: <20261102151211.40701-1-kmatzkaczor244@gmail.com>
TP_HKEY_EV_KBD_LIGHT handling in tpacpi_driver_event() reads back the EC
level, updates the cached brightness and notifies the LED core inline.
Extract this block into a separate kbdlight_notify_change() helper, in
preparation for reusing it in further changes.
No functional change intended.
Signed-off-by: Qiling Zhu <kmatzkaczor244@gmail.com>
---
drivers/platform/x86/lenovo/thinkpad_acpi.c | 41 +++++++++++++--------
1 file changed, 25 insertions(+), 16 deletions(-)
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 4f81855ad..3260eaa62 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -5313,6 +5313,29 @@ static void kbdlight_resume(void)
led_classdev_resume(&tpacpi_led_kbdlight.led_classdev);
}
+/*
+ * The EC cycles the keyboard backlight level itself on Fn+Space; check
+ * the current level and update the LED core state.
+ */
+static void kbdlight_notify_change(void)
+{
+ struct led_classdev *led_cdev = &tpacpi_led_kbdlight.led_classdev;
+ enum led_brightness brightness;
+
+ guard(mutex)(&kbdlight_mutex);
+
+ /*
+ * Check the brightness actually changed, setting the brightness
+ * through kbdlight_set_level() also triggers this event.
+ */
+ brightness = kbdlight_sysfs_get(NULL);
+ if (kbdlight_brightness == brightness)
+ return;
+
+ kbdlight_brightness = brightness;
+ led_classdev_notify_brightness_hw_changed(led_cdev, brightness);
+}
+
static struct ibm_struct kbdlight_driver_data = {
.name = "kbdlight",
.read = kbdlight_read,
@@ -11581,22 +11604,8 @@ static bool tpacpi_driver_event(const unsigned int hkey_event)
/* Key events are suppressed by default hotkey_user_mask */
return false;
case TP_HKEY_EV_KBD_LIGHT:
- if (tp_features.kbdlight) {
- enum led_brightness brightness;
-
- guard(mutex)(&kbdlight_mutex);
-
- /*
- * Check the brightness actually changed, setting the brightness
- * through kbdlight_set_level() also triggers this event.
- */
- brightness = kbdlight_sysfs_get(NULL);
- if (kbdlight_brightness != brightness) {
- kbdlight_brightness = brightness;
- led_classdev_notify_brightness_hw_changed(
- &tpacpi_led_kbdlight.led_classdev, brightness);
- }
- }
+ if (tp_features.kbdlight)
+ kbdlight_notify_change();
/* Key events are suppressed by default hotkey_user_mask */
return false;
case TP_HKEY_EV_DFR_CHANGE_ROW:
--
2.56.0
next prev parent reply other threads:[~2026-11-02 15:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-01 10:01 [RFC PATCH 0/1] platform/x86: thinkpad_acpi: Add support for auto keyboard backlight Qiling Zhu
2026-11-01 10:01 ` [RFC PATCH 1/1] " Qiling Zhu
2026-11-01 18:24 ` Rong Zhang
2026-11-01 17:57 ` [RFC PATCH 0/1] " Rong Zhang
2026-11-02 15:10 ` [RFC PATCH v2 0/2] " Qiling Zhu
2026-11-02 15:10 ` Qiling Zhu [this message]
2026-11-02 15:10 ` [RFC PATCH v2 2/2] platform/x86: thinkpad_acpi: " Qiling Zhu
2026-11-02 18:32 ` Rong Zhang
2026-11-02 18:13 ` [RFC PATCH v2 0/2] " Rong Zhang
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=20261102151211.40701-2-kmatzkaczor244@gmail.com \
--to=kmatzkaczor244@gmail.com \
--cc=derekjohn.clark@gmail.com \
--cc=griffin@kroah.com \
--cc=hansg@kernel.org \
--cc=hmh@hmh.eng.br \
--cc=i@rong.moe \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=mpearson-lenovo@squebb.ca \
--cc=pavel@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=vishnuocv@gmail.com \
--cc=vsankar@lenovo.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®