Commit 3944ad6848e7ae15a3402372a2df4ae805008321
Committed by
David S. Miller
1 parent
735c65ce4a
drivers: isdn: remove custom strtoul()
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 Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 6 additions and 28 deletions Side-by-side Diff
drivers/isdn/hysdn/hysdn_proclog.c
... | ... | @@ -16,6 +16,7 @@ |
16 | 16 | #include <linux/sched.h> |
17 | 17 | #include <linux/slab.h> |
18 | 18 | #include <linux/mutex.h> |
19 | +#include <linux/kernel.h> | |
19 | 20 | |
20 | 21 | #include "hysdn_defs.h" |
21 | 22 | |
... | ... | @@ -155,9 +156,8 @@ |
155 | 156 | hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t * off) |
156 | 157 | { |
157 | 158 | unsigned long u = 0; |
158 | - int found = 0; | |
159 | - unsigned char *cp, valbuf[128]; | |
160 | - long base = 10; | |
159 | + int rc; | |
160 | + unsigned char valbuf[128]; | |
161 | 161 | hysdn_card *card = file->private_data; |
162 | 162 | |
163 | 163 | if (count > (sizeof(valbuf) - 1)) |
164 | 164 | |
165 | 165 | |
... | ... | @@ -166,32 +166,10 @@ |
166 | 166 | return (-EFAULT); /* copy failed */ |
167 | 167 | |
168 | 168 | valbuf[count] = 0; /* terminating 0 */ |
169 | - cp = valbuf; | |
170 | - if ((count > 2) && (valbuf[0] == '0') && (valbuf[1] == 'x')) { | |
171 | - cp += 2; /* pointer after hex modifier */ | |
172 | - base = 16; | |
173 | - } | |
174 | - /* scan the input for debug flags */ | |
175 | - while (*cp) { | |
176 | - if ((*cp >= '0') && (*cp <= '9')) { | |
177 | - found = 1; | |
178 | - u *= base; /* adjust to next digit */ | |
179 | - u += *cp++ - '0'; | |
180 | - continue; | |
181 | - } | |
182 | - if (base != 16) | |
183 | - break; /* end of number */ | |
184 | 169 | |
185 | - if ((*cp >= 'a') && (*cp <= 'f')) { | |
186 | - found = 1; | |
187 | - u *= base; /* adjust to next digit */ | |
188 | - u += *cp++ - 'a' + 10; | |
189 | - continue; | |
190 | - } | |
191 | - break; /* terminated */ | |
192 | - } | |
170 | + rc = strict_strtoul(valbuf, 0, &u); | |
193 | 171 | |
194 | - if (found) { | |
172 | + if (rc == 0) { | |
195 | 173 | card->debug_flags = u; /* remember debug flags */ |
196 | 174 | hysdn_addlog(card, "debug set to 0x%lx", card->debug_flags); |
197 | 175 | } |