From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
Karsten Keil <isdn@linux-pingi.de>,
netdev@vger.kernel.org
Subject: [PATCH 2/3] drivers: isdn: remove custom strtoul()
Date: Thu, 15 Jul 2010 15:37:19 +0300 [thread overview]
Message-ID: <1279197440-6585-2-git-send-email-andy.shevchenko@gmail.com> (raw)
In-Reply-To: <1279197440-6585-1-git-send-email-andy.shevchenko@gmail.com>
In this case we safe to use strict_strtoul().
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: netdev@vger.kernel.org
---
drivers/isdn/hysdn/hysdn_proclog.c | 36 +++++++-----------------------------
1 files changed, 7 insertions(+), 29 deletions(-)
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index 7003698..2ee93d0 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -16,6 +16,7 @@
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/mutex.h>
+#include <linux/kernel.h>
#include "hysdn_defs.h"
@@ -155,9 +156,8 @@ static ssize_t
hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t * off)
{
unsigned long u = 0;
- int found = 0;
- unsigned char *cp, valbuf[128];
- long base = 10;
+ int rc;
+ unsigned char valbuf[128];
hysdn_card *card = file->private_data;
if (count > (sizeof(valbuf) - 1))
@@ -166,32 +166,10 @@ hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t
return (-EFAULT); /* copy failed */
valbuf[count] = 0; /* terminating 0 */
- cp = valbuf;
- if ((count > 2) && (valbuf[0] == '0') && (valbuf[1] == 'x')) {
- cp += 2; /* pointer after hex modifier */
- base = 16;
- }
- /* scan the input for debug flags */
- while (*cp) {
- if ((*cp >= '0') && (*cp <= '9')) {
- found = 1;
- u *= base; /* adjust to next digit */
- u += *cp++ - '0';
- continue;
- }
- if (base != 16)
- break; /* end of number */
-
- if ((*cp >= 'a') && (*cp <= 'f')) {
- found = 1;
- u *= base; /* adjust to next digit */
- u += *cp++ - 'a' + 10;
- continue;
- }
- break; /* terminated */
- }
- if (found) {
+ rc = strict_strtoul(valbuf, 0, &u);
+
+ if (rc == 0) {
card->debug_flags = u; /* remember debug flags */
hysdn_addlog(card, "debug set to 0x%lx", card->debug_flags);
}
--
1.7.1.1
next prev parent reply other threads:[~2010-07-15 12:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-15 12:37 [PATCH 1/3] drivers: isdn: use kernel macros to convert hex digit Andy Shevchenko
2010-07-15 12:37 ` Andy Shevchenko [this message]
2010-07-16 2:08 ` [PATCH 2/3] drivers: isdn: remove custom strtoul() David Miller
2010-07-15 12:37 ` [PATCH 3/3] drivers: isdn: get rid of " Andy Shevchenko
2010-07-16 2:08 ` David Miller
2010-07-16 2:08 ` [PATCH 1/3] drivers: isdn: use kernel macros to convert hex digit David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1279197440-6585-2-git-send-email-andy.shevchenko@gmail.com \
--to=andy.shevchenko@gmail.com \
--cc=isdn@linux-pingi.de \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).