Commit 64b8a16f authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

greybus: es1: move debugfs function to use kstrotoint_from_user()

No need to duplicate built-in functions that the kernel has, so have the
core kernel parse the userspace string.  Saves us an allocation and
makes the logic simpler.
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent d52f9973
...@@ -581,20 +581,19 @@ static ssize_t apb1_log_enable_write(struct file *f, const char __user *buf, ...@@ -581,20 +581,19 @@ static ssize_t apb1_log_enable_write(struct file *f, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
int enable; int enable;
char *tmp_buf; ssize_t retval;
ssize_t retval = -EINVAL;
struct es1_ap_dev *es1 = (struct es1_ap_dev *)f->f_inode->i_private; struct es1_ap_dev *es1 = (struct es1_ap_dev *)f->f_inode->i_private;
tmp_buf = kmalloc(count, GFP_KERNEL); retval = kstrtoint_from_user(buf, count, 10, &enable);
if (!tmp_buf) if (retval)
return -ENOMEM; return retval;
copy_from_user(tmp_buf, buf, count); if (enable) {
if (sscanf(tmp_buf, "%d", &enable) == 1) {
usb_log_enable(es1, enable); usb_log_enable(es1, enable);
retval = count; retval = count;
} else {
retval = -EINVAL;
} }
kfree(tmp_buf);
return retval; return retval;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment