linux-input.vger.kernel.org archive mirror
 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: 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,
	Richard Hughes <hughsient@gmail.com>
Subject: [PATCH v2 09/16] HID: Include firmware version in the uevent
Date: Mon, 29 Dec 2025 03:17:46 +0000	[thread overview]
Message-ID: <20251229031753.581664-10-derekjohn.clark@gmail.com> (raw)
In-Reply-To: <20251229031753.581664-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.

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 a5b3a8ca2fcb..524f2b9ed512 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 a4ddb94e3ee5..8249da55c9ba 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.51.2


  parent reply	other threads:[~2025-12-29  3:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-29  3:17 [PATCH v2 00/16] HID: Add Legion Go and Go S Drivers Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 01/16] include: device.h: Add named device attributes Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 02/16] HID: hid-lenovo-go: Add Lenovo Legion Go Series HID Driver Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 03/16] HID: hid-lenovo-go: Add Feature Status Attributes Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 04/16] HID: hid-lenovo-go: Add Rumble and Haptic Settings Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 05/16] HID: hid-lenovo-go: Add FPS Mode DPI settings Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 06/16] HID: hid-lenovo-go: Add RGB LED control interface Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 07/16] HID: hid-lenovo-go: Add Calibration Settings Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 08/16] HID: hid-lenovo-go: Add OS Mode Toggle Derek J. Clark
2025-12-29  3:17 ` Derek J. Clark [this message]
2025-12-29  3:17 ` [PATCH v2 10/16] HID: hid-lenovo-go-s: Add Lenovo Legion Go S Series HID Driver Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 11/16] HID: hid-lenovo-go-s: Add MCU ID Attribute Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 12/16] HID: hid-lenovo-go-s: Add Feature Status Attributes Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 13/16] HID: hid-lenovo-go-s: Add Touchpad Mode Attributes Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 14/16] HID: hid-lenovo-go-s: Add RGB LED control interface Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 15/16] HID: hid-lenovo-go-s: Add IMU and Touchpad RO Attributes Derek J. Clark
2025-12-29  3:17 ` [PATCH v2 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=20251229031753.581664-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;
as well as URLs for NNTP newsgroup(s).