wl1251: use DRIVER_NAME macro in wl1251_spi_driver
[pandora-wifi.git] / compat / compat-2.6.25.c
1 /*
2  * Copyright 2007-2010  Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
3  *
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.
7  *
8  * Compatibility file for Linux wireless for kernels 2.6.25.
9  */
10
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))
13
14 #include <linux/miscdevice.h>
15
16 /**
17  * The following things are out of ./lib/vsprintf.c
18  * The new iwlwifi driver is using them.
19  */
20
21 /**
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
26  *
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:
32  *
33  *      echo 1024 > /sys/module/e1000/parameters/copybreak
34  *
35  * echo will append a newline to the tail.
36  *
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.
39  *
40  * simple_strtoul just ignores the successive invalid characters and
41  * return the converted value of prefix part of the string.
42  */
43 int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
44
45 /**
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
50  *
51  * strict_strtol is similiar to strict_strtoul, but it allows the first
52  * character of a string is '-'.
53  *
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.
56  */
57 int strict_strtol(const char *cp, unsigned int base, long *res);
58
59 #define define_strict_strtoux(type, valtype)                            \
60 int strict_strtou##type(const char *cp, unsigned int base, valtype *res)\
61 {                                                                       \
62         char *tail;                                                     \
63         valtype val;                                                    \
64         size_t len;                                                     \
65                                                                         \
66         *res = 0;                                                       \
67         len = strlen(cp);                                               \
68         if (len == 0)                                                   \
69                 return -EINVAL;                                         \
70                                                                         \
71         val = simple_strtou##type(cp, &tail, base);                     \
72         if ((*tail == '\0') ||                                          \
73                 ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {\
74                 *res = val;                                             \
75                 return 0;                                               \
76         }                                                               \
77                                                                         \
78         return -EINVAL;                                                 \
79 }                                                                       \
80
81 #define define_strict_strtox(type, valtype)                             \
82 int strict_strto##type(const char *cp, unsigned int base, valtype *res) \
83 {                                                                       \
84         int ret;                                                        \
85         if (*cp == '-') {                                               \
86                 ret = strict_strtou##type(cp+1, base, res);             \
87                 if (!ret)                                               \
88                         *res = -(*res);                                 \
89         } else                                                          \
90                 ret = strict_strtou##type(cp, base, res);               \
91                                                                         \
92         return ret;                                                     \
93 }                                                                       \
94
95 define_strict_strtoux(l, unsigned long)
96 define_strict_strtox(l, long)
97
98 EXPORT_SYMBOL(strict_strtoul);
99 EXPORT_SYMBOL(strict_strtol);
100
101 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) */
102