Skip to contentSkip to conversation

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

PATCH Superseded Jingoo Han 2 participants 3 messages Jun 1, 2013 – Jun 3, 2013 Real time clock (RTC)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 1/1 rtc: rtc-pcf2123: replace strict_strtoul() with kstrtoul()

The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used.

---
 drivers/rtc/rtc-pcf2123.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/rtc/rtc-pcf2123.c +2 -3
index b2a78a0..4130e6b 100644
@@ -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;
Signature · 1 line
1.7.10.4
#1 lore raw

drivers/rtc/rtc-pcf2123.c static ssize_t pcf2123_show(struct device *dev, struct device_attribute *attr, · line 98

Quoted 13 lines · Jingoo Han

The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used.

drivers/rtc/rtc-pcf2123.c +1 -1
@@ -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;

drivers/rtc/rtc-pcf2123.c static ssize_t pcf2123_store(struct device *dev, struct device_attribute *attr, · line 121

Quoted 8 lines
drivers/rtc/rtc-pcf2123.c +1 -2
@@ -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

author
#2 lore raw
Quoted 23 lines · Andy Shevchenko

drivers/rtc/rtc-pcf2123.c static ssize_t pcf2123_show(struct device *dev, struct device_attribute *attr, · line 98

Quoted 13 lines · Jingoo Han

The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used.

drivers/rtc/rtc-pcf2123.c +1 -1
@@ -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;

Quoted 4 lines
drivers/rtc/rtc-pcf2123.c +0 -0
@@ -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);
 
Quoted 8 lines

drivers/rtc/rtc-pcf2123.c static ssize_t pcf2123_store(struct device *dev, struct device_attribute *attr, · line 121

Quoted 4 lines
drivers/rtc/rtc-pcf2123.c +1 -2
-       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

Quoted 8 lines

if (ret)
return ret;

Alessandro, what do you think?

--
With Best Regards,
Andy Shevchenko