Skip to contentSkip to conversation

video: bfin_adv7393fb: Convert to kstrtouint_from_user

PATCH Applied Emil Goode 2 participants 2 messages May 29, 2012 – Jun 9, 2012

Subsystems (2)
lore
Share & tools
lore

Emil Goode

author
#0 lore raw

PATCH 1/1 video: bfin_adv7393fb: Convert to kstrtouint_from_user

This patch removes a call to the deprecated simple_strtoul function and simplifies the code by replacing two function calls with one call to kstrtouint_from_user.

-Simplify the adv7393_write_proc function by replacing the
simple_strtoul and copy_from_user calls with one call to kstrtouint_from_user.

-Change the count parameter from unsigned long to size_t as
this is the type that the kstrtouint_from_user function expects. (size_t is what will be passed to the adv7393_write_proc function by the proc write handler function proc_file_write anyway)

---
 drivers/video/bfin_adv7393fb.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/video/bfin_adv7393fb.c +2 -4
index 1a268a2..8c6edfd 100644
@@ -353,18 +353,16 @@ adv7393_read_proc(char *page, char **start, off_t off,
 
 static int
 adv7393_write_proc(struct file *file, const char __user * buffer,
-		   unsigned long count, void *data)
+		   size_t count, void *data)
 {
 	struct adv7393fb_device *fbdev = data;
-	char line[8];
 	unsigned int val;
 	int ret;
 
-	ret = copy_from_user(line, buffer, count);
+	ret = kstrtouint_from_user(buffer, count, 0, &val);
 	if (ret)
 		return -EFAULT;
 
-	val = simple_strtoul(line, NULL, 0);
 	adv7393_write(fbdev->client, val >> 8, val & 0xff);
 
 	return count;
Signature · 1 line
1.7.10
#1 lore raw
Quoted 13 lines · Emil Goode

This patch removes a call to the deprecated simple_strtoul function and simplifies the code by replacing two function calls with one call to kstrtouint_from_user.

(quoted diff) +0 -2
-Simplify the adv7393_write_proc function by replacing the
 simple_strtoul and copy_from_user calls with one call
 to kstrtouint_from_user.
 
-Change the count parameter from unsigned long to size_t as
 this is the type that the kstrtouint_from_user function expects.
 (size_t is what will be passed to the adv7393_write_proc function
 by the proc write handler function proc_file_write anyway)
Quoted 1 line

Applied.

Thanks,

Florian Tobias Schandinat

Quoted 29 lines
---
 drivers/video/bfin_adv7393fb.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/video/bfin_adv7393fb.c +2 -4
index 1a268a2..8c6edfd 100644
@@ -353,18 +353,16 @@ adv7393_read_proc(char *page, char **start, off_t off,
 
 static int
 adv7393_write_proc(struct file *file, const char __user * buffer,
-		   unsigned long count, void *data)
+		   size_t count, void *data)
 {
 	struct adv7393fb_device *fbdev = data;
-	char line[8];
 	unsigned int val;
 	int ret;
 
-	ret = copy_from_user(line, buffer, count);
+	ret = kstrtouint_from_user(buffer, count, 0, &val);
 	if (ret)
 		return -EFAULT;
 
-	val = simple_strtoul(line, NULL, 0);
 	adv7393_write(fbdev->client, val >> 8, val & 0xff);
 
 	return count;