linux-doc.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 <superm1@kernel.org>,
	Xino Ni <nijs1@lenovo.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,
	Mario Limonciello <mario.limonciello@amd.com>,
	Richard Hughes <hughsient@gmail.com>
Subject: [PATCH 2/6] HID: Allow HID drivers to add more uevent variables
Date: Wed,  2 Jul 2025 17:49:39 -0700	[thread overview]
Message-ID: <20250703004943.515919-3-derekjohn.clark@gmail.com> (raw)
In-Reply-To: <20250703004943.515919-1-derekjohn.clark@gmail.com>

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

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@gmail.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 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


  parent reply	other threads:[~2025-07-03  0:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03  0:49 [PATCH 0/6] HID: Add Legion Go S Driver Derek J. Clark
2025-07-03  0:49 ` [PATCH 1/6] HID: Include firmware version in the uevent Derek J. Clark
2025-07-03  0:49 ` Derek J. Clark [this message]
2025-07-03  0:49 ` [PATCH 3/6] HID: Add Legion Go S ID's Derek J. Clark
2025-07-03  0:49 ` [PATCH 4/6] HID: Add documentation for lenovo-legos-hid driver Derek J. Clark
2025-07-03  0:49 ` [PATCH 5/6] HID: Add lenovo-legos-hid core Derek J. Clark
2025-07-03  0:49 ` [PATCH 6/6] HID: Add lenovo-legos-hid configuration endpoint interface Derek J. Clark
2025-07-03 13:48 ` [PATCH 0/6] HID: Add Legion Go S Driver Benjamin Tissoires
2025-07-04  1:57   ` Mario Limonciello
2025-07-04 16:08     ` Richard Hughes
2025-07-10 15:15   ` 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=20250703004943.515919-3-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=nijs1@lenovo.com \
    --cc=pgriffais@valvesoftware.com \
    --cc=shaohz1@lenovo.com \
    --cc=superm1@kernel.org \
    --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).