Kobject: change GFS2 to use kobject_init_and_add
authorGreg Kroah-Hartman <gregkh@suse.de>
Mon, 17 Dec 2007 19:54:39 +0000 (15:54 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 25 Jan 2008 04:40:26 +0000 (20:40 -0800)
Stop using kobject_register, as this way we can control the sending of
the uevent properly, after everything is properly initialized.

Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/dlm/lockspace.c
fs/gfs2/locking/dlm/sysfs.c
fs/gfs2/sys.c

index e64b0dc664f3fb52a7011b8edaad06368efdc8ee..b750f13d03281aab016545cc80929b32216db283 100644 (file)
@@ -168,23 +168,6 @@ static struct kobj_type dlm_ktype = {
 
 static struct kset *dlm_kset;
 
-static int kobject_setup(struct dlm_ls *ls)
-{
-       char lsname[DLM_LOCKSPACE_LEN];
-       int error;
-
-       memset(lsname, 0, DLM_LOCKSPACE_LEN);
-       snprintf(lsname, DLM_LOCKSPACE_LEN, "%s", ls->ls_name);
-
-       error = kobject_set_name(&ls->ls_kobj, "%s", lsname);
-       if (error)
-               return error;
-
-       ls->ls_kobj.kset = dlm_kset;
-       ls->ls_kobj.ktype = &dlm_ktype;
-       return 0;
-}
-
 static int do_uevent(struct dlm_ls *ls, int in)
 {
        int error;
@@ -545,13 +528,12 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
                goto out_delist;
        }
 
-       error = kobject_setup(ls);
-       if (error)
-               goto out_stop;
-
-       error = kobject_register(&ls->ls_kobj);
+       ls->ls_kobj.kset = dlm_kset;
+       error = kobject_init_and_add(&ls->ls_kobj, &dlm_ktype, NULL,
+                                    "%s", ls->ls_name);
        if (error)
                goto out_stop;
+       kobject_uevent(&ls->ls_kobj, KOBJ_ADD);
 
        /* let kobject handle freeing of ls if there's an error */
        do_unreg = 1;
index e5a4fbf7265f80657281c4cb341f08d0540d7537..a7336b909c61730432184e3fa622fa4130474066 100644 (file)
@@ -195,19 +195,12 @@ int gdlm_kobject_setup(struct gdlm_ls *ls, struct kobject *fskobj)
 {
        int error;
 
-       error = kobject_set_name(&ls->kobj, "%s", "lock_module");
-       if (error) {
-               log_error("can't set kobj name %d", error);
-               return error;
-       }
-
        ls->kobj.kset = gdlm_kset;
-       ls->kobj.ktype = &gdlm_ktype;
-       ls->kobj.parent = fskobj;
-
-       error = kobject_register(&ls->kobj);
+       error = kobject_init_and_add(&ls->kobj, &gdlm_ktype, fskobj,
+                                    "lock_module");
        if (error)
                log_error("can't register kobj %d", error);
+       kobject_uevent(&ls->kobj, KOBJ_ADD);
 
        return error;
 }
index 44cfaae92e764376e5455e44cc1c858a15e0bd39..8d9cd5bd58452e13246b0365e27a356f8b2428da 100644 (file)
@@ -494,13 +494,8 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp)
        int error;
 
        sdp->sd_kobj.kset = gfs2_kset;
-       sdp->sd_kobj.ktype = &gfs2_ktype;
-
-       error = kobject_set_name(&sdp->sd_kobj, "%s", sdp->sd_table_name);
-       if (error)
-               goto fail;
-
-       error = kobject_register(&sdp->sd_kobj);
+       error = kobject_init_and_add(&sdp->sd_kobj, &gfs2_ktype, NULL,
+                                    "%s", sdp->sd_table_name);
        if (error)
                goto fail;
 
@@ -520,6 +515,7 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp)
        if (error)
                goto fail_args;
 
+       kobject_uevent(&sdp->sd_kobj, KOBJ_ADD);
        return 0;
 
 fail_args: