diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2008-05-28 12:28:39 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-07-22 00:54:52 -0400 |
commit | 1fbfee6c6dc0f4a4c587b6b163ee79643fc9aaa7 (patch) | |
tree | 897a68a94e12a9ba92b090f9da5a27086d29b8da /drivers/base | |
parent | 184f1f779d5a2e62de4a0b34842ddf8546beca8f (diff) |
class: rename "subsys" to "class_subsys" in internal class structure
This renames the struct class "subsys" field to be "class_subsys" to
make things easier when struct bus_type and struct class merge in the
future. It also makes grepping for fields easier as well.
Based on an idea from Kay.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/base.h | 7 | ||||
-rw-r--r-- | drivers/base/class.c | 23 | ||||
-rw-r--r-- | drivers/base/core.c | 31 |
3 files changed, 33 insertions, 28 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h index 670b95a1a510..a77d4bd2ea63 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h | |||
@@ -40,7 +40,7 @@ struct driver_private { | |||
40 | /** | 40 | /** |
41 | * struct class_private - structure to hold the private to the driver core portions of the class structure. | 41 | * struct class_private - structure to hold the private to the driver core portions of the class structure. |
42 | * | 42 | * |
43 | * @subsys - the struct kset that defines this class. This is the main kobject | 43 | * @class_subsys - the struct kset that defines this class. This is the main kobject |
44 | * @children - list of class_devices associated with this class | 44 | * @children - list of class_devices associated with this class |
45 | * @class_devices - list of devices associated with this class | 45 | * @class_devices - list of devices associated with this class |
46 | * @class_interfaces - list of class_interfaces associated with this class | 46 | * @class_interfaces - list of class_interfaces associated with this class |
@@ -54,14 +54,15 @@ struct driver_private { | |||
54 | * core should ever touch these fields. | 54 | * core should ever touch these fields. |
55 | */ | 55 | */ |
56 | struct class_private { | 56 | struct class_private { |
57 | struct kset subsys; | 57 | struct kset class_subsys; |
58 | struct list_head class_devices; | 58 | struct list_head class_devices; |
59 | struct list_head class_interfaces; | 59 | struct list_head class_interfaces; |
60 | struct kset class_dirs; | 60 | struct kset class_dirs; |
61 | struct semaphore sem; | 61 | struct semaphore sem; |
62 | struct class *class; | 62 | struct class *class; |
63 | }; | 63 | }; |
64 | #define to_class(obj) container_of(obj, struct class_private, subsys.kobj) | 64 | #define to_class(obj) \ |
65 | container_of(obj, struct class_private, class_subsys.kobj) | ||
65 | 66 | ||
66 | /* initialisation functions */ | 67 | /* initialisation functions */ |
67 | extern int devices_init(void); | 68 | extern int devices_init(void); |
diff --git a/drivers/base/class.c b/drivers/base/class.c index 48b518e66bfc..86778b86496e 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -70,7 +70,7 @@ static struct kobj_type class_ktype = { | |||
70 | .release = class_release, | 70 | .release = class_release, |
71 | }; | 71 | }; |
72 | 72 | ||
73 | /* Hotplug events for classes go to the class_obj subsys */ | 73 | /* Hotplug events for classes go to the class class_subsys */ |
74 | static struct kset *class_kset; | 74 | static struct kset *class_kset; |
75 | 75 | ||
76 | 76 | ||
@@ -78,7 +78,8 @@ int class_create_file(struct class *cls, const struct class_attribute *attr) | |||
78 | { | 78 | { |
79 | int error; | 79 | int error; |
80 | if (cls) | 80 | if (cls) |
81 | error = sysfs_create_file(&cls->p->subsys.kobj, &attr->attr); | 81 | error = sysfs_create_file(&cls->p->class_subsys.kobj, |
82 | &attr->attr); | ||
82 | else | 83 | else |
83 | error = -EINVAL; | 84 | error = -EINVAL; |
84 | return error; | 85 | return error; |
@@ -87,20 +88,20 @@ int class_create_file(struct class *cls, const struct class_attribute *attr) | |||
87 | void class_remove_file(struct class *cls, const struct class_attribute *attr) | 88 | void class_remove_file(struct class *cls, const struct class_attribute *attr) |
88 | { | 89 | { |
89 | if (cls) | 90 | if (cls) |
90 | sysfs_remove_file(&cls->p->subsys.kobj, &attr->attr); | 91 | sysfs_remove_file(&cls->p->class_subsys.kobj, &attr->attr); |
91 | } | 92 | } |
92 | 93 | ||
93 | static struct class *class_get(struct class *cls) | 94 | static struct class *class_get(struct class *cls) |
94 | { | 95 | { |
95 | if (cls) | 96 | if (cls) |
96 | kset_get(&cls->p->subsys); | 97 | kset_get(&cls->p->class_subsys); |
97 | return cls; | 98 | return cls; |
98 | } | 99 | } |
99 | 100 | ||
100 | static void class_put(struct class *cls) | 101 | static void class_put(struct class *cls) |
101 | { | 102 | { |
102 | if (cls) | 103 | if (cls) |
103 | kset_put(&cls->p->subsys); | 104 | kset_put(&cls->p->class_subsys); |
104 | } | 105 | } |
105 | 106 | ||
106 | static int add_class_attrs(struct class *cls) | 107 | static int add_class_attrs(struct class *cls) |
@@ -147,7 +148,7 @@ int class_register(struct class *cls) | |||
147 | INIT_LIST_HEAD(&cp->class_interfaces); | 148 | INIT_LIST_HEAD(&cp->class_interfaces); |
148 | kset_init(&cp->class_dirs); | 149 | kset_init(&cp->class_dirs); |
149 | init_MUTEX(&cp->sem); | 150 | init_MUTEX(&cp->sem); |
150 | error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name); | 151 | error = kobject_set_name(&cp->class_subsys.kobj, "%s", cls->name); |
151 | if (error) { | 152 | if (error) { |
152 | kfree(cp); | 153 | kfree(cp); |
153 | return error; | 154 | return error; |
@@ -160,15 +161,15 @@ int class_register(struct class *cls) | |||
160 | #if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK) | 161 | #if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK) |
161 | /* let the block class directory show up in the root of sysfs */ | 162 | /* let the block class directory show up in the root of sysfs */ |
162 | if (cls != &block_class) | 163 | if (cls != &block_class) |
163 | cp->subsys.kobj.kset = class_kset; | 164 | cp->class_subsys.kobj.kset = class_kset; |
164 | #else | 165 | #else |
165 | cp->subsys.kobj.kset = class_kset; | 166 | cp->class_subsys.kobj.kset = class_kset; |
166 | #endif | 167 | #endif |
167 | cp->subsys.kobj.ktype = &class_ktype; | 168 | cp->class_subsys.kobj.ktype = &class_ktype; |
168 | cp->class = cls; | 169 | cp->class = cls; |
169 | cls->p = cp; | 170 | cls->p = cp; |
170 | 171 | ||
171 | error = kset_register(&cp->subsys); | 172 | error = kset_register(&cp->class_subsys); |
172 | if (error) { | 173 | if (error) { |
173 | kfree(cp); | 174 | kfree(cp); |
174 | return error; | 175 | return error; |
@@ -182,7 +183,7 @@ void class_unregister(struct class *cls) | |||
182 | { | 183 | { |
183 | pr_debug("device class '%s': unregistering\n", cls->name); | 184 | pr_debug("device class '%s': unregistering\n", cls->name); |
184 | remove_class_attrs(cls); | 185 | remove_class_attrs(cls); |
185 | kset_unregister(&cls->p->subsys); | 186 | kset_unregister(&cls->p->class_subsys); |
186 | } | 187 | } |
187 | 188 | ||
188 | static void class_create_release(struct class *cls) | 189 | static void class_create_release(struct class *cls) |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 76fdd41fea0e..6e1cff296d9f 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -551,7 +551,7 @@ static struct kobject *get_device_parent(struct device *dev, | |||
551 | { | 551 | { |
552 | /* class devices without a parent live in /sys/class/<classname>/ */ | 552 | /* class devices without a parent live in /sys/class/<classname>/ */ |
553 | if (dev->class && (!parent || parent->class != dev->class)) | 553 | if (dev->class && (!parent || parent->class != dev->class)) |
554 | return &dev->class->p->subsys.kobj; | 554 | return &dev->class->p->class_subsys.kobj; |
555 | /* all other devices keep their parent */ | 555 | /* all other devices keep their parent */ |
556 | else if (parent) | 556 | else if (parent) |
557 | return &parent->kobj; | 557 | return &parent->kobj; |
@@ -657,16 +657,17 @@ static int device_add_class_symlinks(struct device *dev) | |||
657 | if (!dev->class) | 657 | if (!dev->class) |
658 | return 0; | 658 | return 0; |
659 | 659 | ||
660 | error = sysfs_create_link(&dev->kobj, &dev->class->p->subsys.kobj, | 660 | error = sysfs_create_link(&dev->kobj, |
661 | &dev->class->p->class_subsys.kobj, | ||
661 | "subsystem"); | 662 | "subsystem"); |
662 | if (error) | 663 | if (error) |
663 | goto out; | 664 | goto out; |
664 | 665 | ||
665 | #ifdef CONFIG_SYSFS_DEPRECATED | 666 | #ifdef CONFIG_SYSFS_DEPRECATED |
666 | /* stacked class devices need a symlink in the class directory */ | 667 | /* stacked class devices need a symlink in the class directory */ |
667 | if (dev->kobj.parent != &dev->class->p->subsys.kobj && | 668 | if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && |
668 | device_is_not_partition(dev)) { | 669 | device_is_not_partition(dev)) { |
669 | error = sysfs_create_link(&dev->class->p->subsys.kobj, | 670 | error = sysfs_create_link(&dev->class->p->class_subsys.kobj, |
670 | &dev->kobj, dev->bus_id); | 671 | &dev->kobj, dev->bus_id); |
671 | if (error) | 672 | if (error) |
672 | goto out_subsys; | 673 | goto out_subsys; |
@@ -704,13 +705,14 @@ out_device: | |||
704 | if (dev->parent && device_is_not_partition(dev)) | 705 | if (dev->parent && device_is_not_partition(dev)) |
705 | sysfs_remove_link(&dev->kobj, "device"); | 706 | sysfs_remove_link(&dev->kobj, "device"); |
706 | out_busid: | 707 | out_busid: |
707 | if (dev->kobj.parent != &dev->class->p->subsys.kobj && | 708 | if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && |
708 | device_is_not_partition(dev)) | 709 | device_is_not_partition(dev)) |
709 | sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id); | 710 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, |
711 | dev->bus_id); | ||
710 | #else | 712 | #else |
711 | /* link in the class directory pointing to the device */ | 713 | /* link in the class directory pointing to the device */ |
712 | error = sysfs_create_link(&dev->class->p->subsys.kobj, &dev->kobj, | 714 | error = sysfs_create_link(&dev->class->p->class_subsys.kobj, |
713 | dev->bus_id); | 715 | &dev->kobj, dev->bus_id); |
714 | if (error) | 716 | if (error) |
715 | goto out_subsys; | 717 | goto out_subsys; |
716 | 718 | ||
@@ -723,7 +725,7 @@ out_busid: | |||
723 | return 0; | 725 | return 0; |
724 | 726 | ||
725 | out_busid: | 727 | out_busid: |
726 | sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id); | 728 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id); |
727 | #endif | 729 | #endif |
728 | 730 | ||
729 | out_subsys: | 731 | out_subsys: |
@@ -749,14 +751,15 @@ static void device_remove_class_symlinks(struct device *dev) | |||
749 | sysfs_remove_link(&dev->kobj, "device"); | 751 | sysfs_remove_link(&dev->kobj, "device"); |
750 | } | 752 | } |
751 | 753 | ||
752 | if (dev->kobj.parent != &dev->class->p->subsys.kobj && | 754 | if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && |
753 | device_is_not_partition(dev)) | 755 | device_is_not_partition(dev)) |
754 | sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id); | 756 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, |
757 | dev->bus_id); | ||
755 | #else | 758 | #else |
756 | if (dev->parent && device_is_not_partition(dev)) | 759 | if (dev->parent && device_is_not_partition(dev)) |
757 | sysfs_remove_link(&dev->kobj, "device"); | 760 | sysfs_remove_link(&dev->kobj, "device"); |
758 | 761 | ||
759 | sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id); | 762 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id); |
760 | #endif | 763 | #endif |
761 | 764 | ||
762 | sysfs_remove_link(&dev->kobj, "subsystem"); | 765 | sysfs_remove_link(&dev->kobj, "subsystem"); |
@@ -1350,11 +1353,11 @@ int device_rename(struct device *dev, char *new_name) | |||
1350 | } | 1353 | } |
1351 | #else | 1354 | #else |
1352 | if (dev->class) { | 1355 | if (dev->class) { |
1353 | error = sysfs_create_link(&dev->class->p->subsys.kobj, | 1356 | error = sysfs_create_link(&dev->class->p->class_subsys.kobj, |
1354 | &dev->kobj, dev->bus_id); | 1357 | &dev->kobj, dev->bus_id); |
1355 | if (error) | 1358 | if (error) |
1356 | goto out; | 1359 | goto out; |
1357 | sysfs_remove_link(&dev->class->p->subsys.kobj, | 1360 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, |
1358 | old_device_name); | 1361 | old_device_name); |
1359 | } | 1362 | } |
1360 | #endif | 1363 | #endif |