kset: convert kernel_subsys to use kset_create
authorGreg Kroah-Hartman <gregkh@suse.de>
Mon, 29 Oct 2007 19:13:17 +0000 (20:13 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 25 Jan 2008 04:40:14 +0000 (20:40 -0800)
Dynamically create the kset instead of declaring it statically.  We also
rename kernel_subsys to kernel_kset to catch all users of this symbol
with a build error instead of an easy-to-ignore build warning.

Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/configfs/mount.c
fs/debugfs/inode.c
fs/dlm/lockspace.c
fs/gfs2/locking/dlm/sysfs.c
include/linux/kobject.h
kernel/ksysfs.c
kernel/user.c
security/inode.c

index 1330046..c4ee7f0 100644 (file)
@@ -140,7 +140,7 @@ static int __init configfs_init(void)
        if (!configfs_dir_cachep)
                goto out;
 
-       config_kobj = kobject_create_and_add("config", &kernel_subsys.kobj);
+       config_kobj = kobject_create_and_add("config", &kernel_kset->kobj);
        if (!config_kobj) {
                kmem_cache_destroy(configfs_dir_cachep);
                configfs_dir_cachep = NULL;
index 6672142..5ce92c3 100644 (file)
@@ -432,7 +432,7 @@ static int __init debugfs_init(void)
 {
        int retval;
 
-       debug_kobj = kobject_create_and_add("debug", &kernel_subsys.kobj);
+       debug_kobj = kobject_create_and_add("debug", &kernel_kset->kobj);
        if (!debug_kobj)
                return -EINVAL;
 
index 83a9c4d..0828beb 100644 (file)
@@ -223,7 +223,7 @@ int dlm_lockspace_init(void)
        INIT_LIST_HEAD(&lslist);
        spin_lock_init(&lslist_lock);
 
-       dlm_kset = kset_create_and_add("dlm", NULL, &kernel_subsys.kobj);
+       dlm_kset = kset_create_and_add("dlm", NULL, &kernel_kset->kobj);
        if (!dlm_kset) {
                printk(KERN_WARNING "%s: can not create kset\n", __FUNCTION__);
                return -ENOMEM;
index 0a86140..1a92b6f 100644 (file)
@@ -219,8 +219,7 @@ void gdlm_kobject_release(struct gdlm_ls *ls)
 
 int gdlm_sysfs_init(void)
 {
-       gdlm_kset = kset_create_and_add("lock_dlm", NULL,
-                                       &kernel_subsys.kobj);
+       gdlm_kset = kset_create_and_add("lock_dlm", NULL, &kernel_kset->kobj);
        if (!gdlm_kset) {
                printk(KERN_WARNING "%s: can not create kset\n", __FUNCTION__);
                return -ENOMEM;
index 390ae14..bd741e8 100644 (file)
@@ -194,8 +194,8 @@ struct kset _name##_subsys = { \
        .uevent_ops =_uevent_ops, \
 }
 
-/* The global /sys/kernel/ subsystem for people to chain off of */
-extern struct kset kernel_subsys;
+/* The global /sys/kernel/ kset for people to chain off of */
+extern struct kset *kernel_kset;
 /* The global /sys/hypervisor/ subsystem  */
 extern struct kset hypervisor_subsys;
 
index 094e2bc..cf02d4b 100644 (file)
@@ -94,8 +94,8 @@ static struct bin_attribute notes_attr = {
        .read = &notes_read,
 };
 
-decl_subsys(kernel, NULL);
-EXPORT_SYMBOL_GPL(kernel_subsys);
+struct kset *kernel_kset;
+EXPORT_SYMBOL_GPL(kernel_kset);
 
 static struct attribute * kernel_attrs[] = {
 #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
@@ -116,24 +116,42 @@ static struct attribute_group kernel_attr_group = {
 
 static int __init ksysfs_init(void)
 {
-       int error = subsystem_register(&kernel_subsys);
-       if (!error)
-               error = sysfs_create_group(&kernel_subsys.kobj,
-                                          &kernel_attr_group);
+       int error;
 
-       if (!error && notes_size > 0) {
+       kernel_kset = kset_create_and_add("kernel", NULL, NULL);
+       if (!kernel_kset) {
+               error = -ENOMEM;
+               goto exit;
+       }
+       error = sysfs_create_group(&kernel_kset->kobj, &kernel_attr_group);
+       if (error)
+               goto kset_exit;
+
+       if (notes_size > 0) {
                notes_attr.size = notes_size;
-               error = sysfs_create_bin_file(&kernel_subsys.kobj,
-                                             &notes_attr);
+               error = sysfs_create_bin_file(&kernel_kset->kobj, &notes_attr);
+               if (error)
+                       goto group_exit;
        }
 
        /*
         * Create "/sys/kernel/uids" directory and corresponding root user's
         * directory under it.
         */
-       if (!error)
-               error = uids_kobject_init();
-
+       error = uids_kobject_init();
+       if (error)
+               goto notes_exit;
+
+       return 0;
+
+notes_exit:
+       if (notes_size > 0)
+               sysfs_remove_bin_file(&kernel_kset->kobj, &notes_attr);
+group_exit:
+       sysfs_remove_group(&kernel_kset->kobj, &kernel_attr_group);
+kset_exit:
+       kset_unregister(kernel_kset);
+exit:
        return error;
 }
 
index 8320a87..80f1116 100644 (file)
@@ -198,8 +198,8 @@ int __init uids_kobject_init(void)
        int error;
 
        /* create under /sys/kernel dir */
-       uids_kobject.parent = &kernel_subsys.kobj;
-       uids_kobject.kset = &kernel_subsys;
+       uids_kobject.parent = &kernel_kset->kobj;
+       uids_kobject.kset = kernel_kset;
        kobject_set_name(&uids_kobject, "uids");
        kobject_init(&uids_kobject);
 
index dfc5978..dbe040a 100644 (file)
@@ -321,7 +321,7 @@ static int __init securityfs_init(void)
 {
        int retval;
 
-       security_kobj = kobject_create_and_add("security", &kernel_subsys.kobj);
+       security_kobj = kobject_create_and_add("security", &kernel_kset->kobj);
        if (!security_kobj)
                return -EINVAL;