sysfs: consolidate sysfs_dirent creation functions
Currently there are four functions to create sysfs_dirent - __sysfs_new_dirent(), sysfs_new_dirent(), __sysfs_make_dirent() and sysfs_make_dirent(). Other than sysfs_make_dirent(), no function has two users if calls to implement other functions are excluded. This patch consolidates sysfs_dirent creation functions into the following two. * sysfs_new_dirent() : allocate and initialize * sysfs_attach_dirent() : attach to sysfs_dirent hierarchy and/or associate with dentry This simplifies interface and gives callers more flexibility. This is in preparation of object reference simplification. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
996b73764e
commit
a26cd7226c
@@ -49,6 +49,7 @@ static int sysfs_add_link(struct dentry * parent, const char * name, struct kobj
|
||||
{
|
||||
struct sysfs_dirent * parent_sd = parent->d_fsdata;
|
||||
struct sysfs_symlink * sl;
|
||||
struct sysfs_dirent * sd;
|
||||
int error;
|
||||
|
||||
error = -ENOMEM;
|
||||
@@ -63,10 +64,10 @@ static int sysfs_add_link(struct dentry * parent, const char * name, struct kobj
|
||||
strcpy(sl->link_name, name);
|
||||
sl->target_kobj = kobject_get(target);
|
||||
|
||||
error = sysfs_make_dirent(parent_sd, NULL, sl, S_IFLNK|S_IRWXUGO,
|
||||
SYSFS_KOBJ_LINK);
|
||||
if (error)
|
||||
sd = sysfs_new_dirent(sl, S_IFLNK|S_IRWXUGO, SYSFS_KOBJ_LINK);
|
||||
if (!sd)
|
||||
goto err_out;
|
||||
sysfs_attach_dirent(sd, parent_sd, NULL);
|
||||
|
||||
return 0;
|
||||
|
||||
|
Reference in New Issue
Block a user