[PATCH] ubi: replace simple_strtoul() with kstrtoul()

Zhang Zhen zhenzhang.zhang at huawei.com
Mon May 19 01:38:00 PDT 2014


use the newer and more pleasant kstrtoul() to replace simple_strtoul(),
because simple_strtoul() is marked for obsoletion.

Signed-off-by: Zhang Zhen <zhenzhang.zhang at huawei.com>
Signed-off-by: hujianyang <hujianyang at huawei.com>
---
 drivers/mtd/ubi/build.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 6e30a3c..80c539c 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1190,10 +1190,13 @@ static struct mtd_info * __init open_mtd_by_chdev(const char *mtd_dev)
 static struct mtd_info * __init open_mtd_device(const char *mtd_dev)
 {
 	struct mtd_info *mtd;
-	int mtd_num;
+	int mtd_num, ret;
 	char *endp;

-	mtd_num = simple_strtoul(mtd_dev, &endp, 0);
+	endp = (char *)mtd_dev;
+	ret = kstrtoul(endp, 0, (unsigned long *)&mtd_num);
+	if (ret)
+		return ERR_PTR(-EINVAL);
 	if (*endp != '\0' || mtd_dev == endp) {
 		/*
 		 * This does not look like an ASCII integer, probably this is
@@ -1362,8 +1365,12 @@ static int __init bytes_str_to_int(const char *str)
 {
 	char *endp;
 	unsigned long result;
+	int ret;

-	result = simple_strtoul(str, &endp, 0);
+	endp = (char *)str;
+	ret = kstrtoul(endp, 0, &result);
+	if (ret)
+		return -EINVAL;
 	if (str == endp || result >= INT_MAX) {
 		ubi_err("incorrect bytes count: \"%s\"\n", str);
 		return -EINVAL;
-- 
1.8.1.2


.







More information about the linux-mtd mailing list