Skip to content

Commit b86ff67

Browse files
brglChristoph Hellwig
authored andcommitted
samples: configfs: replace simple_strtoul() with kstrtoint()
simple_strtoul() is deprecated. Use kstrtoint(). Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 1b0d36e commit b86ff67

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

samples/configfs/configfs_sample.c

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
#include <linux/init.h>
16+
#include <linux/kernel.h>
1617
#include <linux/module.h>
1718
#include <linux/slab.h>
1819
#include <linux/configfs.h>
@@ -61,17 +62,11 @@ static ssize_t childless_storeme_store(struct config_item *item,
6162
const char *page, size_t count)
6263
{
6364
struct childless *childless = to_childless(item);
64-
unsigned long tmp;
65-
char *p = (char *) page;
66-
67-
tmp = simple_strtoul(p, &p, 10);
68-
if (!p || (*p && (*p != '\n')))
69-
return -EINVAL;
70-
71-
if (tmp > INT_MAX)
72-
return -ERANGE;
65+
int ret;
7366

74-
childless->storeme = tmp;
67+
ret = kstrtoint(page, 10, &childless->storeme);
68+
if (ret)
69+
return ret;
7570

7671
return count;
7772
}
@@ -144,17 +139,11 @@ static ssize_t simple_child_storeme_store(struct config_item *item,
144139
const char *page, size_t count)
145140
{
146141
struct simple_child *simple_child = to_simple_child(item);
147-
unsigned long tmp;
148-
char *p = (char *) page;
149-
150-
tmp = simple_strtoul(p, &p, 10);
151-
if (!p || (*p && (*p != '\n')))
152-
return -EINVAL;
153-
154-
if (tmp > INT_MAX)
155-
return -ERANGE;
142+
int ret;
156143

157-
simple_child->storeme = tmp;
144+
ret = kstrtoint(page, 10, &simple_child->storeme);
145+
if (ret)
146+
return ret;
158147

159148
return count;
160149
}

0 commit comments

Comments
 (0)