]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/sysfs/symlink.c
[SPARC64]: Fix virq decomposition.
[linux-2.6-omap-h63xx.git] / fs / sysfs / symlink.c
index 683316f0aa967a786f04bd322f97573eeb748774..4ce687f0b5d01751dfb8f8aa189c84360eaab39e 100644 (file)
@@ -55,6 +55,7 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
        struct sysfs_dirent *parent_sd = NULL;
        struct sysfs_dirent *target_sd = NULL;
        struct sysfs_dirent *sd = NULL;
+       struct sysfs_addrm_cxt acxt;
        int error;
 
        BUG_ON(!name);
@@ -85,19 +86,24 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
        sd = sysfs_new_dirent(name, S_IFLNK|S_IRWXUGO, SYSFS_KOBJ_LINK);
        if (!sd)
                goto out_put;
+
        sd->s_elem.symlink.target_sd = target_sd;
+       target_sd = NULL;       /* reference is now owned by the symlink */
 
-       mutex_lock(&sysfs_mutex);
-       error = -EEXIST;
-       if (sysfs_find_dirent(parent_sd, name))
-               goto out_unlock;
-       sysfs_attach_dirent(sd, parent_sd, NULL);
-       mutex_unlock(&sysfs_mutex);
+       sysfs_addrm_start(&acxt, parent_sd);
+
+       if (!sysfs_find_dirent(parent_sd, name)) {
+               sysfs_add_one(&acxt, sd);
+               sysfs_link_sibling(sd);
+       }
+
+       if (!sysfs_addrm_finish(&acxt)) {
+               error = -EEXIST;
+               goto out_put;
+       }
 
        return 0;
 
- out_unlock:
-       mutex_unlock(&sysfs_mutex);
  out_put:
        sysfs_put(target_sd);
        sysfs_put(sd);