diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2006-08-07 22:19:37 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-25 21:08:38 -0700 |
commit | c205ef4880273d2de4ee5388d4e52227ff688cc4 (patch) | |
tree | 78e7cde849b9c40fd323b5550a8e64d5d169c55f /drivers/base/class.c | |
parent | a2de48cace5d0993da6cfa28b276ae724dc3569b (diff) | |
download | linux-c205ef4880273d2de4ee5388d4e52227ff688cc4.tar.gz linux-c205ef4880273d2de4ee5388d4e52227ff688cc4.tar.bz2 linux-c205ef4880273d2de4ee5388d4e52227ff688cc4.zip |
Driver core: create devices/virtual/ tree
This change creates a devices/virtual/CLASS_NAME tree for struct devices
that belong to a class, yet do not have a "real" struct device for a
parent. It automatically creates the directories on the fly as needed.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r-- | drivers/base/class.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index e078bc21d52e..cbdf47c0c60d 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -19,6 +19,8 @@ #include <linux/slab.h> #include "base.h" +extern struct subsystem devices_subsys; + #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) #define to_class(obj) container_of(obj, struct class, subsys.kset.kobj) @@ -878,7 +880,22 @@ void class_interface_unregister(struct class_interface *class_intf) class_put(parent); } +int virtual_device_parent(struct device *dev) +{ + if (!dev->class) + return -ENODEV; + + if (!dev->class->virtual_dir) { + static struct kobject *virtual_dir = NULL; + if (!virtual_dir) + virtual_dir = kobject_add_dir(&devices_subsys.kset.kobj, "virtual"); + dev->class->virtual_dir = kobject_add_dir(virtual_dir, dev->class->name); + } + + dev->kobj.parent = dev->class->virtual_dir; + return 0; +} int __init classes_init(void) { |