media: video: pwc: Use kernel's simple_strtol()
Subsystems (2)
PATCH 1/2 media: video: pwc: Use kernel's simple_strtol()
From: Andy Shevchenko <[email protected]>
Change own implementation of pwc_atoi() by simple_strtol(x, NULL, 10).
--- drivers/media/video/pwc/pwc-if.c | 23 +++++++---------------- 1 files changed, 7 insertions(+), 16 deletions(-)
drivers/media/video/pwc/pwc-if.c +7 -16
@@ -68,6 +68,7 @@#endif #include <linux/vmalloc.h> #include <asm/io.h> +#include <linux/kernel.h> /* simple_strtol() */ #include "pwc.h" #include "pwc-kiara.h"
@@ -1916,19 +1917,6 @@ disconnect_out:unlock_kernel (); } -/* *grunt* We have to do atoi ourselves :-( */ -static int pwc_atoi (const char *s) -{ -int k =0 ; - - k =0 ; -while (*s !='\0' && *s >='0' && *s <='9' ) { - k =10 * k + (*s -'0' ); - s++; - } -return k; -} -/* * Initialization code & module stuff
@@ -2078,13 +2066,16 @@ static int __init usb_pwc_init(void) }else {/* No type or serial number specified, just a number. */ - device_hint[i].device_node =pwc_atoi (s); + device_hint[i].device_node = +simple_strtol (s,NULL ,10 ); } }else {/* There's a colon, so we have at least a type and a device node */ - device_hint[i].type =pwc_atoi (s); - device_hint[i].device_node =pwc_atoi (colon +1 ); + device_hint[i].type = +simple_strtol (s,NULL ,10 ); + device_hint[i].device_node = +simple_strtol (colon +1 ,NULL ,10 );if (*dot !='\0' ) {/* There's a serial number as well */ int k;
Signature · 1 line
1.5.6.5
PATCH 2/2 atoi: Drop custom atoi from drivers/video/modedb.c
From: Andy Shevchenko <[email protected]>
Kernel has simple_strtol() implementation which could be used as atoi().
--- drivers/video/modedb.c | 24 +++++------------------- 1 files changed, 5 insertions(+), 19 deletions(-)
drivers/video/modedb.c +5 -19
@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/fb.h> +#include <linux/kernel.h> #undef DEBUG
@@ -402,21 +403,6 @@ const struct fb_videomode vesa_modes[] = {EXPORT_SYMBOL (vesa_modes);#endif /* CONFIG_FB_MODE_HELPERS */ -static int my_atoi (const char *name) -{ -int val =0 ; - -for (;; name++) { -switch (*name) { - case '0' ... '9': - val =10 *val+(*name-'0' ); -break ; -default : -return val; - } - } -} -/** * fb_try_mode - test a video mode * @var: frame buffer user defined part of display
@@ -539,7 +525,7 @@ int fb_find_mode(struct fb_var_screeninfo *var, namelen = i;if (!refresh_specified && !bpp_specified && !yres_specified) { - refresh =my_atoi (&name[i+1 ]); + refresh =simple_strtol (&name[i+1 ],NULL ,10 ); refresh_specified =1 ;if (cvt || rb) cvt =0 ;
@@ -549,7 +535,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,case '-' : namelen = i;if (!bpp_specified && !yres_specified) { - bpp =my_atoi (&name[i+1 ]); + bpp =simple_strtol (&name[i+1 ],NULL ,10 ); bpp_specified =1 ;if (cvt || rb) cvt =0 ;
@@ -558,7 +544,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,break ;case 'x' :if (!yres_specified) { - yres =my_atoi (&name[i+1 ]); + yres =simple_strtol (&name[i+1 ],NULL ,10 ); yres_specified =1 ; }else goto done;
@@ -586,7 +572,7 @@ int fb_find_mode(struct fb_var_screeninfo *var, } }if (i <0 && yres_specified) { - xres =my_atoi (name); + xres =simple_strtol (name,NULL ,10 ); res_specified =1 ; } done:
Signature · 1 line
1.5.6.5
Re: [PATCH 2/2] atoi: Drop custom atoi from drivers/video/modedb.c
Hi Andy,
You send this patch to the wrong ML. Somebody's else maintain drivers/video.
Btw, it would be better to use strict_atoi instead of simple_atoi.
The same comment applies to pwc patch you sent at the same series, but, as it is better to use simple_atoi, instead of having their own implementation, I've merged it.
Cheers,
Mauro.
Em Thu, 24 Sep 2009 13:58:10 +0300
Andy Shevchenko <[email protected]> escreveu:
Quoted 79 lines
From: Andy Shevchenko <[email protected]>
Kernel has
simple_strtol()implementation which could be used asatoi().Signed-off-by Andy Shevchenko <[email protected]>--- drivers/video/modedb.c | 24 +++++------------------- 1 files changed, 5 insertions(+), 19 deletions(-)drivers/video/modedb.c +5
-19@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/fb.h> +#include <linux/kernel.h> #undef DEBUG@@ -402,21 +403,6 @@ const struct fb_videomode vesa_modes[] = {EXPORT_SYMBOL (vesa_modes);#endif /* CONFIG_FB_MODE_HELPERS */ -static int my_atoi (const char *name) -{ -int val =0 ; - -for (;; name++) { -switch (*name) { - case '0' ... '9': - val =10 *val+(*name-'0' ); -break ; -default : -return val; - } - } -} -/** * fb_try_mode - test a video mode * @var: frame buffer user defined part of display @@ -539,7 +525,7 @@ int fb_find_mode(struct fb_var_screeninfo *var, namelen = i;if (!refresh_specified && !bpp_specified && !yres_specified) { - refresh =my_atoi (&name[i+1 ]); + refresh =simple_strtol (&name[i+1 ],NULL ,10 ); refresh_specified =1 ;if (cvt || rb) cvt =0 ;@@ -549,7 +535,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,case '-' : namelen = i;if (!bpp_specified && !yres_specified) { - bpp =my_atoi (&name[i+1 ]); + bpp =simple_strtol (&name[i+1 ],NULL ,10 ); bpp_specified =1 ;if (cvt || rb) cvt =0 ;@@ -558,7 +544,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,break ;case 'x' :if (!yres_specified) { - yres =my_atoi (&name[i+1 ]); + yres =simple_strtol (&name[i+1 ],NULL ,10 ); yres_specified =1 ; }else goto done;@@ -586,7 +572,7 @@ int fb_find_mode(struct fb_var_screeninfo *var, } }if (i <0 && yres_specified) { - xres =my_atoi (name); + xres =simple_strtol (name,NULL ,10 ); res_specified =1 ; } done:
Signature · 2 lines
Cheers, Mauro