* [PATCH V2] mfd: replace strict_strtoul() with kstrtoul()
@ 2013-06-03 9:04 Jingoo Han
2013-06-03 10:03 ` Lee Jones
2013-06-03 10:30 ` Andy Shevchenko
0 siblings, 2 replies; 4+ messages in thread
From: Jingoo Han @ 2013-06-03 9:04 UTC (permalink / raw)
To: 'Samuel Ortiz'
Cc: linux-kernel, 'Lee Jones', 'Linus Walleij',
'Srinidhi Kasagar', Jingoo Han, 'Andy Shevchenko'
The usage of strict_strtoul() is not preferred, because
strict_strtoul() is obsolete. Thus, kstrtoul() should be
used.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
Changes since v1:
- Used return code from kstrtoul().
- Changed the type of 'user_reg' from 'unsigned long' to 'u8'.
- Replaced kstrtoul() with kstrtou8() to handle u8 variable.
drivers/mfd/aat2870-core.c | 5 +++--
drivers/mfd/ab3100-core.c | 16 ++++++----------
drivers/mfd/ab8500-debugfs.c | 2 +-
3 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/mfd/aat2870-core.c b/drivers/mfd/aat2870-core.c
index dfdb0a2..d4f5945 100644
--- a/drivers/mfd/aat2870-core.c
+++ b/drivers/mfd/aat2870-core.c
@@ -312,8 +312,9 @@ static ssize_t aat2870_reg_write_file(struct file *file,
while (*start == ' ')
start++;
- if (strict_strtoul(start, 16, &val))
- return -EINVAL;
+ ret = kstrtoul(start, 16, &val);
+ if (ret)
+ return ret;
ret = aat2870->write(aat2870, (u8)addr, (u8)val);
if (ret)
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index a9bb140..9cc1bd3 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -491,7 +491,7 @@ static ssize_t ab3100_get_set_reg(struct file *file,
char buf[32];
ssize_t buf_size;
int regp;
- unsigned long user_reg;
+ u8 user_reg;
int err;
int i = 0;
@@ -514,22 +514,20 @@ static ssize_t ab3100_get_set_reg(struct file *file,
/*
* Advance pointer to end of string then terminate
* the register string. This is needed to satisfy
- * the strict_strtoul() function.
+ * the kstrtou8() function.
*/
while ((i < buf_size) && (buf[i] != ' '))
i++;
buf[i] = '\0';
- err = strict_strtoul(&buf[regp], 16, &user_reg);
+ err = kstrtou8(&buf[regp], 16, &user_reg);
if (err)
return err;
- if (user_reg > 0xff)
- return -EINVAL;
/* Either we read or we write a register here */
if (!priv->mode) {
/* Reading */
- u8 reg = (u8) user_reg;
+ u8 reg = user_reg;
u8 regvalue;
ab3100_get_register_interruptible(ab3100, reg, ®value);
@@ -540,7 +538,7 @@ static ssize_t ab3100_get_set_reg(struct file *file,
} else {
int valp;
unsigned long user_value;
- u8 reg = (u8) user_reg;
+ u8 reg = user_reg;
u8 value;
u8 regvalue;
@@ -557,11 +555,9 @@ static ssize_t ab3100_get_set_reg(struct file *file,
i++;
buf[i] = '\0';
- err = strict_strtoul(&buf[valp], 16, &user_value);
+ err = kstrtoul(&buf[valp], 16, &user_value);
if (err)
return err;
- if (user_reg > 0xff)
- return -EINVAL;
value = (u8) user_value;
ab3100_set_register_interruptible(ab3100, reg, value);
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 37b7ce4..11656c2 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -2757,7 +2757,7 @@ static ssize_t show_irq(struct device *dev,
unsigned int irq_index;
int err;
- err = strict_strtoul(attr->attr.name, 0, &name);
+ err = kstrtoul(attr->attr.name, 0, &name);
if (err)
return err;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH V2] mfd: replace strict_strtoul() with kstrtoul()
2013-06-03 9:04 [PATCH V2] mfd: replace strict_strtoul() with kstrtoul() Jingoo Han
@ 2013-06-03 10:03 ` Lee Jones
2013-06-03 10:32 ` Andy Shevchenko
2013-06-03 10:30 ` Andy Shevchenko
1 sibling, 1 reply; 4+ messages in thread
From: Lee Jones @ 2013-06-03 10:03 UTC (permalink / raw)
To: Jingoo Han, 'Andy Shevchenko'
Cc: 'Samuel Ortiz', linux-kernel, 'Linus Walleij',
'Srinidhi Kasagar', 'Andy Shevchenko'
> The usage of strict_strtoul() is not preferred, because
> strict_strtoul() is obsolete. Thus, kstrtoul() should be
> used.
Andy,
Would you mind re-reviewing and providing the appropriate *-by please?
If you're happy I'll take the patch.
--
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] mfd: replace strict_strtoul() with kstrtoul()
2013-06-03 9:04 [PATCH V2] mfd: replace strict_strtoul() with kstrtoul() Jingoo Han
2013-06-03 10:03 ` Lee Jones
@ 2013-06-03 10:30 ` Andy Shevchenko
1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2013-06-03 10:30 UTC (permalink / raw)
To: Jingoo Han
Cc: Samuel Ortiz, linux-kernel@vger.kernel.org, Lee Jones,
Linus Walleij, Srinidhi Kasagar
On Mon, Jun 3, 2013 at 12:04 PM, Jingoo Han <jg1.han@samsung.com> wrote:
> The usage of strict_strtoul() is not preferred, because
> strict_strtoul() is obsolete. Thus, kstrtoul() should be
> used.
Few comments below.
After addressing them take my
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> --- a/drivers/mfd/ab3100-core.c
> +++ b/drivers/mfd/ab3100-core.c
> @@ -514,22 +514,20 @@ static ssize_t ab3100_get_set_reg(struct file *file,
> /*
> * Advance pointer to end of string then terminate
> * the register string. This is needed to satisfy
> - * the strict_strtoul() function.
> + * the kstrtou8() function.
> */
> while ((i < buf_size) && (buf[i] != ' '))
> i++;
> buf[i] = '\0';
>
> - err = strict_strtoul(&buf[regp], 16, &user_reg);
> + err = kstrtou8(&buf[regp], 16, &user_reg);
> if (err)
> return err;
> - if (user_reg > 0xff)
> - return -EINVAL;
>
> /* Either we read or we write a register here */
> if (!priv->mode) {
> /* Reading */
> - u8 reg = (u8) user_reg;
> + u8 reg = user_reg;
Since the reg and user_reg have same type I think no harm to drop away
this local reg variable.
> u8 regvalue;
>
> ab3100_get_register_interruptible(ab3100, reg, ®value);
> @@ -540,7 +538,7 @@ static ssize_t ab3100_get_set_reg(struct file *file,
> } else {
> int valp;
> unsigned long user_value;
> - u8 reg = (u8) user_reg;
> + u8 reg = user_reg;
Same idea.
> u8 value;
> u8 regvalue;
>
> @@ -557,11 +555,9 @@ static ssize_t ab3100_get_set_reg(struct file *file,
> i++;
> buf[i] = '\0';
>
> - err = strict_strtoul(&buf[valp], 16, &user_value);
> + err = kstrtoul(&buf[valp], 16, &user_value);
kstrtou8() as well (see below)
> if (err)
> return err;
> - if (user_reg > 0xff)
> - return -EINVAL;
It seems a bug, and further the u8 is used for value as well.
> value = (u8) user_value;
Thus, you can easily use u8 type for user_value and drop off val variable.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] mfd: replace strict_strtoul() with kstrtoul()
2013-06-03 10:03 ` Lee Jones
@ 2013-06-03 10:32 ` Andy Shevchenko
0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2013-06-03 10:32 UTC (permalink / raw)
To: Lee Jones
Cc: Jingoo Han, Samuel Ortiz, linux-kernel@vger.kernel.org,
Linus Walleij, Srinidhi Kasagar
On Mon, Jun 3, 2013 at 1:03 PM, Lee Jones <lee.jones@linaro.org> wrote:
>> The usage of strict_strtoul() is not preferred, because
>> strict_strtoul() is obsolete. Thus, kstrtoul() should be
>> used.
>
> Andy,
>
> Would you mind re-reviewing and providing the appropriate *-by please?
I do not mind. I just did it.
> If you're happy I'll take the patch.
Not fully. But there are few minor things which I believe Jingoo will
easily fix soon.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-06-03 10:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-03 9:04 [PATCH V2] mfd: replace strict_strtoul() with kstrtoul() Jingoo Han
2013-06-03 10:03 ` Lee Jones
2013-06-03 10:32 ` Andy Shevchenko
2013-06-03 10:30 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.