Commit 964f8363 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman

debugfs: Re-use kstrtobool_from_user()

Re-use kstrtobool_from_user() instead of open coded variant.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f0a46297
...@@ -796,19 +796,13 @@ EXPORT_SYMBOL_GPL(debugfs_read_file_bool); ...@@ -796,19 +796,13 @@ EXPORT_SYMBOL_GPL(debugfs_read_file_bool);
ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf, ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char buf[32];
size_t buf_size;
bool bv; bool bv;
int r; int r;
bool *val = file->private_data; bool *val = file->private_data;
struct dentry *dentry = F_DENTRY(file); struct dentry *dentry = F_DENTRY(file);
buf_size = min(count, (sizeof(buf)-1)); r = kstrtobool_from_user(user_buf, count, &bv);
if (copy_from_user(buf, user_buf, buf_size)) if (!r) {
return -EFAULT;
buf[buf_size] = '\0';
if (strtobool(buf, &bv) == 0) {
r = debugfs_file_get(dentry); r = debugfs_file_get(dentry);
if (unlikely(r)) if (unlikely(r))
return r; return r;
......
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