Commit b6883582 authored by Eliad Peller's avatar Eliad Peller Committed by Luciano Coelho

wl12xx: use kstrtoul_from_user

simplify code by calling kstrtoul_from_user() (instead of
copy_from_user() + kstrtoul())
Signed-off-by: default avatarEliad Peller <eliad@wizery.com>
Signed-off-by: default avatarLuciano Coelho <coelho@ti.com>
parent 04907011
...@@ -265,18 +265,10 @@ static ssize_t gpio_power_write(struct file *file, ...@@ -265,18 +265,10 @@ static ssize_t gpio_power_write(struct file *file,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct wl1271 *wl = file->private_data; struct wl1271 *wl = file->private_data;
char buf[10];
size_t len;
unsigned long value; unsigned long value;
int ret; int ret;
len = min(count, sizeof(buf) - 1); ret = kstrtoul_from_user(user_buf, count, 10, &value);
if (copy_from_user(buf, user_buf, len)) {
return -EFAULT;
}
buf[len] = '\0';
ret = kstrtoul(buf, 0, &value);
if (ret < 0) { if (ret < 0) {
wl1271_warning("illegal value in gpio_power"); wl1271_warning("illegal value in gpio_power");
return -EINVAL; return -EINVAL;
...@@ -427,17 +419,10 @@ static ssize_t dtim_interval_write(struct file *file, ...@@ -427,17 +419,10 @@ static ssize_t dtim_interval_write(struct file *file,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct wl1271 *wl = file->private_data; struct wl1271 *wl = file->private_data;
char buf[10];
size_t len;
unsigned long value; unsigned long value;
int ret; int ret;
len = min(count, sizeof(buf) - 1); ret = kstrtoul_from_user(user_buf, count, 10, &value);
if (copy_from_user(buf, user_buf, len))
return -EFAULT;
buf[len] = '\0';
ret = kstrtoul(buf, 0, &value);
if (ret < 0) { if (ret < 0) {
wl1271_warning("illegal value for dtim_interval"); wl1271_warning("illegal value for dtim_interval");
return -EINVAL; return -EINVAL;
...@@ -492,17 +477,10 @@ static ssize_t beacon_interval_write(struct file *file, ...@@ -492,17 +477,10 @@ static ssize_t beacon_interval_write(struct file *file,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct wl1271 *wl = file->private_data; struct wl1271 *wl = file->private_data;
char buf[10];
size_t len;
unsigned long value; unsigned long value;
int ret; int ret;
len = min(count, sizeof(buf) - 1); ret = kstrtoul_from_user(user_buf, count, 10, &value);
if (copy_from_user(buf, user_buf, len))
return -EFAULT;
buf[len] = '\0';
ret = kstrtoul(buf, 0, &value);
if (ret < 0) { if (ret < 0) {
wl1271_warning("illegal value for beacon_interval"); wl1271_warning("illegal value for beacon_interval");
return -EINVAL; return -EINVAL;
...@@ -542,17 +520,10 @@ static ssize_t rx_streaming_interval_write(struct file *file, ...@@ -542,17 +520,10 @@ static ssize_t rx_streaming_interval_write(struct file *file,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct wl1271 *wl = file->private_data; struct wl1271 *wl = file->private_data;
char buf[10];
size_t len;
unsigned long value; unsigned long value;
int ret; int ret;
len = min(count, sizeof(buf) - 1); ret = kstrtoul_from_user(user_buf, count, 10, &value);
if (copy_from_user(buf, user_buf, len))
return -EFAULT;
buf[len] = '\0';
ret = kstrtoul(buf, 0, &value);
if (ret < 0) { if (ret < 0) {
wl1271_warning("illegal value in rx_streaming_interval!"); wl1271_warning("illegal value in rx_streaming_interval!");
return -EINVAL; return -EINVAL;
...@@ -601,17 +572,10 @@ static ssize_t rx_streaming_always_write(struct file *file, ...@@ -601,17 +572,10 @@ static ssize_t rx_streaming_always_write(struct file *file,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct wl1271 *wl = file->private_data; struct wl1271 *wl = file->private_data;
char buf[10];
size_t len;
unsigned long value; unsigned long value;
int ret; int ret;
len = min(count, sizeof(buf) - 1); ret = kstrtoul_from_user(user_buf, count, 10, &value);
if (copy_from_user(buf, user_buf, len))
return -EFAULT;
buf[len] = '\0';
ret = kstrtoul(buf, 0, &value);
if (ret < 0) { if (ret < 0) {
wl1271_warning("illegal value in rx_streaming_write!"); wl1271_warning("illegal value in rx_streaming_write!");
return -EINVAL; return -EINVAL;
......
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