aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r--drivers/base/class.c17
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 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include "base.h" 20#include "base.h"
21 21
22extern struct subsystem devices_subsys;
23
22#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) 24#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
23#define to_class(obj) container_of(obj, struct class, subsys.kset.kobj) 25#define to_class(obj) container_of(obj, struct class, subsys.kset.kobj)
24 26
@@ -878,7 +880,22 @@ void class_interface_unregister(struct class_interface *class_intf)
878 class_put(parent); 880 class_put(parent);
879} 881}
880 882
883int virtual_device_parent(struct device *dev)
884{
885 if (!dev->class)
886 return -ENODEV;
887
888 if (!dev->class->virtual_dir) {
889 static struct kobject *virtual_dir = NULL;
881 890
891 if (!virtual_dir)
892 virtual_dir = kobject_add_dir(&devices_subsys.kset.kobj, "virtual");
893 dev->class->virtual_dir = kobject_add_dir(virtual_dir, dev->class->name);
894 }
895
896 dev->kobj.parent = dev->class->virtual_dir;
897 return 0;
898}
882 899
883int __init classes_init(void) 900int __init classes_init(void)
884{ 901{