]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
HID: Include firmware version in the uevent
authorMario Limonciello <mario.limonciello@amd.com>
Tue, 10 Mar 2026 07:29:27 +0000 (07:29 +0000)
committerJiri Kosina <jkosina@suse.com>
Tue, 10 Mar 2026 16:53:17 +0000 (17:53 +0100)
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: Derek J. Clark <derekjohn.clark@gmail.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Cc: Richard Hughes <hughsient@gmail.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
drivers/hid/hid-core.c
include/linux/hid.h

index 840a601138688df5ad246b17c1d9a606f7c0380c..da57cbf0af26dd0834f2a0c685d23e8713137de5 100644 (file)
@@ -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;
 }
index 2990b9f94cb57d10e2eede1b7c81c09a51200dc3..b0b70c05049df23bfc81c0a237c39470de892119 100644 (file)
@@ -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;