public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
From: "Derek J. Clark" <derekjohn.clark@gmail.com>
To: Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <bentiss@kernel.org>
Cc: Richard Hughes <hughsient@gmail.com>,
	Mario Limonciello <mario.limonciello@amd.com>,
	Zhixin Zhang <zhangzx36@lenovo.com>,
	Mia Shao <shaohz1@lenovo.com>,
	Mark Pearson <mpearson-lenovo@squebb.ca>,
	"Pierre-Loup A . Griffais" <pgriffais@valvesoftware.com>,
	"Derek J . Clark" <derekjohn.clark@gmail.com>,
	linux-input@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v4 09/16] HID: Include firmware version in the uevent
Date: Fri, 20 Feb 2026 07:05:22 +0000	[thread overview]
Message-ID: <20260220070533.4083667-10-derekjohn.clark@gmail.com> (raw)
In-Reply-To: <20260220070533.4083667-1-derekjohn.clark@gmail.com>

From: Mario Limonciello <mario.limonciello@amd.com>

Userspace software fwupd probes some HID devices when the daemon starts
up to determine the current firmware version in order to be able to offer
updated firmware if the manufacturer has made it available.

In order to do this fwupd will detach the existing kernel driver if one
is present, send a HID command and then reattach the kernel driver.

This can be problematic if the user is using the HID device at the time
that fwupd probes the hardware and can cause a few frames of input to be
dropped.  In some cases HID drivers already have a command to look up the
firmware version, and so if that is exported to userspace fwupd can discover
it and avoid needing to detach the kernel driver until it's time to update
the device.

Introduce a new member in the struct hid_device for the version and export
a new uevent variable HID_FIRMWARE_VERSION that will display the version
that HID drivers obtained.

Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Cc: Richard Hughes <hughsient@gmail.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/hid/hid-core.c | 5 +++++
 include/linux/hid.h    | 1 +
 2 files changed, 6 insertions(+)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index a5b3a8ca2fcbc..524f2b9ed5121 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2887,6 +2887,11 @@ static int hid_uevent(const struct device *dev, struct kobj_uevent_env *env)
 	if (add_uevent_var(env, "MODALIAS=hid:b%04Xg%04Xv%08Xp%08X",
 			   hdev->bus, hdev->group, hdev->vendor, hdev->product))
 		return -ENOMEM;
+	if (hdev->firmware_version) {
+		if (add_uevent_var(env, "HID_FIRMWARE_VERSION=0x%04llX",
+				   hdev->firmware_version))
+			return -ENOMEM;
+	}
 
 	return 0;
 }
diff --git a/include/linux/hid.h b/include/linux/hid.h
index dce862cafbbd3..ce728c8d5bdc4 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -698,6 +698,7 @@ struct hid_device {
 	char name[128];							/* Device name */
 	char phys[64];							/* Device physical location */
 	char uniq[64];							/* Device unique identifier (serial #) */
+	u64 firmware_version;						/* Firmware version */
 
 	void *driver_data;
 
-- 
2.52.0


  parent reply	other threads:[~2026-02-20  7:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-20  7:05 [PATCH v4 00/16] HID: Add Legion Go and Go S Drivers Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 01/16] include: device.h: Add named device attributes Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 02/16] HID: hid-lenovo-go: Add Lenovo Legion Go Series HID Driver Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 03/16] HID: hid-lenovo-go: Add Feature Status Attributes Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 04/16] HID: hid-lenovo-go: Add Rumble and Haptic Settings Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 05/16] HID: hid-lenovo-go: Add FPS Mode DPI settings Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 06/16] HID: hid-lenovo-go: Add RGB LED control interface Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 07/16] HID: hid-lenovo-go: Add Calibration Settings Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 08/16] HID: hid-lenovo-go: Add OS Mode Toggle Derek J. Clark
2026-02-20  7:05 ` Derek J. Clark [this message]
2026-02-20  7:05 ` [PATCH v4 10/16] HID: hid-lenovo-go-s: Add Lenovo Legion Go S Series HID Driver Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 11/16] HID: hid-lenovo-go-s: Add MCU ID Attribute Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 12/16] HID: hid-lenovo-go-s: Add Feature Status Attributes Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 13/16] HID: hid-lenovo-go-s: Add Touchpad Mode Attributes Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 14/16] HID: hid-lenovo-go-s: Add RGB LED control interface Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 15/16] HID: hid-lenovo-go-s: Add IMU and Touchpad RO Attributes Derek J. Clark
2026-02-20  7:05 ` [PATCH v4 16/16] HID: Add documentation for Lenovo Legion Go drivers Derek J. Clark

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=20260220070533.4083667-10-derekjohn.clark@gmail.com \
    --to=derekjohn.clark@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=hughsient@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=pgriffais@valvesoftware.com \
    --cc=shaohz1@lenovo.com \
    --cc=zhangzx36@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