aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r--fs/sysfs/file.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 8240b1687dd0..04f6b0ebc889 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -88,7 +88,6 @@ remove_from_collection(struct sysfs_buffer *buffer, struct inode *node)
88static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer) 88static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer)
89{ 89{
90 struct sysfs_dirent * sd = dentry->d_fsdata; 90 struct sysfs_dirent * sd = dentry->d_fsdata;
91 struct attribute * attr = to_attr(dentry);
92 struct kobject * kobj = to_kobj(dentry->d_parent); 91 struct kobject * kobj = to_kobj(dentry->d_parent);
93 struct sysfs_ops * ops = buffer->ops; 92 struct sysfs_ops * ops = buffer->ops;
94 int ret = 0; 93 int ret = 0;
@@ -100,7 +99,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
100 return -ENOMEM; 99 return -ENOMEM;
101 100
102 buffer->event = atomic_read(&sd->s_event); 101 buffer->event = atomic_read(&sd->s_event);
103 count = ops->show(kobj,attr,buffer->page); 102 count = ops->show(kobj, sd->s_elem.attr.attr, buffer->page);
104 BUG_ON(count > (ssize_t)PAGE_SIZE); 103 BUG_ON(count > (ssize_t)PAGE_SIZE);
105 if (count >= 0) { 104 if (count >= 0) {
106 buffer->needs_read_fill = 0; 105 buffer->needs_read_fill = 0;
@@ -199,11 +198,11 @@ fill_write_buffer(struct sysfs_buffer * buffer, const char __user * buf, size_t
199static int 198static int
200flush_write_buffer(struct dentry * dentry, struct sysfs_buffer * buffer, size_t count) 199flush_write_buffer(struct dentry * dentry, struct sysfs_buffer * buffer, size_t count)
201{ 200{
202 struct attribute * attr = to_attr(dentry); 201 struct sysfs_dirent *attr_sd = dentry->d_fsdata;
203 struct kobject * kobj = to_kobj(dentry->d_parent); 202 struct kobject * kobj = to_kobj(dentry->d_parent);
204 struct sysfs_ops * ops = buffer->ops; 203 struct sysfs_ops * ops = buffer->ops;
205 204
206 return ops->store(kobj,attr,buffer->page,count); 205 return ops->store(kobj, attr_sd->s_elem.attr.attr, buffer->page, count);
207} 206}
208 207
209 208
@@ -248,7 +247,8 @@ out:
248static int sysfs_open_file(struct inode *inode, struct file *file) 247static int sysfs_open_file(struct inode *inode, struct file *file)
249{ 248{
250 struct kobject *kobj = sysfs_get_kobject(file->f_path.dentry->d_parent); 249 struct kobject *kobj = sysfs_get_kobject(file->f_path.dentry->d_parent);
251 struct attribute * attr = to_attr(file->f_path.dentry); 250 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
251 struct attribute *attr = attr_sd->s_elem.attr.attr;
252 struct sysfs_buffer_collection *set; 252 struct sysfs_buffer_collection *set;
253 struct sysfs_buffer * buffer; 253 struct sysfs_buffer * buffer;
254 struct sysfs_ops * ops = NULL; 254 struct sysfs_ops * ops = NULL;
@@ -341,15 +341,15 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
341static int sysfs_release(struct inode * inode, struct file * filp) 341static int sysfs_release(struct inode * inode, struct file * filp)
342{ 342{
343 struct kobject * kobj = to_kobj(filp->f_path.dentry->d_parent); 343 struct kobject * kobj = to_kobj(filp->f_path.dentry->d_parent);
344 struct attribute * attr = to_attr(filp->f_path.dentry); 344 struct sysfs_dirent *attr_sd = filp->f_path.dentry->d_fsdata;
345 struct module * owner = attr->owner; 345 struct attribute *attr = attr_sd->s_elem.attr.attr;
346 struct sysfs_buffer * buffer = filp->private_data; 346 struct sysfs_buffer * buffer = filp->private_data;
347 347
348 if (buffer) 348 if (buffer)
349 remove_from_collection(buffer, inode); 349 remove_from_collection(buffer, inode);
350 kobject_put(kobj); 350 kobject_put(kobj);
351 /* After this point, attr should not be accessed. */ 351 /* After this point, attr should not be accessed. */
352 module_put(owner); 352 module_put(attr->owner);
353 353
354 if (buffer) { 354 if (buffer) {
355 if (buffer->page) 355 if (buffer->page)
@@ -454,11 +454,12 @@ int sysfs_add_file(struct dentry * dir, const struct attribute * attr, int type)
454 goto out_unlock; 454 goto out_unlock;
455 } 455 }
456 456
457 sd = sysfs_new_dirent(attr->name, (void *)attr, mode, type); 457 sd = sysfs_new_dirent(attr->name, mode, type);
458 if (!sd) { 458 if (!sd) {
459 error = -ENOMEM; 459 error = -ENOMEM;
460 goto out_unlock; 460 goto out_unlock;
461 } 461 }
462 sd->s_elem.attr.attr = (void *)attr;
462 sysfs_attach_dirent(sd, parent_sd, NULL); 463 sysfs_attach_dirent(sd, parent_sd, NULL);
463 464
464 out_unlock: 465 out_unlock: