Skip to content

Commit 1e369dc

Browse files
superm1pastaq
authored andcommitted
[FROM-ML] HID: Include firmware version in the uevent
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> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca> Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
1 parent a78805e commit 1e369dc

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

drivers/hid/hid-core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,6 +2887,11 @@ static int hid_uevent(const struct device *dev, struct kobj_uevent_env *env)
28872887
if (add_uevent_var(env, "MODALIAS=hid:b%04Xg%04Xv%08Xp%08X",
28882888
hdev->bus, hdev->group, hdev->vendor, hdev->product))
28892889
return -ENOMEM;
2890+
if (hdev->firmware_version) {
2891+
if (add_uevent_var(env, "HID_FIRMWARE_VERSION=0x%04llX",
2892+
hdev->firmware_version))
2893+
return -ENOMEM;
2894+
}
28902895

28912896
return 0;
28922897
}

include/linux/hid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ struct hid_device {
698698
char name[128]; /* Device name */
699699
char phys[64]; /* Device physical location */
700700
char uniq[64]; /* Device unique identifier (serial #) */
701+
u64 firmware_version; /* Firmware version */
701702

702703
void *driver_data;
703704

0 commit comments

Comments
 (0)