Commit 2e4d27c4 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Greg Kroah-Hartman

[PATCH] Driver core: add driver_find helper to find a driver by its name

Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 4e12ac0f
...@@ -111,10 +111,29 @@ void driver_unregister(struct device_driver * drv) ...@@ -111,10 +111,29 @@ void driver_unregister(struct device_driver * drv)
up(&drv->unload_sem); up(&drv->unload_sem);
} }
/**
* 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.
*
* Note that kset_find_obj increments driver's reference count.
*/
struct device_driver *driver_find(const char *name, struct bus_type *bus)
{
struct kobject *k = kset_find_obj(&bus->drivers, name);
if (k)
return to_drv(k);
return NULL;
}
EXPORT_SYMBOL(driver_register); EXPORT_SYMBOL(driver_register);
EXPORT_SYMBOL(driver_unregister); EXPORT_SYMBOL(driver_unregister);
EXPORT_SYMBOL(get_driver); EXPORT_SYMBOL(get_driver);
EXPORT_SYMBOL(put_driver); EXPORT_SYMBOL(put_driver);
EXPORT_SYMBOL(driver_find);
EXPORT_SYMBOL(driver_create_file); EXPORT_SYMBOL(driver_create_file);
EXPORT_SYMBOL(driver_remove_file); EXPORT_SYMBOL(driver_remove_file);
...@@ -120,6 +120,7 @@ extern void driver_unregister(struct device_driver * drv); ...@@ -120,6 +120,7 @@ extern void driver_unregister(struct device_driver * drv);
extern struct device_driver * get_driver(struct device_driver * drv); extern struct device_driver * get_driver(struct device_driver * drv);
extern void put_driver(struct device_driver * drv); extern void put_driver(struct device_driver * drv);
extern struct device_driver *driver_find(const char *name, struct bus_type *bus);
/* driverfs interface for exporting driver attributes */ /* driverfs interface for exporting driver attributes */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment