aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/mon/mon_stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/mon/mon_stat.c')
-rw-r--r--drivers/usb/mon/mon_stat.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c
index f6d1491256c..ebd6189a501 100644
--- a/drivers/usb/mon/mon_stat.c
+++ b/drivers/usb/mon/mon_stat.c
@@ -8,7 +8,10 @@
*/
#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/export.h>
#include <linux/usb.h>
+#include <linux/fs.h>
#include <asm/uaccess.h>
#include "usb_mon.h"
@@ -42,23 +45,15 @@ 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)
{
+ struct snap *sp = file->private_data;
+ file->private_data = NULL;
+ kfree(sp);
return 0;
}
@@ -69,6 +64,6 @@ const struct file_operations mon_fops_stat = {
.read = mon_stat_read,
/* .write = mon_stat_write, */
/* .poll = mon_stat_poll, */
- /* .ioctl = mon_stat_ioctl, */
+ /* .unlocked_ioctl = mon_stat_ioctl, */
.release = mon_stat_release,
};