diff options
author | Tejun Heo <htejun@gmail.com> | 2007-06-13 14:45:15 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-11 19:09:04 -0400 |
commit | 3e5190380ebef77f2b015c9e7a4ca225a3d75021 (patch) | |
tree | 08d17cd0562acf5101063e93c649f5f71f80b3b9 /fs/sysfs/bin.c | |
parent | 0c096b507f15397da890051ee73de4266d3941fb (diff) |
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/bin.c')
-rw-r--r-- | fs/sysfs/bin.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c index 606267a36275..67a0d5030c96 100644 --- a/fs/sysfs/bin.c +++ b/fs/sysfs/bin.c | |||
@@ -23,7 +23,8 @@ | |||
23 | static int | 23 | static int |
24 | fill_read(struct dentry *dentry, char *buffer, loff_t off, size_t count) | 24 | fill_read(struct dentry *dentry, char *buffer, loff_t off, size_t count) |
25 | { | 25 | { |
26 | struct bin_attribute * attr = to_bin_attr(dentry); | 26 | struct sysfs_dirent *attr_sd = dentry->d_fsdata; |
27 | struct bin_attribute *attr = attr_sd->s_elem.bin_attr.bin_attr; | ||
27 | struct kobject * kobj = to_kobj(dentry->d_parent); | 28 | struct kobject * kobj = to_kobj(dentry->d_parent); |
28 | 29 | ||
29 | if (!attr->read) | 30 | if (!attr->read) |
@@ -65,7 +66,8 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) | |||
65 | static int | 66 | static int |
66 | flush_write(struct dentry *dentry, char *buffer, loff_t offset, size_t count) | 67 | flush_write(struct dentry *dentry, char *buffer, loff_t offset, size_t count) |
67 | { | 68 | { |
68 | struct bin_attribute *attr = to_bin_attr(dentry); | 69 | struct sysfs_dirent *attr_sd = dentry->d_fsdata; |
70 | struct bin_attribute *attr = attr_sd->s_elem.bin_attr.bin_attr; | ||
69 | struct kobject *kobj = to_kobj(dentry->d_parent); | 71 | struct kobject *kobj = to_kobj(dentry->d_parent); |
70 | 72 | ||
71 | if (!attr->write) | 73 | if (!attr->write) |
@@ -101,9 +103,9 @@ static ssize_t write(struct file *file, const char __user *userbuf, | |||
101 | 103 | ||
102 | static int mmap(struct file *file, struct vm_area_struct *vma) | 104 | static int mmap(struct file *file, struct vm_area_struct *vma) |
103 | { | 105 | { |
104 | struct dentry *dentry = file->f_path.dentry; | 106 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; |
105 | struct bin_attribute *attr = to_bin_attr(dentry); | 107 | struct bin_attribute *attr = attr_sd->s_elem.bin_attr.bin_attr; |
106 | struct kobject *kobj = to_kobj(dentry->d_parent); | 108 | struct kobject *kobj = to_kobj(file->f_path.dentry->d_parent); |
107 | 109 | ||
108 | if (!attr->mmap) | 110 | if (!attr->mmap) |
109 | return -EINVAL; | 111 | return -EINVAL; |
@@ -114,7 +116,8 @@ static int mmap(struct file *file, struct vm_area_struct *vma) | |||
114 | static int open(struct inode * inode, struct file * file) | 116 | static int open(struct inode * inode, struct file * file) |
115 | { | 117 | { |
116 | struct kobject *kobj = sysfs_get_kobject(file->f_path.dentry->d_parent); | 118 | struct kobject *kobj = sysfs_get_kobject(file->f_path.dentry->d_parent); |
117 | struct bin_attribute * attr = to_bin_attr(file->f_path.dentry); | 119 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; |
120 | struct bin_attribute *attr = attr_sd->s_elem.bin_attr.bin_attr; | ||
118 | int error = -EINVAL; | 121 | int error = -EINVAL; |
119 | 122 | ||
120 | if (!kobj || !attr) | 123 | if (!kobj || !attr) |
@@ -150,7 +153,8 @@ static int open(struct inode * inode, struct file * file) | |||
150 | static int release(struct inode * inode, struct file * file) | 153 | static int release(struct inode * inode, struct file * file) |
151 | { | 154 | { |
152 | struct kobject * kobj = to_kobj(file->f_path.dentry->d_parent); | 155 | struct kobject * kobj = to_kobj(file->f_path.dentry->d_parent); |
153 | struct bin_attribute * attr = to_bin_attr(file->f_path.dentry); | 156 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; |
157 | struct bin_attribute *attr = attr_sd->s_elem.bin_attr.bin_attr; | ||
154 | u8 * buffer = file->private_data; | 158 | u8 * buffer = file->private_data; |
155 | 159 | ||
156 | kobject_put(kobj); | 160 | kobject_put(kobj); |