Skip to contentSkip to conversation

mfd: replace strict_strtoul() with kstrtoul()

PATCH In review Jingoo Han 2 participants 3 messages Jun 1, 2013 – Jun 3, 2013

Subsystems (2)
lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 1/1 mfd: replace strict_strtoul() with kstrtoul()

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

---
 drivers/mfd/aat2870-core.c   |    2 +-
 drivers/mfd/ab3100-core.c    |    6 +++---
 drivers/mfd/ab8500-debugfs.c |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/mfd/aat2870-core.c +1 -1
index dfdb0a2..5fd81b9 100644
@@ -312,7 +312,7 @@ static ssize_t aat2870_reg_write_file(struct file *file,
 	while (*start == ' ')
 		start++;
 
-	if (strict_strtoul(start, 16, &val))
+	if (kstrtoul(start, 16, &val))
 		return -EINVAL;
 
 	ret = aat2870->write(aat2870, (u8)addr, (u8)val);
drivers/mfd/ab3100-core.c +3 -3
index a9bb140..49cc17e 100644
@@ -514,13 +514,13 @@ 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 kstrtoul() function.
 	 */
 	while ((i < buf_size) && (buf[i] != ' '))
 		i++;
 	buf[i] = '\0';
 
-	err = strict_strtoul(&buf[regp], 16, &user_reg);
+	err = kstrtoul(&buf[regp], 16, &user_reg);
 	if (err)
 		return err;
 	if (user_reg > 0xff)
@@ -557,7 +557,7 @@ 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)
drivers/mfd/ab8500-debugfs.c +1 -1
index 37b7ce4..11656c2 100644
@@ -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;
 
Signature · 1 line
1.7.10.4
#1 lore raw

drivers/mfd/aat2870-core.c static ssize_t aat2870_reg_write_file(struct file *file, · line 316

Quoted 13 lines · Jingoo Han

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

drivers/mfd/aat2870-core.c +1 -1
@@ -312,7 +312,7 @@ static ssize_t aat2870_reg_write_file(struct file *file,
        while (*start == ' ')
                start++;
 
-       if (strict_strtoul(start, 16, &val))
+       if (kstrtoul(start, 16, &val))
                return -EINVAL;

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

Quoted 8 lines
drivers/mfd/ab3100-core.c +1 -1
@@ -514,13 +514,13 @@ 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 kstrtoul() function.

drivers/mfd/ab3100-core.c static ssize_t ab3100_get_set_reg(struct file *file, · line 526

Quoted 10 lines
drivers/mfd/ab3100-core.c +1 -1
         */
        while ((i < buf_size) && (buf[i] != ' '))
                i++;
        buf[i] = '\0';
 
-       err = strict_strtoul(&buf[regp], 16, &user_reg);
+       err = kstrtoul(&buf[regp], 16, &user_reg);
        if (err)
                return err;
        if (user_reg > 0xff)

user_reg couldn't be more than byte.
So, you may change its definition to u8 and use here kstrtou8() and remove later check.

But on first glance on that function it could be optimized a lot (there are so many custom stuff like skip_space() and like that).

drivers/mfd/ab3100-core.c static ssize_t ab3100_get_set_reg(struct file *file, · line 563

Quoted 9 lines
drivers/mfd/ab3100-core.c +1 -1
@@ -557,7 +557,7 @@ 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)

Same idea here.

--
With Best Regards,
Andy Shevchenko

author
#2 lore raw
Quoted 32 lines · Andy Shevchenko

drivers/mfd/aat2870-core.c static ssize_t aat2870_reg_write_file(struct file *file, · line 316

Quoted 13 lines · Jingoo Han

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

drivers/mfd/aat2870-core.c +1 -1
@@ -312,7 +312,7 @@ static ssize_t aat2870_reg_write_file(struct file *file,
        while (*start == ' ')
                start++;
 
-       if (strict_strtoul(start, 16, &val))
+       if (kstrtoul(start, 16, &val))
                return -EINVAL;

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

Quoted 13 lines
drivers/mfd/ab3100-core.c +1 -1
@@ -514,13 +514,13 @@ 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 kstrtoul() function.
         */
        while ((i < buf_size) && (buf[i] != ' '))
                i++;
        buf[i] = '\0';
 
Quoted 9 lines

drivers/mfd/ab3100-core.c static ssize_t ab3100_get_set_reg(struct file *file, · line 526

Quoted 5 lines
drivers/mfd/ab3100-core.c +1 -1
-       err = strict_strtoul(&buf[regp], 16, &user_reg);
+       err = kstrtoul(&buf[regp], 16, &user_reg);
        if (err)
                return err;
        if (user_reg > 0xff)

user_reg couldn't be more than byte.
So, you may change its definition to u8 and use here kstrtou8() and remove later check.

OK, I will change kstrtoul() to kstrtou8().

Best regards,
Jingoo Han

Quoted 19 lines

But on first glance on that function it could be optimized a lot (there are so many custom stuff like skip_space() and like that).

drivers/mfd/ab3100-core.c static ssize_t ab3100_get_set_reg(struct file *file, · line 563

Quoted 9 lines
drivers/mfd/ab3100-core.c +1 -1
@@ -557,7 +557,7 @@ 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)

Same idea here.

--
With Best Regards,
Andy Shevchenko