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.
Showing the changes to drivers (2 of 2 files). Show all
Unified · Split
| @@ -1288,6 +1288,33 @@ int subsys_virtual_register(struct bus_type *subsys, · 1287 unmodified lines | |||
| 1288 | } | 1288 | } |
| 1289 | EXPORT_SYMBOL_GPL(subsys_virtual_register); | 1289 | EXPORT_SYMBOL_GPL(subsys_virtual_register); |
| 1290 | 1290 | ||
| 1291 | /** | ||
| 1292 | * driver_find - locate driver on a bus by its name. | ||
| 1293 | * @name: name of the driver. | ||
| 1294 | * @bus: bus to scan for the driver. | ||
| 1295 | * | ||
| 1296 | * Call kset_find_obj() to iterate over list of drivers on | ||
| 1297 | * a bus to find driver by name. Return driver if found. | ||
| 1298 | * | ||
| 1299 | * This routine provides no locking to prevent the driver it returns | ||
| 1300 | * from being unregistered or unloaded while the caller is using it. | ||
| 1301 | * The caller is responsible for preventing this. | ||
| 1302 | */ | ||
| 1303 | struct device_driver *driver_find(const char *name, struct bus_type *bus) | ||
| 1304 | { | ||
| 1305 | struct kobject *k = kset_find_obj(bus->p->drivers_kset, name); | ||
| 1306 | struct driver_private *priv; | ||
| 1307 | |||
| 1308 | if (k) { | ||
| 1309 | /* Drop reference added by kset_find_obj() */ | ||
| 1310 | kobject_put(k); | ||
| 1311 | priv = to_driver(k); | ||
| 1312 | return priv->driver; | ||
| 1313 | } | ||
| 1314 | return NULL; | ||
| 1315 | } | ||
| 1316 | EXPORT_SYMBOL_GPL(driver_find); | ||
| 1317 | |||
| 1291 | int __init buses_init(void) | 1318 | int __init buses_init(void) |
| 1292 | { | 1319 | { |
| 1293 | bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL); | 1320 | bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL); |
| @@ -274,30 +274,3 @@ void driver_unregister(struct device_driver *drv) · 273 unmodified lines | |||
| 274 | bus_remove_driver(drv); | 274 | bus_remove_driver(drv); |
| 275 | } | 275 | } |
| 276 | EXPORT_SYMBOL_GPL(driver_unregister); | 276 | EXPORT_SYMBOL_GPL(driver_unregister); |
| 277 | |||
| 278 | /** | ||
| 279 | * driver_find - locate driver on a bus by its name. | ||
| 280 | * @name: name of the driver. | ||
| 281 | * @bus: bus to scan for the driver. | ||
| 282 | * | ||
| 283 | * Call kset_find_obj() to iterate over list of drivers on | ||
| 284 | * a bus to find driver by name. Return driver if found. | ||
| 285 | * | ||
| 286 | * This routine provides no locking to prevent the driver it returns | ||
| 287 | * from being unregistered or unloaded while the caller is using it. | ||
| 288 | * The caller is responsible for preventing this. | ||
| 289 | */ | ||
| 290 | struct device_driver *driver_find(const char *name, struct bus_type *bus) | ||
| 291 | { | ||
| 292 | struct kobject *k = kset_find_obj(bus->p->drivers_kset, name); | ||
| 293 | struct driver_private *priv; | ||
| 294 | |||
| 295 | if (k) { | ||
| 296 | /* Drop reference added by kset_find_obj() */ | ||
| 297 | kobject_put(k); | ||
| 298 | priv = to_driver(k); | ||
| 299 | return priv->driver; | ||
| 300 | } | ||
| 301 | return NULL; | ||
| 302 | } | ||
| 303 | EXPORT_SYMBOL_GPL(driver_find); | ||