]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
wl12xx: use kstrtoul_from_user
authorEliad Peller <eliad@wizery.com>
Wed, 31 Aug 2011 11:50:13 +0000 (14:50 +0300)
committerLuciano Coelho <coelho@ti.com>
Wed, 14 Sep 2011 08:47:43 +0000 (11:47 +0300)
simplify code by calling kstrtoul_from_user() (instead of
copy_from_user() + kstrtoul())

Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
drivers/net/wireless/wl12xx/debugfs.c

index d227385a8f9c399a4a9e31c3948670ff8d0a6d0e..3999fd528302cfbadd26a7f9fe8862caaf175656 100644 (file)
@@ -265,18 +265,10 @@ static ssize_t gpio_power_write(struct file *file,
                           size_t count, loff_t *ppos)
 {
        struct wl1271 *wl = file->private_data;
-       char buf[10];
-       size_t len;
        unsigned long value;
        int ret;
 
-       len = min(count, sizeof(buf) - 1);
-       if (copy_from_user(buf, user_buf, len)) {
-               return -EFAULT;
-       }
-       buf[len] = '\0';
-
-       ret = kstrtoul(buf, 0, &value);
+       ret = kstrtoul_from_user(user_buf, count, 10, &value);
        if (ret < 0) {
                wl1271_warning("illegal value in gpio_power");
                return -EINVAL;
@@ -427,17 +419,10 @@ static ssize_t dtim_interval_write(struct file *file,
                                   size_t count, loff_t *ppos)
 {
        struct wl1271 *wl = file->private_data;
-       char buf[10];
-       size_t len;
        unsigned long value;
        int ret;
 
-       len = min(count, sizeof(buf) - 1);
-       if (copy_from_user(buf, user_buf, len))
-               return -EFAULT;
-       buf[len] = '\0';
-
-       ret = kstrtoul(buf, 0, &value);
+       ret = kstrtoul_from_user(user_buf, count, 10, &value);
        if (ret < 0) {
                wl1271_warning("illegal value for dtim_interval");
                return -EINVAL;
@@ -492,17 +477,10 @@ static ssize_t beacon_interval_write(struct file *file,
                                     size_t count, loff_t *ppos)
 {
        struct wl1271 *wl = file->private_data;
-       char buf[10];
-       size_t len;
        unsigned long value;
        int ret;
 
-       len = min(count, sizeof(buf) - 1);
-       if (copy_from_user(buf, user_buf, len))
-               return -EFAULT;
-       buf[len] = '\0';
-
-       ret = kstrtoul(buf, 0, &value);
+       ret = kstrtoul_from_user(user_buf, count, 10, &value);
        if (ret < 0) {
                wl1271_warning("illegal value for beacon_interval");
                return -EINVAL;
@@ -542,17 +520,10 @@ static ssize_t rx_streaming_interval_write(struct file *file,
                           size_t count, loff_t *ppos)
 {
        struct wl1271 *wl = file->private_data;
-       char buf[10];
-       size_t len;
        unsigned long value;
        int ret;
 
-       len = min(count, sizeof(buf) - 1);
-       if (copy_from_user(buf, user_buf, len))
-               return -EFAULT;
-       buf[len] = '\0';
-
-       ret = kstrtoul(buf, 0, &value);
+       ret = kstrtoul_from_user(user_buf, count, 10, &value);
        if (ret < 0) {
                wl1271_warning("illegal value in rx_streaming_interval!");
                return -EINVAL;
@@ -601,17 +572,10 @@ static ssize_t rx_streaming_always_write(struct file *file,
                           size_t count, loff_t *ppos)
 {
        struct wl1271 *wl = file->private_data;
-       char buf[10];
-       size_t len;
        unsigned long value;
        int ret;
 
-       len = min(count, sizeof(buf) - 1);
-       if (copy_from_user(buf, user_buf, len))
-               return -EFAULT;
-       buf[len] = '\0';
-
-       ret = kstrtoul(buf, 0, &value);
+       ret = kstrtoul_from_user(user_buf, count, 10, &value);
        if (ret < 0) {
                wl1271_warning("illegal value in rx_streaming_write!");
                return -EINVAL;