Skip to contentSkip to conversation

HID: lenovo: Re-apply Fn-lock state on reset_resume

PATCH New Stephanie Wilde-Hobbs 1 participant 1 message Aug 19

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: lenovo: Re-apply Fn-lock state on reset_resume

When a ThinkPad 10 Ultrabook or X1 Tablet keyboard is reset during suspend/resume because the USB power session was lost, the keyboard firmware reverts to its power-on Fn-lock state while the driver keeps the value which was in effect before suspend. The fn_lock sysfs attribute then disagrees with the actual key behaviour, and the Fn-lock LED no longer reflects the state.

Re-apply the cached Fn-lock value in reset_resume, the same way the compact keyboards already resend their configuration. This only runs when the device was actually reset during resume, so a warm resume which preserves the keyboard state is unaffected.

Tested on a ThinkPad X1 Tablet Gen 3 keyboard.

Fixes c87de33ed43a ("HID: lenovo: Add ThinkPad 10 Ultrabook Keyboard fn_lock support")
Assisted-by ClaudeCode:deepseek-v4-flash-0731
---
 drivers/hid/hid-lenovo.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/hid/hid-lenovo.c +21 -0
index 3976d7b53b14..1ca58610e425 100644
@@ -1432,6 +1432,8 @@ static int lenovo_probe(struct hid_device *hdev,
 
 static int lenovo_reset_resume(struct hid_device *hdev)
 {
+	struct lenovo_drvdata *data;
+
 	switch (hdev->product) {
 	case USB_DEVICE_ID_LENOVO_CUSBKBD:
 	case USB_DEVICE_ID_LENOVO_TPIIUSBKBD:
@@ -1439,6 +1441,25 @@ static int lenovo_reset_resume(struct hid_device *hdev)
 			lenovo_features_set_cptkbd(hdev);
 
 		break;
+	case USB_DEVICE_ID_LENOVO_X12_TAB:
+	case USB_DEVICE_ID_LENOVO_X12_TAB2:
+	case USB_DEVICE_ID_LENOVO_X13_TAB:
+	case USB_DEVICE_ID_LENOVO_TP10UBKBD:
+	case USB_DEVICE_ID_LENOVO_X1_TAB:
+	case USB_DEVICE_ID_LENOVO_X1_TAB2:
+	case USB_DEVICE_ID_LENOVO_X1_TAB3:
+		/*
+		 * The keyboard reverts to its power-on Fn-lock default when
+		 * it is reset during resume, while we retain the state which
+		 * was in effect before suspend. Re-apply our cached value so
+		 * the Fn-lock behaviour and indicator stay in sync with the
+		 * sysfs interface.
+		 */
+		data = hid_get_drvdata(hdev);
+		if (data)
+			lenovo_led_set_tp10ubkbd(hdev, TP10UBKBD_FN_LOCK_LED,
+						 data->fn_lock);
+		break;
 	default:
 		break;
 	}
Signature · 1 line
2.55.0