diff options
author | Tejun Heo <htejun@gmail.com> | 2007-06-13 20:45:15 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-12 01:09:04 +0200 |
commit | 3e5190380ebef77f2b015c9e7a4ca225a3d75021 (patch) | |
tree | 08d17cd0562acf5101063e93c649f5f71f80b3b9 /fs/sysfs/symlink.c | |
parent | sysfs: add sysfs_dirent->s_name (diff) | |
download | linux-3e5190380ebef77f2b015c9e7a4ca225a3d75021.tar.xz linux-3e5190380ebef77f2b015c9e7a4ca225a3d75021.zip |
sysfs: make sysfs_dirent->s_element a union
Make sd->s_element a union of sysfs_elem_{dir|symlink|attr|bin_attr}
and rename it to s_elem. This is to achieve...
* some level of type checking : changing symlink to point to
sysfs_dirent instead of kobject is much safer and less painful now.
* easier / standardized dereferencing
* allow sysfs_elem_* to contain more than one entry
Where possible, pointer is obtained by directly deferencing from sd
instead of going through other entities. This reduces dependencies to
dentry, inode and kobject. to_attr() and to_bin_attr() are unused now
and removed.
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>
Diffstat (limited to 'fs/sysfs/symlink.c')
-rw-r--r-- | fs/sysfs/symlink.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index c72820450e7c..27df635b786a 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c @@ -48,30 +48,15 @@ static void fill_object_path(struct kobject * kobj, char * buffer, int length) static int sysfs_add_link(struct dentry * parent, const char * name, struct kobject * target) { struct sysfs_dirent * parent_sd = parent->d_fsdata; - struct sysfs_symlink * sl; struct sysfs_dirent * sd; - int error; - error = -ENOMEM; - sl = kzalloc(sizeof(*sl), GFP_KERNEL); - if (!sl) - goto err_out; - - sl->target_kobj = kobject_get(target); - - sd = sysfs_new_dirent(name, sl, S_IFLNK|S_IRWXUGO, SYSFS_KOBJ_LINK); + sd = sysfs_new_dirent(name, S_IFLNK|S_IRWXUGO, SYSFS_KOBJ_LINK); if (!sd) - goto err_out; - sysfs_attach_dirent(sd, parent_sd, NULL); + return -ENOMEM; + sd->s_elem.symlink.target_kobj = kobject_get(target); + sysfs_attach_dirent(sd, parent_sd, NULL); return 0; - - err_out: - if (sl) { - kobject_put(sl->target_kobj); - kfree(sl); - } - return error; } /** |