]> err.no Git - linux-2.6/commitdiff
USB: usbmon: use simple_read_from_buffer()
authorAkinobu Mita <akinobu.mita@gmail.com>
Mon, 9 Jun 2008 23:39:57 +0000 (16:39 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 21 Jul 2008 22:16:31 +0000 (15:16 -0700)
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>
drivers/usb/mon/mon_stat.c

index c7a595cd648ae2b2f473390b94d0f89b0fb2214f..ac8b0d5ce7f852c663dca9af9fbb8dc389348591 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/kernel.h>
 #include <linux/usb.h>
+#include <linux/fs.h>
 #include <asm/uaccess.h>
 
 #include "usb_mon.h"
@@ -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)