aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/class.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2010-11-15 17:13:18 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-11-17 17:21:08 -0500
commit6b6e39a6a8da7234c538d14c43d3583da8875f9c (patch)
treecef5d25998665559ecc0cad2bcdb947cfa401b67 /drivers/base/class.c
parent14c05aa399e30f343f25158c9adfc44631378a96 (diff)
driver-core: merge private parts of class and bus
As classes and busses are pretty much the same thing, and we want to merge them together into a 'subsystem' in the future, let us share the same private data parts to make that merge easier. Signed-off-by: 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.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 7975a52bdf5b..4f1df2e8fd74 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -27,7 +27,7 @@ static ssize_t class_attr_show(struct kobject *kobj, struct attribute *attr,
27 char *buf) 27 char *buf)
28{ 28{
29 struct class_attribute *class_attr = to_class_attr(attr); 29 struct class_attribute *class_attr = to_class_attr(attr);
30 struct class_private *cp = to_class(kobj); 30 struct subsys_private *cp = to_subsys_private(kobj);
31 ssize_t ret = -EIO; 31 ssize_t ret = -EIO;
32 32
33 if (class_attr->show) 33 if (class_attr->show)
@@ -39,7 +39,7 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
39 const char *buf, size_t count) 39 const char *buf, size_t count)
40{ 40{
41 struct class_attribute *class_attr = to_class_attr(attr); 41 struct class_attribute *class_attr = to_class_attr(attr);
42 struct class_private *cp = to_class(kobj); 42 struct subsys_private *cp = to_subsys_private(kobj);
43 ssize_t ret = -EIO; 43 ssize_t ret = -EIO;
44 44
45 if (class_attr->store) 45 if (class_attr->store)
@@ -49,7 +49,7 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
49 49
50static void class_release(struct kobject *kobj) 50static void class_release(struct kobject *kobj)
51{ 51{
52 struct class_private *cp = to_class(kobj); 52 struct subsys_private *cp = to_subsys_private(kobj);
53 struct class *class = cp->class; 53 struct class *class = cp->class;
54 54
55 pr_debug("class '%s': release.\n", class->name); 55 pr_debug("class '%s': release.\n", class->name);
@@ -65,7 +65,7 @@ static void class_release(struct kobject *kobj)
65 65
66static const struct kobj_ns_type_operations *class_child_ns_type(struct kobject *kobj) 66static const struct kobj_ns_type_operations *class_child_ns_type(struct kobject *kobj)
67{ 67{
68 struct class_private *cp = to_class(kobj); 68 struct subsys_private *cp = to_subsys_private(kobj);
69 struct class *class = cp->class; 69 struct class *class = cp->class;
70 70
71 return class->ns_type; 71 return class->ns_type;
@@ -82,7 +82,7 @@ static struct kobj_type class_ktype = {
82 .child_ns_type = class_child_ns_type, 82 .child_ns_type = class_child_ns_type,
83}; 83};
84 84
85/* Hotplug events for classes go to the class class_subsys */ 85/* Hotplug events for classes go to the class subsys */
86static struct kset *class_kset; 86static struct kset *class_kset;
87 87
88 88
@@ -90,7 +90,7 @@ int class_create_file(struct class *cls, const struct class_attribute *attr)
90{ 90{
91 int error; 91 int error;
92 if (cls) 92 if (cls)
93 error = sysfs_create_file(&cls->p->class_subsys.kobj, 93 error = sysfs_create_file(&cls->p->subsys.kobj,
94 &attr->attr); 94 &attr->attr);
95 else 95 else
96 error = -EINVAL; 96 error = -EINVAL;
@@ -100,20 +100,20 @@ int class_create_file(struct class *cls, const struct class_attribute *attr)
100void class_remove_file(struct class *cls, const struct class_attribute *attr) 100void class_remove_file(struct class *cls, const struct class_attribute *attr)
101{ 101{
102 if (cls) 102 if (cls)
103 sysfs_remove_file(&cls->p->class_subsys.kobj, &attr->attr); 103 sysfs_remove_file(&cls->p->subsys.kobj, &attr->attr);
104} 104}
105 105
106static struct class *class_get(struct class *cls) 106static struct class *class_get(struct class *cls)
107{ 107{
108 if (cls) 108 if (cls)
109 kset_get(&cls->p->class_subsys); 109 kset_get(&cls->p->subsys);
110 return cls; 110 return cls;
111} 111}
112 112
113static void class_put(struct class *cls) 113static void class_put(struct class *cls)
114{ 114{
115 if (cls) 115 if (cls)
116 kset_put(&cls->p->class_subsys); 116 kset_put(&cls->p->subsys);
117} 117}
118 118
119static int add_class_attrs(struct class *cls) 119static int add_class_attrs(struct class *cls)
@@ -162,7 +162,7 @@ static void klist_class_dev_put(struct klist_node *n)
162 162
163int __class_register(struct class *cls, struct lock_class_key *key) 163int __class_register(struct class *cls, struct lock_class_key *key)
164{ 164{
165 struct class_private *cp; 165 struct subsys_private *cp;
166 int error; 166 int error;
167 167
168 pr_debug("device class '%s': registering\n", cls->name); 168 pr_debug("device class '%s': registering\n", cls->name);
@@ -170,11 +170,11 @@ int __class_register(struct class *cls, struct lock_class_key *key)
170 cp = kzalloc(sizeof(*cp), GFP_KERNEL); 170 cp = kzalloc(sizeof(*cp), GFP_KERNEL);
171 if (!cp) 171 if (!cp)
172 return -ENOMEM; 172 return -ENOMEM;
173 klist_init(&cp->class_devices, klist_class_dev_get, klist_class_dev_put); 173 klist_init(&cp->klist_devices, klist_class_dev_get, klist_class_dev_put);
174 INIT_LIST_HEAD(&cp->class_interfaces); 174 INIT_LIST_HEAD(&cp->class_interfaces);
175 kset_init(&cp->class_dirs); 175 kset_init(&cp->glue_dirs);
176 __mutex_init(&cp->class_mutex, "struct class mutex", key); 176 __mutex_init(&cp->class_mutex, "struct class mutex", key);
177 error = kobject_set_name(&cp->class_subsys.kobj, "%s", cls->name); 177 error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name);
178 if (error) { 178 if (error) {
179 kfree(cp); 179 kfree(cp);
180 return error; 180 return error;
@@ -187,15 +187,15 @@ int __class_register(struct class *cls, struct lock_class_key *key)
187#if defined(CONFIG_BLOCK) 187#if defined(CONFIG_BLOCK)
188 /* let the block class directory show up in the root of sysfs */ 188 /* let the block class directory show up in the root of sysfs */
189 if (!sysfs_deprecated || cls != &block_class) 189 if (!sysfs_deprecated || cls != &block_class)
190 cp->class_subsys.kobj.kset = class_kset; 190 cp->subsys.kobj.kset = class_kset;
191#else 191#else
192 cp->class_subsys.kobj.kset = class_kset; 192 cp->subsys.kobj.kset = class_kset;
193#endif 193#endif
194 cp->class_subsys.kobj.ktype = &class_ktype; 194 cp->subsys.kobj.ktype = &class_ktype;
195 cp->class = cls; 195 cp->class = cls;
196 cls->p = cp; 196 cls->p = cp;
197 197
198 error = kset_register(&cp->class_subsys); 198 error = kset_register(&cp->subsys);
199 if (error) { 199 if (error) {
200 kfree(cp); 200 kfree(cp);
201 return error; 201 return error;
@@ -210,7 +210,7 @@ void class_unregister(struct class *cls)
210{ 210{
211 pr_debug("device class '%s': unregistering\n", cls->name); 211 pr_debug("device class '%s': unregistering\n", cls->name);
212 remove_class_attrs(cls); 212 remove_class_attrs(cls);
213 kset_unregister(&cls->p->class_subsys); 213 kset_unregister(&cls->p->subsys);
214} 214}
215 215
216static void class_create_release(struct class *cls) 216static void class_create_release(struct class *cls)
@@ -295,7 +295,7 @@ void class_dev_iter_init(struct class_dev_iter *iter, struct class *class,
295 295
296 if (start) 296 if (start)
297 start_knode = &start->knode_class; 297 start_knode = &start->knode_class;
298 klist_iter_init_node(&class->p->class_devices, &iter->ki, start_knode); 298 klist_iter_init_node(&class->p->klist_devices, &iter->ki, start_knode);
299 iter->type = type; 299 iter->type = type;
300} 300}
301EXPORT_SYMBOL_GPL(class_dev_iter_init); 301EXPORT_SYMBOL_GPL(class_dev_iter_init);