diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2007-05-09 05:33:32 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-09 15:30:49 -0400 |
commit | 92f4c701aad794de9e4cf7341d0a486aed027c46 (patch) | |
tree | 59a47427d43670a50409fc91d68a325e7cfa0ab7 /fs/sysfs/file.c | |
parent | 884c3d751093446918c2f7a4b2c745f28cf91c39 (diff) |
use simple_read_from_buffer() in fs/
Cleanup using simple_read_from_buffer() in binfmt_misc, configfs, and sysfs.
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r-- | fs/sysfs/file.c | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 0e637adc2b87..b502c7197ec0 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -111,36 +111,6 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer | |||
111 | return ret; | 111 | return ret; |
112 | } | 112 | } |
113 | 113 | ||
114 | |||
115 | /** | ||
116 | * flush_read_buffer - push buffer to userspace. | ||
117 | * @buffer: data buffer for file. | ||
118 | * @buf: user-passed buffer. | ||
119 | * @count: number of bytes requested. | ||
120 | * @ppos: file position. | ||
121 | * | ||
122 | * Copy the buffer we filled in fill_read_buffer() to userspace. | ||
123 | * This is done at the reader's leisure, copying and advancing | ||
124 | * the amount they specify each time. | ||
125 | * This may be called continuously until the buffer is empty. | ||
126 | */ | ||
127 | static int flush_read_buffer(struct sysfs_buffer * buffer, char __user * buf, | ||
128 | size_t count, loff_t * ppos) | ||
129 | { | ||
130 | int error; | ||
131 | |||
132 | if (*ppos > buffer->count) | ||
133 | return 0; | ||
134 | |||
135 | if (count > (buffer->count - *ppos)) | ||
136 | count = buffer->count - *ppos; | ||
137 | |||
138 | error = copy_to_user(buf,buffer->page + *ppos,count); | ||
139 | if (!error) | ||
140 | *ppos += count; | ||
141 | return error ? -EFAULT : count; | ||
142 | } | ||
143 | |||
144 | /** | 114 | /** |
145 | * sysfs_read_file - read an attribute. | 115 | * sysfs_read_file - read an attribute. |
146 | * @file: file pointer. | 116 | * @file: file pointer. |
@@ -177,7 +147,8 @@ sysfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos) | |||
177 | } | 147 | } |
178 | pr_debug("%s: count = %zd, ppos = %lld, buf = %s\n", | 148 | pr_debug("%s: count = %zd, ppos = %lld, buf = %s\n", |
179 | __FUNCTION__, count, *ppos, buffer->page); | 149 | __FUNCTION__, count, *ppos, buffer->page); |
180 | retval = flush_read_buffer(buffer,buf,count,ppos); | 150 | retval = simple_read_from_buffer(buf, count, ppos, buffer->page, |
151 | buffer->count); | ||
181 | out: | 152 | out: |
182 | up(&buffer->sem); | 153 | up(&buffer->sem); |
183 | return retval; | 154 | return retval; |