samples: configfs: replace simple_strtoul() with kstrtoint()
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Thu, 24 Sep 2020 12:45:21 +0000 (14:45 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 7 Oct 2020 13:44:59 +0000 (15:44 +0200)
simple_strtoul() is deprecated. Use kstrtoint().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
samples/configfs/configfs_sample.c

index 1af7cc965098dec42161e57af3a0c7b91743f560..7cf1d44c1e3717e28fa37f87b97d2807b1396780 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/configfs.h>
@@ -61,17 +62,11 @@ static ssize_t childless_storeme_store(struct config_item *item,
                const char *page, size_t count)
 {
        struct childless *childless = to_childless(item);
-       unsigned long tmp;
-       char *p = (char *) page;
-
-       tmp = simple_strtoul(p, &p, 10);
-       if (!p || (*p && (*p != '\n')))
-               return -EINVAL;
-
-       if (tmp > INT_MAX)
-               return -ERANGE;
+       int ret;
 
-       childless->storeme = tmp;
+       ret = kstrtoint(page, 10, &childless->storeme);
+       if (ret)
+               return ret;
 
        return count;
 }
@@ -144,17 +139,11 @@ static ssize_t simple_child_storeme_store(struct config_item *item,
                const char *page, size_t count)
 {
        struct simple_child *simple_child = to_simple_child(item);
-       unsigned long tmp;
-       char *p = (char *) page;
-
-       tmp = simple_strtoul(p, &p, 10);
-       if (!p || (*p && (*p != '\n')))
-               return -EINVAL;
-
-       if (tmp > INT_MAX)
-               return -ERANGE;
+       int ret;
 
-       simple_child->storeme = tmp;
+       ret = kstrtoint(page, 10, &simple_child->storeme);
+       if (ret)
+               return ret;
 
        return count;
 }