From: Zhang Zhen <zhenzhang.zhang@huawei.com>
To: <adrian.hunter@intel.com>, <dedekind1@gmail.com>
Cc: linux-mtd@lists.infradead.org, Hu Jianyang <hujianyang@huawei.com>
Subject: [PATCH] ubi: replace simple_strtoul() with kstrtoul()
Date: Mon, 19 May 2014 16:38:00 +0800 [thread overview]
Message-ID: <5379C2E8.5040000@huawei.com> (raw)
In-Reply-To: <1400488570-20288-1-git-send-email-zhenzhang.zhang@huawei.com>
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@huawei.com>
Signed-off-by: hujianyang <hujianyang@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
.
next parent reply other threads:[~2014-05-19 8:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1400488570-20288-1-git-send-email-zhenzhang.zhang@huawei.com>
2014-05-19 8:38 ` Zhang Zhen [this message]
2014-05-19 9:14 ` [PATCH] ubi: replace simple_strtoul() with kstrtoul() Geert Uytterhoeven
2014-05-20 1:18 ` Zhang Zhen
2014-05-20 6:57 ` Geert Uytterhoeven
2014-05-20 8:14 ` Zhang Zhen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5379C2E8.5040000@huawei.com \
--to=zhenzhang.zhang@huawei.com \
--cc=adrian.hunter@intel.com \
--cc=dedekind1@gmail.com \
--cc=hujianyang@huawei.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox