aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-04-13 16:15:19 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-05-02 21:57:59 -0400
commit823bccfc4002296ba88c3ad0f049e1abd8108d30 (patch)
tree5338ae0b32409446af4cd00c5107d9405d5bf0b6 /drivers/base
parent2609e7b9bebfd433254c02538ba803dc516ff674 (diff)
remove "struct subsystem" as it is no longer needed
We need to work on cleaning up the relationship between kobjects, ksets and ktypes. The removal of 'struct subsystem' is the first step of this, especially as it is not really needed at all. Thanks to Kay for fixing the bugs in this patch. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/base.h2
-rw-r--r--drivers/base/bus.c16
-rw-r--r--drivers/base/class.c18
-rw-r--r--drivers/base/core.c22
-rw-r--r--drivers/base/firmware.c6
-rw-r--r--drivers/base/power/shutdown.c4
-rw-r--r--drivers/base/sys.c14
7 files changed, 40 insertions, 42 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h
index d597f2659b23..5512d84452f2 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -45,3 +45,5 @@ struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
45extern char *make_class_name(const char *name, struct kobject *kobj); 45extern char *make_class_name(const char *name, struct kobject *kobj);
46 46
47extern void devres_release_all(struct device *dev); 47extern void devres_release_all(struct device *dev);
48
49extern struct kset devices_subsys;
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 1d76e2349654..dca734819e50 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -17,7 +17,7 @@
17#include "power/power.h" 17#include "power/power.h"
18 18
19#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr) 19#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr)
20#define to_bus(obj) container_of(obj, struct bus_type, subsys.kset.kobj) 20#define to_bus(obj) container_of(obj, struct bus_type, subsys.kobj)
21 21
22/* 22/*
23 * sysfs bindings for drivers 23 * sysfs bindings for drivers
@@ -123,7 +123,7 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
123{ 123{
124 int error; 124 int error;
125 if (get_bus(bus)) { 125 if (get_bus(bus)) {
126 error = sysfs_create_file(&bus->subsys.kset.kobj, &attr->attr); 126 error = sysfs_create_file(&bus->subsys.kobj, &attr->attr);
127 put_bus(bus); 127 put_bus(bus);
128 } else 128 } else
129 error = -EINVAL; 129 error = -EINVAL;
@@ -133,7 +133,7 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr)
133void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr) 133void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr)
134{ 134{
135 if (get_bus(bus)) { 135 if (get_bus(bus)) {
136 sysfs_remove_file(&bus->subsys.kset.kobj, &attr->attr); 136 sysfs_remove_file(&bus->subsys.kobj, &attr->attr);
137 put_bus(bus); 137 put_bus(bus);
138 } 138 }
139} 139}
@@ -397,7 +397,7 @@ static void device_remove_attrs(struct bus_type * bus, struct device * dev)
397static int make_deprecated_bus_links(struct device *dev) 397static int make_deprecated_bus_links(struct device *dev)
398{ 398{
399 return sysfs_create_link(&dev->kobj, 399 return sysfs_create_link(&dev->kobj,
400 &dev->bus->subsys.kset.kobj, "bus"); 400 &dev->bus->subsys.kobj, "bus");
401} 401}
402 402
403static void remove_deprecated_bus_links(struct device *dev) 403static void remove_deprecated_bus_links(struct device *dev)
@@ -431,7 +431,7 @@ int bus_add_device(struct device * dev)
431 if (error) 431 if (error)
432 goto out_id; 432 goto out_id;
433 error = sysfs_create_link(&dev->kobj, 433 error = sysfs_create_link(&dev->kobj,
434 &dev->bus->subsys.kset.kobj, "subsystem"); 434 &dev->bus->subsys.kobj, "subsystem");
435 if (error) 435 if (error)
436 goto out_subsys; 436 goto out_subsys;
437 error = make_deprecated_bus_links(dev); 437 error = make_deprecated_bus_links(dev);
@@ -810,7 +810,7 @@ int bus_register(struct bus_type * bus)
810 810
811 BLOCKING_INIT_NOTIFIER_HEAD(&bus->bus_notifier); 811 BLOCKING_INIT_NOTIFIER_HEAD(&bus->bus_notifier);
812 812
813 retval = kobject_set_name(&bus->subsys.kset.kobj, "%s", bus->name); 813 retval = kobject_set_name(&bus->subsys.kobj, "%s", bus->name);
814 if (retval) 814 if (retval)
815 goto out; 815 goto out;
816 816
@@ -820,13 +820,13 @@ int bus_register(struct bus_type * bus)
820 goto out; 820 goto out;
821 821
822 kobject_set_name(&bus->devices.kobj, "devices"); 822 kobject_set_name(&bus->devices.kobj, "devices");
823 bus->devices.subsys = &bus->subsys; 823 bus->devices.kobj.parent = &bus->subsys.kobj;
824 retval = kset_register(&bus->devices); 824 retval = kset_register(&bus->devices);
825 if (retval) 825 if (retval)
826 goto bus_devices_fail; 826 goto bus_devices_fail;
827 827
828 kobject_set_name(&bus->drivers.kobj, "drivers"); 828 kobject_set_name(&bus->drivers.kobj, "drivers");
829 bus->drivers.subsys = &bus->subsys; 829 bus->drivers.kobj.parent = &bus->subsys.kobj;
830 bus->drivers.ktype = &ktype_driver; 830 bus->drivers.ktype = &ktype_driver;
831 retval = kset_register(&bus->drivers); 831 retval = kset_register(&bus->drivers);
832 if (retval) 832 if (retval)
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 80bbb2074636..20c4ea6eb50d 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -19,10 +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
24#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) 22#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
25#define to_class(obj) container_of(obj, struct class, subsys.kset.kobj) 23#define to_class(obj) container_of(obj, struct class, subsys.kobj)
26 24
27static ssize_t 25static ssize_t
28class_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) 26class_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
@@ -80,7 +78,7 @@ int class_create_file(struct class * cls, const struct class_attribute * attr)
80{ 78{
81 int error; 79 int error;
82 if (cls) { 80 if (cls) {
83 error = sysfs_create_file(&cls->subsys.kset.kobj, &attr->attr); 81 error = sysfs_create_file(&cls->subsys.kobj, &attr->attr);
84 } else 82 } else
85 error = -EINVAL; 83 error = -EINVAL;
86 return error; 84 return error;
@@ -89,7 +87,7 @@ int class_create_file(struct class * cls, const struct class_attribute * attr)
89void class_remove_file(struct class * cls, const struct class_attribute * attr) 87void class_remove_file(struct class * cls, const struct class_attribute * attr)
90{ 88{
91 if (cls) 89 if (cls)
92 sysfs_remove_file(&cls->subsys.kset.kobj, &attr->attr); 90 sysfs_remove_file(&cls->subsys.kobj, &attr->attr);
93} 91}
94 92
95static struct class *class_get(struct class *cls) 93static struct class *class_get(struct class *cls)
@@ -147,7 +145,7 @@ int class_register(struct class * cls)
147 INIT_LIST_HEAD(&cls->interfaces); 145 INIT_LIST_HEAD(&cls->interfaces);
148 kset_init(&cls->class_dirs); 146 kset_init(&cls->class_dirs);
149 init_MUTEX(&cls->sem); 147 init_MUTEX(&cls->sem);
150 error = kobject_set_name(&cls->subsys.kset.kobj, "%s", cls->name); 148 error = kobject_set_name(&cls->subsys.kobj, "%s", cls->name);
151 if (error) 149 if (error)
152 return error; 150 return error;
153 151
@@ -611,7 +609,7 @@ int class_device_add(struct class_device *class_dev)
611 if (parent_class_dev) 609 if (parent_class_dev)
612 class_dev->kobj.parent = &parent_class_dev->kobj; 610 class_dev->kobj.parent = &parent_class_dev->kobj;
613 else 611 else
614 class_dev->kobj.parent = &parent_class->subsys.kset.kobj; 612 class_dev->kobj.parent = &parent_class->subsys.kobj;
615 613
616 error = kobject_add(&class_dev->kobj); 614 error = kobject_add(&class_dev->kobj);
617 if (error) 615 if (error)
@@ -619,7 +617,7 @@ int class_device_add(struct class_device *class_dev)
619 617
620 /* add the needed attributes to this device */ 618 /* add the needed attributes to this device */
621 error = sysfs_create_link(&class_dev->kobj, 619 error = sysfs_create_link(&class_dev->kobj,
622 &parent_class->subsys.kset.kobj, "subsystem"); 620 &parent_class->subsys.kobj, "subsystem");
623 if (error) 621 if (error)
624 goto out3; 622 goto out3;
625 class_dev->uevent_attr.attr.name = "uevent"; 623 class_dev->uevent_attr.attr.name = "uevent";
@@ -917,8 +915,8 @@ int __init classes_init(void)
917 /* ick, this is ugly, the things we go through to keep from showing up 915 /* ick, this is ugly, the things we go through to keep from showing up
918 * in sysfs... */ 916 * in sysfs... */
919 subsystem_init(&class_obj_subsys); 917 subsystem_init(&class_obj_subsys);
920 if (!class_obj_subsys.kset.subsys) 918 if (!class_obj_subsys.kobj.parent)
921 class_obj_subsys.kset.subsys = &class_obj_subsys; 919 class_obj_subsys.kobj.parent = &class_obj_subsys.kobj;
922 return 0; 920 return 0;
923} 921}
924 922
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 59d9816c332e..b78fc1e68264 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -565,7 +565,7 @@ static struct kobject * get_device_parent(struct device *dev,
565 /* Set the parent to the class, not the parent device */ 565 /* Set the parent to the class, not the parent device */
566 /* this keeps sysfs from having a symlink to make old udevs happy */ 566 /* this keeps sysfs from having a symlink to make old udevs happy */
567 if (dev->class) 567 if (dev->class)
568 return &dev->class->subsys.kset.kobj; 568 return &dev->class->subsys.kobj;
569 else if (parent) 569 else if (parent)
570 return &parent->kobj; 570 return &parent->kobj;
571 571
@@ -577,7 +577,7 @@ static struct kobject *virtual_device_parent(struct device *dev)
577 static struct kobject *virtual_dir = NULL; 577 static struct kobject *virtual_dir = NULL;
578 578
579 if (!virtual_dir) 579 if (!virtual_dir)
580 virtual_dir = kobject_add_dir(&devices_subsys.kset.kobj, "virtual"); 580 virtual_dir = kobject_add_dir(&devices_subsys.kobj, "virtual");
581 581
582 return virtual_dir; 582 return virtual_dir;
583} 583}
@@ -711,12 +711,12 @@ int device_add(struct device *dev)
711 } 711 }
712 712
713 if (dev->class) { 713 if (dev->class) {
714 sysfs_create_link(&dev->kobj, &dev->class->subsys.kset.kobj, 714 sysfs_create_link(&dev->kobj, &dev->class->subsys.kobj,
715 "subsystem"); 715 "subsystem");
716 /* If this is not a "fake" compatible device, then create the 716 /* If this is not a "fake" compatible device, then create the
717 * symlink from the class to the device. */ 717 * symlink from the class to the device. */
718 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 718 if (dev->kobj.parent != &dev->class->subsys.kobj)
719 sysfs_create_link(&dev->class->subsys.kset.kobj, 719 sysfs_create_link(&dev->class->subsys.kobj,
720 &dev->kobj, dev->bus_id); 720 &dev->kobj, dev->bus_id);
721 if (parent) { 721 if (parent) {
722 sysfs_create_link(&dev->kobj, &dev->parent->kobj, 722 sysfs_create_link(&dev->kobj, &dev->parent->kobj,
@@ -774,8 +774,8 @@ int device_add(struct device *dev)
774 sysfs_remove_link(&dev->kobj, "subsystem"); 774 sysfs_remove_link(&dev->kobj, "subsystem");
775 /* If this is not a "fake" compatible device, remove the 775 /* If this is not a "fake" compatible device, remove the
776 * symlink from the class to the device. */ 776 * symlink from the class to the device. */
777 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 777 if (dev->kobj.parent != &dev->class->subsys.kobj)
778 sysfs_remove_link(&dev->class->subsys.kset.kobj, 778 sysfs_remove_link(&dev->class->subsys.kobj,
779 dev->bus_id); 779 dev->bus_id);
780 if (parent) { 780 if (parent) {
781#ifdef CONFIG_SYSFS_DEPRECATED 781#ifdef CONFIG_SYSFS_DEPRECATED
@@ -875,8 +875,8 @@ void device_del(struct device * dev)
875 sysfs_remove_link(&dev->kobj, "subsystem"); 875 sysfs_remove_link(&dev->kobj, "subsystem");
876 /* If this is not a "fake" compatible device, remove the 876 /* If this is not a "fake" compatible device, remove the
877 * symlink from the class to the device. */ 877 * symlink from the class to the device. */
878 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 878 if (dev->kobj.parent != &dev->class->subsys.kobj)
879 sysfs_remove_link(&dev->class->subsys.kset.kobj, 879 sysfs_remove_link(&dev->class->subsys.kobj,
880 dev->bus_id); 880 dev->bus_id);
881 if (parent) { 881 if (parent) {
882#ifdef CONFIG_SYSFS_DEPRECATED 882#ifdef CONFIG_SYSFS_DEPRECATED
@@ -1192,9 +1192,9 @@ int device_rename(struct device *dev, char *new_name)
1192#endif 1192#endif
1193 1193
1194 if (dev->class) { 1194 if (dev->class) {
1195 sysfs_remove_link(&dev->class->subsys.kset.kobj, 1195 sysfs_remove_link(&dev->class->subsys.kobj,
1196 old_symlink_name); 1196 old_symlink_name);
1197 sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, 1197 sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
1198 dev->bus_id); 1198 dev->bus_id);
1199 } 1199 }
1200 put_device(dev); 1200 put_device(dev);
diff --git a/drivers/base/firmware.c b/drivers/base/firmware.c
index cb1b98ae0d58..90c862932169 100644
--- a/drivers/base/firmware.c
+++ b/drivers/base/firmware.c
@@ -17,13 +17,13 @@
17 17
18static decl_subsys(firmware, NULL, NULL); 18static decl_subsys(firmware, NULL, NULL);
19 19
20int firmware_register(struct subsystem * s) 20int firmware_register(struct kset *s)
21{ 21{
22 kset_set_kset_s(s, firmware_subsys); 22 kobj_set_kset_s(s, firmware_subsys);
23 return subsystem_register(s); 23 return subsystem_register(s);
24} 24}
25 25
26void firmware_unregister(struct subsystem * s) 26void firmware_unregister(struct kset *s)
27{ 27{
28 subsystem_unregister(s); 28 subsystem_unregister(s);
29} 29}
diff --git a/drivers/base/power/shutdown.c b/drivers/base/power/shutdown.c
index 58b6f77a1b34..a47ee1b70d20 100644
--- a/drivers/base/power/shutdown.c
+++ b/drivers/base/power/shutdown.c
@@ -16,8 +16,6 @@
16 16
17#define to_dev(node) container_of(node, struct device, kobj.entry) 17#define to_dev(node) container_of(node, struct device, kobj.entry)
18 18
19extern struct subsystem devices_subsys;
20
21 19
22/** 20/**
23 * We handle system devices differently - we suspend and shut them 21 * We handle system devices differently - we suspend and shut them
@@ -36,7 +34,7 @@ void device_shutdown(void)
36{ 34{
37 struct device * dev, *devn; 35 struct device * dev, *devn;
38 36
39 list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.kset.list, 37 list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.list,
40 kobj.entry) { 38 kobj.entry) {
41 if (dev->bus && dev->bus->shutdown) { 39 if (dev->bus && dev->bus->shutdown) {
42 dev_dbg(dev, "shutdown\n"); 40 dev_dbg(dev, "shutdown\n");
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 04e5db445c74..29f1291966c1 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -25,7 +25,7 @@
25 25
26#include "base.h" 26#include "base.h"
27 27
28extern struct subsystem devices_subsys; 28extern struct kset devices_subsys;
29 29
30#define to_sysdev(k) container_of(k, struct sys_device, kobj) 30#define to_sysdev(k) container_of(k, struct sys_device, kobj)
31#define to_sysdev_attr(a) container_of(a, struct sysdev_attribute, attr) 31#define to_sysdev_attr(a) container_of(a, struct sysdev_attribute, attr)
@@ -138,7 +138,7 @@ int sysdev_class_register(struct sysdev_class * cls)
138 pr_debug("Registering sysdev class '%s'\n", 138 pr_debug("Registering sysdev class '%s'\n",
139 kobject_name(&cls->kset.kobj)); 139 kobject_name(&cls->kset.kobj));
140 INIT_LIST_HEAD(&cls->drivers); 140 INIT_LIST_HEAD(&cls->drivers);
141 cls->kset.subsys = &system_subsys; 141 cls->kset.kobj.parent = &system_subsys.kobj;
142 kset_set_kset_s(cls, system_subsys); 142 kset_set_kset_s(cls, system_subsys);
143 return kset_register(&cls->kset); 143 return kset_register(&cls->kset);
144} 144}
@@ -309,7 +309,7 @@ void sysdev_shutdown(void)
309 pr_debug("Shutting Down System Devices\n"); 309 pr_debug("Shutting Down System Devices\n");
310 310
311 down(&sysdev_drivers_lock); 311 down(&sysdev_drivers_lock);
312 list_for_each_entry_reverse(cls, &system_subsys.kset.list, 312 list_for_each_entry_reverse(cls, &system_subsys.list,
313 kset.kobj.entry) { 313 kset.kobj.entry) {
314 struct sys_device * sysdev; 314 struct sys_device * sysdev;
315 315
@@ -384,7 +384,7 @@ int sysdev_suspend(pm_message_t state)
384 384
385 pr_debug("Suspending System Devices\n"); 385 pr_debug("Suspending System Devices\n");
386 386
387 list_for_each_entry_reverse(cls, &system_subsys.kset.list, 387 list_for_each_entry_reverse(cls, &system_subsys.list,
388 kset.kobj.entry) { 388 kset.kobj.entry) {
389 389
390 pr_debug("Suspending type '%s':\n", 390 pr_debug("Suspending type '%s':\n",
@@ -457,7 +457,7 @@ gbl_driver:
457 } 457 }
458 458
459 /* resume other classes */ 459 /* resume other classes */
460 list_for_each_entry_continue(cls, &system_subsys.kset.list, 460 list_for_each_entry_continue(cls, &system_subsys.list,
461 kset.kobj.entry) { 461 kset.kobj.entry) {
462 list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) { 462 list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) {
463 pr_debug(" %s\n", kobject_name(&err_dev->kobj)); 463 pr_debug(" %s\n", kobject_name(&err_dev->kobj));
@@ -483,7 +483,7 @@ int sysdev_resume(void)
483 483
484 pr_debug("Resuming System Devices\n"); 484 pr_debug("Resuming System Devices\n");
485 485
486 list_for_each_entry(cls, &system_subsys.kset.list, kset.kobj.entry) { 486 list_for_each_entry(cls, &system_subsys.list, kset.kobj.entry) {
487 struct sys_device * sysdev; 487 struct sys_device * sysdev;
488 488
489 pr_debug("Resuming type '%s':\n", 489 pr_debug("Resuming type '%s':\n",
@@ -501,7 +501,7 @@ int sysdev_resume(void)
501 501
502int __init system_bus_init(void) 502int __init system_bus_init(void)
503{ 503{
504 system_subsys.kset.kobj.parent = &devices_subsys.kset.kobj; 504 system_subsys.kobj.parent = &devices_subsys.kobj;
505 return subsystem_register(&system_subsys); 505 return subsystem_register(&system_subsys);
506} 506}
507 507