2 * Copyright 2007-2010 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * Compatibility file for Linux wireless for kernels 2.6.25.
11 /* All things not in 2.6.22, 2.6.23 and 2.6.24 */
12 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25))
14 #include <linux/miscdevice.h>
17 * The following things are out of ./lib/vsprintf.c
18 * The new iwlwifi driver is using them.
22 * strict_strtoul - convert a string to an unsigned long strictly
23 * @cp: The string to be converted
24 * @base: The number base to use
25 * @res: The converted result value
27 * strict_strtoul converts a string to an unsigned long only if the
28 * string is really an unsigned long string, any string containing
29 * any invalid char at the tail will be rejected and -EINVAL is returned,
30 * only a newline char at the tail is acceptible because people generally
31 * change a module parameter in the following way:
33 * echo 1024 > /sys/module/e1000/parameters/copybreak
35 * echo will append a newline to the tail.
37 * It returns 0 if conversion is successful and *res is set to the converted
38 * value, otherwise it returns -EINVAL and *res is set to 0.
40 * simple_strtoul just ignores the successive invalid characters and
41 * return the converted value of prefix part of the string.
43 int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
46 * strict_strtol - convert a string to a long strictly
47 * @cp: The string to be converted
48 * @base: The number base to use
49 * @res: The converted result value
51 * strict_strtol is similiar to strict_strtoul, but it allows the first
52 * character of a string is '-'.
54 * It returns 0 if conversion is successful and *res is set to the converted
55 * value, otherwise it returns -EINVAL and *res is set to 0.
57 int strict_strtol(const char *cp, unsigned int base, long *res);
59 #define define_strict_strtoux(type, valtype) \
60 int strict_strtou##type(const char *cp, unsigned int base, valtype *res)\
71 val = simple_strtou##type(cp, &tail, base); \
72 if ((*tail == '\0') || \
73 ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {\
81 #define define_strict_strtox(type, valtype) \
82 int strict_strto##type(const char *cp, unsigned int base, valtype *res) \
86 ret = strict_strtou##type(cp+1, base, res); \
90 ret = strict_strtou##type(cp, base, res); \
95 define_strict_strtoux(l, unsigned long)
96 define_strict_strtox(l, long)
98 EXPORT_SYMBOL(strict_strtoul);
99 EXPORT_SYMBOL(strict_strtol);
101 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) */