[PATCH next] usb: usbfs: Add reset_resume for usbfs

From: Hongyu Xie
Date: Thu Jul 11 2024 - 04:43:38 EST


During hibernation, usb_resume_interface will set needs_binding to 1 if
the usb_driver has no reset_resume implimentation. The USB interface
will be rebind after usb_resume_complete.

Normally, that's fine. But if a USB interface has a matched kernel
driver, and a userspace driver or application is using this USB
interface through usbfs during hibernation, usbfs will be
detatched with the USB interface after resume. And this USB interface
will be bind with a kernel driver instead of usbfs.

So add reset_resume to fix this.

Signed-off-by: Hongyu Xie <xiehongyu1@xxxxxxxxxx>
---
drivers/usb/core/devio.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 3beb6a862e80..8c07df104c9a 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -746,6 +746,11 @@ static int driver_resume(struct usb_interface *intf)
return 0;
}

+static int driver_reset_resume(struct usb_interface *intf)
+{
+ return 0;
+}
+
#ifdef CONFIG_PM
/* The following routines apply to the entire device, not interfaces */
void usbfs_notify_suspend(struct usb_device *udev)
@@ -773,6 +778,7 @@ struct usb_driver usbfs_driver = {
.disconnect = driver_disconnect,
.suspend = driver_suspend,
.resume = driver_resume,
+ .reset_resume = driver_reset_resume,
.supports_autosuspend = 1,
};

--
2.34.1