use simple_read_from_buffer in kernel/

Cleanup using simple_read_from_buffer() for /dev/cpuset/tasks and
/proc/config.gz.

Cc: Paul Jackson <pj@sgi.com>
Cc: Randy Dunlap <rdunlap@xenotime.net>
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>
This commit is contained in:
Akinobu Mita 2007-05-09 02:33:33 -07:00 committed by Linus Torvalds
parent 92f4c701aa
commit 85badbdf51
2 changed files with 4 additions and 18 deletions

View file

@ -61,18 +61,9 @@ static ssize_t
ikconfig_read_current(struct file *file, char __user *buf, ikconfig_read_current(struct file *file, char __user *buf,
size_t len, loff_t * offset) size_t len, loff_t * offset)
{ {
loff_t pos = *offset; return simple_read_from_buffer(buf, len, offset,
ssize_t count; kernel_config_data + MAGIC_SIZE,
kernel_config_data_size);
if (pos >= kernel_config_data_size)
return 0;
count = min(len, (size_t)(kernel_config_data_size - pos));
if (copy_to_user(buf, kernel_config_data + MAGIC_SIZE + pos, count))
return -EFAULT;
*offset += count;
return count;
} }
static const struct file_operations ikconfig_file_ops = { static const struct file_operations ikconfig_file_ops = {

View file

@ -1772,12 +1772,7 @@ static ssize_t cpuset_tasks_read(struct file *file, char __user *buf,
{ {
struct ctr_struct *ctr = file->private_data; struct ctr_struct *ctr = file->private_data;
if (*ppos + nbytes > ctr->bufsz) return simple_read_from_buffer(buf, nbytes, ppos, ctr->buf, ctr->bufsz);
nbytes = ctr->bufsz - *ppos;
if (copy_to_user(buf, ctr->buf + *ppos, nbytes))
return -EFAULT;
*ppos += nbytes;
return nbytes;
} }
static int cpuset_tasks_release(struct inode *unused_inode, struct file *file) static int cpuset_tasks_release(struct inode *unused_inode, struct file *file)