Commit 3514faca authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c11c4154
...@@ -57,7 +57,7 @@ static struct subsys_attribute auto_poweron_attr = { ...@@ -57,7 +57,7 @@ static struct subsys_attribute auto_poweron_attr = {
}; };
#ifndef CONFIG_PM #ifndef CONFIG_PM
decl_subsys(power,NULL,NULL); decl_subsys(power, NULL);
static struct attribute *g[] = { static struct attribute *g[] = {
&auto_poweron_attr.attr, &auto_poweron_attr.attr,
......
...@@ -490,7 +490,7 @@ static struct super_operations hypfs_s_ops = { ...@@ -490,7 +490,7 @@ static struct super_operations hypfs_s_ops = {
.show_options = hypfs_show_options, .show_options = hypfs_show_options,
}; };
static decl_subsys(s390, NULL, NULL); static decl_subsys(s390, NULL);
static int __init hypfs_init(void) static int __init hypfs_init(void)
{ {
...@@ -506,7 +506,7 @@ static int __init hypfs_init(void) ...@@ -506,7 +506,7 @@ static int __init hypfs_init(void)
goto fail_diag; goto fail_diag;
} }
} }
kobj_set_kset_s(&s390_subsys, hypervisor_subsys); s390_subsys.kobj.kset = &hypervisor_subsys;
rc = subsystem_register(&s390_subsys); rc = subsystem_register(&s390_subsys);
if (rc) if (rc)
goto fail_sysfs; goto fail_sysfs;
......
...@@ -418,7 +418,7 @@ static struct attribute_group ipl_unknown_attr_group = { ...@@ -418,7 +418,7 @@ static struct attribute_group ipl_unknown_attr_group = {
.attrs = ipl_unknown_attrs, .attrs = ipl_unknown_attrs,
}; };
static decl_subsys(ipl, NULL, NULL); static decl_subsys(ipl, NULL);
/* /*
* reipl section * reipl section
...@@ -590,7 +590,7 @@ static ssize_t reipl_type_store(struct kset *kset, const char *buf, ...@@ -590,7 +590,7 @@ static ssize_t reipl_type_store(struct kset *kset, const char *buf,
static struct subsys_attribute reipl_type_attr = static struct subsys_attribute reipl_type_attr =
__ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store); __ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store);
static decl_subsys(reipl, NULL, NULL); static decl_subsys(reipl, NULL);
/* /*
* dump section * dump section
...@@ -685,13 +685,13 @@ static ssize_t dump_type_store(struct kset *kset, const char *buf, ...@@ -685,13 +685,13 @@ static ssize_t dump_type_store(struct kset *kset, const char *buf,
static struct subsys_attribute dump_type_attr = static struct subsys_attribute dump_type_attr =
__ATTR(dump_type, 0644, dump_type_show, dump_type_store); __ATTR(dump_type, 0644, dump_type_show, dump_type_store);
static decl_subsys(dump, NULL, NULL); static decl_subsys(dump, NULL);
/* /*
* Shutdown actions section * Shutdown actions section
*/ */
static decl_subsys(shutdown_actions, NULL, NULL); static decl_subsys(shutdown_actions, NULL);
/* on panic */ /* on panic */
......
...@@ -584,7 +584,7 @@ static struct kset_uevent_ops block_uevent_ops = { ...@@ -584,7 +584,7 @@ static struct kset_uevent_ops block_uevent_ops = {
.uevent = block_uevent, .uevent = block_uevent,
}; };
decl_subsys(block, &ktype_block, &block_uevent_ops); decl_subsys(block, &block_uevent_ops);
/* /*
* aggregate disk stat collector. Uses the same stats that the sysfs * aggregate disk stat collector. Uses the same stats that the sysfs
...@@ -721,7 +721,8 @@ struct gendisk *alloc_disk_node(int minors, int node_id) ...@@ -721,7 +721,8 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
} }
} }
disk->minors = minors; disk->minors = minors;
kobj_set_kset_s(disk,block_subsys); disk->kobj.kset = &block_subsys;
disk->kobj.ktype = &ktype_block;
kobject_init(&disk->kobj); kobject_init(&disk->kobj);
rand_initialize_disk(disk); rand_initialize_disk(disk);
INIT_WORK(&disk->async_notify, INIT_WORK(&disk->async_notify,
......
...@@ -743,7 +743,7 @@ static int __init acpi_bus_init(void) ...@@ -743,7 +743,7 @@ static int __init acpi_bus_init(void)
return -ENODEV; return -ENODEV;
} }
decl_subsys(acpi, NULL, NULL); decl_subsys(acpi, NULL);
static int __init acpi_init(void) static int __init acpi_init(void)
{ {
......
...@@ -166,7 +166,7 @@ static struct kset_uevent_ops bus_uevent_ops = { ...@@ -166,7 +166,7 @@ static struct kset_uevent_ops bus_uevent_ops = {
.filter = bus_uevent_filter, .filter = bus_uevent_filter,
}; };
static decl_subsys(bus, &bus_ktype, &bus_uevent_ops); static decl_subsys(bus, &bus_uevent_ops);
#ifdef CONFIG_HOTPLUG #ifdef CONFIG_HOTPLUG
...@@ -639,6 +639,7 @@ int bus_add_driver(struct device_driver *drv) ...@@ -639,6 +639,7 @@ int bus_add_driver(struct device_driver *drv)
if (error) if (error)
goto out_put_bus; goto out_put_bus;
drv->kobj.kset = &bus->drivers; drv->kobj.kset = &bus->drivers;
drv->kobj.ktype = &driver_ktype;
error = kobject_register(&drv->kobj); error = kobject_register(&drv->kobj);
if (error) if (error)
goto out_put_bus; goto out_put_bus;
...@@ -851,6 +852,7 @@ int bus_register(struct bus_type * bus) ...@@ -851,6 +852,7 @@ int bus_register(struct bus_type * bus)
goto out; goto out;
bus->subsys.kobj.kset = &bus_subsys; bus->subsys.kobj.kset = &bus_subsys;
bus->subsys.kobj.ktype = &bus_ktype;
retval = subsystem_register(&bus->subsys); retval = subsystem_register(&bus->subsys);
if (retval) if (retval)
...@@ -868,7 +870,6 @@ int bus_register(struct bus_type * bus) ...@@ -868,7 +870,6 @@ int bus_register(struct bus_type * bus)
kobject_set_name(&bus->drivers.kobj, "drivers"); kobject_set_name(&bus->drivers.kobj, "drivers");
bus->drivers.kobj.parent = &bus->subsys.kobj; bus->drivers.kobj.parent = &bus->subsys.kobj;
bus->drivers.ktype = &driver_ktype;
retval = kset_register(&bus->drivers); retval = kset_register(&bus->drivers);
if (retval) if (retval)
goto bus_drivers_fail; goto bus_drivers_fail;
......
...@@ -71,7 +71,7 @@ static struct kobj_type class_ktype = { ...@@ -71,7 +71,7 @@ static struct kobj_type class_ktype = {
}; };
/* Hotplug events for classes go to the class_obj subsys */ /* Hotplug events for classes go to the class_obj subsys */
static decl_subsys(class, &class_ktype, NULL); static decl_subsys(class, NULL);
int class_create_file(struct class * cls, const struct class_attribute * attr) int class_create_file(struct class * cls, const struct class_attribute * attr)
...@@ -150,6 +150,7 @@ int class_register(struct class * cls) ...@@ -150,6 +150,7 @@ int class_register(struct class * cls)
return error; return error;
cls->subsys.kobj.kset = &class_subsys; cls->subsys.kobj.kset = &class_subsys;
cls->subsys.kobj.ktype = &class_ktype;
error = subsystem_register(&cls->subsys); error = subsystem_register(&cls->subsys);
if (!error) { if (!error) {
...@@ -452,7 +453,7 @@ static struct kset_uevent_ops class_uevent_ops = { ...@@ -452,7 +453,7 @@ static struct kset_uevent_ops class_uevent_ops = {
.uevent = class_uevent, .uevent = class_uevent,
}; };
static decl_subsys(class_obj, &class_device_ktype, &class_uevent_ops); static decl_subsys(class_obj, &class_uevent_ops);
static int class_device_add_attrs(struct class_device * cd) static int class_device_add_attrs(struct class_device * cd)
...@@ -537,7 +538,8 @@ static struct class_device_attribute class_uevent_attr = ...@@ -537,7 +538,8 @@ static struct class_device_attribute class_uevent_attr =
void class_device_initialize(struct class_device *class_dev) void class_device_initialize(struct class_device *class_dev)
{ {
kobj_set_kset_s(class_dev, class_obj_subsys); class_dev->kobj.kset = &class_obj_subsys;
class_dev->kobj.ktype = &class_device_ktype;
kobject_init(&class_dev->kobj); kobject_init(&class_dev->kobj);
INIT_LIST_HEAD(&class_dev->node); INIT_LIST_HEAD(&class_dev->node);
} }
......
...@@ -405,7 +405,7 @@ static struct device_attribute devt_attr = ...@@ -405,7 +405,7 @@ static struct device_attribute devt_attr =
* devices_subsys - structure to be registered with kobject core. * devices_subsys - structure to be registered with kobject core.
*/ */
decl_subsys(devices, &device_ktype, &device_uevent_ops); decl_subsys(devices, &device_uevent_ops);
/** /**
...@@ -525,7 +525,8 @@ static void klist_children_put(struct klist_node *n) ...@@ -525,7 +525,8 @@ static void klist_children_put(struct klist_node *n)
void device_initialize(struct device *dev) void device_initialize(struct device *dev)
{ {
kobj_set_kset_s(dev, devices_subsys); dev->kobj.kset = &devices_subsys;
dev->kobj.ktype = &device_ktype;
kobject_init(&dev->kobj); kobject_init(&dev->kobj);
klist_init(&dev->klist_children, klist_children_get, klist_init(&dev->klist_children, klist_children_get,
klist_children_put); klist_children_put);
......
...@@ -15,11 +15,12 @@ ...@@ -15,11 +15,12 @@
#include "base.h" #include "base.h"
static decl_subsys(firmware, NULL, NULL); static decl_subsys(firmware, NULL);
int firmware_register(struct kset *s) int firmware_register(struct kset *s)
{ {
kobj_set_kset_s(s, firmware_subsys); s->kobj.kset = &firmware_subsys;
s->kobj.ktype = NULL;
return subsystem_register(s); return subsystem_register(s);
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "base.h" #include "base.h"
decl_subsys(hypervisor, NULL, NULL); decl_subsys(hypervisor, NULL);
EXPORT_SYMBOL_GPL(hypervisor_subsys); EXPORT_SYMBOL_GPL(hypervisor_subsys);
int __init hypervisor_init(void) int __init hypervisor_init(void)
......
...@@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(sysdev_class_remove_file); ...@@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(sysdev_class_remove_file);
/* /*
* declare system_subsys * declare system_subsys
*/ */
static decl_subsys(system, &ktype_sysdev_class, NULL); static decl_subsys(system, NULL);
int sysdev_class_register(struct sysdev_class * cls) int sysdev_class_register(struct sysdev_class * cls)
{ {
...@@ -139,6 +139,7 @@ int sysdev_class_register(struct sysdev_class * cls) ...@@ -139,6 +139,7 @@ int sysdev_class_register(struct sysdev_class * cls)
kobject_name(&cls->kset.kobj)); kobject_name(&cls->kset.kobj));
INIT_LIST_HEAD(&cls->drivers); INIT_LIST_HEAD(&cls->drivers);
cls->kset.kobj.parent = &system_subsys.kobj; cls->kset.kobj.parent = &system_subsys.kobj;
cls->kset.kobj.ktype = &ktype_sysdev_class;
cls->kset.kobj.kset = &system_subsys; cls->kset.kobj.kset = &system_subsys;
return kset_register(&cls->kset); return kset_register(&cls->kset);
} }
......
...@@ -744,7 +744,6 @@ static struct kobj_type ktype_mc_set_attribs = { ...@@ -744,7 +744,6 @@ static struct kobj_type ktype_mc_set_attribs = {
*/ */
static struct kset mc_kset = { static struct kset mc_kset = {
.kobj = {.ktype = &ktype_mc_set_attribs }, .kobj = {.ktype = &ktype_mc_set_attribs },
.ktype = &ktype_mci,
}; };
...@@ -767,6 +766,7 @@ int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci) ...@@ -767,6 +766,7 @@ int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci)
/* this instance become part of the mc_kset */ /* this instance become part of the mc_kset */
kobj_mci->kset = &mc_kset; kobj_mci->kset = &mc_kset;
kobj_mci->ktype = &ktype_mci;
/* set the name of the mc<id> object */ /* set the name of the mc<id> object */
err = kobject_set_name(kobj_mci, "mc%d", mci->mc_idx); err = kobject_set_name(kobj_mci, "mc%d", mci->mc_idx);
......
...@@ -631,7 +631,7 @@ static struct kobj_type edd_ktype = { ...@@ -631,7 +631,7 @@ static struct kobj_type edd_ktype = {
.default_attrs = def_attrs, .default_attrs = def_attrs,
}; };
static decl_subsys(edd, &edd_ktype, NULL); static decl_subsys(edd, NULL);
/** /**
...@@ -723,7 +723,8 @@ edd_device_register(struct edd_device *edev, int i) ...@@ -723,7 +723,8 @@ edd_device_register(struct edd_device *edev, int i)
edd_dev_set_info(edev, i); edd_dev_set_info(edev, i);
kobject_set_name(&edev->kobj, "int13_dev%02x", kobject_set_name(&edev->kobj, "int13_dev%02x",
0x80 + i); 0x80 + i);
kobj_set_kset_s(edev,edd_subsys); edev->kobj.kset = &edd_subsys;
edev->kobj.ktype = &edd_ktype;
error = kobject_register(&edev->kobj); error = kobject_register(&edev->kobj);
if (!error) if (!error)
edd_populate_dir(edev); edd_populate_dir(edev);
......
...@@ -583,8 +583,8 @@ static struct subsys_attribute *efi_subsys_attrs[] = { ...@@ -583,8 +583,8 @@ static struct subsys_attribute *efi_subsys_attrs[] = {
NULL, /* maybe more in the future? */ NULL, /* maybe more in the future? */
}; };
static decl_subsys(vars, &efivar_ktype, NULL); static decl_subsys(vars, NULL);
static decl_subsys(efi, NULL, NULL); static decl_subsys(efi, NULL);
/* /*
* efivar_create_sysfs_entry() * efivar_create_sysfs_entry()
...@@ -629,7 +629,8 @@ efivar_create_sysfs_entry(unsigned long variable_name_size, ...@@ -629,7 +629,8 @@ efivar_create_sysfs_entry(unsigned long variable_name_size,
efi_guid_unparse(vendor_guid, short_name + strlen(short_name)); efi_guid_unparse(vendor_guid, short_name + strlen(short_name));
kobject_set_name(&new_efivar->kobj, "%s", short_name); kobject_set_name(&new_efivar->kobj, "%s", short_name);
kobj_set_kset_s(new_efivar, vars_subsys); new_efivar->kobj.kset = &vars_subsys;
new_efivar->kobj.ktype = &efivar_ktype;
i = kobject_register(&new_efivar->kobj); i = kobject_register(&new_efivar->kobj);
if (i) { if (i) {
kfree(short_name); kfree(short_name);
...@@ -687,7 +688,7 @@ efivars_init(void) ...@@ -687,7 +688,7 @@ efivars_init(void)
goto out_free; goto out_free;
} }
kobj_set_kset_s(&vars_subsys, efi_subsys); vars_subsys.kobj.kset = &efi_subsys;
error = subsystem_register(&vars_subsys); error = subsystem_register(&vars_subsys);
......
...@@ -964,8 +964,8 @@ static struct subsys_attribute *pdcs_subsys_attrs[] = { ...@@ -964,8 +964,8 @@ static struct subsys_attribute *pdcs_subsys_attrs[] = {
NULL, NULL,
}; };
static decl_subsys(paths, &ktype_pdcspath, NULL); static decl_subsys(paths, NULL);
static decl_subsys(stable, NULL, NULL); static decl_subsys(stable, NULL);
/** /**
* pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage. * pdcs_register_pathentries - Prepares path entries kobjects for sysfs usage.
...@@ -997,7 +997,8 @@ pdcs_register_pathentries(void) ...@@ -997,7 +997,8 @@ pdcs_register_pathentries(void)
if ((err = kobject_set_name(&entry->kobj, "%s", entry->name))) if ((err = kobject_set_name(&entry->kobj, "%s", entry->name)))
return err; return err;
kobj_set_kset_s(entry, paths_subsys); entry->kobj.kset = &paths_subsys;
entry->kobj.ktype = &ktype_pdcspath;
if ((err = kobject_register(&entry->kobj))) if ((err = kobject_register(&entry->kobj)))
return err; return err;
...@@ -1072,7 +1073,7 @@ pdc_stable_init(void) ...@@ -1072,7 +1073,7 @@ pdc_stable_init(void)
error = subsys_create_file(&stable_subsys, attr); error = subsys_create_file(&stable_subsys, attr);
/* register the paths subsys as a subsystem of stable subsys */ /* register the paths subsys as a subsystem of stable subsys */
kobj_set_kset_s(&paths_subsys, stable_subsys); paths_subsys.kobj.kset = &stable_subsys;
if ((rc = subsystem_register(&paths_subsys))) if ((rc = subsystem_register(&paths_subsys)))
goto fail_subsysreg; goto fail_subsysreg;
......
...@@ -96,7 +96,7 @@ static struct kobj_type hotplug_slot_ktype = { ...@@ -96,7 +96,7 @@ static struct kobj_type hotplug_slot_ktype = {
.release = &hotplug_slot_release, .release = &hotplug_slot_release,
}; };
decl_subsys_name(pci_hotplug_slots, slots, &hotplug_slot_ktype, NULL); decl_subsys_name(pci_hotplug_slots, slots, NULL);
/* these strings match up with the values in pci_bus_speed */ /* these strings match up with the values in pci_bus_speed */
static char *pci_bus_speed_strings[] = { static char *pci_bus_speed_strings[] = {
...@@ -633,7 +633,8 @@ int pci_hp_register (struct hotplug_slot *slot) ...@@ -633,7 +633,8 @@ int pci_hp_register (struct hotplug_slot *slot)
} }
kobject_set_name(&slot->kobj, "%s", slot->name); kobject_set_name(&slot->kobj, "%s", slot->name);
kobj_set_kset_s(slot, pci_hotplug_slots_subsys); slot->kobj.kset = &pci_hotplug_slots_subsys;
slot->kobj.ktype = &hotplug_slot_ktype;
/* this can fail if we have already registered a slot with the same name */ /* this can fail if we have already registered a slot with the same name */
if (kobject_register(&slot->kobj)) { if (kobject_register(&slot->kobj)) {
...@@ -701,7 +702,7 @@ static int __init pci_hotplug_init (void) ...@@ -701,7 +702,7 @@ static int __init pci_hotplug_init (void)
{ {
int result; int result;
kobj_set_kset_s(&pci_hotplug_slots_subsys, pci_bus_type.subsys); pci_hotplug_slots_subsys.kobj.kset = &pci_bus_type.subsys;
result = subsystem_register(&pci_hotplug_slots_subsys); result = subsystem_register(&pci_hotplug_slots_subsys);
if (result) { if (result) {
err("Register subsys with error %d\n", result); err("Register subsys with error %d\n", result);
......
...@@ -131,7 +131,6 @@ struct kobj_type ktype_dlpar_io = { ...@@ -131,7 +131,6 @@ struct kobj_type ktype_dlpar_io = {
struct kset dlpar_io_kset = { struct kset dlpar_io_kset = {
.kobj = {.ktype = &ktype_dlpar_io, .kobj = {.ktype = &ktype_dlpar_io,
.parent = &pci_hotplug_slots_subsys.kobj}, .parent = &pci_hotplug_slots_subsys.kobj},
.ktype = &ktype_dlpar_io,
}; };
int dlpar_sysfs_init(void) int dlpar_sysfs_init(void)
......
...@@ -160,7 +160,7 @@ static int uio_dev_add_attributes(struct uio_device *idev) ...@@ -160,7 +160,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
if (!map_found) { if (!map_found) {
map_found = 1; map_found = 1;
kobject_set_name(&idev->map_attr_kset.kobj,"maps"); kobject_set_name(&idev->map_attr_kset.kobj,"maps");
idev->map_attr_kset.ktype = &map_attr_type; idev->map_attr_kset.kobj.ktype = &map_attr_type;
idev->map_attr_kset.kobj.parent = &idev->dev->kobj; idev->map_attr_kset.kobj.parent = &idev->dev->kobj;
ret = kset_register(&idev->map_attr_kset); ret = kset_register(&idev->map_attr_kset);
if (ret) if (ret)
......
...@@ -128,7 +128,7 @@ void configfs_release_fs(void) ...@@ -128,7 +128,7 @@ void configfs_release_fs(void)
} }
static decl_subsys(config, NULL, NULL); static decl_subsys(config, NULL);
static int __init configfs_init(void) static int __init configfs_init(void)
{ {
...@@ -140,7 +140,7 @@ static int __init configfs_init(void) ...@@ -140,7 +140,7 @@ static int __init configfs_init(void)
if (!configfs_dir_cachep) if (!configfs_dir_cachep)
goto out; goto out;
kobj_set_kset_s(&config_subsys, kernel_subsys); config_subsys.kobj.kset = &kernel_subsys;
err = subsystem_register(&config_subsys); err = subsystem_register(&config_subsys);
if (err) { if (err) {
kmem_cache_destroy(configfs_dir_cachep); kmem_cache_destroy(configfs_dir_cachep);
......
...@@ -426,13 +426,13 @@ exit: ...@@ -426,13 +426,13 @@ exit:
} }
EXPORT_SYMBOL_GPL(debugfs_rename); EXPORT_SYMBOL_GPL(debugfs_rename);
static decl_subsys(debug, NULL, NULL); static decl_subsys(debug, NULL);
static int __init debugfs_init(void) static int __init debugfs_init(void)
{ {
int retval; int retval;
kobj_set_kset_s(&debug_subsys, kernel_subsys); debug_subsys.kobj.kset = &kernel_subsys;
retval = subsystem_register(&debug_subsys); retval = subsystem_register(&debug_subsys);
if (retval) if (retval)
return retval; return retval;
......
...@@ -166,9 +166,7 @@ static struct kobj_type dlm_ktype = { ...@@ -166,9 +166,7 @@ static struct kobj_type dlm_ktype = {
.release = lockspace_kobj_release, .release = lockspace_kobj_release,
}; };
static struct kset dlm_kset = { static struct kset dlm_kset;
.ktype = &dlm_ktype,
};
static int kobject_setup(struct dlm_ls *ls) static int kobject_setup(struct dlm_ls *ls)
{ {
...@@ -228,7 +226,7 @@ int dlm_lockspace_init(void) ...@@ -228,7 +226,7 @@ int dlm_lockspace_init(void)
spin_lock_init(&lslist_lock); spin_lock_init(&lslist_lock);
kobject_set_name(&dlm_kset.kobj, "dlm"); kobject_set_name(&dlm_kset.kobj, "dlm");
kobj_set_kset_s(&dlm_kset, kernel_subsys); dlm_kset.kobj.kset = &kernel_subsys;
error = kset_register(&dlm_kset); error = kset_register(&dlm_kset);
if (error) if (error)
printk("dlm_lockspace_init: cannot register kset %d\n", error); printk("dlm_lockspace_init: cannot register kset %d\n", error);
......
...@@ -734,7 +734,7 @@ static int ecryptfs_init_kmem_caches(void) ...@@ -734,7 +734,7 @@ static int ecryptfs_init_kmem_caches(void)
return 0; return 0;
} }
static decl_subsys(ecryptfs, NULL, NULL); static decl_subsys(ecryptfs, NULL);
static ssize_t version_show(struct kset *kset, char *buff) static ssize_t version_show(struct kset *kset, char *buff)
{ {
...@@ -798,6 +798,7 @@ static int do_sysfs_registration(void) ...@@ -798,6 +798,7 @@ static int do_sysfs_registration(void)
{ {
int rc; int rc;
ecryptfs_subsys.kobj.kset = &fs_subsys;
rc = subsystem_register(&ecryptfs_subsys); rc = subsystem_register(&ecryptfs_subsys);
if (rc) { if (rc) {
printk(KERN_ERR printk(KERN_ERR
...@@ -845,7 +846,6 @@ static int __init ecryptfs_init(void) ...@@ -845,7 +846,6 @@ static int __init ecryptfs_init(void)
printk(KERN_ERR "Failed to register filesystem\n"); printk(KERN_ERR "Failed to register filesystem\n");
goto out_free_kmem_caches; goto out_free_kmem_caches;
} }
kobj_set_kset_s(&ecryptfs_subsys, fs_subsys);
rc = do_sysfs_registration(); rc = do_sysfs_registration();
if (rc) { if (rc) {
printk(KERN_ERR "sysfs registration failed\n"); printk(KERN_ERR "sysfs registration failed\n");
......
...@@ -744,8 +744,8 @@ static inline void unregister_fuseblk(void) ...@@ -744,8 +744,8 @@ static inline void unregister_fuseblk(void)
} }
#endif #endif
static decl_subsys(fuse, NULL, NULL); static decl_subsys(fuse, NULL);
static decl_subsys(connections, NULL, NULL); static decl_subsys(connections, NULL);
static void fuse_inode_init_once(struct kmem_cache *cachep, void *foo) static void fuse_inode_init_once(struct kmem_cache *cachep, void *foo)
{ {
...@@ -795,12 +795,12 @@ static int fuse_sysfs_init(void) ...@@ -795,12 +795,12 @@ static int fuse_sysfs_init(void)
{ {
int err; int err;
kobj_set_kset_s(&fuse_subsys, fs_subsys); fuse_subsys.kobj.kset = &fs_subsys;
err = subsystem_register(&fuse_subsys); err = subsystem_register(&fuse_subsys);
if (err) if (err)
goto out_err; goto out_err;
kobj_set_kset_s(&connections_subsys, fuse_subsys); connections_subsys.kobj.kset = &fuse_subsys;
err = subsystem_register(&connections_subsys); err = subsystem_register(&connections_subsys);
if (err) if (err)
goto out_fuse_unregister; goto out_fuse_unregister;
......
...@@ -189,9 +189,7 @@ static struct kobj_type gdlm_ktype = { ...@@ -189,9 +189,7 @@ static struct kobj_type gdlm_ktype = {
.sysfs_ops = &gdlm_attr_ops, .sysfs_ops = &gdlm_attr_ops,
}; };
static struct kset gdlm_kset = { static struct kset gdlm_kset;
.ktype = &gdlm_ktype,
};
int gdlm_kobject_setup(struct gdlm_ls *ls, struct kobject *fskobj) int gdlm_kobject_setup(struct gdlm_ls *ls, struct kobject *fskobj)
{ {
...@@ -224,7 +222,7 @@ int gdlm_sysfs_init(void) ...@@ -224,7 +222,7 @@ int gdlm_sysfs_init(void)
int error; int error;
kobject_set_name(&gdlm_kset.kobj, "lock_dlm"); kobject_set_name(&gdlm_kset.kobj, "lock_dlm");
kobj_set_kset_s(&gdlm_kset, kernel_subsys); gdlm_kset.kobj.kset = &kernel_subsys;
error = kset_register(&gdlm_kset); error = kset_register(&gdlm_kset);
if (error) if (error)
printk("lock_dlm: cannot register kset %d\n", error); printk("lock_dlm: cannot register kset %d\n", error);
......
...@@ -221,9 +221,7 @@ static struct kobj_type gfs2_ktype = { ...@@ -221,9 +221,7 @@ static struct kobj_type gfs2_ktype = {
.sysfs_ops = &gfs2_attr_ops, .sysfs_ops = &gfs2_attr_ops,
}; };
static struct kset gfs2_kset = { static struct kset gfs2_kset;
.ktype = &gfs2_ktype,
};
/* /*
* display struct lm_lockstruct fields * display struct lm_lockstruct fields
...@@ -551,7 +549,7 @@ int gfs2_sys_init(void) ...@@ -551,7 +549,7 @@ int gfs2_sys_init(void)
gfs2_sys_margs = NULL; gfs2_sys_margs = NULL;
spin_lock_init(&gfs2_sys_margs_lock); spin_lock_init(&gfs2_sys_margs_lock);
kobject_set_name(&gfs2_kset.kobj, "gfs2"); kobject_set_name(&gfs2_kset.kobj, "gfs2");
kobj_set_kset_s(&gfs2_kset, fs_subsys); gfs2_kset.kobj.kset = &fs_subsys;
return kset_register(&gfs2_kset); return kset_register(&gfs2_kset);
} }
......
...@@ -41,7 +41,7 @@ static struct kmem_cache *mnt_cache __read_mostly; ...@@ -41,7 +41,7 @@ static struct kmem_cache *mnt_cache __read_mostly;
static struct rw_semaphore namespace_sem; static struct rw_semaphore namespace_sem;
/* /sys/fs */ /* /sys/fs */
decl_subsys(fs, NULL, NULL); decl_subsys(fs, NULL);
EXPORT_SYMBOL_GPL(fs_subsys); EXPORT_SYMBOL_GPL(fs_subsys);
static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry) static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
......
...@@ -157,7 +157,7 @@ int mlog_sys_init(struct kset *o2cb_subsys) ...@@ -157,7 +157,7 @@ int mlog_sys_init(struct kset *o2cb_subsys)
mlog_attr_ptrs[i] = NULL; mlog_attr_ptrs[i] = NULL;
kobject_set_name(&mlog_kset.kobj, "logmask"); kobject_set_name(&mlog_kset.kobj, "logmask");
kobj_set_kset_s(&mlog_kset, *o2cb_subsys); mlog_kset.kobj.kset = o2cb_subsys;
return kset_register(&mlog_kset); return kset_register(&mlog_kset);
} }
......
...@@ -72,7 +72,7 @@ static struct kobj_type o2cb_subsys_type = { ...@@ -72,7 +72,7 @@ static struct kobj_type o2cb_subsys_type = {
}; };
/* gives us o2cb_subsys */ /* gives us o2cb_subsys */
static decl_subsys(o2cb, NULL, NULL); static decl_subsys(o2cb, NULL);
static ssize_t static ssize_t
o2cb_show(struct kobject * kobj, struct attribute * attr, char * buffer) o2cb_show(struct kobject * kobj, struct attribute * attr, char * buffer)
......
...@@ -365,9 +365,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file) ...@@ -365,9 +365,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
/* if the kobject has no ktype, then we assume that it is a subsystem /* if the kobject has no ktype, then we assume that it is a subsystem
* itself, and use ops for it. * itself, and use ops for it.
*/ */
if (kobj->kset && kobj->kset->ktype) if (kobj->ktype)
ops = kobj->kset->ktype->sysfs_ops;
else if (kobj->ktype)
ops = kobj->ktype->sysfs_ops; ops = kobj->ktype->sysfs_ops;
else else
ops = &subsys_sysfs_ops; ops = &subsys_sysfs_ops;
......
...@@ -135,7 +135,6 @@ struct kset_uevent_ops { ...@@ -135,7 +135,6 @@ struct kset_uevent_ops {
* define the attribute callbacks and other common events that happen to * define the attribute callbacks and other common events that happen to
* a kobject. * a kobject.
* *
* @ktype: the struct kobj_type for this specific kset
* @list: the list of all kobjects for this kset * @list: the list of all kobjects for this kset
* @list_lock: a lock for iterating over the kobjects * @list_lock: a lock for iterating over the kobjects
* @kobj: the embedded kobject for this kset (recursion, isn't it fun...) * @kobj: the embedded kobject for this kset (recursion, isn't it fun...)
...@@ -145,7 +144,6 @@ struct kset_uevent_ops { ...@@ -145,7 +144,6 @@ struct kset_uevent_ops {
* desired. * desired.
*/ */
struct kset { struct kset {
struct kobj_type *ktype;
struct list_head list; struct list_head list;
spinlock_t list_lock; spinlock_t list_lock;
struct kobject kobj; struct kobject kobj;
...@@ -173,12 +171,9 @@ static inline void kset_put(struct kset * k) ...@@ -173,12 +171,9 @@ static inline void kset_put(struct kset * k)
kobject_put(&k->kobj); kobject_put(&k->kobj);
} }
static inline struct kobj_type * get_ktype(struct kobject * k) static inline struct kobj_type *get_ktype(struct kobject *kobj)
{ {
if (k->kset && k->kset->ktype) return kobj->ktype;
return k->kset->ktype;
else
return k->ktype;
} }
extern struct kobject * kset_find_obj(struct kset *, const char *); extern struct kobject * kset_find_obj(struct kset *, const char *);
...@@ -191,16 +186,14 @@ extern struct kobject * kset_find_obj(struct kset *, const char *); ...@@ -191,16 +186,14 @@ extern struct kobject * kset_find_obj(struct kset *, const char *);
#define set_kset_name(str) .kset = { .kobj = { .k_name = str } } #define set_kset_name(str) .kset = { .kobj = { .k_name = str } }
#define decl_subsys(_name,_type,_uevent_ops) \ #define decl_subsys(_name,_uevent_ops) \
struct kset _name##_subsys = { \ struct kset _name##_subsys = { \
.kobj = { .k_name = __stringify(_name) }, \ .kobj = { .k_name = __stringify(_name) }, \
.ktype = _type, \
.uevent_ops =_uevent_ops, \ .uevent_ops =_uevent_ops, \
} }
#define decl_subsys_name(_varname,_name,_type,_uevent_ops) \ #define decl_subsys_name(_varname,_name,_uevent_ops) \
struct kset _varname##_subsys = { \ struct kset _varname##_subsys = { \
.kobj = { .k_name = __stringify(_name) }, \ .kobj = { .k_name = __stringify(_name) }, \
.ktype = _type, \
.uevent_ops =_uevent_ops, \ .uevent_ops =_uevent_ops, \
} }
......
...@@ -94,7 +94,7 @@ static struct bin_attribute notes_attr = { ...@@ -94,7 +94,7 @@ static struct bin_attribute notes_attr = {
.read = &notes_read, .read = &notes_read,
}; };
decl_subsys(kernel, NULL, NULL); decl_subsys(kernel, NULL);
EXPORT_SYMBOL_GPL(kernel_subsys); EXPORT_SYMBOL_GPL(kernel_subsys);
static struct attribute * kernel_attrs[] = { static struct attribute * kernel_attrs[] = {
......
...@@ -1223,7 +1223,7 @@ int mod_sysfs_init(struct module *mod) ...@@ -1223,7 +1223,7 @@ int mod_sysfs_init(struct module *mod)
err = kobject_set_name(&mod->mkobj.kobj, "%s", mod->name); err = kobject_set_name(&mod->mkobj.kobj, "%s", mod->name);
if (err) if (err)
goto out; goto out;
kobj_set_kset_s(&mod->mkobj, module_subsys); mod->mkobj.kobj.kset = &module_subsys;
mod->mkobj.mod = mod; mod->mkobj.mod = mod;
kobject_init(&mod->mkobj.kobj); kobject_init(&mod->mkobj.kobj);
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#define DEBUGP(fmt, a...) #define DEBUGP(fmt, a...)
#endif #endif
static struct kobj_type module_ktype;
static inline char dash2underscore(char c) static inline char dash2underscore(char c)
{ {
if (c == '-') if (c == '-')
...@@ -560,7 +562,8 @@ static void __init kernel_param_sysfs_setup(const char *name, ...@@ -560,7 +562,8 @@ static void __init kernel_param_sysfs_setup(const char *name,
BUG_ON(!mk); BUG_ON(!mk);
mk->mod = THIS_MODULE; mk->mod = THIS_MODULE;
kobj_set_kset_s(mk, module_subsys); mk->kobj.kset = &module_subsys;
mk->kobj.ktype = &module_ktype;
kobject_set_name(&mk->kobj, name); kobject_set_name(&mk->kobj, name);
kobject_init(&mk->kobj); kobject_init(&mk->kobj);
ret = kobject_add(&mk->kobj); ret = kobject_add(&mk->kobj);
...@@ -679,8 +682,6 @@ static struct sysfs_ops module_sysfs_ops = { ...@@ -679,8 +682,6 @@ static struct sysfs_ops module_sysfs_ops = {
.store = module_attr_store, .store = module_attr_store,
}; };
static struct kobj_type module_ktype;
static int uevent_filter(struct kset *kset, struct kobject *kobj) static int uevent_filter(struct kset *kset, struct kobject *kobj)
{ {
struct kobj_type *ktype = get_ktype(kobj); struct kobj_type *ktype = get_ktype(kobj);
...@@ -694,7 +695,7 @@ static struct kset_uevent_ops module_uevent_ops = { ...@@ -694,7 +695,7 @@ static struct kset_uevent_ops module_uevent_ops = {
.filter = uevent_filter, .filter = uevent_filter,
}; };
decl_subsys(module, &module_ktype, &module_uevent_ops); decl_subsys(module, &module_uevent_ops);
int module_sysfs_initialized; int module_sysfs_initialized;
static void module_release(struct kobject *kobj) static void module_release(struct kobject *kobj)
......
...@@ -276,7 +276,7 @@ EXPORT_SYMBOL(pm_suspend); ...@@ -276,7 +276,7 @@ EXPORT_SYMBOL(pm_suspend);
#endif /* CONFIG_SUSPEND */ #endif /* CONFIG_SUSPEND */
decl_subsys(power,NULL,NULL); decl_subsys(power, NULL);
/** /**
......
...@@ -3962,7 +3962,7 @@ static struct kset_uevent_ops slab_uevent_ops = { ...@@ -3962,7 +3962,7 @@ static struct kset_uevent_ops slab_uevent_ops = {
.filter = uevent_filter, .filter = uevent_filter,
}; };
static decl_subsys(slab, &slab_ktype, &slab_uevent_ops); static decl_subsys(slab, &slab_uevent_ops);
#define ID_STR_LENGTH 64 #define ID_STR_LENGTH 64
...@@ -4025,8 +4025,9 @@ static int sysfs_slab_add(struct kmem_cache *s) ...@@ -4025,8 +4025,9 @@ static int sysfs_slab_add(struct kmem_cache *s)
name = create_unique_id(s); name = create_unique_id(s);
} }
kobj_set_kset_s(s, slab_subsys);
kobject_set_name(&s->kobj, name); kobject_set_name(&s->kobj, name);
s->kobj.kset = &slab_subsys;
s->kobj.ktype = &slab_ktype;
kobject_init(&s->kobj); kobject_init(&s->kobj);
err = kobject_add(&s->kobj); err = kobject_add(&s->kobj);
if (err) if (err)
......
...@@ -315,13 +315,13 @@ void securityfs_remove(struct dentry *dentry) ...@@ -315,13 +315,13 @@ void securityfs_remove(struct dentry *dentry)
} }
EXPORT_SYMBOL_GPL(securityfs_remove); EXPORT_SYMBOL_GPL(securityfs_remove);
static decl_subsys(security, NULL, NULL); static decl_subsys(security, NULL);
static int __init securityfs_init(void) static int __init securityfs_init(void)
{ {
int retval; int retval;
kobj_set_kset_s(&security_subsys, kernel_subsys); security_subsys.kobj.kset = &kernel_subsys;
retval = subsystem_register(&security_subsys); retval = subsystem_register(&security_subsys);
if (retval) if (retval)
return retval; return retval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment