diff options
author | Tejun Heo <htejun@gmail.com> | 2007-08-02 08:38:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-12 17:51:04 -0400 |
commit | 23dc279950a056c33a14d09cf759f5173d41abd9 (patch) | |
tree | 852f8cc24c24988717dbae8f98da999ff27755fa /fs/sysfs/symlink.c | |
parent | 41fc1c27452e041a18e5141b8203ee0ea72bc483 (diff) |
sysfs: make sysfs_add_one() automatically check for duplicate entry
Make sysfs_add_one() check for duplicate entry and return -EEXIST if
such entry exists. This simplifies node addition code a bit.
This patch doesn't introduce any noticeable behavior change.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/symlink.c')
-rw-r--r-- | fs/sysfs/symlink.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index c129f307936a..a6b13f12b0e7 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c | |||
@@ -91,14 +91,11 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char | |||
91 | target_sd = NULL; /* reference is now owned by the symlink */ | 91 | target_sd = NULL; /* reference is now owned by the symlink */ |
92 | 92 | ||
93 | sysfs_addrm_start(&acxt, parent_sd); | 93 | sysfs_addrm_start(&acxt, parent_sd); |
94 | error = sysfs_add_one(&acxt, sd); | ||
95 | sysfs_addrm_finish(&acxt); | ||
94 | 96 | ||
95 | if (!sysfs_find_dirent(parent_sd, name)) | 97 | if (error) |
96 | sysfs_add_one(&acxt, sd); | ||
97 | |||
98 | if (!sysfs_addrm_finish(&acxt)) { | ||
99 | error = -EEXIST; | ||
100 | goto out_put; | 98 | goto out_put; |
101 | } | ||
102 | 99 | ||
103 | return 0; | 100 | return 0; |
104 | 101 | ||