diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-16 12:11:44 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-24 23:40:10 -0500 |
commit | 3514faca19a6fdc209734431c509631ea92b094e (patch) | |
tree | f6d102e6dec276f8e8d1044b47c74a02b901554f /drivers/base | |
parent | c11c4154e7ff4cebfadad849b1e22689d759c3f4 (diff) |
kobject: remove struct kobj_type from struct kset
We don't need a "default" ktype for a kset. We should set this
explicitly every time for each kset. This change is needed so that we
can make ksets dynamic, and cleans up one of the odd, undocumented
assumption that the kset/kobject/ktype model has.
This patch is based on a lot of help from Kay Sievers.
Nasty bug in the block code was found by Dave Young
<hidave.darkstar@gmail.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Dave Young <hidave.darkstar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/bus.c | 5 | ||||
-rw-r--r-- | drivers/base/class.c | 8 | ||||
-rw-r--r-- | drivers/base/core.c | 5 | ||||
-rw-r--r-- | drivers/base/firmware.c | 5 | ||||
-rw-r--r-- | drivers/base/hypervisor.c | 2 | ||||
-rw-r--r-- | drivers/base/sys.c | 3 |
6 files changed, 17 insertions, 11 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 9a19b071c573..630956037e18 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -166,7 +166,7 @@ static struct kset_uevent_ops bus_uevent_ops = { | |||
166 | .filter = bus_uevent_filter, | 166 | .filter = bus_uevent_filter, |
167 | }; | 167 | }; |
168 | 168 | ||
169 | static decl_subsys(bus, &bus_ktype, &bus_uevent_ops); | 169 | static decl_subsys(bus, &bus_uevent_ops); |
170 | 170 | ||
171 | 171 | ||
172 | #ifdef CONFIG_HOTPLUG | 172 | #ifdef CONFIG_HOTPLUG |
@@ -639,6 +639,7 @@ int bus_add_driver(struct device_driver *drv) | |||
639 | if (error) | 639 | if (error) |
640 | goto out_put_bus; | 640 | goto out_put_bus; |
641 | drv->kobj.kset = &bus->drivers; | 641 | drv->kobj.kset = &bus->drivers; |
642 | drv->kobj.ktype = &driver_ktype; | ||
642 | error = kobject_register(&drv->kobj); | 643 | error = kobject_register(&drv->kobj); |
643 | if (error) | 644 | if (error) |
644 | goto out_put_bus; | 645 | goto out_put_bus; |
@@ -851,6 +852,7 @@ int bus_register(struct bus_type * bus) | |||
851 | goto out; | 852 | goto out; |
852 | 853 | ||
853 | bus->subsys.kobj.kset = &bus_subsys; | 854 | bus->subsys.kobj.kset = &bus_subsys; |
855 | bus->subsys.kobj.ktype = &bus_ktype; | ||
854 | 856 | ||
855 | retval = subsystem_register(&bus->subsys); | 857 | retval = subsystem_register(&bus->subsys); |
856 | if (retval) | 858 | if (retval) |
@@ -868,7 +870,6 @@ int bus_register(struct bus_type * bus) | |||
868 | 870 | ||
869 | kobject_set_name(&bus->drivers.kobj, "drivers"); | 871 | kobject_set_name(&bus->drivers.kobj, "drivers"); |
870 | bus->drivers.kobj.parent = &bus->subsys.kobj; | 872 | bus->drivers.kobj.parent = &bus->subsys.kobj; |
871 | bus->drivers.ktype = &driver_ktype; | ||
872 | retval = kset_register(&bus->drivers); | 873 | retval = kset_register(&bus->drivers); |
873 | if (retval) | 874 | if (retval) |
874 | goto bus_drivers_fail; | 875 | goto bus_drivers_fail; |
diff --git a/drivers/base/class.c b/drivers/base/class.c index a863bb091e11..8ad98924cddb 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -71,7 +71,7 @@ static struct kobj_type class_ktype = { | |||
71 | }; | 71 | }; |
72 | 72 | ||
73 | /* Hotplug events for classes go to the class_obj subsys */ | 73 | /* Hotplug events for classes go to the class_obj subsys */ |
74 | static decl_subsys(class, &class_ktype, NULL); | 74 | static decl_subsys(class, NULL); |
75 | 75 | ||
76 | 76 | ||
77 | int class_create_file(struct class * cls, const struct class_attribute * attr) | 77 | int class_create_file(struct class * cls, const struct class_attribute * attr) |
@@ -150,6 +150,7 @@ int class_register(struct class * cls) | |||
150 | return error; | 150 | return error; |
151 | 151 | ||
152 | cls->subsys.kobj.kset = &class_subsys; | 152 | cls->subsys.kobj.kset = &class_subsys; |
153 | cls->subsys.kobj.ktype = &class_ktype; | ||
153 | 154 | ||
154 | error = subsystem_register(&cls->subsys); | 155 | error = subsystem_register(&cls->subsys); |
155 | if (!error) { | 156 | if (!error) { |
@@ -452,7 +453,7 @@ static struct kset_uevent_ops class_uevent_ops = { | |||
452 | .uevent = class_uevent, | 453 | .uevent = class_uevent, |
453 | }; | 454 | }; |
454 | 455 | ||
455 | static decl_subsys(class_obj, &class_device_ktype, &class_uevent_ops); | 456 | static decl_subsys(class_obj, &class_uevent_ops); |
456 | 457 | ||
457 | 458 | ||
458 | static int class_device_add_attrs(struct class_device * cd) | 459 | static int class_device_add_attrs(struct class_device * cd) |
@@ -537,7 +538,8 @@ static struct class_device_attribute class_uevent_attr = | |||
537 | 538 | ||
538 | void class_device_initialize(struct class_device *class_dev) | 539 | void class_device_initialize(struct class_device *class_dev) |
539 | { | 540 | { |
540 | kobj_set_kset_s(class_dev, class_obj_subsys); | 541 | class_dev->kobj.kset = &class_obj_subsys; |
542 | class_dev->kobj.ktype = &class_device_ktype; | ||
541 | kobject_init(&class_dev->kobj); | 543 | kobject_init(&class_dev->kobj); |
542 | INIT_LIST_HEAD(&class_dev->node); | 544 | INIT_LIST_HEAD(&class_dev->node); |
543 | } | 545 | } |
diff --git a/drivers/base/core.c b/drivers/base/core.c index ce6b64c489ad..c8f2ac03d46d 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -405,7 +405,7 @@ static struct device_attribute devt_attr = | |||
405 | * devices_subsys - structure to be registered with kobject core. | 405 | * devices_subsys - structure to be registered with kobject core. |
406 | */ | 406 | */ |
407 | 407 | ||
408 | decl_subsys(devices, &device_ktype, &device_uevent_ops); | 408 | decl_subsys(devices, &device_uevent_ops); |
409 | 409 | ||
410 | 410 | ||
411 | /** | 411 | /** |
@@ -525,7 +525,8 @@ static void klist_children_put(struct klist_node *n) | |||
525 | 525 | ||
526 | void device_initialize(struct device *dev) | 526 | void device_initialize(struct device *dev) |
527 | { | 527 | { |
528 | kobj_set_kset_s(dev, devices_subsys); | 528 | dev->kobj.kset = &devices_subsys; |
529 | dev->kobj.ktype = &device_ktype; | ||
529 | kobject_init(&dev->kobj); | 530 | kobject_init(&dev->kobj); |
530 | klist_init(&dev->klist_children, klist_children_get, | 531 | klist_init(&dev->klist_children, klist_children_get, |
531 | klist_children_put); | 532 | klist_children_put); |
diff --git a/drivers/base/firmware.c b/drivers/base/firmware.c index 90c862932169..336be0450d54 100644 --- a/drivers/base/firmware.c +++ b/drivers/base/firmware.c | |||
@@ -15,11 +15,12 @@ | |||
15 | 15 | ||
16 | #include "base.h" | 16 | #include "base.h" |
17 | 17 | ||
18 | static decl_subsys(firmware, NULL, NULL); | 18 | static decl_subsys(firmware, NULL); |
19 | 19 | ||
20 | int firmware_register(struct kset *s) | 20 | int firmware_register(struct kset *s) |
21 | { | 21 | { |
22 | kobj_set_kset_s(s, firmware_subsys); | 22 | s->kobj.kset = &firmware_subsys; |
23 | s->kobj.ktype = NULL; | ||
23 | return subsystem_register(s); | 24 | return subsystem_register(s); |
24 | } | 25 | } |
25 | 26 | ||
diff --git a/drivers/base/hypervisor.c b/drivers/base/hypervisor.c index 7080b413ddc9..14e75e9ec783 100644 --- a/drivers/base/hypervisor.c +++ b/drivers/base/hypervisor.c | |||
@@ -11,7 +11,7 @@ | |||
11 | 11 | ||
12 | #include "base.h" | 12 | #include "base.h" |
13 | 13 | ||
14 | decl_subsys(hypervisor, NULL, NULL); | 14 | decl_subsys(hypervisor, NULL); |
15 | EXPORT_SYMBOL_GPL(hypervisor_subsys); | 15 | EXPORT_SYMBOL_GPL(hypervisor_subsys); |
16 | 16 | ||
17 | int __init hypervisor_init(void) | 17 | int __init hypervisor_init(void) |
diff --git a/drivers/base/sys.c b/drivers/base/sys.c index ac7ff6d0c6e5..7cf19fc318da 100644 --- a/drivers/base/sys.c +++ b/drivers/base/sys.c | |||
@@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(sysdev_class_remove_file); | |||
131 | /* | 131 | /* |
132 | * declare system_subsys | 132 | * declare system_subsys |
133 | */ | 133 | */ |
134 | static decl_subsys(system, &ktype_sysdev_class, NULL); | 134 | static decl_subsys(system, NULL); |
135 | 135 | ||
136 | int sysdev_class_register(struct sysdev_class * cls) | 136 | int sysdev_class_register(struct sysdev_class * cls) |
137 | { | 137 | { |
@@ -139,6 +139,7 @@ int sysdev_class_register(struct sysdev_class * cls) | |||
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.kobj.parent = &system_subsys.kobj; | 141 | cls->kset.kobj.parent = &system_subsys.kobj; |
142 | cls->kset.kobj.ktype = &ktype_sysdev_class; | ||
142 | cls->kset.kobj.kset = &system_subsys; | 143 | cls->kset.kobj.kset = &system_subsys; |
143 | return kset_register(&cls->kset); | 144 | return kset_register(&cls->kset); |
144 | } | 145 | } |