diff options
-rw-r--r-- | drivers/base/base.h | 62 | ||||
-rw-r--r-- | drivers/base/bus.c | 13 | ||||
-rw-r--r-- | drivers/base/class.c | 42 | ||||
-rw-r--r-- | drivers/base/core.c | 24 | ||||
-rw-r--r-- | fs/sysfs/group.c | 10 | ||||
-rw-r--r-- | include/linux/device.h | 7 |
6 files changed, 70 insertions, 88 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h index 2ca7f5b7b824..19f49e41ce5d 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h | |||
@@ -1,31 +1,46 @@ | |||
1 | 1 | ||
2 | /** | 2 | /** |
3 | * struct bus_type_private - structure to hold the private to the driver core portions of the bus_type structure. | 3 | * struct subsys_private - structure to hold the private to the driver core portions of the bus_type/class structure. |
4 | * | 4 | * |
5 | * @subsys - the struct kset that defines this bus. This is the main kobject | 5 | * @subsys - the struct kset that defines this subsystem |
6 | * @drivers_kset - the list of drivers associated with this bus | 6 | * @devices_kset - the list of devices associated |
7 | * @devices_kset - the list of devices associated with this bus | 7 | * |
8 | * @drivers_kset - the list of drivers associated | ||
8 | * @klist_devices - the klist to iterate over the @devices_kset | 9 | * @klist_devices - the klist to iterate over the @devices_kset |
9 | * @klist_drivers - the klist to iterate over the @drivers_kset | 10 | * @klist_drivers - the klist to iterate over the @drivers_kset |
10 | * @bus_notifier - the bus notifier list for anything that cares about things | 11 | * @bus_notifier - the bus notifier list for anything that cares about things |
11 | * on this bus. | 12 | * on this bus. |
12 | * @bus - pointer back to the struct bus_type that this structure is associated | 13 | * @bus - pointer back to the struct bus_type that this structure is associated |
13 | * with. | 14 | * with. |
15 | * | ||
16 | * @class_interfaces - list of class_interfaces associated | ||
17 | * @glue_dirs - "glue" directory to put in-between the parent device to | ||
18 | * avoid namespace conflicts | ||
19 | * @class_mutex - mutex to protect the children, devices, and interfaces lists. | ||
20 | * @class - pointer back to the struct class that this structure is associated | ||
21 | * with. | ||
14 | * | 22 | * |
15 | * This structure is the one that is the actual kobject allowing struct | 23 | * This structure is the one that is the actual kobject allowing struct |
16 | * bus_type to be statically allocated safely. Nothing outside of the driver | 24 | * bus_type/class to be statically allocated safely. Nothing outside of the |
17 | * core should ever touch these fields. | 25 | * driver core should ever touch these fields. |
18 | */ | 26 | */ |
19 | struct bus_type_private { | 27 | struct subsys_private { |
20 | struct kset subsys; | 28 | struct kset subsys; |
21 | struct kset *drivers_kset; | ||
22 | struct kset *devices_kset; | 29 | struct kset *devices_kset; |
30 | |||
31 | struct kset *drivers_kset; | ||
23 | struct klist klist_devices; | 32 | struct klist klist_devices; |
24 | struct klist klist_drivers; | 33 | struct klist klist_drivers; |
25 | struct blocking_notifier_head bus_notifier; | 34 | struct blocking_notifier_head bus_notifier; |
26 | unsigned int drivers_autoprobe:1; | 35 | unsigned int drivers_autoprobe:1; |
27 | struct bus_type *bus; | 36 | struct bus_type *bus; |
37 | |||
38 | struct list_head class_interfaces; | ||
39 | struct kset glue_dirs; | ||
40 | struct mutex class_mutex; | ||
41 | struct class *class; | ||
28 | }; | 42 | }; |
43 | #define to_subsys_private(obj) container_of(obj, struct subsys_private, subsys.kobj) | ||
29 | 44 | ||
30 | struct driver_private { | 45 | struct driver_private { |
31 | struct kobject kobj; | 46 | struct kobject kobj; |
@@ -36,33 +51,6 @@ struct driver_private { | |||
36 | }; | 51 | }; |
37 | #define to_driver(obj) container_of(obj, struct driver_private, kobj) | 52 | #define to_driver(obj) container_of(obj, struct driver_private, kobj) |
38 | 53 | ||
39 | |||
40 | /** | ||
41 | * struct class_private - structure to hold the private to the driver core portions of the class structure. | ||
42 | * | ||
43 | * @class_subsys - the struct kset that defines this class. This is the main kobject | ||
44 | * @class_devices - list of devices associated with this class | ||
45 | * @class_interfaces - list of class_interfaces associated with this class | ||
46 | * @class_dirs - "glue" directory for virtual devices associated with this class | ||
47 | * @class_mutex - mutex to protect the children, devices, and interfaces lists. | ||
48 | * @class - pointer back to the struct class that this structure is associated | ||
49 | * with. | ||
50 | * | ||
51 | * This structure is the one that is the actual kobject allowing struct | ||
52 | * class to be statically allocated safely. Nothing outside of the driver | ||
53 | * core should ever touch these fields. | ||
54 | */ | ||
55 | struct class_private { | ||
56 | struct kset class_subsys; | ||
57 | struct klist class_devices; | ||
58 | struct list_head class_interfaces; | ||
59 | struct kset class_dirs; | ||
60 | struct mutex class_mutex; | ||
61 | struct class *class; | ||
62 | }; | ||
63 | #define to_class(obj) \ | ||
64 | container_of(obj, struct class_private, class_subsys.kobj) | ||
65 | |||
66 | /** | 54 | /** |
67 | * struct device_private - structure to hold the private to the driver core portions of the device structure. | 55 | * struct device_private - structure to hold the private to the driver core portions of the device structure. |
68 | * | 56 | * |
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 33c270a64db7..e243bd49764b 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include "power/power.h" | 20 | #include "power/power.h" |
21 | 21 | ||
22 | #define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr) | 22 | #define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr) |
23 | #define to_bus(obj) container_of(obj, struct bus_type_private, subsys.kobj) | ||
24 | 23 | ||
25 | /* | 24 | /* |
26 | * sysfs bindings for drivers | 25 | * sysfs bindings for drivers |
@@ -96,11 +95,11 @@ static ssize_t bus_attr_show(struct kobject *kobj, struct attribute *attr, | |||
96 | char *buf) | 95 | char *buf) |
97 | { | 96 | { |
98 | struct bus_attribute *bus_attr = to_bus_attr(attr); | 97 | struct bus_attribute *bus_attr = to_bus_attr(attr); |
99 | struct bus_type_private *bus_priv = to_bus(kobj); | 98 | struct subsys_private *subsys_priv = to_subsys_private(kobj); |
100 | ssize_t ret = 0; | 99 | ssize_t ret = 0; |
101 | 100 | ||
102 | if (bus_attr->show) | 101 | if (bus_attr->show) |
103 | ret = bus_attr->show(bus_priv->bus, buf); | 102 | ret = bus_attr->show(subsys_priv->bus, buf); |
104 | return ret; | 103 | return ret; |
105 | } | 104 | } |
106 | 105 | ||
@@ -108,11 +107,11 @@ static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr, | |||
108 | const char *buf, size_t count) | 107 | const char *buf, size_t count) |
109 | { | 108 | { |
110 | struct bus_attribute *bus_attr = to_bus_attr(attr); | 109 | struct bus_attribute *bus_attr = to_bus_attr(attr); |
111 | struct bus_type_private *bus_priv = to_bus(kobj); | 110 | struct subsys_private *subsys_priv = to_subsys_private(kobj); |
112 | ssize_t ret = 0; | 111 | ssize_t ret = 0; |
113 | 112 | ||
114 | if (bus_attr->store) | 113 | if (bus_attr->store) |
115 | ret = bus_attr->store(bus_priv->bus, buf, count); | 114 | ret = bus_attr->store(subsys_priv->bus, buf, count); |
116 | return ret; | 115 | return ret; |
117 | } | 116 | } |
118 | 117 | ||
@@ -858,9 +857,9 @@ static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store); | |||
858 | int bus_register(struct bus_type *bus) | 857 | int bus_register(struct bus_type *bus) |
859 | { | 858 | { |
860 | int retval; | 859 | int retval; |
861 | struct bus_type_private *priv; | 860 | struct subsys_private *priv; |
862 | 861 | ||
863 | priv = kzalloc(sizeof(struct bus_type_private), GFP_KERNEL); | 862 | priv = kzalloc(sizeof(struct subsys_private), GFP_KERNEL); |
864 | if (!priv) | 863 | if (!priv) |
865 | return -ENOMEM; | 864 | return -ENOMEM; |
866 | 865 | ||
diff --git a/drivers/base/class.c b/drivers/base/class.c index 9c63a5687d69..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 | ||
50 | static void class_release(struct kobject *kobj) | 50 | static 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 | ||
66 | static const struct kobj_ns_type_operations *class_child_ns_type(struct kobject *kobj) | 66 | static 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 */ |
86 | static struct kset *class_kset; | 86 | static 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) | |||
100 | void class_remove_file(struct class *cls, const struct class_attribute *attr) | 100 | void 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 | ||
106 | static struct class *class_get(struct class *cls) | 106 | static 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 | ||
113 | static void class_put(struct class *cls) | 113 | static 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 | ||
119 | static int add_class_attrs(struct class *cls) | 119 | static int add_class_attrs(struct class *cls) |
@@ -162,7 +162,7 @@ static void klist_class_dev_put(struct klist_node *n) | |||
162 | 162 | ||
163 | int __class_register(struct class *cls, struct lock_class_key *key) | 163 | int __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 | ||
216 | static void class_create_release(struct class *cls) | 216 | static 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 | } |
301 | EXPORT_SYMBOL_GPL(class_dev_iter_init); | 301 | EXPORT_SYMBOL_GPL(class_dev_iter_init); |
@@ -482,8 +482,8 @@ void class_interface_unregister(struct class_interface *class_intf) | |||
482 | class_put(parent); | 482 | class_put(parent); |
483 | } | 483 | } |
484 | 484 | ||
485 | ssize_t show_class_attr_string(struct class *class, struct class_attribute *attr, | 485 | ssize_t show_class_attr_string(struct class *class, |
486 | char *buf) | 486 | struct class_attribute *attr, char *buf) |
487 | { | 487 | { |
488 | struct class_attribute_string *cs; | 488 | struct class_attribute_string *cs; |
489 | cs = container_of(attr, struct class_attribute_string, attr); | 489 | cs = container_of(attr, struct class_attribute_string, attr); |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 761359261589..080e9ca11017 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -647,7 +647,7 @@ class_dir_create_and_add(struct class *class, struct kobject *parent_kobj) | |||
647 | dir->class = class; | 647 | dir->class = class; |
648 | kobject_init(&dir->kobj, &class_dir_ktype); | 648 | kobject_init(&dir->kobj, &class_dir_ktype); |
649 | 649 | ||
650 | dir->kobj.kset = &class->p->class_dirs; | 650 | dir->kobj.kset = &class->p->glue_dirs; |
651 | 651 | ||
652 | retval = kobject_add(&dir->kobj, parent_kobj, "%s", class->name); | 652 | retval = kobject_add(&dir->kobj, parent_kobj, "%s", class->name); |
653 | if (retval < 0) { | 653 | if (retval < 0) { |
@@ -672,7 +672,7 @@ static struct kobject *get_device_parent(struct device *dev, | |||
672 | if (sysfs_deprecated && dev->class == &block_class) { | 672 | if (sysfs_deprecated && dev->class == &block_class) { |
673 | if (parent && parent->class == &block_class) | 673 | if (parent && parent->class == &block_class) |
674 | return &parent->kobj; | 674 | return &parent->kobj; |
675 | return &block_class.p->class_subsys.kobj; | 675 | return &block_class.p->subsys.kobj; |
676 | } | 676 | } |
677 | #endif | 677 | #endif |
678 | 678 | ||
@@ -691,13 +691,13 @@ static struct kobject *get_device_parent(struct device *dev, | |||
691 | mutex_lock(&gdp_mutex); | 691 | mutex_lock(&gdp_mutex); |
692 | 692 | ||
693 | /* find our class-directory at the parent and reference it */ | 693 | /* find our class-directory at the parent and reference it */ |
694 | spin_lock(&dev->class->p->class_dirs.list_lock); | 694 | spin_lock(&dev->class->p->glue_dirs.list_lock); |
695 | list_for_each_entry(k, &dev->class->p->class_dirs.list, entry) | 695 | list_for_each_entry(k, &dev->class->p->glue_dirs.list, entry) |
696 | if (k->parent == parent_kobj) { | 696 | if (k->parent == parent_kobj) { |
697 | kobj = kobject_get(k); | 697 | kobj = kobject_get(k); |
698 | break; | 698 | break; |
699 | } | 699 | } |
700 | spin_unlock(&dev->class->p->class_dirs.list_lock); | 700 | spin_unlock(&dev->class->p->glue_dirs.list_lock); |
701 | if (kobj) { | 701 | if (kobj) { |
702 | mutex_unlock(&gdp_mutex); | 702 | mutex_unlock(&gdp_mutex); |
703 | return kobj; | 703 | return kobj; |
@@ -719,7 +719,7 @@ static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir) | |||
719 | { | 719 | { |
720 | /* see if we live in a "glue" directory */ | 720 | /* see if we live in a "glue" directory */ |
721 | if (!glue_dir || !dev->class || | 721 | if (!glue_dir || !dev->class || |
722 | glue_dir->kset != &dev->class->p->class_dirs) | 722 | glue_dir->kset != &dev->class->p->glue_dirs) |
723 | return; | 723 | return; |
724 | 724 | ||
725 | kobject_put(glue_dir); | 725 | kobject_put(glue_dir); |
@@ -746,7 +746,7 @@ static int device_add_class_symlinks(struct device *dev) | |||
746 | return 0; | 746 | return 0; |
747 | 747 | ||
748 | error = sysfs_create_link(&dev->kobj, | 748 | error = sysfs_create_link(&dev->kobj, |
749 | &dev->class->p->class_subsys.kobj, | 749 | &dev->class->p->subsys.kobj, |
750 | "subsystem"); | 750 | "subsystem"); |
751 | if (error) | 751 | if (error) |
752 | goto out; | 752 | goto out; |
@@ -765,7 +765,7 @@ static int device_add_class_symlinks(struct device *dev) | |||
765 | #endif | 765 | #endif |
766 | 766 | ||
767 | /* link in the class directory pointing to the device */ | 767 | /* link in the class directory pointing to the device */ |
768 | error = sysfs_create_link(&dev->class->p->class_subsys.kobj, | 768 | error = sysfs_create_link(&dev->class->p->subsys.kobj, |
769 | &dev->kobj, dev_name(dev)); | 769 | &dev->kobj, dev_name(dev)); |
770 | if (error) | 770 | if (error) |
771 | goto out_device; | 771 | goto out_device; |
@@ -793,7 +793,7 @@ static void device_remove_class_symlinks(struct device *dev) | |||
793 | if (sysfs_deprecated && dev->class == &block_class) | 793 | if (sysfs_deprecated && dev->class == &block_class) |
794 | return; | 794 | return; |
795 | #endif | 795 | #endif |
796 | sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev)); | 796 | sysfs_delete_link(&dev->class->p->subsys.kobj, &dev->kobj, dev_name(dev)); |
797 | } | 797 | } |
798 | 798 | ||
799 | /** | 799 | /** |
@@ -984,7 +984,7 @@ int device_add(struct device *dev) | |||
984 | mutex_lock(&dev->class->p->class_mutex); | 984 | mutex_lock(&dev->class->p->class_mutex); |
985 | /* tie the class to the device */ | 985 | /* tie the class to the device */ |
986 | klist_add_tail(&dev->knode_class, | 986 | klist_add_tail(&dev->knode_class, |
987 | &dev->class->p->class_devices); | 987 | &dev->class->p->klist_devices); |
988 | 988 | ||
989 | /* notify any interfaces that the device is here */ | 989 | /* notify any interfaces that the device is here */ |
990 | list_for_each_entry(class_intf, | 990 | list_for_each_entry(class_intf, |
@@ -1550,6 +1550,8 @@ EXPORT_SYMBOL_GPL(device_destroy); | |||
1550 | * exclusion between two different calls of device_rename | 1550 | * exclusion between two different calls of device_rename |
1551 | * on the same device to ensure that new_name is valid and | 1551 | * on the same device to ensure that new_name is valid and |
1552 | * won't conflict with other devices. | 1552 | * won't conflict with other devices. |
1553 | * | ||
1554 | * "Never use this function, bad things will happen" - gregkh | ||
1553 | */ | 1555 | */ |
1554 | int device_rename(struct device *dev, const char *new_name) | 1556 | int device_rename(struct device *dev, const char *new_name) |
1555 | { | 1557 | { |
@@ -1572,7 +1574,7 @@ int device_rename(struct device *dev, const char *new_name) | |||
1572 | } | 1574 | } |
1573 | 1575 | ||
1574 | if (dev->class) { | 1576 | if (dev->class) { |
1575 | error = sysfs_rename_link(&dev->class->p->class_subsys.kobj, | 1577 | error = sysfs_rename_link(&dev->class->p->subsys.kobj, |
1576 | &dev->kobj, old_device_name, new_name); | 1578 | &dev->kobj, old_device_name, new_name); |
1577 | if (error) | 1579 | if (error) |
1578 | goto out; | 1580 | goto out; |
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index 442f34ff1af8..c8769dc222d8 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c | |||
@@ -165,10 +165,7 @@ int sysfs_merge_group(struct kobject *kobj, | |||
165 | struct attribute *const *attr; | 165 | struct attribute *const *attr; |
166 | int i; | 166 | int i; |
167 | 167 | ||
168 | if (grp) | 168 | dir_sd = sysfs_get_dirent(kobj->sd, NULL, grp->name); |
169 | dir_sd = sysfs_get_dirent(kobj->sd, NULL, grp->name); | ||
170 | else | ||
171 | dir_sd = sysfs_get(kobj->sd); | ||
172 | if (!dir_sd) | 169 | if (!dir_sd) |
173 | return -ENOENT; | 170 | return -ENOENT; |
174 | 171 | ||
@@ -195,10 +192,7 @@ void sysfs_unmerge_group(struct kobject *kobj, | |||
195 | struct sysfs_dirent *dir_sd; | 192 | struct sysfs_dirent *dir_sd; |
196 | struct attribute *const *attr; | 193 | struct attribute *const *attr; |
197 | 194 | ||
198 | if (grp) | 195 | dir_sd = sysfs_get_dirent(kobj->sd, NULL, grp->name); |
199 | dir_sd = sysfs_get_dirent(kobj->sd, NULL, grp->name); | ||
200 | else | ||
201 | dir_sd = sysfs_get(kobj->sd); | ||
202 | if (dir_sd) { | 196 | if (dir_sd) { |
203 | for (attr = grp->attrs; *attr; ++attr) | 197 | for (attr = grp->attrs; *attr; ++attr) |
204 | sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name); | 198 | sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name); |
diff --git a/include/linux/device.h b/include/linux/device.h index d96af9701d60..1bf5cf0b4513 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -30,9 +30,8 @@ struct device_private; | |||
30 | struct device_driver; | 30 | struct device_driver; |
31 | struct driver_private; | 31 | struct driver_private; |
32 | struct class; | 32 | struct class; |
33 | struct class_private; | 33 | struct subsys_private; |
34 | struct bus_type; | 34 | struct bus_type; |
35 | struct bus_type_private; | ||
36 | struct device_node; | 35 | struct device_node; |
37 | 36 | ||
38 | struct bus_attribute { | 37 | struct bus_attribute { |
@@ -65,7 +64,7 @@ struct bus_type { | |||
65 | 64 | ||
66 | const struct dev_pm_ops *pm; | 65 | const struct dev_pm_ops *pm; |
67 | 66 | ||
68 | struct bus_type_private *p; | 67 | struct subsys_private *p; |
69 | }; | 68 | }; |
70 | 69 | ||
71 | extern int __must_check bus_register(struct bus_type *bus); | 70 | extern int __must_check bus_register(struct bus_type *bus); |
@@ -214,7 +213,7 @@ struct class { | |||
214 | 213 | ||
215 | const struct dev_pm_ops *pm; | 214 | const struct dev_pm_ops *pm; |
216 | 215 | ||
217 | struct class_private *p; | 216 | struct subsys_private *p; |
218 | }; | 217 | }; |
219 | 218 | ||
220 | struct class_dev_iter { | 219 | struct class_dev_iter { |