summaryrefslogtreecommitdiff
path: root/package/madwifi/patches/446-single_module.patch
blob: 2ad9af87e294ed0da693c5874cba879f5b2034f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
--- a/ath/Makefile
+++ b/ath/Makefile
@@ -41,7 +41,6 @@
 #
 
 obj := $(firstword $(obj) $(SUBDIRS) .)
-TOP = $(obj)/..
 
 ifeq ($(strip $(BUS)),AHB)
 BUSNAME=ahb
@@ -57,7 +56,24 @@ COPTS	+= -DDFS_DOMAIN_ETSI -DDFS_DOMAIN_
 include $(TOP)/Makefile.inc
 
 obj-m		+= ath_$(BUSNAME).o
-ath_$(BUSNAME)-objs	:= if_ath.o if_ath_radar.o if_ath_$(BUSNAME).o
+ath_objs := if_ath.o if_ath_radar.o if_ath_$(BUSNAME).o
+ath_$(BUSNAME)-objs	:= $(ath_objs)
+
+ifneq ($(SINGLE_MODULE),)
+include $(TOP)/net80211/Makefile
+include $(TOP)/ath_rate/sample/Makefile
+include $(TOP)/ath_rate/minstrel/Makefile
+RC_DECLARE=$(foreach R,$(ATH_RATE),extern void ath_rate_$(R)_init(void);extern void ath_rate_$(R)_exit(void);)
+RC_INIT=$(foreach R,$(ATH_RATE),ath_rate_$(R)_init();)
+RC_EXIT=$(foreach R,$(ATH_RATE),ath_rate_$(R)_exit();)
+
+ath_$(BUSNAME)-objs += $(patsubst %,../net80211/%,$(wlan-objs) $(foreach var,wep tkip ccmp acl xauth scan_sta scan_ap,$(wlan_$(var)-objs))) $(foreach RC,$(ATH_RATE),$(patsubst %,../ath_rate/$(RC)/%,$(ath_rate_$(RC)-objs)))
+ifdef LINUX24
+  ath_$(BUSNAME)-linkobjs := $(ath_objs) $(wlan-objs) $(foreach var,wep tkip ccmp acl xauth scan_sta scan_ap,$(wlan_$(var)-objs)) $(foreach RC,$(ATH_RATE),$(ath_rate_$(RC)-objs))
+endif
+
+EXTRA_CFLAGS += -DSINGLE_MODULE -DRC_INIT="$(RC_INIT)" -DRC_EXIT="$(RC_EXIT)" -DRC_DECLARE="$(RC_DECLARE)"
+endif
 
 INCS += -I$(TOP) -I$(ATH_HAL) -I$(HAL) -I$(WLAN)
 
@@ -72,13 +88,8 @@ install:
 	test -d $(DESTDIR)/$(KMODPATH) || mkdir -p $(DESTDIR)/$(KMODPATH)
 	install -m 0644 ath_$(BUSNAME).$(KMODSUF) $(DESTDIR)/$(KMODPATH)
 
-clean:
-	rm -f *~ *.o *.ko *.mod.c .*.cmd
-	rm -f .depend .version .*.o.flags .*.o.d
-	rm -rf .tmp_versions
-
 ath_$(BUSNAME).o: $(ath_$(BUSNAME)-objs)
-	$(LD) $(LDOPTS) -o ath_$(BUSNAME).$(KMODSUF) -r $(ath_$(BUSNAME)-objs)
+	$(LD) $(LDOPTS) -o ath_$(BUSNAME).$(KMODSUF) -r $(if $(ath_$(BUSNAME)-linkobjs),$(ath_$(BUSNAME)-linkobjs),$(ath_$(BUSNAME)-objs))
 
 if_ath_hal.h: $(HAL)/ah.h
 	$(TOP)/scripts/if_ath_hal_generator.pl $< $@
