Linux USB
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <bentiss@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Pierre-Loup Griffais <pgriffais@valvesoftware.com>,
	open list <linux-kernel@vger.kernel.org>,
	"open list:HID CORE LAYER" <linux-input@vger.kernel.org>,
	"open list:USB SUBSYSTEM" <linux-usb@vger.kernel.org>,
	Curtis Vogt <curtis.vogt@gmail.com>,
	"Mario Limonciello" <mario.limonciello@amd.com>
Subject: [PATCH 1/3] HID: Add shutdown callback for device drivers
Date: Thu, 10 Sep 2026 12:02:52 -0500	[thread overview]
Message-ID: <20260910170254.833871-2-mario.limonciello@amd.com> (raw)
In-Reply-To: <20260910170254.833871-1-mario.limonciello@amd.com>

HID device drivers can receive suspend and resume notifications through
callbacks forwarded by their transport driver.  There is no corresponding
way to perform device-specific work during an orderly system shutdown.

Add a shutdown callback to struct hid_driver and dispatch it from the HID
bus shutdown operation.  This allows a HID device driver to communicate
with hardware before its transport is shut down.

Assisted-by: LLM
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/hid/hid-core.c | 13 +++++++++++++
 include/linux/hid.h    |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index a3ff0514f9cdf..7c8c1aa1f09c3 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2738,6 +2738,18 @@ static int hid_bus_match(struct device *dev, const struct device_driver *drv)
 	return hid_match_device(hdev, hdrv) != NULL;
 }
 
+static void hid_bus_shutdown(struct device *dev)
+{
+	struct hid_driver *hdrv;
+
+	if (!dev->driver)
+		return;
+
+	hdrv = to_hid_driver(dev->driver);
+	if (hdrv->shutdown)
+		hdrv->shutdown(to_hid_device(dev));
+}
+
 /**
  * hid_compare_device_paths - check if both devices share the same path
  * @hdev_a: hid device
@@ -3012,6 +3024,7 @@ const struct bus_type hid_bus_type = {
 	.match		= hid_bus_match,
 	.probe		= hid_device_probe,
 	.remove		= hid_device_remove,
+	.shutdown	= hid_bus_shutdown,
 	.uevent		= hid_uevent,
 };
 EXPORT_SYMBOL(hid_bus_type);
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 8d17b741638c9..ddf57779bb3ef 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -861,6 +861,7 @@ struct hid_usage_id {
  * @suspend: invoked on suspend (NULL means nop)
  * @resume: invoked on resume if device was not reset (NULL means nop)
  * @reset_resume: invoked on resume if device was reset (NULL means nop)
+ * @shutdown: invoked on system shutdown (NULL means nop)
  * @on_hid_hw_open: invoked when hid core opens first instance (NULL means nop)
  * @on_hid_hw_close: invoked when hid core closes last instance (NULL means nop)
  *
@@ -924,6 +925,7 @@ struct hid_driver {
 	int (*suspend)(struct hid_device *hdev, pm_message_t message);
 	int (*resume)(struct hid_device *hdev);
 	int (*reset_resume)(struct hid_device *hdev);
+	void (*shutdown)(struct hid_device *hdev);
 	void (*on_hid_hw_open)(struct hid_device *hdev);
 	void (*on_hid_hw_close)(struct hid_device *hdev);
 
-- 
2.43.0


  reply	other threads:[~2026-09-10 17:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 17:02 [PATCH 0/3] Add 'hid-valve-index' reset driver Mario Limonciello
2026-09-10 17:02 ` Mario Limonciello [this message]
2026-09-10 17:02 ` [PATCH 2/3] HID: valve-index: Reboot headset on system power transitions Mario Limonciello
2026-09-10 20:04   ` Michal Pecio
2026-09-10 20:43     ` Mario Limonciello
2026-09-10 20:52       ` Michal Pecio
2026-09-10 20:58         ` Mario Limonciello
2026-09-12 14:07           ` Curtis Vogt
2026-09-11  4:54       ` Curtis Vogt
2026-09-11  9:08         ` Michal Pecio
2026-09-11  5:54   ` Greg Kroah-Hartman
2026-09-11  6:01     ` Mario Limonciello
2026-09-11  9:16     ` Michal Pecio
2026-09-11  9:23       ` Greg Kroah-Hartman
2026-09-11 15:12         ` Mario Limonciello
2026-09-11 18:20           ` Michal Pecio
2026-09-10 17:02 ` [PATCH 3/3] USB: quirks: Ignore remote wakeup from the Valve Index breakout box hub Mario Limonciello

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=20260910170254.833871-2-mario.limonciello@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=bentiss@kernel.org \
    --cc=curtis.vogt@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pgriffais@valvesoftware.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