* [PATCH] media: video: pwc: Use kernel's simple_strtol()
@ 2009-09-16 11:42 Andy Shevchenko
2009-09-16 12:05 ` Andrey Panin
0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2009-09-16 11:42 UTC (permalink / raw)
To: linux-kernel; +Cc: Andy Shevchenko
From: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Change own implementation of atoi() by simple_strtol(x, NULL, 10).
Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
---
drivers/media/video/pwc/pwc-if.c | 13 +++----------
1 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index f976df4..cb995c6 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -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,17 +1917,9 @@ disconnect_out:
unlock_kernel();
}
-/* *grunt* We have to do atoi ourselves :-( */
-static int pwc_atoi(const char *s)
+static inline 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;
+ return (int)simple_strtol(s, NULL, 10);
}
--
1.5.6.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] media: video: pwc: Use kernel's simple_strtol()
2009-09-16 11:42 [PATCH] media: video: pwc: Use kernel's simple_strtol() Andy Shevchenko
@ 2009-09-16 12:05 ` Andrey Panin
2009-09-16 12:16 ` Andy Shevchenko
2009-09-16 12:26 ` [PATCH v2] " Andy Shevchenko
0 siblings, 2 replies; 8+ messages in thread
From: Andrey Panin @ 2009-09-16 12:05 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-kernel, Andy Shevchenko
On 259, 09 16, 2009 at 02:42:27PM +0300, Andy Shevchenko wrote:
> From: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
>
> Change own implementation of atoi() by simple_strtol(x, NULL, 10).
Why did you keep the wrapper itself then ?
> Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
> ---
> drivers/media/video/pwc/pwc-if.c | 13 +++----------
> 1 files changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
> index f976df4..cb995c6 100644
> --- a/drivers/media/video/pwc/pwc-if.c
> +++ b/drivers/media/video/pwc/pwc-if.c
> @@ -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,17 +1917,9 @@ disconnect_out:
> unlock_kernel();
> }
>
> -/* *grunt* We have to do atoi ourselves :-( */
> -static int pwc_atoi(const char *s)
> +static inline 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;
> + return (int)simple_strtol(s, NULL, 10);
> }
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] media: video: pwc: Use kernel's simple_strtol()
2009-09-16 12:05 ` Andrey Panin
@ 2009-09-16 12:16 ` Andy Shevchenko
2009-09-16 12:26 ` [PATCH v2] " Andy Shevchenko
1 sibling, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2009-09-16 12:16 UTC (permalink / raw)
To: Andy Shevchenko, linux-kernel, Andy Shevchenko
On Wed, Sep 16, 2009 at 3:05 PM, Andrey Panin <pazke@centrinvest.ru> wrote:
>> Change own implementation of atoi() by simple_strtol(x, NULL, 10).
> Why did you keep the wrapper itself then ?
I could change in all places, but it's only tiny inline function.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] media: video: pwc: Use kernel's simple_strtol()
2009-09-16 12:05 ` Andrey Panin
2009-09-16 12:16 ` Andy Shevchenko
@ 2009-09-16 12:26 ` Andy Shevchenko
2009-09-16 12:43 ` Pekka Enberg
1 sibling, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2009-09-16 12:26 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org; +Cc: Andy Shevchenko
From: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Change own implementation of pwc_atoi() by simple_strtol(x, NULL, 10).
Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
---
drivers/media/video/pwc/pwc-if.c | 20 ++++----------------
1 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index f976df4..0037a8c 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -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,13 @@ 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 = (int)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 = (int)simple_strtol(s, NULL, 10);
+ device_hint[i].device_node = (int)simple_strtol(colon + 1, NULL, 10);
if (*dot != '\0') {
/* There's a serial number as well */
int k;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] media: video: pwc: Use kernel's simple_strtol()
2009-09-16 12:26 ` [PATCH v2] " Andy Shevchenko
@ 2009-09-16 12:43 ` Pekka Enberg
2009-09-16 13:53 ` [PATCH v3] " Andy Shevchenko
2009-09-16 13:54 ` [PATCH v2] " Andy Shevchenko
0 siblings, 2 replies; 8+ messages in thread
From: Pekka Enberg @ 2009-09-16 12:43 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-kernel@vger.kernel.org, Andy Shevchenko
On Wed, Sep 16, 2009 at 3:26 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> @@ -2078,13 +2066,13 @@ 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 = (int)simple_strtol(s, NULL, 10);
What's with all the casting to int?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3] media: video: pwc: Use kernel's simple_strtol()
2009-09-16 12:43 ` Pekka Enberg
@ 2009-09-16 13:53 ` Andy Shevchenko
2009-09-16 15:34 ` Pekka Enberg
2009-09-16 13:54 ` [PATCH v2] " Andy Shevchenko
1 sibling, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2009-09-16 13:53 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org; +Cc: penberg, Andy Shevchenko
From: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Change own implementation of pwc_atoi() by simple_strtol(x, NULL, 10).
Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
---
drivers/media/video/pwc/pwc-if.c | 23 +++++++----------------
1 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index f976df4..89b620f 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -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;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] media: video: pwc: Use kernel's simple_strtol()
2009-09-16 12:43 ` Pekka Enberg
2009-09-16 13:53 ` [PATCH v3] " Andy Shevchenko
@ 2009-09-16 13:54 ` Andy Shevchenko
1 sibling, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2009-09-16 13:54 UTC (permalink / raw)
To: Pekka Enberg; +Cc: linux-kernel@vger.kernel.org, Andy Shevchenko
On Wed, Sep 16, 2009 at 3:43 PM, Pekka Enberg <penberg@cs.helsinki.fi> wrote:
> What's with all the casting to int?
Yeah, you are right, they are redundant. See next iteration of the patch :-)
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3] media: video: pwc: Use kernel's simple_strtol()
2009-09-16 13:53 ` [PATCH v3] " Andy Shevchenko
@ 2009-09-16 15:34 ` Pekka Enberg
0 siblings, 0 replies; 8+ messages in thread
From: Pekka Enberg @ 2009-09-16 15:34 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-kernel@vger.kernel.org, Andy Shevchenko
Andy Shevchenko wrote:
> From: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
>
> Change own implementation of pwc_atoi() by simple_strtol(x, NULL, 10).
>
> Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Looks good to me, FWIW,
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Pekka
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-09-16 15:34 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-16 11:42 [PATCH] media: video: pwc: Use kernel's simple_strtol() Andy Shevchenko
2009-09-16 12:05 ` Andrey Panin
2009-09-16 12:16 ` Andy Shevchenko
2009-09-16 12:26 ` [PATCH v2] " Andy Shevchenko
2009-09-16 12:43 ` Pekka Enberg
2009-09-16 13:53 ` [PATCH v3] " Andy Shevchenko
2009-09-16 15:34 ` Pekka Enberg
2009-09-16 13:54 ` [PATCH v2] " Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox