1 Index: madwifi-dfs-r3252/ath/if_athvar.h
2 ===================================================================
3 --- madwifi-dfs-r3252.orig/ath/if_athvar.h 2008-01-25 21:13:50.832747032 +0100
4 +++ madwifi-dfs-r3252/ath/if_athvar.h 2008-01-25 21:14:09.785827106 +0100
6 #define NETDEV_TX_BUSY 1
10 +#define NETDEV_TX_OK 0
11 +#define NETDEV_TX_BUSY 1
14 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23)
15 static inline struct net_device *_alloc_netdev(int sizeof_priv, const char *mask,
16 void (*setup)(struct net_device *))
17 Index: madwifi-dfs-r3252/ath/if_ath_radar.c
18 ===================================================================
19 --- madwifi-dfs-r3252.orig/ath/if_ath_radar.c 2008-01-25 21:13:50.840747487 +0100
20 +++ madwifi-dfs-r3252/ath/if_ath_radar.c 2008-01-25 21:14:09.789827335 +0100
22 #define nofloat_pct(_value, _pct) \
23 ( (_value * (1000 + _pct)) / 1000 )
25 +#ifndef list_for_each_entry_reverse
26 +#define list_for_each_entry_reverse(pos, head, member) \
27 + for (pos = list_entry((head)->prev, typeof(*pos), member); \
28 + prefetch(pos->member.prev), &pos->member != (head); \
29 + pos = list_entry(pos->member.prev, typeof(*pos), member))
32 struct radar_pattern_specification {
33 /* The name of the rule/specification (i.e. what did we detect) */
35 Index: madwifi-dfs-r3252/ath/if_ath.c
36 ===================================================================
37 --- madwifi-dfs-r3252.orig/ath/if_ath.c 2008-01-25 21:13:59.245226430 +0100
38 +++ madwifi-dfs-r3252/ath/if_ath.c 2008-01-25 21:14:09.797827791 +0100
39 @@ -4698,6 +4698,46 @@
43 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
44 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
47 + unsigned long flags;
49 + local_irq_save(flags);
51 + if (likely(ret == old))
53 + local_irq_restore(flags);
59 + * atomic_add_unless - add unless the number is a given value
60 + * @v: pointer of type atomic_t
61 + * @a: the amount to add to v...
62 + * @u: ...unless v is equal to u.
64 + * Atomically adds @a to @v, so long as it was not @u.
65 + * Returns non-zero if @v was not @u, and zero otherwise.
67 +static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
72 + if (unlikely(c == (u)))
74 + old = atomic_cmpxchg((v), c, c + (a));
75 + if (likely(old == c))
84 * Generate beacon frame and queue cab data for a VAP.
86 Index: madwifi-dfs-r3252/net80211/ieee80211_scan_ap.c
87 ===================================================================
88 --- madwifi-dfs-r3252.orig/net80211/ieee80211_scan_ap.c 2008-01-25 21:13:50.852748172 +0100
89 +++ madwifi-dfs-r3252/net80211/ieee80211_scan_ap.c 2008-01-25 21:14:33.343169561 +0100
91 #include <linux/netdevice.h>
92 #include <linux/init.h>
93 #include <linux/delay.h>
95 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
98 #include <linux/sort.h>
101 #include "if_media.h"
103 Index: madwifi-dfs-r3252/net80211/sort.c
104 ===================================================================
105 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
106 +++ madwifi-dfs-r3252/net80211/sort.c 2008-01-25 21:14:09.801828016 +0100
109 + * A fast, small, non-recursive O(nlog n) sort for the Linux kernel
111 + * Jan 23 2005 Matt Mackall <mpm@selenic.com>
114 +#include <linux/kernel.h>
115 +#include <linux/module.h>
116 +#include <linux/slab.h>
118 +static void u32_swap(void *a, void *b, int size)
121 + *(u32 *)a = *(u32 *)b;
125 +static void generic_swap(void *a, void *b, int size)
131 + *(char *)a++ = *(char *)b;
133 + } while (--size > 0);
137 + * sort - sort an array of elements
138 + * @base: pointer to data to sort
139 + * @num: number of elements
140 + * @size: size of each element
141 + * @cmp: pointer to comparison function
142 + * @swap: pointer to swap function or NULL
144 + * This function does a heapsort on the given array. You may provide a
145 + * swap function optimized to your element type.
147 + * Sorting time is O(n log n) both on average and worst-case. While
148 + * qsort is about 20% faster on average, it suffers from exploitable
149 + * O(n*n) worst-case behavior and extra memory requirements that make
150 + * it less suitable for kernel use.
153 +static void sort(void *base, size_t num, size_t size,
154 + int (*cmp)(const void *, const void *),
155 + void (*swap)(void *, void *, int size))
157 + /* pre-scale counters for performance */
158 + int i = (num/2 - 1) * size, n = num * size, c, r;
161 + swap = (size == 4 ? u32_swap : generic_swap);
164 + for ( ; i >= 0; i -= size) {
165 + for (r = i; r * 2 + size < n; r = c) {
167 + if (c < n - size && cmp(base + c, base + c + size) < 0)
169 + if (cmp(base + r, base + c) >= 0)
171 + swap(base + r, base + c, size);
176 + for (i = n - size; i >= 0; i -= size) {
177 + swap(base, base + i, size);
178 + for (r = 0; r * 2 + size < i; r = c) {
180 + if (c < i - size && cmp(base + c, base + c + size) < 0)
182 + if (cmp(base + r, base + c) >= 0)
184 + swap(base + r, base + c, size);
189 +EXPORT_SYMBOL(sort);
192 +/* a simple boot-time regression test */
194 +int cmpint(const void *a, const void *b)
196 + return *(int *)a - *(int *)b;
199 +static int sort_test(void)
203 + a = kmalloc(1000 * sizeof(int), GFP_KERNEL);
206 + printk("testing sort()\n");
208 + for (i = 0; i < 1000; i++) {
209 + r = (r * 725861) % 6599;
213 + sort(a, 1000, sizeof(int), cmpint, NULL);
215 + for (i = 0; i < 999; i++)
216 + if (a[i] > a[i+1]) {
217 + printk("sort() failed!\n");
226 +module_init(sort_test);