All of lore.kernel.org
 help / color / mirror / Atom feed
From: ccc194101@163.com
To: gregkh@linuxfoundation.org
Cc: jannh@google.com, stern@rowland.harvard.edu,
	rex.nie@jaguarmicro.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	chenchangcheng <chenchangcheng@kylinos.cn>
Subject: [PATCH] usb: usbfs: Add reset_resume callback to usbfs.
Date: Fri, 22 Aug 2025 10:46:02 +0800	[thread overview]
Message-ID: <20250822024602.42894-1-ccc194101@163.com> (raw)

From: chenchangcheng <chenchangcheng@kylinos.cn>

When an Apple device is inserted into the host, and the host
wakes up from S3/S4 power states, if the reset_resume process
is triggered, the absence of a reset_resume callback in usbfs will
cause the device to unbind.
By adding a reset_resume callback to usbfs and reporting REMOVE and ADD
uevents in reset_resume, the userspace is prompted to reissue commands
to re-establish the binding with usbfs.

Signed-off-by: chenchangcheng <chenchangcheng@kylinos.cn>
---
 drivers/usb/core/devio.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index f6ce6e26e0d4..358850596b0d 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -749,6 +749,14 @@ static int driver_resume(struct usb_interface *intf)
 	return 0;
 }
 
+static int driver_reset_resume(struct usb_interface *intf)
+{
+	struct usb_device *udev = interface_to_usbdev(intf);
+
+	kobject_uevent(&udev->dev.kobj, KOBJ_REMOVE);
+	kobject_uevent(&udev->dev.kobj, KOBJ_ADD);
+	return 0;
+}
 #ifdef CONFIG_PM
 /* The following routines apply to the entire device, not interfaces */
 void usbfs_notify_suspend(struct usb_device *udev)
@@ -776,6 +784,7 @@ struct usb_driver usbfs_driver = {
 	.disconnect =	driver_disconnect,
 	.suspend =	driver_suspend,
 	.resume =	driver_resume,
+	.reset_resume =	driver_reset_resume,
 	.supports_autosuspend = 1,
 };
 

base-commit: b19a97d57c15643494ac8bfaaa35e3ee472d41da
-- 
2.25.1


             reply	other threads:[~2025-08-22  2:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22  2:46 ccc194101 [this message]
2025-08-22  4:49 ` [PATCH] usb: usbfs: Add reset_resume callback to usbfs Greg KH
2025-08-22 20:30 ` Alan Stern
2025-08-25  1:36   ` 自己
2025-08-25  2:01     ` Alan Stern
2025-08-25  2:19       ` 自己
2025-08-25  9:50         ` Oliver Neukum
2025-08-25 14:04         ` Re: " Alan Stern

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=20250822024602.42894-1-ccc194101@163.com \
    --to=ccc194101@163.com \
    --cc=chenchangcheng@kylinos.cn \
    --cc=gregkh@linuxfoundation.org \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rex.nie@jaguarmicro.com \
    --cc=stern@rowland.harvard.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.