Linux Input/HID development
 help / color / mirror / Atom feed
From: Stephanie Wilde-Hobbs <git@stephanie.is>
To: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <bentiss@kernel.org>,
	linux-kernel@vger.kernel.org
Cc: linux-input@vger.kernel.org,
	"Derek J . Clark" <derekjohn.clark@gmail.com>,
	Mark Pearson <mpearson-lenovo@squebb.ca>,
	stable@vger.kernel.org, Stephanie Wilde-Hobbs <git@stephanie.is>
Subject: [PATCH] HID: lenovo: Re-apply Fn-lock state on reset_resume
Date: Wed, 19 Aug 2026 17:16:09 +0200	[thread overview]
Message-ID: <20260819151609.68209-1-git@stephanie.is> (raw)

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
Signed-off-by: Stephanie Wilde-Hobbs <git@stephanie.is>
---
 drivers/hid/hid-lenovo.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 3976d7b53b14..1ca58610e425 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -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;
 	}
-- 
2.55.0


                 reply	other threads:[~2026-08-19 15:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260819151609.68209-1-git@stephanie.is \
    --to=git@stephanie.is \
    --cc=bentiss@kernel.org \
    --cc=derekjohn.clark@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=stable@vger.kernel.org \
    /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