From: James Clark <jjc@jclark.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>,
Matthias Kaehlcke <mka@chromium.org>
Cc: Johan Hovold <johan@kernel.org>,
Bastien Nocera <hadess@hadess.net>, Arnd Bergmann <arnd@arndb.de>,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
Douglas Anderson <dianders@chromium.org>,
Robert Nelson <robertcnelson@gmail.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org, regressions@lists.linux.dev
Subject: [PATCH v5 1/2] usb: core: export the generic device driver's operations
Date: Sat, 7 Nov 2026 09:36:37 +0700 [thread overview]
Message-ID: <50db3bea8dd8bbc09bd8a9c3b38f44d6523442eb.1794018128.git.jjc@jclark.com> (raw)
In-Reply-To: <cover.1794018128.git.jjc@jclark.com>
Export usb_generic_driver_probe(), usb_generic_driver_disconnect(),
usb_generic_driver_suspend() and usb_generic_driver_resume(), and move
their declarations to include/linux/usb.h. This lets a driver whose
probe may return -EPROBE_DEFER leave generic_subclass unset and call
them itself, so that it can defer before the device is configured.
Say in the generic_subclass kerneldoc not to set it in that case.
Signed-off-by: James Clark <jjc@jclark.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
Changes in v5:
- Added Alan's Acked-by
Changes in v4:
- New patch
drivers/usb/core/generic.c | 4 ++++
drivers/usb/core/usb.h | 6 ------
include/linux/usb.h | 10 +++++++++-
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index a48994e11ef3..53675d9fdb03 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -261,6 +261,7 @@ int usb_generic_driver_probe(struct usb_device *udev)
return 0;
}
+EXPORT_SYMBOL_GPL(usb_generic_driver_probe);
void usb_generic_driver_disconnect(struct usb_device *udev)
{
@@ -271,6 +272,7 @@ void usb_generic_driver_disconnect(struct usb_device *udev)
if (udev->actconfig)
usb_set_configuration(udev, -1);
}
+EXPORT_SYMBOL_GPL(usb_generic_driver_disconnect);
#ifdef CONFIG_PM
@@ -301,6 +303,7 @@ int usb_generic_driver_suspend(struct usb_device *udev, pm_message_t msg)
usbfs_notify_suspend(udev);
return rc;
}
+EXPORT_SYMBOL_GPL(usb_generic_driver_suspend);
int usb_generic_driver_resume(struct usb_device *udev, pm_message_t msg)
{
@@ -320,6 +323,7 @@ int usb_generic_driver_resume(struct usb_device *udev, pm_message_t msg)
usbfs_notify_resume(udev);
return rc;
}
+EXPORT_SYMBOL_GPL(usb_generic_driver_resume);
#endif /* CONFIG_PM */
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index a9b37aeb515b..9f1e4d197695 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -50,12 +50,6 @@ extern int usb_get_bos_descriptor(struct usb_device *dev);
extern void usb_release_bos_descriptor(struct usb_device *dev);
extern int usb_set_configuration(struct usb_device *dev, int configuration);
extern int usb_choose_configuration(struct usb_device *udev);
-extern int usb_generic_driver_probe(struct usb_device *udev);
-extern void usb_generic_driver_disconnect(struct usb_device *udev);
-extern int usb_generic_driver_suspend(struct usb_device *udev,
- pm_message_t msg);
-extern int usb_generic_driver_resume(struct usb_device *udev,
- pm_message_t msg);
static inline unsigned usb_get_max_power(struct usb_device *udev,
struct usb_host_config *c)
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 825f03b29067..4844f53e2fa8 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1301,7 +1301,8 @@ struct usb_driver {
* for devices bound to this driver.
* @generic_subclass: if set to 1, the generic USB driver's probe, disconnect,
* resume and suspend functions will be called in addition to the driver's
- * own, so this part of the setup does not need to be replicated.
+ * own, so this part of the setup does not need to be replicated. Do not set
+ * this if @probe may return -EPROBE_DEFER.
*
* USB device drivers must provide a name, other driver fields are optional.
*/
@@ -1375,6 +1376,13 @@ extern int __usb_register_device_driver(struct usb_device_driver *,
struct module *, const char *);
extern void usb_deregister_device_driver(struct usb_device_driver *);
+extern int usb_generic_driver_probe(struct usb_device *udev);
+extern void usb_generic_driver_disconnect(struct usb_device *udev);
+extern int usb_generic_driver_suspend(struct usb_device *udev,
+ pm_message_t msg);
+extern int usb_generic_driver_resume(struct usb_device *udev,
+ pm_message_t msg);
+
extern int usb_register_dev(struct usb_interface *intf,
struct usb_class_driver *class_driver);
extern void usb_deregister_dev(struct usb_interface *intf,
--
2.56.0
next prev parent reply other threads:[~2026-11-07 2:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 2:36 [PATCH v5 0/2] usb: misc: onboard_usb_dev: don't defer probing after the device is configured James Clark
2026-11-07 2:36 ` James Clark [this message]
2026-11-07 2:36 ` [PATCH v5 2/2] " James 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=50db3bea8dd8bbc09bd8a9c3b38f44d6523442eb.1794018128.git.jjc@jclark.com \
--to=jjc@jclark.com \
--cc=arnd@arndb.de \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=dianders@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=hadess@hadess.net \
--cc=johan@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mka@chromium.org \
--cc=regressions@lists.linux.dev \
--cc=robertcnelson@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®