From: Mario Limonciello <mario.limonciello@xxxxxxx> Some drivers have static information that can be useful for userspace to have, but maintaining a sysfs file is overkill. Add an optional callback for drivers to be able to add their own uevent variables. Cc: Richard Hughes <hughsient@xxxxxxxxx> Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx> --- drivers/hid/hid-core.c | 6 ++++++ include/linux/hid.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 1b18e0dadbac..de95470066d9 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2844,6 +2844,12 @@ static int hid_uevent(const struct device *dev, struct kobj_uevent_env *env) hdev->firmware_version)) return -ENOMEM; } + if (hdev->uevent) { + int ret = hdev->uevent(dev, env); + + if (ret) + return ret; + } return 0; } diff --git a/include/linux/hid.h b/include/linux/hid.h index ffc81a8c7a49..36e3c167c7ff 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -680,6 +680,7 @@ struct hid_device { void (*hiddev_hid_event) (struct hid_device *, struct hid_field *field, struct hid_usage *, __s32); void (*hiddev_report_event) (struct hid_device *, struct hid_report *); + int (*uevent)(const struct device *dev, struct kobj_uevent_env *env); /* debugging support via debugfs */ unsigned short debug; -- 2.50.0