ChangeSet 1.1496, 2004/01/19 16:31:36-08:00, hollisb@us.ibm.com [PATCH] Driver Core: add device_find() function Greg KH wrote: > > How about just adding a device_find() function to the driver core, where > you pass in a name and a type, so that others can use it? Something like this? drivers/base/core.c | 9 +++++++++ include/linux/device.h | 1 + 2 files changed, 10 insertions(+) diff -Nru a/drivers/base/core.c b/drivers/base/core.c --- a/drivers/base/core.c Mon Jan 19 17:05:19 2004 +++ b/drivers/base/core.c Mon Jan 19 17:05:19 2004 @@ -400,6 +400,14 @@ return error; } +struct device *device_find(const char *name, struct bus_type *bus) +{ + struct kobject *k = kset_find_obj(&bus->devices, name); + if (k) + return to_dev(k); + return NULL; +} + int __init devices_init(void) { return subsystem_register(&devices_subsys); @@ -416,6 +424,7 @@ EXPORT_SYMBOL(device_unregister_wait); EXPORT_SYMBOL(get_device); EXPORT_SYMBOL(put_device); +EXPORT_SYMBOL(device_find); EXPORT_SYMBOL(device_create_file); EXPORT_SYMBOL(device_remove_file); diff -Nru a/include/linux/device.h b/include/linux/device.h --- a/include/linux/device.h Mon Jan 19 17:05:19 2004 +++ b/include/linux/device.h Mon Jan 19 17:05:19 2004 @@ -354,6 +354,7 @@ */ extern struct device * get_device(struct device * dev); extern void put_device(struct device * dev); +extern struct device *device_find(const char *name, struct bus_type *bus); /* drivers/base/platform.c */