Skip to content

Commit

Permalink
USB: usbmon: use simple_read_from_buffer()
Browse files Browse the repository at this point in the history
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Akinobu Mita authored and Greg Kroah-Hartman committed Jul 21, 2008
1 parent bef4665 commit 518386c
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions drivers/usb/mon/mon_stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <linux/kernel.h>
#include <linux/usb.h>
#include <linux/fs.h>
#include <asm/uaccess.h>

#include "usb_mon.h"
Expand Down Expand Up @@ -42,19 +43,8 @@ static ssize_t mon_stat_read(struct file *file, char __user *buf,
size_t nbytes, loff_t *ppos)
{
struct snap *sp = file->private_data;
loff_t pos = *ppos;
int cnt;

if (pos < 0 || pos >= sp->slen)
return 0;
if (nbytes == 0)
return 0;
if ((cnt = sp->slen - pos) > nbytes)
cnt = nbytes;
if (copy_to_user(buf, sp->str + pos, cnt))
return -EFAULT;
*ppos = pos + cnt;
return cnt;
return simple_read_from_buffer(buf, nbytes, ppos, sp->str, sp->slen);
}

static int mon_stat_release(struct inode *inode, struct file *file)
Expand Down

0 comments on commit 518386c

Please sign in to comment.