diff mbox

rtc: rtc-pcf2123: replace strict_strtoul() with kstrtoul()

Message ID 001501ce5e9a$15731080$40593180$@samsung.com
State Superseded
Headers show

Commit Message

Jingoo Han June 1, 2013, 7:31 a.m. UTC
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>
---
 drivers/rtc/rtc-pcf2123.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Andy Shevchenko June 2, 2013, 11:56 a.m. UTC | #1
On Sat, Jun 1, 2013 at 10:31 AM, 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.

> --- a/drivers/rtc/rtc-pcf2123.c
> +++ b/drivers/rtc/rtc-pcf2123.c
> @@ -94,7 +94,7 @@ static ssize_t pcf2123_show(struct device *dev, struct device_attribute *attr,
>
>         r = container_of(attr, struct pcf2123_sysfs_reg, attr);
>
> -       if (strict_strtoul(r->name, 16, &reg))
> +       if (kstrtoul(r->name, 16, &reg))
>                 return -EINVAL;

ret = kstrtoul(...);
if (ret)
return ret;

> @@ -117,8 +117,7 @@ static ssize_t pcf2123_store(struct device *dev, struct device_attribute *attr,
>
>         r = container_of(attr, struct pcf2123_sysfs_reg, attr);
>
> -       if (strict_strtoul(r->name, 16, &reg)
> -               || strict_strtoul(buffer, 10, &val))
> +       if (kstrtoul(r->name, 16, &reg) || kstrtoul(buffer, 10, &val))
>                 return -EINVAL;

I see no harm to allow user to write octal values as well.
Thus, just
ret = kstrtoul(r->name, 0, &reg);
if (ret)
return ret;

Alessandro, what do you think?

--
With Best Regards,
Andy Shevchenko
Jingoo Han June 3, 2013, 7:05 a.m. UTC | #2
On Sunday, June 02, 2013 8:56 PM, Andy Shevchenko wrote:
> On Sat, Jun 1, 2013 at 10:31 AM, 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.
> 
> > --- a/drivers/rtc/rtc-pcf2123.c
> > +++ b/drivers/rtc/rtc-pcf2123.c
> > @@ -94,7 +94,7 @@ static ssize_t pcf2123_show(struct device *dev, struct device_attribute *attr,
> >
> >         r = container_of(attr, struct pcf2123_sysfs_reg, attr);
> >
> > -       if (strict_strtoul(r->name, 16, &reg))
> > +       if (kstrtoul(r->name, 16, &reg))
> >                 return -EINVAL;
> 
> ret = kstrtoul(...);
> if (ret)
> return ret;
> 
> > @@ -117,8 +117,7 @@ static ssize_t pcf2123_store(struct device *dev, struct device_attribute *attr,
> >
> >         r = container_of(attr, struct pcf2123_sysfs_reg, attr);
> >
> > -       if (strict_strtoul(r->name, 16, &reg)
> > -               || strict_strtoul(buffer, 10, &val))
> > +       if (kstrtoul(r->name, 16, &reg) || kstrtoul(buffer, 10, &val))
> >                 return -EINVAL;
> 
> I see no harm to allow user to write octal values as well.
> Thus, just
> ret = kstrtoul(r->name, 0, &reg);

If you want to do this, please send another patch later, on top of this patch.
I just want to address the replacing strict_strtoul() with kstrtoul().

Best regards,
Jingoo Han

> if (ret)
> return ret;
> 
> Alessandro, what do you think?
> 
> --
> With Best Regards,
> Andy Shevchenko
diff mbox

Patch

diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c
index b2a78a0..4130e6b 100644
--- a/drivers/rtc/rtc-pcf2123.c
+++ b/drivers/rtc/rtc-pcf2123.c
@@ -94,7 +94,7 @@  static ssize_t pcf2123_show(struct device *dev, struct device_attribute *attr,
 
 	r = container_of(attr, struct pcf2123_sysfs_reg, attr);
 
-	if (strict_strtoul(r->name, 16, &reg))
+	if (kstrtoul(r->name, 16, &reg))
 		return -EINVAL;
 
 	txbuf[0] = PCF2123_READ | reg;
@@ -117,8 +117,7 @@  static ssize_t pcf2123_store(struct device *dev, struct device_attribute *attr,
 
 	r = container_of(attr, struct pcf2123_sysfs_reg, attr);
 
-	if (strict_strtoul(r->name, 16, &reg)
-		|| strict_strtoul(buffer, 10, &val))
+	if (kstrtoul(r->name, 16, &reg) || kstrtoul(buffer, 10, &val))
 		return -EINVAL;
 
 	txbuf[0] = PCF2123_WRITE | reg;