[RFC PATCH v2 1/2] platform/x86: thinkpad_acpi: Extract kbdlight_notify_change() helper
From: Qiling Zhu
Date: Mon Nov 02 2026 - 11:16:19 EST
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@xxxxxxxxx>
---
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