diff options
| author | Dmitry Torokhov <dtor_core@ameritech.net> | 2004-07-08 02:46:47 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <greg@kroah.com> | 2004-07-08 02:46:47 -0700 |
| commit | 2e4d27c4f4e427c4d08fa458f6b6f66b5afd7797 (patch) | |
| tree | c725d9d55c969065e4a0b255b5878cf365b775c4 | |
| parent | 4e12ac0f127911a024dbd15671a9073c23a0b312 (diff) | |
[PATCH] Driver core: add driver_find helper to find a driver by its name
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
| -rw-r--r-- | drivers/base/driver.c | 19 | ||||
| -rw-r--r-- | include/linux/device.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 0604b2b20e6f..735bd1702c40 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -111,10 +111,29 @@ void driver_unregister(struct device_driver * drv) 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_unregister); EXPORT_SYMBOL(get_driver); EXPORT_SYMBOL(put_driver); +EXPORT_SYMBOL(driver_find); EXPORT_SYMBOL(driver_create_file); EXPORT_SYMBOL(driver_remove_file); diff --git a/include/linux/device.h b/include/linux/device.h index 5e7f4219a8b8..49d3865aa27b 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -120,6 +120,7 @@ extern void driver_unregister(struct device_driver * drv); extern struct device_driver * get_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 */ |
