diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-02-08 14:13:24 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-02-09 12:43:33 +0300 |
commit | fb451966ae7d7e6d6802de39bda5fa2f15781244 (patch) | |
tree | 31cf22cfe487741b7c7d35814102e26daaa86160 /drivers/base | |
parent | adc18506941dcafe216aba80766ab51c890358e8 (diff) | |
download | linux-fb451966ae7d7e6d6802de39bda5fa2f15781244.tar.xz |
driver core: bus: clean up driver_find()
Convert the driver_find() function to use bus_to_subsys() and not use
the back-pointer to the private structure.
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Link: https://lore.kernel.org/r/20230208111330.439504-16-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/bus.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 1040c724e50c..98edc7aa4fc4 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -1302,16 +1302,23 @@ EXPORT_SYMBOL_GPL(subsys_virtual_register); */ struct device_driver *driver_find(const char *name, struct bus_type *bus) { - struct kobject *k = kset_find_obj(bus->p->drivers_kset, name); + struct subsys_private *sp = bus_to_subsys(bus); + struct kobject *k; 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; + if (!sp) + return NULL; + + k = kset_find_obj(sp->drivers_kset, name); + subsys_put(sp); + if (!k) + return NULL; + + priv = to_driver(k); + + /* Drop reference added by kset_find_obj() */ + kobject_put(k); + return priv->driver; } EXPORT_SYMBOL_GPL(driver_find); |