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>
This commit is contained in:
Tejun Heo
2007-08-02 21:38:03 +09:00
committed by Greg Kroah-Hartman
parent 41fc1c2745
commit 23dc279950
4 changed files with 26 additions and 23 deletions

View File

@@ -91,14 +91,11 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
target_sd = NULL; /* reference is now owned by the symlink */
sysfs_addrm_start(&acxt, parent_sd);
error = sysfs_add_one(&acxt, sd);
sysfs_addrm_finish(&acxt);
if (!sysfs_find_dirent(parent_sd, name))
sysfs_add_one(&acxt, sd);
if (!sysfs_addrm_finish(&acxt)) {
error = -EEXIST;
if (error)
goto out_put;
}
return 0;