aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-10-16 12:11:44 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 23:40:10 -0500
commit3514faca19a6fdc209734431c509631ea92b094e (patch)
treef6d102e6dec276f8e8d1044b47c74a02b901554f /drivers
parentc11c4154e7ff4cebfadad849b1e22689d759c3f4 (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')
-rw-r--r--drivers/acpi/bus.c2
-rw-r--r--drivers/base/bus.c5
-rw-r--r--drivers/base/class.c8
-rw-r--r--drivers/base/core.c5
-rw-r--r--drivers/base/firmware.c5
-rw-r--r--drivers/base/hypervisor.c2
-rw-r--r--drivers/base/sys.c3
-rw-r--r--drivers/edac/edac_mc_sysfs.c2
-rw-r--r--drivers/firmware/edd.c5
-rw-r--r--drivers/firmware/efivars.c9
-rw-r--r--drivers/parisc/pdc_stable.c9
-rw-r--r--drivers/pci/hotplug/pci_hotplug_core.c7
-rw-r--r--drivers/pci/hotplug/rpadlpar_sysfs.c1
-rw-r--r--drivers/uio/uio.c2
14 files changed, 37 insertions, 28 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index f4487c38d9f2..7c172d9d7acf 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -743,7 +743,7 @@ static int __init acpi_bus_init(void)
743 return -ENODEV; 743 return -ENODEV;
744} 744}
745 745
746decl_subsys(acpi, NULL, NULL); 746decl_subsys(acpi, NULL);
747 747
748static int __init acpi_init(void) 748static int __init acpi_init(void)
749{ 749{
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
169static decl_subsys(bus, &bus_ktype, &bus_uevent_ops); 169static 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 */
74static decl_subsys(class, &class_ktype, NULL); 74static decl_subsys(class, NULL);
75 75
76 76
77int class_create_file(struct class * cls, const struct class_attribute * attr) 77int 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
455static decl_subsys(class_obj, &class_device_ktype, &class_uevent_ops); 456static decl_subsys(class_obj, &class_uevent_ops);
456 457
457 458
458static int class_device_add_attrs(struct class_device * cd) 459static int class_device_add_attrs(struct class_device * cd)
@@ -537,7 +538,8 @@ static struct class_device_attribute class_uevent_attr =
537 538
538void class_device_initialize(struct class_device *class_dev) 539void 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
408decl_subsys(devices, &device_ktype, &device_uevent_ops); 408decl_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
526void device_initialize(struct device *dev) 526void 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
18static decl_subsys(firmware, NULL, NULL); 18static decl_subsys(firmware, NULL);
19 19
20int firmware_register(struct kset *s) 20int 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
14decl_subsys(hypervisor, NULL, NULL); 14decl_subsys(hypervisor, NULL);
15EXPORT_SYMBOL_GPL(hypervisor_subsys); 15EXPORT_SYMBOL_GPL(hypervisor_subsys);
16 16
17int __init hypervisor_init(void) 17int __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 */
134static decl_subsys(system, &ktype_sysdev_class, NULL); 134static decl_subsys(system, NULL);
135 135
136int sysdev_class_register(struct sysdev_class * cls) 136int 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}
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 3706b2bc0987..905fcd73c26e 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -744,7 +744,6 @@ static struct kobj_type ktype_mc_set_attribs = {
744 */ 744 */
745static struct kset mc_kset = { 745static struct kset mc_kset = {
746 .kobj = {.ktype = &ktype_mc_set_attribs }, 746 .kobj = {.ktype = &ktype_mc_set_attribs },
747 .ktype = &ktype_mci,
748}; 747};
749 748
750 749
@@ -767,6 +766,7 @@ int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci)
767 766
768 /* this instance become part of the mc_kset */ 767 /* this instance become part of the mc_kset */
769 kobj_mci->kset = &mc_kset; 768 kobj_mci->kset = &mc_kset;
769 kobj_mci->ktype = &ktype_mci;
770 770
771 /* set the name of the mc<id> object */ 771 /* set the name of the mc<id> object */
772 err = kobject_set_name(kobj_mci, "mc%d", mci->mc_idx); 772 err = kobject_set_name(kobj_mci, "mc%d", mci->mc_idx);
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index 6942e065e609..fc567fad3f7c 100644
--- a/drivers/firmware/edd.c
+++ b/drivers/firmware/edd.c
@@ -631,7 +631,7 @@ static struct kobj_type edd_ktype = {
631 .default_attrs = def_attrs, 631 .default_attrs = def_attrs,
632}; 632};
633 633
634static decl_subsys(edd, &edd_ktype, NULL); 634static decl_subsys(edd, NULL);
635 635
636 636
637/** 637/**
@@ -723,7 +723,8 @@ edd_device_register(struct edd_device *edev, int i)
723 edd_dev_set_info(edev, i); 723 edd_dev_set_info(edev, i);
724 kobject_set_name(&edev->kobj, "int13_dev%02x", 724 kobject_set_name(&edev->kobj, "int13_dev%02x",
725 0x80 + i); 725 0x80 + i);
726 kobj_set_kset_s(edev,edd_subsys); 726 edev->kobj.kset = &edd_subsys;
727 edev->kobj.ktype = &edd_ktype;
727 error = kobject_register(&edev->kobj); 728 error = kobject_register(&edev->kobj);
728 if (!error) 729 if (!error)
729 edd_populate_dir(edev); 730 edd_populate_dir(edev);
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 858a7b95933b..06ecdb9f6013 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -583,8 +583,8 @@ static struct subsys_attribute *efi_subsys_attrs[] = {
583 NULL, /* maybe more in the future? */ 583 NULL, /* maybe more in the future? */
584}; 584};
585 585
586static decl_subsys(vars, &efivar_ktype, NULL); 586static decl_subsys(vars, NULL);
587static decl_subsys(efi, NULL, NULL); 587static decl_subsys(efi, NULL);
588 588
589/* 589/*
590 * efivar_create_sysfs_entry() 590 * efivar_create_sysfs_entry()
@@ -629,7 +629,8 @@ efivar_create_sysfs_entry(unsigned long variable_name_size,
629 efi_guid_unparse(vendor_guid, short_name + strlen(short_name)); 629 efi_guid_unparse(vendor_guid, short_name + strlen(short_name));
630 630
631 kobject_set_name(&new_efivar->kobj, "%s", short_name); 631 kobject_set_name(&new_efivar->kobj, "%s", short_name);
632 kobj_set_kset_s(new_efivar, vars_subsys); 632 new_efivar->kobj.kset = &vars_subsys;
633 new_efivar->kobj.ktype = &efivar_ktype;
633 i = kobject_register(&new_efivar->kobj); 634 i = kobject_register(&new_efivar->kobj);
634 if (i) { 635 if (i) {
635 kfree(short_name); 636 kfree(short_name);
@@ -687,7 +688,7 @@ efivars_init(void)
687 goto out_free; 688 goto out_free;
688 } 689 }
689 690
690 kobj_set_kset_s(&vars_subsys, efi_subsys); 691 vars_subsys.kobj.kset = &efi_subsys;
691 692
692 error = subsystem_register(&vars_subsys); 693 error = subsystem_register(&vars_subsys);
693 694
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index ebb09e98d215..1382be64cc3f 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -964,8 +964,8 @@ static struct subsys_attribute *pdcs_subsys_attrs[] = {
964 NULL, 964 NULL,
965}; 965};
966 966
967static decl_subsys(paths, &ktype_pdcspath, NULL); 967static decl_subsys(paths, NULL);
968static decl_subsys(stable, NULL, NULL); 968static decl_subsys(stable, NULL);
969 969
970/** 970/**
971 * pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage. 971 * pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage.
@@ -997,7 +997,8 @@ pdcs_register_pathentries(void)
997 997
998 if ((err = kobject_set_name(&entry->kobj, "%s", entry->name))) 998 if ((err = kobject_set_name(&entry->kobj, "%s", entry->name)))
999 return err; 999 return err;
1000 kobj_set_kset_s(entry, paths_subsys); 1000 entry->kobj.kset = &paths_subsys;
1001 entry->kobj.ktype = &ktype_pdcspath;
1001 if ((err = kobject_register(&entry->kobj))) 1002 if ((err = kobject_register(&entry->kobj)))
1002 return err; 1003 return err;
1003 1004
@@ -1072,7 +1073,7 @@ pdc_stable_init(void)
1072 error = subsys_create_file(&stable_subsys, attr); 1073 error = subsys_create_file(&stable_subsys, attr);
1073 1074
1074 /* register the paths subsys as a subsystem of stable subsys */ 1075 /* register the paths subsys as a subsystem of stable subsys */
1075 kobj_set_kset_s(&paths_subsys, stable_subsys); 1076 paths_subsys.kobj.kset = &stable_subsys;
1076 if ((rc = subsystem_register(&paths_subsys))) 1077 if ((rc = subsystem_register(&paths_subsys)))
1077 goto fail_subsysreg; 1078 goto fail_subsysreg;
1078 1079
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 01c351c176ac..ce1cff0fdeca 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -96,7 +96,7 @@ static struct kobj_type hotplug_slot_ktype = {
96 .release = &hotplug_slot_release, 96 .release = &hotplug_slot_release,
97}; 97};
98 98
99decl_subsys_name(pci_hotplug_slots, slots, &hotplug_slot_ktype, NULL); 99decl_subsys_name(pci_hotplug_slots, slots, NULL);
100 100
101/* these strings match up with the values in pci_bus_speed */ 101/* these strings match up with the values in pci_bus_speed */
102static char *pci_bus_speed_strings[] = { 102static char *pci_bus_speed_strings[] = {
@@ -633,7 +633,8 @@ int pci_hp_register (struct hotplug_slot *slot)
633 } 633 }
634 634
635 kobject_set_name(&slot->kobj, "%s", slot->name); 635 kobject_set_name(&slot->kobj, "%s", slot->name);
636 kobj_set_kset_s(slot, pci_hotplug_slots_subsys); 636 slot->kobj.kset = &pci_hotplug_slots_subsys;
637 slot->kobj.ktype = &hotplug_slot_ktype;
637 638
638 /* this can fail if we have already registered a slot with the same name */ 639 /* this can fail if we have already registered a slot with the same name */
639 if (kobject_register(&slot->kobj)) { 640 if (kobject_register(&slot->kobj)) {
@@ -701,7 +702,7 @@ static int __init pci_hotplug_init (void)
701{ 702{
702 int result; 703 int result;
703 704
704 kobj_set_kset_s(&pci_hotplug_slots_subsys, pci_bus_type.subsys); 705 pci_hotplug_slots_subsys.kobj.kset = &pci_bus_type.subsys;
705 result = subsystem_register(&pci_hotplug_slots_subsys); 706 result = subsystem_register(&pci_hotplug_slots_subsys);
706 if (result) { 707 if (result) {
707 err("Register subsys with error %d\n", result); 708 err("Register subsys with error %d\n", result);
diff --git a/drivers/pci/hotplug/rpadlpar_sysfs.c b/drivers/pci/hotplug/rpadlpar_sysfs.c
index a080fedf0332..76090937c758 100644
--- a/drivers/pci/hotplug/rpadlpar_sysfs.c
+++ b/drivers/pci/hotplug/rpadlpar_sysfs.c
@@ -131,7 +131,6 @@ struct kobj_type ktype_dlpar_io = {
131struct kset dlpar_io_kset = { 131struct kset dlpar_io_kset = {
132 .kobj = {.ktype = &ktype_dlpar_io, 132 .kobj = {.ktype = &ktype_dlpar_io,
133 .parent = &pci_hotplug_slots_subsys.kobj}, 133 .parent = &pci_hotplug_slots_subsys.kobj},
134 .ktype = &ktype_dlpar_io,
135}; 134};
136 135
137int dlpar_sysfs_init(void) 136int dlpar_sysfs_init(void)
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 865f32b63b5c..606aae7490ab 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -160,7 +160,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
160 if (!map_found) { 160 if (!map_found) {
161 map_found = 1; 161 map_found = 1;
162 kobject_set_name(&idev->map_attr_kset.kobj,"maps"); 162 kobject_set_name(&idev->map_attr_kset.kobj,"maps");
163 idev->map_attr_kset.ktype = &map_attr_type; 163 idev->map_attr_kset.kobj.ktype = &map_attr_type;
164 idev->map_attr_kset.kobj.parent = &idev->dev->kobj; 164 idev->map_attr_kset.kobj.parent = &idev->dev->kobj;
165 ret = kset_register(&idev->map_attr_kset); 165 ret = kset_register(&idev->map_attr_kset);
166 if (ret) 166 if (ret)