summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-02-08 14:13:23 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-02-09 12:43:31 +0300
commitadc18506941dcafe216aba80766ab51c890358e8 (patch)
treeafac0a089dcd0cb824cb4034bb1c4e0d1be27757 /drivers/base
parentb5aaecb82ac0d008ddec8132979398b9b4e925fc (diff)
downloadlinux-adc18506941dcafe216aba80766ab51c890358e8.tar.xz
driver core: move driver_find() to bus.c
This function really is a bus function, not a driver one, so move it from driver.c to bus.c so that we can clean up some internal bus logic easier. Cc: "Rafael J. Wysocki" <rafael@kernel.org> Link: https://lore.kernel.org/r/20230208111330.439504-15-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/bus.c27
-rw-r--r--drivers/base/driver.c27
2 files changed, 27 insertions, 27 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 87c44661dcad..1040c724e50c 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -1288,6 +1288,33 @@ int subsys_virtual_register(struct bus_type *subsys,
}
EXPORT_SYMBOL_GPL(subsys_virtual_register);
+/**
+ * driver_find - locate driver on a bus by its name.
+ * @name: name of the driver.
+ * @bus: bus to scan for the driver.
+ *
+ * Call kset_find_obj() to iterate over list of drivers on
+ * a bus to find driver by name. Return driver if found.
+ *
+ * This routine provides no locking to prevent the driver it returns
+ * from being unregistered or unloaded while the caller is using it.
+ * The caller is responsible for preventing this.
+ */
+struct device_driver *driver_find(const char *name, struct bus_type *bus)
+{
+ struct kobject *k = kset_find_obj(bus->p->drivers_kset, name);
+ struct driver_private *priv;
+
+ if (k) {
+ /* Drop reference added by kset_find_obj() */
+ kobject_put(k);
+ priv = to_driver(k);
+ return priv->driver;
+ }
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(driver_find);
+
int __init buses_init(void)
{
bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL);
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 676b6275d5b5..aa5e5166a671 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -274,30 +274,3 @@ void driver_unregister(struct device_driver *drv)
bus_remove_driver(drv);
}
EXPORT_SYMBOL_GPL(driver_unregister);
-
-/**
- * driver_find - locate driver on a bus by its name.
- * @name: name of the driver.
- * @bus: bus to scan for the driver.
- *
- * Call kset_find_obj() to iterate over list of drivers on
- * a bus to find driver by name. Return driver if found.
- *
- * This routine provides no locking to prevent the driver it returns
- * from being unregistered or unloaded while the caller is using it.
- * The caller is responsible for preventing this.
- */
-struct device_driver *driver_find(const char *name, struct bus_type *bus)
-{
- struct kobject *k = kset_find_obj(bus->p->drivers_kset, name);
- struct driver_private *priv;
-
- if (k) {
- /* Drop reference added by kset_find_obj() */
- kobject_put(k);
- priv = to_driver(k);
- return priv->driver;
- }
- return NULL;
-}
-EXPORT_SYMBOL_GPL(driver_find);