--- a/net80211/ieee80211_acl.c
+++ b/net80211/ieee80211_acl.c
@@ -281,16 +281,6 @@ acl_getpolicy(struct ieee80211vap *vap)
 	return as->as_policy;
 }
 
-/*
- * Module glue.
- */
-
-MODULE_AUTHOR("Errno Consulting, Sam Leffler");
-MODULE_DESCRIPTION("802.11 wireless support: MAC-based ACL policy");
-#ifdef MODULE_LICENSE
-MODULE_LICENSE("Dual BSD/GPL");
-#endif
-
 static const struct ieee80211_aclator mac = {
 	.iac_name	= "mac",
 	.iac_attach	= acl_attach,
@@ -303,6 +293,18 @@ static const struct ieee80211_aclator ma
 	.iac_getpolicy	= acl_getpolicy,
 };
 
+#include "module.h"
+/*
+ * Module glue.
+ */
+
+MODULE_AUTHOR("Errno Consulting, Sam Leffler");
+MODULE_DESCRIPTION("802.11 wireless support: MAC-based ACL policy");
+#ifdef MODULE_LICENSE
+MODULE_LICENSE("Dual BSD/GPL");
+#endif
+
+
 static int __init
 init_ieee80211_acl(void)
 {
--- a/net80211/ieee80211_crypto_ccmp.c
+++ b/net80211/ieee80211_crypto_ccmp.c
@@ -686,6 +686,8 @@ ccmp_decrypt(struct ieee80211_key *key, 
 }
 #undef CCMP_DECRYPT
 
+#include "module.h"
+
 /*
  * Module glue.
  */
--- a/net80211/ieee80211_crypto_tkip.c
+++ b/net80211/ieee80211_crypto_tkip.c
@@ -1046,6 +1046,8 @@ tkip_decrypt(struct tkip_ctx *ctx, struc
 	return 1;
 }
 
+#include "module.h"
+
 /*
  * Module glue.
  */
--- a/net80211/ieee80211_crypto_wep.c
+++ b/net80211/ieee80211_crypto_wep.c
@@ -497,6 +497,8 @@ wep_decrypt(struct ieee80211_key *key, s
  * Module glue.
  */
 
+#include "module.h"
+
 MODULE_AUTHOR("Errno Consulting, Sam Leffler");
 MODULE_DESCRIPTION("802.11 wireless support: WEP cipher");
 #ifdef MODULE_LICENSE
--- a/net80211/ieee80211_linux.c
+++ b/net80211/ieee80211_linux.c
@@ -1015,6 +1015,10 @@ static struct notifier_block ieee80211_e
 static char *version = RELEASE_VERSION;
 static char *dev_info = "wlan";
 
+extern	void ieee80211_auth_setup(void);
+
+#include "module.h"
+
 MODULE_AUTHOR("Errno Consulting, Sam Leffler");
 MODULE_DESCRIPTION("802.11 wireless LAN protocol support");
 #ifdef MODULE_VERSION
@@ -1024,8 +1028,6 @@ MODULE_VERSION(RELEASE_VERSION);
 MODULE_LICENSE("Dual BSD/GPL");
 #endif
 
-extern	void ieee80211_auth_setup(void);
-
 static int __init
 init_wlan(void)
 {
--- a/net80211/ieee80211_scan_ap.c
+++ b/net80211/ieee80211_scan_ap.c
@@ -763,15 +763,6 @@ action_tasklet(IEEE80211_TQUEUE_ARG data
 	(*ss->ss_ops->scan_default)(vap, &as->as_selbss);
 }
 
-/*
- * Module glue.
- */
-MODULE_AUTHOR("Errno Consulting, Sam Leffler");
-MODULE_DESCRIPTION("802.11 wireless support: default ap scanner");
-#ifdef MODULE_LICENSE
-MODULE_LICENSE("Dual BSD/GPL");
-#endif
-
 static const struct ieee80211_scanner ap_default = {
 	.scan_name		= "default",
 	.scan_attach		= ap_attach,
@@ -789,6 +780,16 @@ static const struct ieee80211_scanner ap
 	.scan_default		= ap_default_action,
 };
 
+#include "module.h"
+
+/*
+ * Module glue.
+ */
+MODULE_AUTHOR("Errno Consulting, Sam Leffler");
+MODULE_DESCRIPTION("802.11 wireless support: default ap scanner");
+#ifdef MODULE_LICENSE
+MODULE_LICENSE("Dual BSD/GPL");
+#endif
 
 static int __init
 init_scanner_ap(void)
--- a/net80211/ieee80211_scan_sta.c
+++ b/net80211/ieee80211_scan_sta.c
@@ -1208,6 +1208,8 @@ action_tasklet(IEEE80211_TQUEUE_ARG data
 		ieee80211_start_scan(vap, ss->ss_flags, ss->ss_duration, ss->ss_nssid, ss->ss_ssid);
 }
 
+#include "module.h"
+
 /*
  * Module glue.
  */
@@ -1217,6 +1219,7 @@ MODULE_DESCRIPTION("802.11 wireless supp
 MODULE_LICENSE("Dual BSD/GPL");
 #endif
 
+
 static int __init
 init_scanner_sta(void)
 {
--- a/net80211/ieee80211_xauth.c
+++ b/net80211/ieee80211_xauth.c
@@ -65,15 +65,6 @@
 #include <net80211/ieee80211_var.h>
 
 /*
- * Module glue.
- */
-MODULE_AUTHOR("Errno Consulting, Sam Leffler");
-MODULE_DESCRIPTION("802.11 wireless support: external (user mode) authenticator");
-#ifdef MODULE_LICENSE
-MODULE_LICENSE("Dual BSD/GPL");
-#endif
-
-/*
  * One module handles everything for now.  May want
  * to split things up for embedded applications.
  */
@@ -85,6 +76,18 @@ static const struct ieee80211_authentica
 	.ia_node_leave	= NULL,
 };
 
+#include "module.h"
+
+/*
+ * Module glue.
+ */
+MODULE_AUTHOR("Errno Consulting, Sam Leffler");
+MODULE_DESCRIPTION("802.11 wireless support: external (user mode) authenticator");
+#ifdef MODULE_LICENSE
+MODULE_LICENSE("Dual BSD/GPL");
+#endif
+
+
 static int __init
 init_ieee80211_xauth(void)
 {
--- a/net80211/Makefile
+++ b/net80211/Makefile
@@ -40,7 +40,11 @@
 # Makefile for the 802.11 WLAN modules.
 #
 obj := $(firstword $(obj) $(SUBDIRS) .)
-TOP = $(obj)/..
+
+include $(TOP)/Makefile.inc
+
+ifeq ($(SINGLE_MODULE),)
+
 #
 # There is one authenticator mechanism: an in-kernel implementation
 # (wlan_xauth). 
@@ -59,29 +63,8 @@ MOD_INSTALL	:= wlan.o wlan_wep.o wlan_tk
 
 obj-m		+= $(MOD_INSTALL)
 
-wlan-objs	:= if_media.o \
-		   ieee80211_skb.o \
-		   ieee80211.o ieee80211_beacon.o ieee80211_crypto.o \
-		   ieee80211_crypto_none.o ieee80211_input.o ieee80211_node.o \
-		   ieee80211_output.o ieee80211_power.o ieee80211_proto.o \
-		   ieee80211_scan.o ieee80211_wireless.o ieee80211_linux.o \
-		   ieee80211_monitor.o ieee80211_rate.o
-wlan_wep-objs	:= ieee80211_crypto_wep.o
-wlan_tkip-objs	:= ieee80211_crypto_tkip.o
-wlan_ccmp-objs	:= ieee80211_crypto_ccmp.o
-wlan_acl-objs	:= ieee80211_acl.o
-wlan_xauth-objs	:= ieee80211_xauth.o
-wlan_scan_sta-objs :=ieee80211_scan_sta.o
-wlan_scan_ap-objs := ieee80211_scan_ap.o
-
-include $(TOP)/Makefile.inc
-
 INCS += -I$(TOP) -I$(ATH_HAL) -I$(HAL)
 
-EXTRA_CFLAGS+=$(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
-
--include $(TOPDIR)/Rules.make
-
 all:
 	$(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
 
@@ -108,8 +91,28 @@ install:
 		f=`basename $$i .o`; \
 		install -m 0644  $$f.$(KMODSUF) $(DESTDIR)/$(KMODPATH); \
 	done
+else
+all:
+endif
+
+wlan-objs	:= if_media.o \
+		   ieee80211_skb.o \
+		   ieee80211.o ieee80211_beacon.o ieee80211_crypto.o \
+		   ieee80211_crypto_none.o ieee80211_input.o ieee80211_node.o \
+		   ieee80211_output.o ieee80211_power.o ieee80211_proto.o \
+		   ieee80211_scan.o ieee80211_wireless.o ieee80211_linux.o \
+		   ieee80211_monitor.o ieee80211_rate.o
+wlan_wep-objs	:= ieee80211_crypto_wep.o
+wlan_tkip-objs	:= ieee80211_crypto_tkip.o
+wlan_ccmp-objs	:= ieee80211_crypto_ccmp.o
+wlan_acl-objs	:= ieee80211_acl.o
+wlan_xauth-objs	:= ieee80211_xauth.o
+wlan_scan_sta-objs :=ieee80211_scan_sta.o
+wlan_scan_ap-objs := ieee80211_scan_ap.o
+
+
+EXTRA_CFLAGS+=$(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
+
+-include $(TOPDIR)/Rules.make
+
 
-clean:
-	-rm -f *~ *.o *.ko *.mod.c
-	-rm -f .depend .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd
-	-rm -rf .tmp_versions
--- /dev/null
+++ b/net80211/module.h
@@ -0,0 +1,19 @@
+#ifdef SINGLE_MODULE
+
+#undef static
+#define static
+#undef module_init
+#undef module_exit
+#define module_init(...)
+#define module_exit(...)
+
+#undef MODULE_AUTHOR
+#undef MODULE_LICENSE
+#undef MODULE_VERSION
+#undef MODULE_DESCRIPTION
+#define MODULE_AUTHOR(...)
+#define MODULE_LICENSE(...)
+#define MODULE_VERSION(...)
+#define MODULE_DESCRIPTION(...)
+
+#endif
--- a/ath/if_ath.c
+++ b/ath/if_ath.c
@@ -13777,3 +13777,5 @@ cleanup_ath_buf(struct ath_softc *sc, st
 	return bf;
 }
 
+
+
--- a/net80211/ieee80211.c
+++ b/net80211/ieee80211.c
@@ -42,6 +42,7 @@
 #include <linux/config.h>
 #endif
 #include <linux/version.h>
+#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
@@ -2014,3 +2015,65 @@ ieee80211_build_sc_ie(struct ieee80211co
 int ath_debug_global = 0;
 EXPORT_SYMBOL(ath_debug_global);
 
+#ifdef SINGLE_MODULE
+typedef void (*initfunc)(void);
+
+extern void init_ieee80211_acl(void);
+extern void init_crypto_ccmp(void);
+extern void init_crypto_tkip(void);
+extern void init_crypto_wep(void);
+extern void init_wlan(void);
+extern void init_scanner_ap(void);
+extern void init_scanner_sta(void);
+extern void init_ieee80211_xauth(void);
+
+extern void exit_ieee80211_acl(void);
+extern void exit_crypto_ccmp(void);
+extern void exit_crypto_tkip(void);
+extern void exit_crypto_wep(void);
+extern void exit_wlan(void);
+extern void exit_scanner_ap(void);
+extern void exit_scanner_sta(void);
+extern void exit_ieee80211_xauth(void);
+
+static __initdata initfunc net80211_init[] = {
+	init_wlan,
+	init_ieee80211_acl,
+	init_crypto_ccmp,
+	init_crypto_tkip,
+	init_crypto_wep,
+	init_ieee80211_xauth,
+	init_scanner_ap,
+	init_scanner_sta,
+};
+
+static __exitdata initfunc net80211_exit[] = {
+	exit_crypto_ccmp,
+	exit_crypto_tkip,
+	exit_crypto_wep,
+	exit_scanner_ap,
+	exit_scanner_sta,
+	exit_ieee80211_xauth,
+	exit_ieee80211_acl,
+	exit_wlan,
+};
+
+void net80211_init_module(void)
+{
+	int i;
+	for (i = 0; i < sizeof(net80211_init)/sizeof(net80211_init[0]); i++) {
+		if (net80211_init[i])
+			net80211_init[i]();
+	}
+}
+
+void net80211_exit_module(void)
+{
+	int i;
+	for (i = 0; i < sizeof(net80211_exit)/sizeof(net80211_exit[0]); i++) {
+		if (net80211_exit[i])
+			net80211_exit[i]();
+	}
+}
+
+#endif
--- a/ath/if_ath_ahb.c
+++ b/ath/if_ath_ahb.c
@@ -447,10 +447,18 @@ MODULE_SUPPORTED_DEVICE("Atheros WLAN ca
 MODULE_LICENSE("Dual BSD/GPL");
 #endif
 
+#ifdef SINGLE_MODULE
+RC_DECLARE
+#endif
+
 static int __init
 init_ath_ahb(void)
 {
 	printk(KERN_INFO "%s: %s\n", dev_info, version);
+#ifdef SINGLE_MODULE
+	net80211_init_module();
+	RC_INIT
+#endif
 	platform_driver_register(&ahb_wmac_driver);
 	ath_sysctl_register();
 
@@ -463,6 +471,10 @@ exit_ath_ahb(void)
 {
 	ath_sysctl_unregister();
 	platform_driver_unregister(&ahb_wmac_driver);
+#ifdef SINGLE_MODULE
+	RC_EXIT
+	net80211_exit_module();
+#endif
 	printk(KERN_INFO "%s: driver unloaded\n", dev_info);
 }
 module_exit(exit_ath_ahb);
--- a/ath/if_ath_pci.c
+++ b/ath/if_ath_pci.c
@@ -415,11 +415,19 @@ MODULE_SUPPORTED_DEVICE("Atheros WLAN ca
 MODULE_LICENSE("Dual BSD/GPL");
 #endif
 
+#ifdef SINGLE_MODULE
+RC_DECLARE
+#endif
+
 static int __init
 init_ath_pci(void)
 {
 	printk(KERN_INFO "%s: %s\n", dev_info, version);
 
+#ifdef SINGLE_MODULE
+	net80211_init_module();
+	RC_INIT
+#endif
 	if (pci_register_driver(&ath_pci_driver) < 0) {
 		printk(KERN_ERR "%s: No devices found, driver not installed.\n", dev_info);
 		return (-ENODEV);
@@ -434,6 +442,10 @@ exit_ath_pci(void)
 {
 	ath_sysctl_unregister();
 	pci_unregister_driver(&ath_pci_driver);
+#ifdef SINGLE_MODULE
+	RC_EXIT
+	net80211_exit_module();
+#endif
 
 	printk(KERN_INFO "%s: driver unloaded\n", dev_info);
 }
--- a/ath_rate/minstrel/Makefile
+++ b/ath_rate/minstrel/Makefile
@@ -39,9 +39,7 @@
 # Makefile for the Atheros Rate Control Support.
 #
 obj := $(firstword $(obj) $(SUBDIRS) .)
-TOP = $(obj)/../..
 
-obj-m		+= ath_rate_minstrel.o
 ath_rate_minstrel-objs	:= minstrel.o
 
 include $(TOP)/Makefile.inc
@@ -50,6 +48,10 @@ INCS += -I$(TOP) -I$(ATH) -I$(ATH_HAL) -
 
 EXTRA_CFLAGS+= $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
 
+ifeq ($(SINGLE_MODULE),)
+
+obj-m		+= ath_rate_minstrel.o
+
 -include $(TOPDIR)/Rules.make
 
 all:
@@ -59,10 +61,9 @@ install:
 	test -d $(DESTDIR)/$(KMODPATH) || mkdir -p $(DESTDIR)/$(KMODPATH)
 	install -m 0644 ath_rate_minstrel.$(KMODSUF) $(DESTDIR)/$(KMODPATH)
 
-clean:
-	-rm -f *~ *.o *.ko *.mod.c
-	-rm -f .depend .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd
-	-rm -rf .tmp_versions
-
 ath_rate_minstrel.o: $(ath_rate_minstrel-objs)
 	$(LD) $(LDOPTS) -o ath_rate_minstrel.$(KMODSUF) -r $(ath_rate_minstrel-objs)
+else
+all:
+install:
+endif
--- a/ath_rate/minstrel/minstrel.c
+++ b/ath_rate/minstrel/minstrel.c
@@ -945,6 +945,8 @@ static struct ieee80211_rate_ops ath_rat
 		.dynamic_proc_register = ath_rate_dynamic_proc_register,
 };
 
+#include <net80211/module.h>
+
 MODULE_AUTHOR("John Bicket/Derek Smithies");
 MODULE_DESCRIPTION("Minstrel Rate bit-rate selection algorithm for Atheros devices");
 #ifdef MODULE_VERSION
--- a/net80211/ieee80211_var.h
+++ b/net80211/ieee80211_var.h
@@ -47,6 +47,7 @@
 #include <net80211/ieee80211_power.h>
 #include <net80211/ieee80211_proto.h>
 #include <net80211/ieee80211_scan.h>
+#include "symbol.h"
 
 /* NB: 
  * - Atheros chips use 6 bits when power is specified in whole dBm units, with 
@@ -741,6 +742,8 @@ void ieee80211_dfs_action(struct ieee802
 void ieee80211_expire_channel_excl_restrictions(struct ieee80211com *);
 void ieee80211_setpuregbasicrates(struct ieee80211_rateset *rs);
 int ieee80211_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
+void net80211_init_module(void);
+void net80211_exit_module(void);
 
 /*
  * Iterate through ic_channels to enumerate all distinct ic_ieee channel numbers.
--- a/net80211/ieee80211_linux.h
+++ b/net80211/ieee80211_linux.h
@@ -521,7 +521,10 @@ extern struct sk_buff * ieee80211_getmgt
 #define	IF_DRAIN(_q)		skb_queue_drain(_q)
 extern	void skb_queue_drain(struct sk_buff_head *q);
 
-#ifndef __MOD_INC_USE_COUNT
+#ifdef SINGLE_MODULE
+#define _MOD_DEC_USE(_m) do {} while(0)
+#define _MOD_INC_USE(_m, _err) do {} while(0)
+#elif !defined(__MOD_INC_USE_COUNT)
 #define	_MOD_INC_USE(_m, _err)						\
 	if (!try_module_get(_m)) {					\
 		printk(KERN_WARNING "%s: try_module_get failed\n",	\
--- a/ath_rate/sample/Makefile
+++ b/ath_rate/sample/Makefile
@@ -39,9 +39,7 @@
 # Makefile for the Atheros Rate Control Support.
 #
 obj := $(firstword $(obj) $(SUBDIRS) .)
-TOP = $(obj)/../..
 
-obj-m		+= ath_rate_sample.o
 ath_rate_sample-objs	:= sample.o
 
 include $(TOP)/Makefile.inc
@@ -50,6 +48,9 @@ INCS += -I$(TOP) -I$(ATH) -I$(ATH_HAL) -
 
 EXTRA_CFLAGS+= $(INCS) $(COPTS) -DOPT_AH_H=\"public/$(TARGET).opt_ah.h\"
 
+ifeq ($(SINGLE_MODULE),)
+obj-m		+= ath_rate_sample.o
+
 -include $(TOPDIR)/Rules.make
 
 all:
@@ -59,10 +60,9 @@ install:
 	test -d $(DESTDIR)/$(KMODPATH) || mkdir -p $(DESTDIR)/$(KMODPATH)
 	install -m 0644 ath_rate_sample.$(KMODSUF) $(DESTDIR)/$(KMODPATH)
 
-clean:
-	-rm -f *~ *.o *.ko *.mod.c
-	-rm -f .depend .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd
-	-rm -rf .tmp_versions
-
 ath_rate_sample.o: $(ath_rate_sample-objs)
 	$(LD) $(LDOPTS) -o ath_rate_sample.$(KMODSUF) -r $(ath_rate_sample-objs)
+else
+all:
+install:
+endif
--- a/Makefile
+++ b/Makefile
@@ -41,7 +41,7 @@
 #
 
 obj := $(firstword $(obj) $(SUBDIRS) .)
-TOP = $(obj)
+export TOP:=$(if $(wildcard $(firstword $(SUBDIRS))/Makefile.inc),$(firstword $(SUBDIRS)),$(CURDIR))
 
 ifneq (svnversion.h,$(MAKECMDGOALS))
 include $(TOP)/Makefile.inc
@@ -54,7 +54,7 @@ all: modules tools
 modules: configcheck svnversion.h
 ifdef LINUX24
 	for i in $(obj-y); do \
-		$(MAKE) -C $$i || exit 1; \
+		$(MAKE) -C $$i TOP="$(TOP)" || exit 1; \
 	done
 else
 	$(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules
@@ -89,7 +89,7 @@ install-modules: modules
 	sh scripts/find-madwifi-modules.sh -r $(KERNELRELEASE) $(DESTDIR)
 
 	for i in $(obj-y); do \
-		$(MAKE) -C $$i install || exit 1; \
+		$(MAKE) -C $$i install TOP="$(TOP)" || exit 1; \
 	done
 ifeq ($(DESTDIR),)
 	(export KMODPATH=$(KMODPATH); /sbin/depmod -ae $(KERNELRELEASE))
@@ -114,12 +114,21 @@ reinstall-tools: uninstall-tools install
 reinstall-modules: uninstall-modules install-modules
 
 clean:
-	for i in $(obj-y); do \
-		$(MAKE) -C $$i clean; \
-	done
-	-$(MAKE) -C $(TOOLS) clean
-	rm -rf .tmp_versions
+	-find $(obj-y) -name '*~' \
+		-or -name '*.o' \
+		-or -name '*.o.d' \
+		-or -name '*.o.cmd' \
+		-or -name '*.o.flags' \
+		-or -name '*.ko' \
+		-or -name '*.ko.cmd' \
+		-or -name '*.mod.c' \
+		-or -name '.depend' \
+		-or -name '.version' \
+		-or -name '.symvers' | \
+		xargs -r rm -f
 	rm -f *.symvers svnversion.h
+	rm -rf .tmp_versions
+	make -C tools clean
 
 info:
 	@echo "The following settings will be used for compilation:"
@@ -135,18 +144,6 @@ info:
 	@echo "KMODPATH     : $(KMODPATH)"
 	@echo "KMODSUF      : $(KMODSUF)"
 
-sanitycheck:
-	@echo -n "Checking requirements... "
-	
-	@# check if specified rate control is available
-	@if [ ! -d $(ATH_RATE) ]; then \
-	    echo "FAILED"; \
-	    echo "Selected rate control $(ATH_RATE) not available."; \
-	    exit 1; \
-	fi
-	
-	@echo "ok."
-
 .PHONY: release
 release:
 	sh scripts/make-release.bash
@@ -155,7 +152,7 @@ release:
 unload:
 	bash scripts/madwifi-unload
 
-configcheck: sanitycheck
+configcheck:
 	@echo -n "Checking kernel configuration... "
 	
 	@# check version of kernel
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -68,6 +68,9 @@ endif
 export KERNELPATH
 endif
 
+# build net80211 and ath_ahb/ath_pci into a single module
+export SINGLE_MODULE=1
+
 # KERNELRELEASE is the target kernel's version.  It's always taken from
 # the kernel build tree.  Kernel Makefile doesn't always know the exact
 # kernel version (especially for vendor stock kernels), so we get it
@@ -100,6 +103,7 @@ export ARCH
 include $(TOP)/ath_hal/ah_target.inc
 export TARGET
 COPTS += -DTARGET='"$(TARGET)"'
+COPTS += -DCONFIG_ATHEROS_RATE_DEFAULT='"$(firstword $(ATH_RATE))"'
 
 # KMODPATH nominates the directory where the modules will be
 # installed to
@@ -141,7 +145,7 @@ ATH=	$(TOP)/ath
 #
 # Path to the rate control algorithms.
 #
-ATH_RATE=	$(TOP)/ath_rate
+ATH_RATE=	minstrel
 #
 # Path to the userspace utilities. 
 # 
--- a/ath_rate/sample/sample.c
+++ b/ath_rate/sample/sample.c
@@ -991,6 +991,8 @@ static struct ieee80211_rate_ops ath_rat
 	.dynamic_proc_register = ath_rate_dynamic_proc_register,
 };
 
+#include <net80211/module.h>
+
 MODULE_AUTHOR("John Bicket");
 MODULE_DESCRIPTION("SampleRate bit-rate selection algorithm for Atheros devices");
 #ifdef MODULE_VERSION
@@ -1000,18 +1002,17 @@ MODULE_VERSION(RELEASE_VERSION);
 MODULE_LICENSE("Dual BSD/GPL");
 #endif
 
-static int __init
-init_ath_rate_sample(void)
+static int __init ath_rate_sample_init(void)
 {
 	printk(KERN_INFO "%s: %s\n", dev_info, version);
 	return ieee80211_rate_register(&ath_rate_ops);
 }
-module_init(init_ath_rate_sample);
+module_init(ath_rate_sample_init);
 
 static void __exit
-exit_ath_rate_sample(void)
+ath_rate_sample_exit(void)
 {
 	ieee80211_rate_unregister(&ath_rate_ops);
 	printk(KERN_INFO "%s: unloaded\n", dev_info);
 }
-module_exit(exit_ath_rate_sample);
+module_exit(ath_rate_sample_exit);
--- a/net80211/if_media.h
+++ b/net80211/if_media.h
@@ -42,6 +42,7 @@
 #define _NET_IF_MEDIA_H_
 
 #include <net80211/ieee80211_linux.h>
+#include "symbol.h"
 
 /*
  * Prototypes and definitions for BSD/OS-compatible network interface
--- /dev/null
+++ b/net80211/symbol.h
@@ -0,0 +1,4 @@
+#ifdef SINGLE_MODULE
+#undef EXPORT_SYMBOL
+#define EXPORT_SYMBOL(...)
+#endif
--- a/ath_rate/Makefile
+++ b/ath_rate/Makefile
@@ -1,7 +1,7 @@
 obj := $(firstword $(obj) $(SUBDIRS) .)
 TOP = $(obj)/..
 
-obj-y := amrr/ onoe/ sample/ minstrel/
+obj-y := sample/ minstrel/
 
 include $(TOP)/Makefile.inc