Skip to contentSkip to conversation

Convert simple_strtoul to kstrtoul

PATCH In review Navya Sri Nizamkari 2 participants 2 messages Feb 20, 2015 – Feb 26, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 Convert simple_strtoul to kstrtoul

This patch fixes the checkpatch.pl warning:
simple_strtoul is obsolete, use kstrtoul instead.

Replaced simple_strtoul with kstrtoul as both can perform parsing error checks on the string to the converted. The parsing error condition for simple_strtoul is that the string to be converted is same as the converted string, with kstrtoul the return value is non-zero in case of this error.

---
Changes in v4:
-Updated commit explanation to be more generic.

 drivers/staging/media/parport/bw-qcam.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/media/parport/bw-qcam.c +1 -3
index 67b9da1..6c9b400 100644
@@ -1106,10 +1106,8 @@ static int accept_bwqcam(struct parport *port)
 	if (parport[0] && strncmp(parport[0], "auto", 4) != 0) {
 		/* user gave parport parameters */
 		for (n = 0; n < MAX_CAMS && parport[n]; n++) {
-			char *ep;
 			unsigned long r;
-			r = simple_strtoul(parport[n], &ep, 0);
-			if (ep == parport[n]) {
+			if (kstrtoul(parport[n], 0, &r)) {
 				printk(KERN_ERR
 					"bw-qcam: bad port specifier \"%s\"\n",
 					parport[n]);
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 8 lines · Navya Sri Nizamkari

This patch fixes the checkpatch.pl warning:
simple_strtoul is obsolete, use kstrtoul instead.

Replaced simple_strtoul with kstrtoul as both can perform parsing error checks on the string to the converted. The parsing error condition for simple_strtoul is that the string to be converted is same as the converted string, with kstrtoul the return value is non-zero in case of this error.

Quoted 6 lines

---
Changes in v4:
-Updated commit explanation to be more generic.

 drivers/staging/media/parport/bw-qcam.c | 4 +---

This file is no longer in Linus's tree :(