4 #define ATH_GET_NETDEV_DEV(ndev) ((ndev)->class_dev.dev)
8 +#define NETDEV_TX_OK 0
9 +#define NETDEV_TX_BUSY 1
12 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23)
13 static inline struct net_device *_alloc_netdev(int sizeof_priv, const char *mask,
14 void (*setup)(struct net_device *))
15 --- a/ath/if_ath_radar.c
16 +++ b/ath/if_ath_radar.c
18 #define nofloat_pct(_value, _pct) \
19 ( (_value * (1000 + _pct)) / 1000 )
21 +#ifndef list_for_each_entry_reverse
22 +#define list_for_each_entry_reverse(pos, head, member) \
23 + for (pos = list_entry((head)->prev, typeof(*pos), member); \
24 + prefetch(pos->member.prev), &pos->member != (head); \
25 + pos = list_entry(pos->member.prev, typeof(*pos), member))
28 struct radar_pattern_specification {
29 /* The name of the rule/specification (i.e. what did we detect) */
33 @@ -4705,6 +4705,46 @@
37 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
38 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
41 + unsigned long flags;
43 + local_irq_save(flags);
45 + if (likely(ret == old))
47 + local_irq_restore(flags);
53 + * atomic_add_unless - add unless the number is a given value
54 + * @v: pointer of type atomic_t
55 + * @a: the amount to add to v...
56 + * @u: ...unless v is equal to u.
58 + * Atomically adds @a to @v, so long as it was not @u.
59 + * Returns non-zero if @v was not @u, and zero otherwise.
61 +static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
66 + if (unlikely(c == (u)))
68 + old = atomic_cmpxchg((v), c, c + (a));
69 + if (likely(old == c))
78 * Generate beacon frame and queue cab data for a VAP.
84 + * A fast, small, non-recursive O(nlog n) sort for the Linux kernel
86 + * Jan 23 2005 Matt Mackall <mpm@selenic.com>
89 +#include <linux/kernel.h>
90 +#include <linux/module.h>
91 +#include <linux/slab.h>
93 +static void u32_swap(void *a, void *b, int size)
96 + *(u32 *)a = *(u32 *)b;
100 +static void generic_swap(void *a, void *b, int size)
106 + *(char *)a++ = *(char *)b;
108 + } while (--size > 0);
112 + * sort - sort an array of elements
113 + * @base: pointer to data to sort
114 + * @num: number of elements
115 + * @size: size of each element
116 + * @cmp: pointer to comparison function
117 + * @swap: pointer to swap function or NULL
119 + * This function does a heapsort on the given array. You may provide a
120 + * swap function optimized to your element type.
122 + * Sorting time is O(n log n) both on average and worst-case. While
123 + * qsort is about 20% faster on average, it suffers from exploitable
124 + * O(n*n) worst-case behavior and extra memory requirements that make
125 + * it less suitable for kernel use.
128 +static void sort(void *base, size_t num, size_t size,
129 + int (*cmp)(const void *, const void *),
130 + void (*swap)(void *, void *, int size))
132 + /* pre-scale counters for performance */
133 + int i = (num/2 - 1) * size, n = num * size, c, r;
136 + swap = (size == 4 ? u32_swap : generic_swap);
139 + for ( ; i >= 0; i -= size) {
140 + for (r = i; r * 2 + size < n; r = c) {
142 + if (c < n - size && cmp(base + c, base + c + size) < 0)
144 + if (cmp(base + r, base + c) >= 0)
146 + swap(base + r, base + c, size);
151 + for (i = n - size; i >= 0; i -= size) {
152 + swap(base, base + i, size);
153 + for (r = 0; r * 2 + size < i; r = c) {
155 + if (c < i - size && cmp(base + c, base + c + size) < 0)
157 + if (cmp(base + r, base + c) >= 0)
159 + swap(base + r, base + c, size);
164 +EXPORT_SYMBOL(sort);
167 +/* a simple boot-time regression test */
169 +int cmpint(const void *a, const void *b)
171 + return *(int *)a - *(int *)b;
174 +static int sort_test(void)
178 + a = kmalloc(1000 * sizeof(int), GFP_KERNEL);
181 + printk("testing sort()\n");
183 + for (i = 0; i < 1000; i++) {
184 + r = (r * 725861) % 6599;
188 + sort(a, 1000, sizeof(int), cmpint, NULL);
190 + for (i = 0; i < 999; i++)
191 + if (a[i] > a[i+1]) {
192 + printk("sort() failed!\n");
201 +module_init(sort_test);