1diff -Naur rtl8187_orig/beta-8187/ieee80211.h rtl8187_txpower/beta-8187/ieee80211.h
2--- rtl8187_orig/beta-8187/ieee80211.h	2006-06-06 04:58:02.000000000 +0200
3+++ rtl8187_txpower/beta-8187/ieee80211.h	2007-02-26 03:05:07.691423532 +0100
4@@ -156,6 +156,22 @@
5 	struct list_head list;
6 };
7
8+#define LWNG_CAP_DID_BASE   (4 | (1 << 6)) /* section 4, group 1 */
9+/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header
10+ * (from linux-wlan-ng) */
11+struct linux_wlan_ng_val {
12+	u32 did;
13+	u16 status, len;
14+	u32 data;
15+} __attribute__ ((packed));
16+
17+struct linux_wlan_ng_prism_hdr {
18+	u32 msgcode, msglen;
19+	char devname[16];
20+	struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal,
21+		noise, rate, istx, frmlen;
22+} __attribute__ ((packed));
23+
24 struct ieee80211_hdr {
25 	u16 frame_ctl;
26 	u16 duration_id;
27@@ -840,14 +856,14 @@
28
29
30 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
31-extern inline int is_multicast_ether_addr(const u8 *addr)
32+extern inline int is_multicast_ether_addr_rtl7(const u8 *addr)
33 {
34         return ((addr[0] != 0xff) && (0x01 & addr[0]));
35 }
36 #endif
37
38 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
39-extern inline int is_broadcast_ether_addr(const u8 *addr)
40+extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr)
41 {
42 	return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&   \
43 		(addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
44@@ -1015,10 +1031,16 @@
45 	struct timer_list beacon_timer;
46
47 	struct work_struct associate_complete_wq;
48+
49+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
50+	struct delayed_work associate_retry_wq;
51+	struct delayed_work softmac_scan_wq;
52+#else
53 	struct work_struct associate_retry_wq;
54+	struct work_struct softmac_scan_wq;
55+#endif
56 	struct work_struct start_ibss_wq;
57 	struct work_struct associate_procedure_wq;
58-	struct work_struct softmac_scan_wq;
59 	struct work_struct wx_sync_scan_wq;
60
61 	struct workqueue_struct *wq;
62@@ -1154,12 +1176,12 @@
63
64
65
66-extern inline void *ieee80211_priv(struct net_device *dev)
67+extern inline void *ieee80211_priv_rtl7(struct net_device *dev)
68 {
69 	return ((struct ieee80211_device *)netdev_priv(dev))->priv;
70 }
71
72-extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
73+extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len)
74 {
75 	/* Single white space is for Linksys APs */
76 	if (essid_len == 1 && essid[0] == ' ')
77@@ -1175,7 +1197,7 @@
78 	return 1;
79 }
80
81-extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
82+extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode)
83 {
84 	/*
85 	 * It is possible for both access points and our device to support
86@@ -1201,7 +1223,7 @@
87 	return 0;
88 }
89
90-extern inline int ieee80211_get_hdrlen(u16 fc)
91+extern inline int ieee80211_get_hdrlen_rtl7(u16 fc)
92 {
93 	int hdrlen = 24;
94
95@@ -1229,140 +1251,144 @@
96
97
98 /* ieee80211.c */
99-extern void free_ieee80211(struct net_device *dev);
100-extern struct net_device *alloc_ieee80211(int sizeof_priv);
101+extern void free_ieee80211_rtl7(struct net_device *dev);
102+extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv);
103
104-extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
105+extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee);
106
107 /* ieee80211_tx.c */
108
109-extern int ieee80211_encrypt_fragment(
110+extern int ieee80211_encrypt_fragment_rtl7(
111 	struct ieee80211_device *ieee,
112 	struct sk_buff *frag,
113 	int hdr_len);
114
115-extern int ieee80211_xmit(struct sk_buff *skb,
116+extern int ieee80211_xmit_rtl7(struct sk_buff *skb,
117 			  struct net_device *dev);
118-extern void ieee80211_txb_free(struct ieee80211_txb *);
119+extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *);
120
121
122 /* ieee80211_rx.c */
123-extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
124+extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
125 			struct ieee80211_rx_stats *rx_stats);
126-extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
127+extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
128 			     struct ieee80211_hdr *header,
129 			     struct ieee80211_rx_stats *stats);
130
131 /* ieee80211_wx.c */
132-extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
133+extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
134 				 struct iw_request_info *info,
135 				 union iwreq_data *wrqu, char *key);
136-extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
137+extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
138 				   struct iw_request_info *info,
139 				   union iwreq_data *wrqu, char *key);
140-extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
141+extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
142 				   struct iw_request_info *info,
143 				   union iwreq_data *wrqu, char *key);
144 /* ieee80211_softmac.c */
145-extern short ieee80211_is_54g(struct ieee80211_network net);
146-extern short ieee80211_is_shortslot(struct ieee80211_network net);
147-extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
148+extern short ieee80211_is_54g_rtl7(struct ieee80211_network net);
149+extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net);
150+extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
151 			struct ieee80211_rx_stats *rx_stats, u16 type,
152 			u16 stype);
153-extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
154+extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net);
155
156-extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
157-extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
158-extern void ieee80211_start_bss(struct ieee80211_device *ieee);
159-extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
160-extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
161-extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
162-extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
163-extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
164-extern void ieee80211_disassociate(struct ieee80211_device *ieee);
165-extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
166-extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
167-extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
168-extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
169-extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
170-extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
171-extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
172-extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
173-extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
174-extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
175-extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
176-extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
177-extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
178-extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
179-extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
180-extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
181+extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
182+extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee);
183+extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee);
184+extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee);
185+extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee);
186+extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee);
187+extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee);
188+extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee);
189+extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee);
190+extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee);
191+extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee);
192+extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee);
193+extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee);
194+extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee);
195+extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee);
196+extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee);
197+extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee);
198+extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee);
199+extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee);
200+extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee);
201+extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee);
202+extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee);
203+extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p);
204+extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee);
205+extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success);
206
207 /* ieee80211_softmac_wx.c */
208
209-extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
210+extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
211 			    struct iw_request_info *info,
212 			    union iwreq_data *wrqu, char *ext);
213
214-extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
215+extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
216 			 struct iw_request_info *info,
217 			 union iwreq_data *awrq,
218 			 char *extra);
219
220-extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
221+extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
222
223-extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
224+extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
225 			     struct iw_request_info *info,
226 			     union iwreq_data *wrqu, char *extra);
227
228-extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
229+extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
230 			     struct iw_request_info *info,
231 			     union iwreq_data *wrqu, char *extra);
232
233-extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
234+extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
235 			     union iwreq_data *wrqu, char *b);
236
237-extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
238+extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
239 			     union iwreq_data *wrqu, char *b);
240
241-extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
242+extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
243 			      struct iw_request_info *a,
244 			      union iwreq_data *wrqu, char *extra);
245
246-extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
247+extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
248 			     union iwreq_data *wrqu, char *b);
249
250-extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
251+extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
252 			     union iwreq_data *wrqu, char *b);
253
254-extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
255+extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
256 			     union iwreq_data *wrqu, char *b);
257
258-extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
259+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
260+extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work);
261+#else
262+extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee);
263+#endif
264
265-extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
266+extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
267 			       struct iw_request_info *info,
268 			       union iwreq_data *wrqu, char *extra);
269
270-extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
271+extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
272 			     struct iw_request_info *info,
273 			     union iwreq_data *wrqu, char *extra);
274
275-extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
276+extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
277 				 struct iw_request_info *info,
278 				 union iwreq_data *wrqu, char *extra);
279
280-extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
281+extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
282 				 struct iw_request_info *info,
283 				 union iwreq_data *wrqu, char *extra);
284
285-extern const long ieee80211_wlan_frequencies[];
286+extern const long ieee80211_wlan_frequencies_rtl7[];
287
288-extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
289+extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee)
290 {
291 	ieee->scans++;
292 }
293
294-extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
295+extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee)
296 {
297 	return ieee->scans;
298 }
299@@ -1372,7 +1398,7 @@
300 	const char *s = essid;
301 	char *d = escaped;
302
303-	if (ieee80211_is_empty_essid(essid, essid_len)) {
304+	if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) {
305 		memcpy(escaped, "<hidden>", sizeof("<hidden>"));
306 		return escaped;
307 	}
308diff -Naur rtl8187_orig/beta-8187/r8180_93cx6.c rtl8187_txpower/beta-8187/r8180_93cx6.c
309--- rtl8187_orig/beta-8187/r8180_93cx6.c	2006-06-06 04:58:00.000000000 +0200
310+++ rtl8187_txpower/beta-8187/r8180_93cx6.c	2007-02-26 03:05:03.241356403 +0100
311@@ -87,7 +87,7 @@
312
313 u32 eprom_read(struct net_device *dev, u32 addr)
314 {
315-	struct r8180_priv *priv = ieee80211_priv(dev);
316+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
317 	short read_cmd[]={1,1,0};
318 	short addr_str[8];
319 	int i;
320diff -Naur rtl8187_orig/beta-8187/r8180_hw.h rtl8187_txpower/beta-8187/r8180_hw.h
321--- rtl8187_orig/beta-8187/r8180_hw.h	2006-06-06 04:58:00.000000000 +0200
322+++ rtl8187_txpower/beta-8187/r8180_hw.h	2007-02-26 03:05:07.761424588 +0100
323@@ -646,6 +646,7 @@
324 #define FFER_INTR    ((1<<15))
325 #define FFER_GWAKE   ((1<< 4))
326
327-
328+#define MAX_TX_POWER	27
329+#define MIN_TX_POWER	20
330
331 #endif
332diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.c rtl8187_txpower/beta-8187/r8180_rtl8225.c
333--- rtl8187_orig/beta-8187/r8180_rtl8225.c	2006-06-06 04:58:02.000000000 +0200
334+++ rtl8187_txpower/beta-8187/r8180_rtl8225.c	2007-02-26 03:05:03.311357459 +0100
335@@ -173,7 +173,7 @@
336
337 void rtl8225_set_gain(struct net_device *dev, short gain)
338 {
339-	struct r8180_priv *priv = ieee80211_priv(dev);
340+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
341
342 	rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
343
344@@ -208,7 +208,7 @@
345 {
346 #ifdef USE_8051_3WIRE
347
348-        struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
349+        struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
350         struct usb_device *udev = priv->udev;
351         //u8 bit;
352         u16                             wReg80, wReg82, wReg84;
353@@ -255,7 +255,7 @@
354 	u16 out,select;
355 	u8 bit;
356 	u32 bangdata = (data << 4) | (adr & 0xf);
357-	struct r8180_priv *priv = ieee80211_priv(dev);
358+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
359
360 	out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
361
362@@ -349,7 +349,7 @@
363
364 void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch)
365 {
366-	struct r8180_priv *priv = ieee80211_priv(dev);
367+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
368
369 	int GainIdx;
370 	int GainSetting;
371@@ -454,9 +454,9 @@
372
373 void rtl8225_rf_set_chan(struct net_device *dev, short ch)
374 {
375-	struct r8180_priv *priv = ieee80211_priv(dev);
376+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
377 	short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
378-		ieee80211_is_54g(priv->ieee80211->current_network)) ||
379+		ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) ||
380 		priv->ieee80211->iw_mode == IW_MODE_MONITOR;
381
382 	rtl8225_SetTXPowerLevel(dev, ch);
383@@ -474,7 +474,7 @@
384 		write_nic_byte(dev,DIFS,0x24); //DIFS: 36
385
386 	if(priv->ieee80211->state == IEEE80211_LINKED &&
387-		ieee80211_is_shortslot(priv->ieee80211->current_network))
388+		ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network))
389 		write_nic_byte(dev,SLOT,0x9); //SLOT: 9
390
391 	else
392@@ -546,7 +546,7 @@
393
394 void rtl8225_rf_init(struct net_device *dev)
395 {
396-	struct r8180_priv *priv = ieee80211_priv(dev);
397+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
398 	int i;
399 	short channel = 1;
400 	u16 brsr;
401diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225.h rtl8187_txpower/beta-8187/r8180_rtl8225.h
402--- rtl8187_orig/beta-8187/r8180_rtl8225.h	2006-06-06 04:58:00.000000000 +0200
403+++ rtl8187_txpower/beta-8187/r8180_rtl8225.h	2007-02-26 03:05:07.811425342 +0100
404@@ -44,3 +44,5 @@
405 extern u32 rtl8225_chan[];
406
407 #endif
408+
409+void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch);
410diff -Naur rtl8187_orig/beta-8187/r8180_rtl8225z2.c rtl8187_txpower/beta-8187/r8180_rtl8225z2.c
411--- rtl8187_orig/beta-8187/r8180_rtl8225z2.c	2006-06-06 04:58:02.000000000 +0200
412+++ rtl8187_txpower/beta-8187/r8180_rtl8225z2.c	2007-02-26 03:05:03.371358364 +0100
413@@ -129,7 +129,7 @@
414 void rtl8225z2_set_gain(struct net_device *dev, short gain)
415 {
416 	u8* rtl8225_gain;
417-	struct r8180_priv *priv = ieee80211_priv(dev);
418+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
419
420 	u8 mode = priv->ieee80211->mode;
421
422@@ -153,7 +153,7 @@
423
424 void rtl8225_set_gain(struct net_device *dev, short gain)
425 {
426-	struct r8180_priv *priv = ieee80211_priv(dev);
427+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
428
429 	rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
430
431@@ -280,7 +280,7 @@
432 	u16 out,select;
433 	u8 bit;
434 	u32 bangdata = (data << 4) | (adr & 0xf);
435-	struct r8180_priv *priv = ieee80211_priv(dev);
436+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
437
438 	out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
439
440@@ -396,7 +396,7 @@
441 #endif
442 void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch)
443 {
444-	struct r8180_priv *priv = ieee80211_priv(dev);
445+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
446
447 //	int GainIdx;
448 //	int GainSetting;
449@@ -418,7 +418,10 @@
450
451 	/* CCK power setting */
452 	if(cck_power_level > max_cck_power_level)
453+	{
454 		cck_power_level = max_cck_power_level;
455+		priv->chtxpwr[ch] = max_cck_power_level;
456+	}
457
458 	cck_power_level += priv->cck_txpwr_base;
459
460@@ -489,9 +492,9 @@
461
462 void rtl8225z2_rf_set_chan(struct net_device *dev, short ch)
463 {
464-	struct r8180_priv *priv = ieee80211_priv(dev);
465+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
466 	short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
467-		ieee80211_is_54g(priv->ieee80211->current_network)) ||
468+		ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) ||
469 		priv->ieee80211->iw_mode == IW_MODE_MONITOR;
470
471 	rtl8225z2_SetTXPowerLevel(dev, ch);
472@@ -509,7 +512,7 @@
473 		write_nic_byte(dev,DIFS,0x24); //DIFS: 36
474
475 	if(priv->ieee80211->state == IEEE80211_LINKED &&
476-		ieee80211_is_shortslot(priv->ieee80211->current_network))
477+		ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network))
478 		write_nic_byte(dev,SLOT,0x9); //SLOT: 9
479
480 	else
481@@ -581,7 +584,7 @@
482 #endif
483 void rtl8225z2_rf_init(struct net_device *dev)
484 {
485-	struct r8180_priv *priv = ieee80211_priv(dev);
486+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
487 	int i;
488 	short channel = 1;
489 	u16	brsr;
490@@ -958,7 +961,7 @@
491
492 void rtl8225z2_rf_set_mode(struct net_device *dev)
493 {
494-	struct r8180_priv *priv = ieee80211_priv(dev);
495+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
496
497 	if(priv->ieee80211->mode == IEEE_A)
498 	{
499diff -Naur rtl8187_orig/beta-8187/r8180_wx.c rtl8187_txpower/beta-8187/r8180_wx.c
500--- rtl8187_orig/beta-8187/r8180_wx.c	2006-06-06 04:58:02.000000000 +0200
501+++ rtl8187_txpower/beta-8187/r8180_wx.c	2007-02-26 03:05:03.371358364 +0100
502@@ -21,6 +21,7 @@
503
504 #include "r8187.h"
505 #include "r8180_hw.h"
506+#include "r8180_rtl8225.h"
507
508
509 #define RATE_COUNT 4
510@@ -32,9 +33,9 @@
511 			     struct iw_request_info *a,
512 			     union iwreq_data *wrqu, char *b)
513 {
514-	struct r8180_priv *priv = ieee80211_priv(dev);
515+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
516
517-	return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b);
518+	return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b);
519 }
520
521
522@@ -46,7 +47,7 @@
523 	int *parms = (int *)b;
524 	int bi = parms[0];
525
526-	struct r8180_priv *priv = ieee80211_priv(dev);
527+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
528
529 	down(&priv->wx_sem);
530 	DMESG("setting beacon interval to %x",bi);
531@@ -62,7 +63,7 @@
532 static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa,
533 			  union iwreq_data *wrqu, char *extra)
534 {
535-	struct r8180_priv *priv=ieee80211_priv(dev);
536+	struct r8180_priv *priv=ieee80211_priv_rtl7(dev);
537 	int *parms = (int *)extra;
538
539 	priv->ieee80211->force_associate = (parms[0] > 0);
540@@ -75,9 +76,9 @@
541 static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
542 			     union iwreq_data *wrqu, char *b)
543 {
544-	struct r8180_priv *priv=ieee80211_priv(dev);
545+	struct r8180_priv *priv=ieee80211_priv_rtl7(dev);
546
547-	return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b);
548+	return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b);
549 }
550
551
552@@ -86,8 +87,8 @@
553 			     struct iw_request_info *info,
554 			     union iwreq_data *wrqu, char *extra)
555 {
556-	struct r8180_priv *priv = ieee80211_priv(dev);
557-	return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra);
558+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
559+	return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra);
560 }
561
562
563@@ -97,27 +98,83 @@
564 			     union iwreq_data *wrqu, char *extra)
565 {
566 	int ret;
567-	struct r8180_priv *priv = ieee80211_priv(dev);
568+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
569
570 	down(&priv->wx_sem);
571+	ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra);
572+
573+	up(&priv->wx_sem);
574+
575+	return ret;
576+}
577+
578+static int r8180_wx_get_txpow(struct net_device *dev,
579+			      struct iw_request_info *info,
580+			      union iwreq_data *wrqu, char *extra)
581+{
582+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
583+	down(&priv->wx_sem);
584+	wrqu->power.value = priv->chtxpwr_ofdm[1] + MIN_TX_POWER;
585+	wrqu->power.fixed = 1;
586+	wrqu->power.flags = IW_TXPOW_DBM;
587+	wrqu->power.disabled = 0;
588+	up(&priv->wx_sem);
589
590-	ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra);
591+	return 0;
592+}
593+
594+#if 0
595+static int r8180_wx_set_txpow(struct net_device *dev,
596+			      struct iw_request_info *info,
597+			      union iwreq_data *wrqu, char *extra)
598+{
599+	int ret = 0, i = 0;
600+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
601
602+	down(&priv->wx_sem);
603+
604+	if (wrqu->power.flags != IW_TXPOW_DBM)
605+	{
606+		ret = -EINVAL;
607+		goto out;
608+	}
609+
610+	if(wrqu->power.value > MAX_TX_POWER)
611+	{
612+		ret = -EINVAL;
613+		goto out;
614+	}
615+
616+	if(wrqu->power.value < MIN_TX_POWER)
617+	{
618+		ret = -EINVAL;
619+		goto out;
620+	}
621+
622+	for(i=1;i<=14;i++)
623+	{
624+		priv->chtxpwr[i] = wrqu->power.value + 1 - MIN_TX_POWER;
625+		priv->chtxpwr_ofdm[i] = wrqu->power.value - MIN_TX_POWER;
626+	}
627+	rtl8225z2_SetTXPowerLevel(dev, 1);
628+
629+	out:
630 	up(&priv->wx_sem);
631
632 	return ret;
633 }
634+#endif
635
636 static int r8180_wx_set_rawtx(struct net_device *dev,
637 			       struct iw_request_info *info,
638 			       union iwreq_data *wrqu, char *extra)
639 {
640-	struct r8180_priv *priv = ieee80211_priv(dev);
641+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
642 	int ret;
643
644 	down(&priv->wx_sem);
645
646-	ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra);
647+	ret = ieee80211_wx_set_rawtx_rtl7(priv->ieee80211, info, wrqu, extra);
648
649 	up(&priv->wx_sem);
650
651@@ -129,7 +186,7 @@
652 			       struct iw_request_info *info,
653 			       union iwreq_data *wrqu, char *extra)
654 {
655-	struct r8180_priv *priv = ieee80211_priv(dev);
656+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
657 	int *parms = (int *)extra;
658 	int enable = (parms[0] > 0);
659 	short prev = priv->crcmon;
660@@ -157,12 +214,12 @@
661 static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
662 			     union iwreq_data *wrqu, char *b)
663 {
664-	struct r8180_priv *priv = ieee80211_priv(dev);
665+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
666 	int ret;
667
668 	down(&priv->wx_sem);
669
670-	ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b);
671+	ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b);
672
673 	rtl8187_set_rxconf(dev);
674
675@@ -176,7 +233,7 @@
676 				union iwreq_data *wrqu, char *extra)
677 {
678 	struct iw_range *range = (struct iw_range *)extra;
679-	struct r8180_priv *priv = ieee80211_priv(dev);
680+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
681 	u16 val;
682 	int i;
683
684@@ -247,7 +304,7 @@
685 		// Include only legal frequencies for some countries
686 		if ((priv->challow)[i+1]) {
687 		        range->freq[val].i = i + 1;
688-			range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000;
689+			range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000;
690 			range->freq[val].e = 1;
691 			val++;
692 		} else {
693@@ -267,14 +324,14 @@
694 static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
695 			     union iwreq_data *wrqu, char *b)
696 {
697-	struct r8180_priv *priv = ieee80211_priv(dev);
698+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
699 	int ret;
700
701 	if(!priv->up) return -1;
702
703 	down(&priv->wx_sem);
704
705-	ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b);
706+	ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b);
707
708 	up(&priv->wx_sem);
709 	return ret;
710@@ -286,13 +343,13 @@
711 {
712
713 	int ret;
714-	struct r8180_priv *priv = ieee80211_priv(dev);
715+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
716
717 	if(!priv->up) return -1;
718
719 	down(&priv->wx_sem);
720
721-	ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b);
722+	ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b);
723
724 	up(&priv->wx_sem);
725
726@@ -304,13 +361,13 @@
727 			      struct iw_request_info *a,
728 			      union iwreq_data *wrqu, char *b)
729 {
730-	struct r8180_priv *priv = ieee80211_priv(dev);
731+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
732
733 	int ret;
734
735 	down(&priv->wx_sem);
736
737-	ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b);
738+	ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b);
739
740 	up(&priv->wx_sem);
741 	return ret;
742@@ -322,11 +379,11 @@
743 			      union iwreq_data *wrqu, char *b)
744 {
745 	int ret;
746-	struct r8180_priv *priv = ieee80211_priv(dev);
747+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
748
749 	down(&priv->wx_sem);
750
751-	ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b);
752+	ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b);
753
754 	up(&priv->wx_sem);
755
756@@ -338,11 +395,11 @@
757 			     union iwreq_data *wrqu, char *b)
758 {
759 	int ret;
760-	struct r8180_priv *priv = ieee80211_priv(dev);
761+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
762
763 	down(&priv->wx_sem);
764
765-	ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b);
766+	ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b);
767
768 	up(&priv->wx_sem);
769 	return ret;
770@@ -352,8 +409,8 @@
771 			     struct iw_request_info *info,
772 			     union iwreq_data *wrqu, char *extra)
773 {
774-	struct r8180_priv *priv = ieee80211_priv(dev);
775-	return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra);
776+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
777+	return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra);
778 }
779
780
781@@ -361,7 +418,7 @@
782 			     struct iw_request_info *info,
783 			     union iwreq_data *wrqu, char *extra)
784 {
785-	struct r8180_priv *priv = ieee80211_priv(dev);
786+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
787
788 	if (wrqu->frag.disabled)
789 		priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
790@@ -381,7 +438,7 @@
791 			     struct iw_request_info *info,
792 			     union iwreq_data *wrqu, char *extra)
793 {
794-	struct r8180_priv *priv = ieee80211_priv(dev);
795+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
796
797 	wrqu->frag.value = priv->ieee80211->fts;
798 	wrqu->frag.fixed = 0;	/* no auto select */
799@@ -397,11 +454,11 @@
800 			 char *extra)
801 {
802 	int ret;
803-	struct r8180_priv *priv = ieee80211_priv(dev);
804+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
805
806 	down(&priv->wx_sem);
807
808-	ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra);
809+	ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra);
810
811 	up(&priv->wx_sem);
812 	return ret;
813@@ -413,9 +470,9 @@
814 			    struct iw_request_info *info,
815 			    union iwreq_data *wrqu, char *extra)
816 {
817-	struct r8180_priv *priv = ieee80211_priv(dev);
818+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
819
820-	return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra);
821+	return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra);
822 }
823
824
825@@ -423,22 +480,22 @@
826 			    struct iw_request_info *info,
827 			    union iwreq_data *wrqu, char *key)
828 {
829-	struct r8180_priv *priv = ieee80211_priv(dev);
830+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
831
832-	return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key);
833+	return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key);
834 }
835
836 static int r8180_wx_set_enc(struct net_device *dev,
837 			    struct iw_request_info *info,
838 			    union iwreq_data *wrqu, char *key)
839 {
840-	struct r8180_priv *priv = ieee80211_priv(dev);
841+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
842 	int ret;
843
844 	down(&priv->wx_sem);
845
846 		DMESG("Setting SW wep key");
847-		ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key);
848+		ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key);
849
850 	up(&priv->wx_sem);
851 	return ret;
852@@ -448,7 +505,7 @@
853 static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union
854  iwreq_data *wrqu, char *p){
855
856- 	struct r8180_priv *priv = ieee80211_priv(dev);
857+ 	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
858 	int *parms=(int*)p;
859 	int mode=parms[0];
860
861@@ -463,7 +520,7 @@
862 				struct iw_request_info *info,
863 				union iwreq_data *wrqu, char *extra)
864 {
865-	struct r8180_priv *priv = ieee80211_priv(dev);
866+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
867 	int err = 0;
868
869 	down(&priv->wx_sem);
870@@ -516,7 +573,7 @@
871 				struct iw_request_info *info,
872 				union iwreq_data *wrqu, char *extra)
873 {
874-	struct r8180_priv *priv = ieee80211_priv(dev);
875+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
876
877
878 	wrqu->retry.disabled = 0; /* can't be disabled */
879@@ -542,7 +599,7 @@
880 				struct iw_request_info *info,
881 				union iwreq_data *wrqu, char *extra)
882 {
883-	struct r8180_priv *priv = ieee80211_priv(dev);
884+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
885 	if(priv->rf_set_sens == NULL)
886 		return -1; /* we have not this support for this radio */
887 	wrqu->sens.value = priv->sens;
888@@ -555,7 +612,7 @@
889 				union iwreq_data *wrqu, char *extra)
890 {
891
892-	struct r8180_priv *priv = ieee80211_priv(dev);
893+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
894
895 	short err = 0;
896 	down(&priv->wx_sem);
897@@ -624,7 +681,7 @@
898         r8180_wx_set_frag,        /* SIOCSIWFRAG */
899         r8180_wx_get_frag,        /* SIOCGIWFRAG */
900         dummy,                    /* SIOCSIWTXPOW */
901-        dummy,                    /* SIOCGIWTXPOW */
902+        r8180_wx_get_txpow,       /* SIOCGIWTXPOW */
903         r8180_wx_set_retry,       /* SIOCSIWRETRY */
904         r8180_wx_get_retry,       /* SIOCGIWRETRY */
905         r8180_wx_set_enc,         /* SIOCSIWENCODE */
906@@ -666,7 +723,7 @@
907 #if WIRELESS_EXT >= 17
908 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
909 {
910-       struct r8180_priv *priv = ieee80211_priv(dev);
911+       struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
912
913        return &priv->wstats;
914 }
915diff -Naur rtl8187_orig/beta-8187/r8187_core.c rtl8187_txpower/beta-8187/r8187_core.c
916--- rtl8187_orig/beta-8187/r8187_core.c	2006-06-22 07:43:30.000000000 +0200
917+++ rtl8187_txpower/beta-8187/r8187_core.c	2007-02-26 03:05:03.381358515 +0100
918@@ -57,6 +57,7 @@
919 #undef DEBUG_IRQ_TASKLET
920 #undef DEBUG_TX_ALLOC
921 #undef DEBUG_TX_DESC
922+#undef DEBUG_TX_POWER
923
924 //#define CONFIG_RTL8180_IO_MAP
925
926@@ -98,6 +99,10 @@
927 #endif
928 static int channels = 0x3fff;
929
930+#define DEBUG_EPROM
931+#define DEBUG_REGISTERS
932+#define DEBUG_TX_POWER
933+
934 MODULE_LICENSE("GPL");
935 MODULE_VERSION("V 1.1");
936 MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl);
937@@ -158,11 +163,10 @@
938 #endif
939 };
940
941-
942 void write_nic_byte_E(struct net_device *dev, int indx, u8 data)
943 {
944
945-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
946+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
947 	struct usb_device *udev = priv->udev;
948
949 	usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
950@@ -174,7 +178,7 @@
951 void write_nic_byte(struct net_device *dev, int indx, u8 data)
952 {
953
954-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
955+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
956 	struct usb_device *udev = priv->udev;
957
958 	usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
959@@ -186,7 +190,7 @@
960 void write_nic_word(struct net_device *dev, int indx, u16 data)
961 {
962
963-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
964+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
965 	struct usb_device *udev = priv->udev;
966
967 	usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
968@@ -198,7 +202,7 @@
969 void write_nic_dword(struct net_device *dev, int indx, u32 data)
970 {
971
972-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
973+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
974 	struct usb_device *udev = priv->udev;
975
976 	usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
977@@ -211,7 +215,7 @@
978 u8 read_nic_byte(struct net_device *dev, int indx)
979 {
980 	u8 data;
981-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
982+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
983 	struct usb_device *udev = priv->udev;
984
985 	usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
986@@ -223,7 +227,7 @@
987 u8 read_nic_byte_E(struct net_device *dev, int indx)
988 {
989 	u8 data;
990-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
991+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
992 	struct usb_device *udev = priv->udev;
993
994 	usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
995@@ -236,7 +240,7 @@
996 u16 read_nic_word(struct net_device *dev, int indx)
997 {
998 	u16 data;
999-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1000+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1001 	struct usb_device *udev = priv->udev;
1002
1003 	usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
1004@@ -249,7 +253,7 @@
1005 u32 read_nic_dword(struct net_device *dev, int indx)
1006 {
1007 	u32 data;
1008-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1009+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1010 	struct usb_device *udev = priv->udev;
1011
1012 	usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
1013@@ -271,7 +275,12 @@
1014 //void set_nic_txring(struct net_device *dev);
1015 static struct net_device_stats *rtl8180_stats(struct net_device *dev);
1016 void rtl8180_commit(struct net_device *dev);
1017+
1018+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
1019+void rtl8180_restart(struct work_struct *work);
1020+#else
1021 void rtl8180_restart(struct net_device *dev);
1022+#endif
1023
1024 /****************************************************************************
1025    -----------------------------PROCFS STUFF-------------------------
1026@@ -284,7 +293,7 @@
1027 			  int *eof, void *data)
1028 {
1029 	struct net_device *dev = data;
1030-//	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1031+//	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1032
1033 	int len = 0;
1034 	int i,n;
1035@@ -319,7 +328,7 @@
1036 			  int *eof, void *data)
1037 {
1038 	struct net_device *dev = data;
1039-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1040+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1041
1042 	int len = 0;
1043
1044@@ -339,7 +348,7 @@
1045 			  int *eof, void *data)
1046 {
1047 	struct net_device *dev = data;
1048-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1049+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1050
1051 	int len = 0;
1052
1053@@ -391,7 +400,7 @@
1054 			  int *eof, void *data)
1055 {
1056 	struct net_device *dev = data;
1057-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1058+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1059
1060 	int len = 0;
1061
1062@@ -407,13 +416,14 @@
1063 	return len;
1064 }
1065
1066-
1067+#if WIRELESS_EXT < 17
1068 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
1069 {
1070-       struct r8180_priv *priv = ieee80211_priv(dev);
1071+       struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1072
1073        return &priv->wstats;
1074 }
1075+#endif
1076
1077 void rtl8180_proc_module_init(void)
1078 {
1079@@ -430,7 +440,7 @@
1080
1081 void rtl8180_proc_remove_one(struct net_device *dev)
1082 {
1083-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1084+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1085 	if (priv->dir_dev) {
1086 	//	remove_proc_entry("stats-hw", priv->dir_dev);
1087 		remove_proc_entry("stats-tx", priv->dir_dev);
1088@@ -447,7 +457,7 @@
1089 void rtl8180_proc_init_one(struct net_device *dev)
1090 {
1091 	struct proc_dir_entry *e;
1092-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1093+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1094 	priv->dir_dev = create_proc_entry(dev->name,
1095 					  S_IFDIR | S_IRUGO | S_IXUGO,
1096 					  rtl8180_proc);
1097@@ -539,7 +549,7 @@
1098
1099 short check_nic_enought_desc(struct net_device *dev, priority_t priority)
1100 {
1101-	struct r8180_priv *priv = ieee80211_priv(dev);
1102+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1103
1104 	int used = atomic_read((priority == NORM_PRIORITY) ?
1105 		&priv->tx_np_pending : &priv->tx_lp_pending);
1106@@ -549,7 +559,7 @@
1107
1108 void tx_timeout(struct net_device *dev)
1109 {
1110-	struct r8180_priv *priv = ieee80211_priv(dev);
1111+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1112 	//rtl8180_commit(dev);
1113 	schedule_work(&priv->reset_wq);
1114 	//DMESG("TXTIMEOUT");
1115@@ -561,7 +571,20 @@
1116 {
1117 	int i;
1118 	for(i=0; i<63; i++)
1119-		DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i));
1120+		DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i));
1121+}
1122+
1123+/* this is only for debug */
1124+void dump_tx_power(struct net_device *dev)
1125+{
1126+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1127+	int i;
1128+	DMESG("CCK TX-Power (b-mode):");
1129+	for(i=1; i<=14; i++)
1130+		DMESG("Channel %d: %d", i, priv->chtxpwr[i]);
1131+	DMESG("OFDM TX-Power (g-mode):");
1132+	for(i=1; i<=14; i++)
1133+		DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]);
1134 }
1135
1136 /* this is only for debug */
1137@@ -575,9 +598,9 @@
1138
1139 	for(n=0;n<=max;)
1140 	{
1141-		printk( "\nD: %2x> ", n);
1142+		printk( "\nD: %02X> ", n);
1143 		for(i=0;i<16 && n<=max;i++,n++)
1144-			printk("%2x ",read_nic_byte(dev,n));
1145+			printk("%02X ",read_nic_byte(dev,n));
1146 	}
1147 	printk("\n");
1148 }
1149@@ -589,7 +612,7 @@
1150
1151 void rtl8180_irq_enable(struct net_device *dev)
1152 {
1153-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1154+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1155 	//priv->irq_enabled = 1;
1156 /*
1157 	write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\
1158@@ -603,7 +626,7 @@
1159
1160 void rtl8180_irq_disable(struct net_device *dev)
1161 {
1162-//	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1163+//	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1164
1165 	write_nic_word(dev,INTA_MASK,0);
1166 	force_pci_posting(dev);
1167@@ -625,7 +648,7 @@
1168
1169 void rtl8180_update_msr(struct net_device *dev)
1170 {
1171-	struct r8180_priv *priv = ieee80211_priv(dev);
1172+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1173 	u8 msr;
1174
1175 	msr  = read_nic_byte(dev, MSR);
1176@@ -653,7 +676,7 @@
1177
1178 void rtl8180_set_chan(struct net_device *dev,short ch)
1179 {
1180-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1181+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1182 	u32 tx;
1183 	priv->chan=ch;
1184 	#if 0
1185@@ -670,20 +693,20 @@
1186 	tx = read_nic_dword(dev,TX_CONF);
1187 	tx &= ~TX_LOOPBACK_MASK;
1188
1189-#ifndef LOOP_TEST
1190+#ifndef LOOP_TEST
1191 	write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<<TX_LOOPBACK_SHIFT));
1192-
1193 	priv->rf_set_chan(dev,priv->chan);
1194 	mdelay(10);
1195-	write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
1196+ 	write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
1197 #endif
1198 }
1199+
1200 void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs);
1201
1202
1203 void rtl8187_rx_urbsubmit(struct net_device *dev, struct urb* rx_urb)
1204 {
1205-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1206+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1207 	int err;
1208
1209 //	u8 *rx;
1210@@ -710,7 +733,7 @@
1211 void rtl8187_rx_initiate(struct net_device *dev)
1212 {
1213 	int i;
1214-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1215+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1216
1217 	if(!priv->rx_urb)
1218 		DMESGE("Cannot intiate RX urb mechanism");
1219@@ -721,7 +744,7 @@
1220
1221 void rtl8187_set_rxconf(struct net_device *dev)
1222 {
1223-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1224+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1225 	u32 rxconf;
1226
1227 	rxconf=read_nic_dword(dev,RX_CONF);
1228@@ -810,7 +833,7 @@
1229 	u8 cmd;
1230 	u8 byte;
1231 	u32 txconf;
1232-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1233+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1234
1235 	byte = read_nic_byte(dev,CW_CONF);
1236 	byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT);
1237@@ -889,7 +912,7 @@
1238 #if 0
1239 void rtl8180_beacon_tx_enable(struct net_device *dev)
1240 {
1241-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1242+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1243 	priv->dma_poll_mask &=~(1<<TX_DMA_STOP_BEACON_SHIFT);
1244 	rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
1245 	write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
1246@@ -900,7 +923,7 @@
1247 void rtl8180_
1248 _disable(struct net_device *dev)
1249 {
1250-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1251+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1252 	priv->dma_poll_mask |= (1<<TX_DMA_STOP_BEACON_SHIFT);
1253 	rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
1254 	write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
1255@@ -914,7 +937,7 @@
1256 {
1257 	u8 cmd;
1258 	int i;
1259-	struct r8180_priv *priv = ieee80211_priv(dev);
1260+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1261
1262 	cmd=read_nic_byte(dev,CMD);
1263 	write_nic_byte(dev, CMD, cmd &~ \
1264@@ -939,7 +962,7 @@
1265 	#if 0
1266 	int i;
1267 	u32 *tmp;
1268-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1269+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1270
1271 	priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev,
1272 					  sizeof(u32)*8*count,
1273@@ -1051,7 +1074,7 @@
1274 void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs)
1275 {
1276 	struct net_device *dev = (struct net_device*)rx_urb->context;
1277-	struct r8180_priv *priv = ieee80211_priv(dev);
1278+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1279
1280 	priv->rxurb_task = rx_urb;
1281 //	DMESGW("David: Rx tasklet start!");
1282@@ -1062,7 +1085,7 @@
1283 #if 0
1284 void rtl8180_tx_queues_stop(struct net_device *dev)
1285 {
1286-	//struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1287+	//struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1288 	u8 dma_poll_mask = (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
1289 	dma_poll_mask |= (1<<TX_DMA_STOP_HIPRIORITY_SHIFT);
1290 	dma_poll_mask |= (1<<TX_DMA_STOP_NORMPRIORITY_SHIFT);
1291@@ -1078,7 +1101,7 @@
1292 {
1293 	//FIXME !!
1294 	#if 0
1295-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1296+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1297 	priv->dma_poll_mask |= (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
1298 	rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
1299 	write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
1300@@ -1091,7 +1114,7 @@
1301 {
1302 	// FIXME !!
1303 	#if 0
1304-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1305+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1306 	priv->dma_poll_mask &= ~(1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
1307 	rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
1308 	write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
1309@@ -1105,14 +1128,17 @@
1310  */
1311 void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
1312 {
1313-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1314+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1315
1316 	short morefrag = 0;
1317 	unsigned long flags;
1318 	struct ieee80211_hdr *h = (struct ieee80211_hdr  *) skb->data;
1319
1320 	if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS)
1321-		morefrag = 1;
1322+	{
1323+		if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1)
1324+			morefrag = 1;
1325+	}
1326 //	DMESG("%x %x", h->frame_ctl, h->seq_ctl);
1327 	/*
1328 	* This function doesn't require lock because we make
1329@@ -1126,7 +1152,7 @@
1330 	//DMESG("TX");
1331 	if (!check_nic_enought_desc(dev, LOW_PRIORITY)){
1332 		DMESG("Error: no TX slot ");
1333-		ieee80211_stop_queue(priv->ieee80211);
1334+		ieee80211_stop_queue_rtl7(priv->ieee80211);
1335 	}
1336
1337 	rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag,
1338@@ -1135,7 +1161,7 @@
1339 	priv->stats.txdatapkt++;
1340
1341 	if (!check_nic_enought_desc(dev, LOW_PRIORITY))
1342-		ieee80211_stop_queue(priv->ieee80211);
1343+		ieee80211_stop_queue_rtl7(priv->ieee80211);
1344
1345 	spin_unlock_irqrestore(&priv->tx_lock,flags);
1346
1347@@ -1148,7 +1174,7 @@
1348  */
1349 int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
1350 {
1351-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1352+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1353 	int ret;
1354 	unsigned long flags;
1355
1356@@ -1228,7 +1254,7 @@
1357 void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs)
1358 {
1359 	struct net_device *dev = (struct net_device*)tx_urb->context;
1360-	struct r8180_priv *priv = ieee80211_priv(dev);
1361+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1362 	if(tx_urb->status == 0)
1363 		priv->stats.txlpokint++;
1364 	else
1365@@ -1259,7 +1285,7 @@
1366 void rtl8187_net_update(struct net_device *dev)
1367 {
1368
1369-	struct r8180_priv *priv = ieee80211_priv(dev);
1370+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1371 	struct ieee80211_network *net;
1372 	net = & priv->ieee80211->current_network;
1373
1374@@ -1283,13 +1309,13 @@
1375 void rtl8187_beacon_tx(struct net_device *dev)
1376 {
1377
1378-	struct r8180_priv *priv = ieee80211_priv(dev);
1379+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1380 	struct sk_buff *skb;
1381 	int i = 0;
1382
1383 	rtl8187_net_update(dev);
1384
1385-	skb = ieee80211_get_beacon(priv->ieee80211);
1386+	skb = ieee80211_get_beacon_rtl7(priv->ieee80211);
1387
1388
1389 	if(!skb){
1390@@ -1327,7 +1353,7 @@
1391 void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs)
1392 {
1393 	struct net_device *dev = (struct net_device*)tx_urb->context;
1394-	struct r8180_priv *priv = ieee80211_priv(dev);
1395+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1396 	if(tx_urb->status == 0)
1397 		priv->stats.txnpokint++;
1398 	else
1399@@ -1353,7 +1379,7 @@
1400 	int status;
1401 	struct urb *tx_urb;
1402 	int urb_len;
1403-	struct r8180_priv *priv = ieee80211_priv(dev);
1404+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1405 //	int rate = ieeerate2rtlrate(priv->ieee80211->rate);
1406
1407 	pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
1408@@ -1445,7 +1471,7 @@
1409
1410 short rtl8187_usb_initendpoints(struct net_device *dev)
1411 {
1412-	struct r8180_priv *priv = ieee80211_priv(dev);
1413+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1414 	int i;
1415
1416 	priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL);
1417@@ -1483,7 +1509,7 @@
1418
1419 void rtl8187_usb_deleteendpoints(struct net_device *dev)
1420 {
1421-	struct r8180_priv *priv = ieee80211_priv(dev);
1422+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1423 	int i;
1424
1425 	if(priv->rx_urb){
1426@@ -1506,9 +1532,9 @@
1427 	u16 word;
1428 	int basic_rate,min_rr_rate,max_rr_rate;
1429
1430-//	struct r8180_priv *priv = ieee80211_priv(dev);
1431+//	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1432
1433-	//if (ieee80211_is_54g(priv->ieee80211->current_network) &&
1434+	//if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) &&
1435 //		priv->ieee80211->state == IEEE80211_LINKED){
1436 	basic_rate = ieeerate2rtlrate(240);
1437 	min_rr_rate = ieeerate2rtlrate(60);
1438@@ -1540,7 +1566,7 @@
1439 {
1440 //	int i;
1441
1442-	struct r8180_priv *priv = ieee80211_priv(dev);
1443+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1444 	//write_nic_word(dev, BintrItv, net->beacon_interval);
1445 	rtl8187_net_update(dev);
1446 	/*update timing params*/
1447@@ -1554,13 +1580,13 @@
1448 short rtl8180_init(struct net_device *dev)
1449 {
1450
1451-	struct r8180_priv *priv = ieee80211_priv(dev);
1452+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1453 	int i, j;
1454 	u16 word;
1455-	int ch;
1456+	int ch, chans;
1457 	//u16 version;
1458-	//u8 hw_version;
1459-	//u8 config3;
1460+	u8 hw_version;
1461+	u8 config3;
1462
1463 	//FIXME: these constants are placed in a bad pleace.
1464
1465@@ -1580,6 +1606,13 @@
1466 		return -1;
1467 	}
1468 	ch=channels;
1469+	chans=0;
1470+	for (i=1; i<=14; i++) {
1471+		if( (u8)(ch & 0x01) ) chans++;
1472+		ch >>= 1;
1473+	}
1474+	DMESG("Enabling %d channels.", chans);
1475+	ch=channels;
1476 	 // set channels 1..14 allowed in given locale
1477 	for (i=1; i<=14; i++) {
1478 		(priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01);
1479@@ -1588,6 +1621,8 @@
1480 	//memcpy(priv->stats,0,sizeof(struct Stats));
1481
1482 	//priv->irq_enabled=0;
1483+
1484+	priv->dev = dev;
1485
1486 //	priv->stats.rxdmafail=0;
1487 	priv->stats.txrdu=0;
1488@@ -1622,7 +1657,11 @@
1489 	priv->ieee80211->mode = IEEE_G;
1490 	priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0;
1491 	spin_lock_init(&priv->tx_lock);
1492+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
1493 	INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev);
1494+#else
1495+	INIT_WORK(&priv->reset_wq, rtl8180_restart);
1496+#endif
1497 	sema_init(&priv->wx_sem,1);
1498 	tasklet_init(&priv->irq_rx_tasklet,
1499 		     (void(*)(unsigned long))rtl8180_irq_rx_tasklet,
1500@@ -1716,6 +1755,12 @@
1501 	priv->enable_gpio0 = 0;
1502
1503
1504+	hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT;
1505+	config3 = read_nic_byte(dev, CONFIG3);
1506+
1507+	DMESG("MAC chip version: %02X", hw_version);
1508+	DMESG("Card type: %02X", config3);
1509+
1510 	/* commented out just because we already do
1511 	   this when resetting the card
1512 	   andrea 20050924
1513@@ -1807,6 +1852,12 @@
1514
1515
1516 	priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID);
1517+
1518+#ifdef DEBUG_TX_POWER
1519+	dump_tx_power(dev);
1520+#endif
1521+
1522+	DMESG("RF Chip ID: %02X", priv->rf_chip);
1523
1524 	word = eprom_read(dev,EPROM_TXPW_BASE);
1525 	priv->cck_txpwr_base = word & 0xf;
1526@@ -1988,7 +2039,7 @@
1527
1528 void rtl8180_adapter_start(struct net_device *dev)
1529 {
1530-        struct r8180_priv *priv = ieee80211_priv(dev);
1531+        struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1532 	//u32 anaparam;
1533 	//u8 config3;
1534
1535@@ -2077,7 +2128,7 @@
1536 void rtl8180_start_tx_beacon(struct net_device *dev)
1537 {
1538 	int i;
1539-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1540+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1541 	u16 word;
1542 	DMESG("Enabling beacon TX");
1543 	//write_nic_byte(dev, 0x42,0xe6);// TCR
1544@@ -2135,7 +2186,7 @@
1545 ***************************************************************************/
1546 static struct net_device_stats *rtl8180_stats(struct net_device *dev)
1547 {
1548-	struct r8180_priv *priv = ieee80211_priv(dev);
1549+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1550
1551 	return &priv->ieee80211->stats;
1552 }
1553@@ -2143,36 +2194,32 @@
1554
1555 int _rtl8180_up(struct net_device *dev)
1556 {
1557-	struct r8180_priv *priv = ieee80211_priv(dev);
1558+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1559
1560 	priv->up=1;
1561
1562-	//DMESG("Bringing up iface");
1563+// 	DMESG("Bringing up iface");
1564
1565 	rtl8180_adapter_start(dev);
1566-
1567 	rtl8180_rx_enable(dev);
1568-
1569 	rtl8180_tx_enable(dev);
1570-
1571-	ieee80211_softmac_start_protocol(priv->ieee80211);
1572-
1573-	ieee80211_reset_queue(priv->ieee80211);
1574+	ieee80211_softmac_start_protocol_rtl7(priv->ieee80211);
1575+	ieee80211_reset_queue_rtl7(priv->ieee80211);
1576 	if(!netif_queue_stopped(dev))
1577 		netif_start_queue(dev);
1578 	else
1579 		netif_wake_queue(dev);
1580-
1581 	return 0;
1582 }
1583
1584
1585 int rtl8180_open(struct net_device *dev)
1586 {
1587-	struct r8180_priv *priv = ieee80211_priv(dev);
1588+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1589 	int ret;
1590
1591 	down(&priv->wx_sem);
1592+
1593 	ret = rtl8180_up(dev);
1594 	up(&priv->wx_sem);
1595 	return ret;
1596@@ -2182,7 +2229,7 @@
1597
1598 int rtl8180_up(struct net_device *dev)
1599 {
1600-	struct r8180_priv *priv = ieee80211_priv(dev);
1601+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1602
1603 	if (priv->up == 1) return -1;
1604
1605@@ -2192,7 +2239,7 @@
1606
1607 int rtl8180_close(struct net_device *dev)
1608 {
1609-	struct r8180_priv *priv = ieee80211_priv(dev);
1610+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1611 	int ret;
1612
1613 	down(&priv->wx_sem);
1614@@ -2207,7 +2254,7 @@
1615
1616 int rtl8180_down(struct net_device *dev)
1617 {
1618-	struct r8180_priv *priv = ieee80211_priv(dev);
1619+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1620
1621 	if (priv->up == 0) return -1;
1622
1623@@ -2220,7 +2267,7 @@
1624 	rtl8180_rtx_disable(dev);
1625 	rtl8180_irq_disable(dev);
1626
1627-	ieee80211_softmac_stop_protocol(priv->ieee80211);
1628+	ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211);
1629
1630 	return 0;
1631 }
1632@@ -2228,23 +2275,28 @@
1633
1634 void rtl8180_commit(struct net_device *dev)
1635 {
1636-	struct r8180_priv *priv = ieee80211_priv(dev);
1637+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1638
1639 	if (priv->up == 0) return ;
1640
1641-	ieee80211_softmac_stop_protocol(priv->ieee80211);
1642+	ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211);
1643
1644 	rtl8180_irq_disable(dev);
1645 	rtl8180_rtx_disable(dev);
1646 	_rtl8180_up(dev);
1647 }
1648
1649+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
1650+void rtl8180_restart(struct work_struct *work)
1651+{
1652+	struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq);
1653+	struct net_device *dev = priv->dev;
1654+#else
1655 void rtl8180_restart(struct net_device *dev)
1656 {
1657-	struct r8180_priv *priv = ieee80211_priv(dev);
1658-
1659+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1660+#endif
1661 	down(&priv->wx_sem);
1662-
1663 	rtl8180_commit(dev);
1664
1665 	up(&priv->wx_sem);
1666@@ -2252,7 +2304,7 @@
1667
1668 static void r8180_set_multicast(struct net_device *dev)
1669 {
1670-	struct r8180_priv *priv = ieee80211_priv(dev);
1671+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1672 	short promisc;
1673
1674 	//down(&priv->wx_sem);
1675@@ -2273,7 +2325,7 @@
1676
1677 int r8180_set_mac_adr(struct net_device *dev, void *mac)
1678 {
1679-	struct r8180_priv *priv = ieee80211_priv(dev);
1680+	struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1681 	struct sockaddr *addr = mac;
1682
1683 	down(&priv->wx_sem);
1684@@ -2291,8 +2343,9 @@
1685 /* based on ipw2200 driver */
1686 int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1687 {
1688-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1689+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1690
1691+
1692 	down(&priv->wx_sem);
1693
1694 	struct iwreq *wrq = (struct iwreq *)rq;
1695@@ -2300,7 +2353,7 @@
1696 	int ret=-1;
1697 	switch (cmd) {
1698 	    case RTL_IOCTL_WPA_SUPPLICANT:
1699-		ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data);
1700+		ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data);
1701 		break;
1702
1703 	    default:
1704@@ -2346,7 +2399,8 @@
1705
1706 		if( flen <= rx_urb->actual_length){
1707
1708-			stats.signal = (desc[1] & 0x7f00)>>8;
1709+//			stats.signal = (desc[1] & 0x7f00)>>8;
1710+			stats.signal = (desc[1] & 0xff00)>>8;
1711 			stats.noise = desc[1] &0xff;
1712 			stats.rate = desc[0] >> 20 & 0xf;
1713 			stats.mac_time[0] = desc[2];
1714@@ -2368,7 +2422,9 @@
1715 		//	priv->rxskb = skb;
1716 		//	priv->tempstats = &stats;
1717
1718-			if(!ieee80211_rx(priv->ieee80211,
1719+
1720+			stats.signal -= stats.noise;
1721+			if(!ieee80211_rx_rtl7(priv->ieee80211,
1722 				skb, &stats))
1723 			dev_kfree_skb_any(skb);
1724 			}
1725@@ -2398,14 +2454,14 @@
1726
1727 //printk("===> rtl8187_usb_probe()\n");
1728
1729-	dev = alloc_ieee80211(sizeof(struct r8180_priv));
1730+	dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv));
1731
1732 	SET_MODULE_OWNER(dev);
1733 	usb_set_intfdata(intf, dev);
1734
1735 	SET_NETDEV_DEV(dev, &intf->dev);
1736
1737-	priv = ieee80211_priv(dev);
1738+	priv = ieee80211_priv_rtl7(dev);
1739 	priv->ieee80211 = netdev_priv(dev);
1740
1741 	priv->udev=udev;
1742@@ -2418,7 +2474,12 @@
1743 	dev->do_ioctl = rtl8180_ioctl;
1744 	dev->set_multicast_list = r8180_set_multicast;
1745 	dev->set_mac_address = r8180_set_mac_adr;
1746+#if WIRELESS_EXT >= 12
1747+#if WIRELESS_EXT < 17
1748 	dev->get_wireless_stats = r8180_get_wireless_stats;
1749+#endif
1750+	dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def;
1751+#endif
1752 	dev->type=ARPHRD_ETHER;
1753
1754 	if (dev_alloc_name(dev, ifname) < 0){
1755@@ -2447,7 +2508,7 @@
1756
1757
1758 fail:
1759-	free_ieee80211(dev);
1760+	free_ieee80211_rtl7(dev);
1761
1762 	DMESG("wlan driver load failed\n");
1763
1764@@ -2464,7 +2525,7 @@
1765
1766 		unregister_netdev(dev);
1767
1768-		priv=ieee80211_priv(dev);
1769+		priv=ieee80211_priv_rtl7(dev);
1770
1771 		rtl8180_proc_remove_one(dev);
1772
1773@@ -2478,12 +2539,12 @@
1774
1775 	}
1776 //	pci_disable_device(pdev);
1777-	free_ieee80211(dev);
1778+	free_ieee80211_rtl7(dev);
1779 	DMESG("wlan driver removed\n");
1780 }
1781
1782
1783-static int __init rtl8187_usb_module_init(void)
1784+static int __init rtl8187_usb_module_init_rtl7(void)
1785 {
1786 	printk(KERN_INFO "\nLinux kernel driver for RTL8187 \
1787 based WLAN cards\n");
1788@@ -2495,7 +2556,7 @@
1789 }
1790
1791
1792-static void __exit rtl8187_usb_module_exit(void)
1793+static void __exit rtl8187_usb_module_exit_rtl7(void)
1794 {
1795 	usb_deregister(&rtl8187_usb_driver);
1796
1797@@ -2508,14 +2569,14 @@
1798 {
1799 	unsigned long flags;
1800 	short enough_desc;
1801-	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
1802+	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
1803
1804 	spin_lock_irqsave(&priv->tx_lock,flags);
1805 	enough_desc = check_nic_enought_desc(dev,pri);
1806         spin_unlock_irqrestore(&priv->tx_lock,flags);
1807
1808 	if(enough_desc)
1809-		ieee80211_wake_queue(priv->ieee80211);
1810+		ieee80211_wake_queue_rtl7(priv->ieee80211);
1811 }
1812
1813
1814@@ -2523,5 +2584,5 @@
1815 /***************************************************************************
1816      ------------------- module init / exit stubs ----------------
1817 ****************************************************************************/
1818-module_init(rtl8187_usb_module_init);
1819-module_exit(rtl8187_usb_module_exit);
1820+module_init(rtl8187_usb_module_init_rtl7);
1821+module_exit(rtl8187_usb_module_exit_rtl7);
1822diff -Naur rtl8187_orig/beta-8187/r8187.h rtl8187_txpower/beta-8187/r8187.h
1823--- rtl8187_orig/beta-8187/r8187.h	2006-06-06 08:48:10.000000000 +0200
1824+++ rtl8187_txpower/beta-8187/r8187.h	2007-02-26 03:05:07.891426549 +0100
1825@@ -26,7 +26,6 @@
1826
1827 #include <linux/module.h>
1828 #include <linux/kernel.h>
1829-#include <linux/config.h>
1830 #include <linux/init.h>
1831 #include <linux/ioport.h>
1832 #include <linux/sched.h>
1833@@ -47,6 +46,10 @@
1834 #include <asm/io.h>
1835 #include <asm/semaphore.h>
1836
1837+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
1838+#include <linux/config.h>
1839+#endif
1840+
1841 #include "ieee80211.h"
1842
1843 #define EPROM_93c46 0
1844@@ -148,7 +151,7 @@
1845 	u8 challow[15]; //channels from 1 to 14, 0 not used
1846 	short up;
1847 	short crcmon; //if 1 allow bad crc frame reception in monitor mode
1848-//	short prism_hdr;
1849+	short prism_hdr;
1850
1851 //	struct timer_list scan_timer;
1852 	/*short scanpending;
1853diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.c rtl8187_txpower/ieee80211/ieee80211_crypt.c
1854--- rtl8187_orig/ieee80211/ieee80211_crypt.c	2006-06-06 04:57:56.000000000 +0200
1855+++ rtl8187_txpower/ieee80211/ieee80211_crypt.c	2007-02-26 03:05:15.811546022 +0100
1856@@ -11,7 +11,6 @@
1857  *
1858  */
1859
1860-#include <linux/config.h>
1861 #include <linux/version.h>
1862 #include <linux/module.h>
1863 #include <linux/init.h>
1864@@ -19,6 +18,10 @@
1865 #include <asm/string.h>
1866 #include <asm/errno.h>
1867
1868+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
1869+#include <linux/config.h>
1870+#endif
1871+
1872 #include "ieee80211.h"
1873
1874 MODULE_AUTHOR("Jouni Malinen");
1875@@ -38,7 +41,7 @@
1876
1877 static struct ieee80211_crypto *hcrypt;
1878
1879-void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
1880+void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee,
1881 					   int force)
1882 {
1883 	struct list_head *ptr, *n;
1884@@ -61,13 +64,13 @@
1885 	}
1886 }
1887
1888-void ieee80211_crypt_deinit_handler(unsigned long data)
1889+void ieee80211_crypt_deinit_handler_rtl7(unsigned long data)
1890 {
1891 	struct ieee80211_device *ieee = (struct ieee80211_device *)data;
1892 	unsigned long flags;
1893
1894 	spin_lock_irqsave(&ieee->lock, flags);
1895-	ieee80211_crypt_deinit_entries(ieee, 0);
1896+	ieee80211_crypt_deinit_entries_rtl7(ieee, 0);
1897 	if (!list_empty(&ieee->crypt_deinit_list)) {
1898 		printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
1899 		       "deletion list\n", ieee->dev->name);
1900@@ -78,7 +81,7 @@
1901
1902 }
1903
1904-void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
1905+void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee,
1906 				    struct ieee80211_crypt_data **crypt)
1907 {
1908 	struct ieee80211_crypt_data *tmp;
1909@@ -103,7 +106,7 @@
1910 	spin_unlock_irqrestore(&ieee->lock, flags);
1911 }
1912
1913-int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
1914+int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops)
1915 {
1916 	unsigned long flags;
1917 	struct ieee80211_crypto_alg *alg;
1918@@ -128,7 +131,7 @@
1919 	return 0;
1920 }
1921
1922-int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops)
1923+int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops)
1924 {
1925 	unsigned long flags;
1926 	struct list_head *ptr;
1927@@ -159,7 +162,7 @@
1928 }
1929
1930
1931-struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
1932+struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name)
1933 {
1934 	unsigned long flags;
1935 	struct list_head *ptr;
1936@@ -186,13 +189,13 @@
1937 }
1938
1939
1940-static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; }
1941-static void ieee80211_crypt_null_deinit(void *priv) {}
1942+static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; }
1943+static void ieee80211_crypt_null_deinit_rtl7(void *priv) {}
1944
1945 static struct ieee80211_crypto_ops ieee80211_crypt_null = {
1946 	.name			= "NULL",
1947-	.init			= ieee80211_crypt_null_init,
1948-	.deinit			= ieee80211_crypt_null_deinit,
1949+	.init			= ieee80211_crypt_null_init_rtl7,
1950+	.deinit			= ieee80211_crypt_null_deinit_rtl7,
1951 	.encrypt_mpdu		= NULL,
1952 	.decrypt_mpdu		= NULL,
1953 	.encrypt_msdu		= NULL,
1954@@ -205,7 +208,7 @@
1955 };
1956
1957
1958-static int __init ieee80211_crypto_init(void)
1959+static int __init ieee80211_crypto_init_rtl7(void)
1960 {
1961 	int ret = -ENOMEM;
1962
1963@@ -217,7 +220,7 @@
1964 	INIT_LIST_HEAD(&hcrypt->algs);
1965 	spin_lock_init(&hcrypt->lock);
1966
1967-	ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null);
1968+	ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null);
1969 	if (ret < 0) {
1970 		kfree(hcrypt);
1971 		hcrypt = NULL;
1972@@ -227,7 +230,7 @@
1973 }
1974
1975
1976-static void __exit ieee80211_crypto_deinit(void)
1977+static void __exit ieee80211_crypto_deinit_rtl7(void)
1978 {
1979 	struct list_head *ptr, *n;
1980
1981@@ -247,13 +250,13 @@
1982 	kfree(hcrypt);
1983 }
1984
1985-EXPORT_SYMBOL(ieee80211_crypt_deinit_entries);
1986-EXPORT_SYMBOL(ieee80211_crypt_deinit_handler);
1987-EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit);
1988-
1989-EXPORT_SYMBOL(ieee80211_register_crypto_ops);
1990-EXPORT_SYMBOL(ieee80211_unregister_crypto_ops);
1991-EXPORT_SYMBOL(ieee80211_get_crypto_ops);
1992+EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7);
1993+EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7);
1994+EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7);
1995+
1996+EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7);
1997+EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7);
1998+EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7);
1999
2000-module_init(ieee80211_crypto_init);
2001-module_exit(ieee80211_crypto_deinit);
2002+module_init(ieee80211_crypto_init_rtl7);
2003+module_exit(ieee80211_crypto_deinit_rtl7);
2004diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_txpower/ieee80211/ieee80211_crypt_ccmp.c
2005--- rtl8187_orig/ieee80211/ieee80211_crypt_ccmp.c	2006-06-06 04:58:00.000000000 +0200
2006+++ rtl8187_txpower/ieee80211/ieee80211_crypt_ccmp.c	2007-02-26 03:05:15.821546173 +0100
2007@@ -9,7 +9,6 @@
2008  * more details.
2009  */
2010
2011-#include <linux/config.h>
2012 #include <linux/version.h>
2013 #include <linux/module.h>
2014 #include <linux/init.h>
2015@@ -22,11 +21,20 @@
2016 #include <asm/string.h>
2017 #include <linux/wireless.h>
2018
2019+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
2020+    #include <linux/config.h>
2021+#endif
2022+
2023 #include "ieee80211.h"
2024
2025
2026 #include <linux/crypto.h>
2027-#include <asm/scatterlist.h>
2028+
2029+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
2030+    #include <asm/scatterlist.h>
2031+#else
2032+    #include <linux/scatterlist.h>
2033+#endif
2034
2035 MODULE_AUTHOR("Jouni Malinen");
2036 MODULE_DESCRIPTION("Host AP crypt: CCMP");
2037@@ -59,7 +67,7 @@
2038 	u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN];
2039 };
2040
2041-void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
2042+void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm,
2043 			     const u8 pt[16], u8 ct[16])
2044 {
2045 	struct scatterlist src, dst;
2046@@ -75,7 +83,7 @@
2047 	crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
2048 }
2049
2050-static void * ieee80211_ccmp_init(int key_idx)
2051+static void * ieee80211_ccmp_init_rtl7(int key_idx)
2052 {
2053 	struct ieee80211_ccmp_data *priv;
2054
2055@@ -105,7 +113,7 @@
2056 }
2057
2058
2059-static void ieee80211_ccmp_deinit(void *priv)
2060+static void ieee80211_ccmp_deinit_rtl7(void *priv)
2061 {
2062 	struct ieee80211_ccmp_data *_priv = priv;
2063 	if (_priv && _priv->tfm)
2064@@ -114,7 +122,7 @@
2065 }
2066
2067
2068-static inline void xor_block(u8 *b, u8 *a, size_t len)
2069+static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len)
2070 {
2071 	int i;
2072 	for (i = 0; i < len; i++)
2073@@ -122,7 +130,7 @@
2074 }
2075
2076
2077-static void ccmp_init_blocks(struct crypto_tfm *tfm,
2078+static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm,
2079 			     struct ieee80211_hdr *hdr,
2080 			     u8 *pn, size_t dlen, u8 *b0, u8 *auth,
2081 			     u8 *s0)
2082@@ -186,18 +194,18 @@
2083 	}
2084
2085 	/* Start with the first block and AAD */
2086-	ieee80211_ccmp_aes_encrypt(tfm, b0, auth);
2087-	xor_block(auth, aad, AES_BLOCK_LEN);
2088-	ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
2089-	xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
2090-	ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
2091+	ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth);
2092+	xor_block_rtl7(auth, aad, AES_BLOCK_LEN);
2093+	ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth);
2094+	xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
2095+	ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth);
2096 	b0[0] &= 0x07;
2097 	b0[14] = b0[15] = 0;
2098-	ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
2099+	ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0);
2100 }
2101
2102
2103-static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
2104+static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
2105 {
2106 	struct ieee80211_ccmp_data *key = priv;
2107 	int data_len, i, blocks, last, len;
2108@@ -237,7 +245,7 @@
2109 	*pos++ = key->tx_pn[0];
2110
2111 	hdr = (struct ieee80211_hdr *) skb->data;
2112-	ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
2113+	ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
2114
2115 	blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
2116 	last = data_len % AES_BLOCK_LEN;
2117@@ -245,13 +253,13 @@
2118 	for (i = 1; i <= blocks; i++) {
2119 		len = (i == blocks && last) ? last : AES_BLOCK_LEN;
2120 		/* Authentication */
2121-		xor_block(b, pos, len);
2122-		ieee80211_ccmp_aes_encrypt(key->tfm, b, b);
2123+		xor_block_rtl7(b, pos, len);
2124+		ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b);
2125 		/* Encryption, with counter */
2126 		b0[14] = (i >> 8) & 0xff;
2127 		b0[15] = i & 0xff;
2128-		ieee80211_ccmp_aes_encrypt(key->tfm, b0, e);
2129-		xor_block(pos, e, len);
2130+		ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e);
2131+		xor_block_rtl7(pos, e, len);
2132 		pos += len;
2133 	}
2134
2135@@ -262,7 +270,7 @@
2136 }
2137
2138
2139-static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
2140+static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
2141 {
2142 	struct ieee80211_ccmp_data *key = priv;
2143 	u8 keyidx, *pos;
2144@@ -326,8 +334,8 @@
2145 		return -4;
2146 	}
2147
2148-	ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
2149-	xor_block(mic, b, CCMP_MIC_LEN);
2150+	ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b);
2151+	xor_block_rtl7(mic, b, CCMP_MIC_LEN);
2152
2153 	blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
2154 	last = data_len % AES_BLOCK_LEN;
2155@@ -337,11 +345,11 @@
2156 		/* Decrypt, with counter */
2157 		b0[14] = (i >> 8) & 0xff;
2158 		b0[15] = i & 0xff;
2159-		ieee80211_ccmp_aes_encrypt(key->tfm, b0, b);
2160-		xor_block(pos, b, len);
2161+		ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b);
2162+		xor_block_rtl7(pos, b, len);
2163 		/* Authentication */
2164-		xor_block(a, pos, len);
2165-		ieee80211_ccmp_aes_encrypt(key->tfm, a, a);
2166+		xor_block_rtl7(a, pos, len);
2167+		ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a);
2168 		pos += len;
2169 	}
2170
2171@@ -365,7 +373,7 @@
2172 }
2173
2174
2175-static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
2176+static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
2177 {
2178 	struct ieee80211_ccmp_data *data = priv;
2179 	int keyidx;
2180@@ -396,7 +404,7 @@
2181 }
2182
2183
2184-static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
2185+static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
2186 {
2187 	struct ieee80211_ccmp_data *data = priv;
2188
2189@@ -420,7 +428,7 @@
2190 }
2191
2192
2193-static char * ieee80211_ccmp_print_stats(char *p, void *priv)
2194+static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv)
2195 {
2196 	struct ieee80211_ccmp_data *ccmp = priv;
2197 	p += sprintf(p, "key[%d] alg=CCMP key_set=%d "
2198@@ -437,34 +445,34 @@
2199 }
2200
2201
2202-static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
2203+static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = {
2204 	.name			= "CCMP",
2205-	.init			= ieee80211_ccmp_init,
2206-	.deinit			= ieee80211_ccmp_deinit,
2207-	.encrypt_mpdu		= ieee80211_ccmp_encrypt,
2208-	.decrypt_mpdu		= ieee80211_ccmp_decrypt,
2209+	.init			= ieee80211_ccmp_init_rtl7,
2210+	.deinit			= ieee80211_ccmp_deinit_rtl7,
2211+	.encrypt_mpdu		= ieee80211_ccmp_encrypt_rtl7,
2212+	.decrypt_mpdu		= ieee80211_ccmp_decrypt_rtl7,
2213 	.encrypt_msdu		= NULL,
2214 	.decrypt_msdu		= NULL,
2215-	.set_key		= ieee80211_ccmp_set_key,
2216-	.get_key		= ieee80211_ccmp_get_key,
2217-	.print_stats		= ieee80211_ccmp_print_stats,
2218+	.set_key		= ieee80211_ccmp_set_key_rtl7,
2219+	.get_key		= ieee80211_ccmp_get_key_rtl7,
2220+	.print_stats		= ieee80211_ccmp_print_stats_rtl7,
2221 	.extra_prefix_len	= CCMP_HDR_LEN,
2222 	.extra_postfix_len	= CCMP_MIC_LEN,
2223 	.owner			= THIS_MODULE,
2224 };
2225
2226
2227-static int __init ieee80211_crypto_ccmp_init(void)
2228+static int __init ieee80211_crypto_ccmp_init_rtl7(void)
2229 {
2230-	return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp);
2231+	return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7);
2232 }
2233
2234
2235-static void __exit ieee80211_crypto_ccmp_exit(void)
2236+static void __exit ieee80211_crypto_ccmp_exit_rtl7(void)
2237 {
2238-	ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
2239+	ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7);
2240 }
2241
2242
2243-module_init(ieee80211_crypto_ccmp_init);
2244-module_exit(ieee80211_crypto_ccmp_exit);
2245+module_init(ieee80211_crypto_ccmp_init_rtl7);
2246+module_exit(ieee80211_crypto_ccmp_exit_rtl7);
2247diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt.h rtl8187_txpower/ieee80211/ieee80211_crypt.h
2248--- rtl8187_orig/ieee80211/ieee80211_crypt.h	2006-06-06 04:58:00.000000000 +0200
2249+++ rtl8187_txpower/ieee80211/ieee80211_crypt.h	2007-02-26 03:05:12.091489906 +0100
2250@@ -75,12 +75,12 @@
2251 	atomic_t refcnt;
2252 };
2253
2254-int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
2255-int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
2256-struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
2257-void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
2258-void ieee80211_crypt_deinit_handler(unsigned long);
2259-void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
2260+int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops);
2261+int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops);
2262+struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name);
2263+void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int);
2264+void ieee80211_crypt_deinit_handler_rtl7(unsigned long);
2265+void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee,
2266 				    struct ieee80211_crypt_data **crypt);
2267
2268 #endif
2269diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_txpower/ieee80211/ieee80211_crypt_tkip.c
2270--- rtl8187_orig/ieee80211/ieee80211_crypt_tkip.c	2006-06-06 04:57:54.000000000 +0200
2271+++ rtl8187_txpower/ieee80211/ieee80211_crypt_tkip.c	2007-02-26 03:05:15.841546474 +0100
2272@@ -9,7 +9,6 @@
2273  * more details.
2274  */
2275
2276-#include <linux/config.h>
2277 #include <linux/version.h>
2278 #include <linux/module.h>
2279 #include <linux/init.h>
2280@@ -21,13 +20,22 @@
2281 #include <linux/if_arp.h>
2282 #include <asm/string.h>
2283
2284+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
2285+#include <linux/config.h>
2286+#endif
2287+
2288 #include "ieee80211.h"
2289
2290+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
2291+    #include <asm/scatterlist.h>
2292+#else
2293+    #include <linux/scatterlist.h>
2294+#endif
2295
2296 #include <linux/crypto.h>
2297-#include <asm/scatterlist.h>
2298 #include <linux/crc32.h>
2299
2300+
2301 MODULE_AUTHOR("Jouni Malinen");
2302 MODULE_DESCRIPTION("Host AP crypt: TKIP");
2303 MODULE_LICENSE("GPL");
2304@@ -62,7 +70,7 @@
2305 	u8 rx_hdr[16], tx_hdr[16];
2306 };
2307
2308-static void * ieee80211_tkip_init(int key_idx)
2309+static void * ieee80211_tkip_init_rtl7(int key_idx)
2310 {
2311 	struct ieee80211_tkip_data *priv;
2312
2313@@ -101,7 +109,7 @@
2314 }
2315
2316
2317-static void ieee80211_tkip_deinit(void *priv)
2318+static void ieee80211_tkip_deinit_rtl7(void *priv)
2319 {
2320 	struct ieee80211_tkip_data *_priv = priv;
2321 	if (_priv && _priv->tfm_michael)
2322@@ -200,7 +208,7 @@
2323
2324 #define PHASE1_LOOP_COUNT 8
2325
2326-static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
2327+static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
2328 {
2329 	int i, j;
2330
2331@@ -222,7 +230,7 @@
2332 }
2333
2334
2335-static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
2336+static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
2337 			       u16 IV16)
2338 {
2339 	/* Make temporary area overlap WEP seed so that the final copy can be
2340@@ -268,7 +276,7 @@
2341 #endif
2342 }
2343
2344-static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
2345+static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
2346 {
2347 	struct ieee80211_tkip_data *tkey = priv;
2348 	int len;
2349@@ -283,11 +291,11 @@
2350
2351 	hdr = (struct ieee80211_hdr *) skb->data;
2352 	if (!tkey->tx_phase1_done) {
2353-		tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
2354+		tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2,
2355 				   tkey->tx_iv32);
2356 		tkey->tx_phase1_done = 1;
2357 	}
2358-	tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
2359+	tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
2360
2361 	len = skb->len - hdr_len;
2362 	pos = skb_push(skb, 8);
2363@@ -325,7 +333,7 @@
2364 	return 0;
2365 }
2366
2367-static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
2368+static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
2369 {
2370 	struct ieee80211_tkip_data *tkey = priv;
2371 	u8 rc4key[16];
2372@@ -382,10 +390,10 @@
2373 	}
2374
2375 	if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) {
2376-		tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
2377+		tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
2378 		tkey->rx_phase1_done = 1;
2379 	}
2380-	tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16);
2381+	tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16);
2382
2383 	plen = skb->len - hdr_len - 12;
2384
2385@@ -428,10 +436,14 @@
2386 }
2387
2388
2389-static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
2390+static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
2391 		       u8 *data, size_t data_len, u8 *mic)
2392 {
2393+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2394+	struct hash_desc desc;
2395+#endif
2396 	struct scatterlist sg[2];
2397+	int ret=0;
2398
2399 	if (tkey->tfm_michael == NULL) {
2400 		printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
2401@@ -445,15 +457,24 @@
2402 	sg[1].offset = offset_in_page(data);
2403 	sg[1].length = data_len;
2404
2405+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
2406 	crypto_digest_init(tkey->tfm_michael);
2407 	crypto_digest_setkey(tkey->tfm_michael, key, 8);
2408 	crypto_digest_update(tkey->tfm_michael, sg, 2);
2409 	crypto_digest_final(tkey->tfm_michael, mic);
2410+#else
2411+	if (crypto_hash_setkey(tkey->tfm_michael, key, 8))
2412+		return -1;
2413
2414-	return 0;
2415+	desc.tfm = tkey->tfm_michael;
2416+	desc.flags = 0;
2417+	ret = crypto_hash_digest(&desc, sg, data_len + 16, mic);
2418+#endif
2419+
2420+	return ret;
2421 }
2422
2423-static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
2424+static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr)
2425 {
2426 	struct ieee80211_hdr *hdr11;
2427
2428@@ -483,7 +504,7 @@
2429 }
2430
2431
2432-static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
2433+static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
2434 {
2435 	struct ieee80211_tkip_data *tkey = priv;
2436 	u8 *pos;
2437@@ -495,9 +516,9 @@
2438 		return -1;
2439 	}
2440
2441-	michael_mic_hdr(skb, tkey->tx_hdr);
2442+	michael_mic_hdr_rtl7(skb, tkey->tx_hdr);
2443 	pos = skb_put(skb, 8);
2444-	if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr,
2445+	if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr,
2446 			skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
2447 		return -1;
2448
2449@@ -506,7 +527,7 @@
2450
2451
2452 #if WIRELESS_EXT >= 18
2453-static void ieee80211_michael_mic_failure(struct net_device *dev,
2454+static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
2455 				       struct ieee80211_hdr *hdr,
2456 				       int keyidx)
2457 {
2458@@ -527,7 +548,7 @@
2459 	wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
2460 }
2461 #elif WIRELESS_EXT >= 15
2462-static void ieee80211_michael_mic_failure(struct net_device *dev,
2463+static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
2464 				       struct ieee80211_hdr *hdr,
2465 				       int keyidx)
2466 {
2467@@ -543,7 +564,7 @@
2468 	wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
2469 }
2470 #else /* WIRELESS_EXT >= 15 */
2471-static inline void ieee80211_michael_mic_failure(struct net_device *dev,
2472+static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
2473 					      struct ieee80211_hdr *hdr,
2474 					      int keyidx)
2475 {
2476@@ -551,7 +572,7 @@
2477 #endif /* WIRELESS_EXT >= 15 */
2478
2479
2480-static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
2481+static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx,
2482 				     int hdr_len, void *priv)
2483 {
2484 	struct ieee80211_tkip_data *tkey = priv;
2485@@ -560,8 +581,8 @@
2486 	if (!tkey->key_set)
2487 		return -1;
2488
2489-	michael_mic_hdr(skb, tkey->rx_hdr);
2490-	if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr,
2491+	michael_mic_hdr_rtl7(skb, tkey->rx_hdr);
2492+	if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr,
2493 			skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
2494 		return -1;
2495 	if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
2496@@ -572,7 +593,7 @@
2497 		       skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2),
2498 		       keyidx);
2499 		if (skb->dev)
2500-			ieee80211_michael_mic_failure(skb->dev, hdr, keyidx);
2501+			ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx);
2502 		tkey->dot11RSNAStatsTKIPLocalMICFailures++;
2503 		return -1;
2504 	}
2505@@ -588,7 +609,7 @@
2506 }
2507
2508
2509-static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv)
2510+static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
2511 {
2512 	struct ieee80211_tkip_data *tkey = priv;
2513 	int keyidx;
2514@@ -618,7 +639,7 @@
2515 }
2516
2517
2518-static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv)
2519+static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
2520 {
2521 	struct ieee80211_tkip_data *tkey = priv;
2522
2523@@ -648,7 +669,7 @@
2524 }
2525
2526
2527-static char * ieee80211_tkip_print_stats(char *p, void *priv)
2528+static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv)
2529 {
2530 	struct ieee80211_tkip_data *tkip = priv;
2531 	p += sprintf(p, "key[%d] alg=TKIP key_set=%d "
2532@@ -675,34 +696,34 @@
2533 }
2534
2535
2536-static struct ieee80211_crypto_ops ieee80211_crypt_tkip = {
2537+static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = {
2538 	.name			= "TKIP",
2539-	.init			= ieee80211_tkip_init,
2540-	.deinit			= ieee80211_tkip_deinit,
2541-	.encrypt_mpdu		= ieee80211_tkip_encrypt,
2542-	.decrypt_mpdu		= ieee80211_tkip_decrypt,
2543-	.encrypt_msdu		= ieee80211_michael_mic_add,
2544-	.decrypt_msdu		= ieee80211_michael_mic_verify,
2545-	.set_key		= ieee80211_tkip_set_key,
2546-	.get_key		= ieee80211_tkip_get_key,
2547-	.print_stats		= ieee80211_tkip_print_stats,
2548+	.init			= ieee80211_tkip_init_rtl7,
2549+	.deinit			= ieee80211_tkip_deinit_rtl7,
2550+	.encrypt_mpdu		= ieee80211_tkip_encrypt_rtl7,
2551+	.decrypt_mpdu		= ieee80211_tkip_decrypt_rtl7,
2552+	.encrypt_msdu		= ieee80211_michael_mic_add_rtl7,
2553+	.decrypt_msdu		= ieee80211_michael_mic_verify_rtl7,
2554+	.set_key		= ieee80211_tkip_set_key_rtl7,
2555+	.get_key		= ieee80211_tkip_get_key_rtl7,
2556+	.print_stats		= ieee80211_tkip_print_stats_rtl7,
2557 	.extra_prefix_len	= 4 + 4, /* IV + ExtIV */
2558 	.extra_postfix_len	= 8 + 4, /* MIC + ICV */
2559 	.owner		        = THIS_MODULE,
2560 };
2561
2562
2563-static int __init ieee80211_crypto_tkip_init(void)
2564+static int __init ieee80211_crypto_tkip_init_rtl7(void)
2565 {
2566-	return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip);
2567+	return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7);
2568 }
2569
2570
2571-static void __exit ieee80211_crypto_tkip_exit(void)
2572+static void __exit ieee80211_crypto_tkip_exit_rtl7(void)
2573 {
2574-	ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip);
2575+	ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7);
2576 }
2577
2578
2579-module_init(ieee80211_crypto_tkip_init);
2580-module_exit(ieee80211_crypto_tkip_exit);
2581+module_init(ieee80211_crypto_tkip_init_rtl7);
2582+module_exit(ieee80211_crypto_tkip_exit_rtl7);
2583diff -Naur rtl8187_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_txpower/ieee80211/ieee80211_crypt_wep.c
2584--- rtl8187_orig/ieee80211/ieee80211_crypt_wep.c	2006-06-06 04:57:54.000000000 +0200
2585+++ rtl8187_txpower/ieee80211/ieee80211_crypt_wep.c	2007-02-26 03:05:15.881547078 +0100
2586@@ -9,7 +9,6 @@
2587  * more details.
2588  */
2589
2590-#include <linux/config.h>
2591 #include <linux/version.h>
2592 #include <linux/module.h>
2593 #include <linux/init.h>
2594@@ -18,13 +17,22 @@
2595 #include <linux/skbuff.h>
2596 #include <asm/string.h>
2597
2598+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
2599+#include <linux/config.h>
2600+#endif
2601+
2602 #include "ieee80211.h"
2603
2604
2605 #include <linux/crypto.h>
2606-#include <asm/scatterlist.h>
2607 #include <linux/crc32.h>
2608
2609+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
2610+    #include <asm/scatterlist.h>
2611+#else
2612+    #include <linux/scatterlist.h>
2613+#endif
2614+
2615 MODULE_AUTHOR("Jouni Malinen");
2616 MODULE_DESCRIPTION("Host AP crypt: WEP");
2617 MODULE_LICENSE("GPL");
2618@@ -40,7 +48,7 @@
2619 };
2620
2621
2622-static void * prism2_wep_init(int keyidx)
2623+static void * prism2_wep_init_rtl7(int keyidx)
2624 {
2625 	struct prism2_wep_data *priv;
2626
2627@@ -72,7 +80,7 @@
2628 }
2629
2630
2631-static void prism2_wep_deinit(void *priv)
2632+static void prism2_wep_deinit_rtl7(void *priv)
2633 {
2634 	struct prism2_wep_data *_priv = priv;
2635 	if (_priv && _priv->tfm)
2636@@ -87,7 +95,7 @@
2637  *
2638  * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
2639  */
2640-static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
2641+static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
2642 {
2643 	struct prism2_wep_data *wep = priv;
2644 	u32 crc, klen, len;
2645@@ -151,7 +159,7 @@
2646  * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on
2647  * failure. If frame is OK, IV and ICV will be removed.
2648  */
2649-static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
2650+static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
2651 {
2652 	struct prism2_wep_data *wep = priv;
2653 	u32 crc, klen, plen;
2654@@ -203,7 +211,7 @@
2655 }
2656
2657
2658-static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv)
2659+static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
2660 {
2661 	struct prism2_wep_data *wep = priv;
2662
2663@@ -217,7 +225,7 @@
2664 }
2665
2666
2667-static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv)
2668+static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
2669 {
2670 	struct prism2_wep_data *wep = priv;
2671
2672@@ -230,7 +238,7 @@
2673 }
2674
2675
2676-static char * prism2_wep_print_stats(char *p, void *priv)
2677+static char * prism2_wep_print_stats_rtl7(char *p, void *priv)
2678 {
2679 	struct prism2_wep_data *wep = priv;
2680 	p += sprintf(p, "key[%d] alg=WEP len=%d\n",
2681@@ -239,34 +247,34 @@
2682 }
2683
2684
2685-static struct ieee80211_crypto_ops ieee80211_crypt_wep = {
2686+static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = {
2687 	.name			= "WEP",
2688-	.init			= prism2_wep_init,
2689-	.deinit			= prism2_wep_deinit,
2690-	.encrypt_mpdu		= prism2_wep_encrypt,
2691-	.decrypt_mpdu		= prism2_wep_decrypt,
2692+	.init			= prism2_wep_init_rtl7,
2693+	.deinit			= prism2_wep_deinit_rtl7,
2694+	.encrypt_mpdu		= prism2_wep_encrypt_rtl7,
2695+	.decrypt_mpdu		= prism2_wep_decrypt_rtl7,
2696 	.encrypt_msdu		= NULL,
2697 	.decrypt_msdu		= NULL,
2698-	.set_key		= prism2_wep_set_key,
2699-	.get_key		= prism2_wep_get_key,
2700-	.print_stats		= prism2_wep_print_stats,
2701+	.set_key		= prism2_wep_set_key_rtl7,
2702+	.get_key		= prism2_wep_get_key_rtl7,
2703+	.print_stats		= prism2_wep_print_stats_rtl7,
2704 	.extra_prefix_len	= 4, /* IV */
2705 	.extra_postfix_len	= 4, /* ICV */
2706 	.owner			= THIS_MODULE,
2707 };
2708
2709
2710-static int __init ieee80211_crypto_wep_init(void)
2711+static int __init ieee80211_crypto_wep_init_rtl7(void)
2712 {
2713-	return ieee80211_register_crypto_ops(&ieee80211_crypt_wep);
2714+	return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7);
2715 }
2716
2717
2718-static void __exit ieee80211_crypto_wep_exit(void)
2719+static void __exit ieee80211_crypto_wep_exit_rtl7(void)
2720 {
2721-	ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep);
2722+	ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7);
2723 }
2724
2725
2726-module_init(ieee80211_crypto_wep_init);
2727-module_exit(ieee80211_crypto_wep_exit);
2728+module_init(ieee80211_crypto_wep_init_rtl7);
2729+module_exit(ieee80211_crypto_wep_exit_rtl7);
2730diff -Naur rtl8187_orig/ieee80211/ieee80211.h rtl8187_txpower/ieee80211/ieee80211.h
2731--- rtl8187_orig/ieee80211/ieee80211.h	2006-06-06 04:57:56.000000000 +0200
2732+++ rtl8187_txpower/ieee80211/ieee80211.h	2007-02-26 03:05:12.121490358 +0100
2733@@ -156,6 +156,22 @@
2734 	struct list_head list;
2735 };
2736
2737+#define LWNG_CAP_DID_BASE   (4 | (1 << 6)) /* section 4, group 1 */
2738+/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header
2739+ * (from linux-wlan-ng) */
2740+struct linux_wlan_ng_val {
2741+	u32 did;
2742+	u16 status, len;
2743+	u32 data;
2744+} __attribute__ ((packed));
2745+
2746+struct linux_wlan_ng_prism_hdr {
2747+	u32 msgcode, msglen;
2748+	char devname[16];
2749+	struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal,
2750+		noise, rate, istx, frmlen;
2751+} __attribute__ ((packed));
2752+
2753 struct ieee80211_hdr {
2754 	u16 frame_ctl;
2755 	u16 duration_id;
2756@@ -840,14 +856,14 @@
2757
2758
2759 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
2760-extern inline int is_multicast_ether_addr(const u8 *addr)
2761+extern inline int is_multicast_ether_addr_rtl7(const u8 *addr)
2762 {
2763         return ((addr[0] != 0xff) && (0x01 & addr[0]));
2764 }
2765 #endif
2766
2767 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
2768-extern inline int is_broadcast_ether_addr(const u8 *addr)
2769+extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr)
2770 {
2771 	return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&   \
2772 		(addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
2773@@ -1015,10 +1031,16 @@
2774 	struct timer_list beacon_timer;
2775
2776 	struct work_struct associate_complete_wq;
2777+
2778+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
2779+	struct delayed_work associate_retry_wq;
2780+	struct delayed_work softmac_scan_wq;
2781+#else
2782 	struct work_struct associate_retry_wq;
2783+	struct work_struct softmac_scan_wq;
2784+#endif
2785 	struct work_struct start_ibss_wq;
2786 	struct work_struct associate_procedure_wq;
2787-	struct work_struct softmac_scan_wq;
2788 	struct work_struct wx_sync_scan_wq;
2789
2790 	struct workqueue_struct *wq;
2791@@ -1154,12 +1176,12 @@
2792
2793
2794
2795-extern inline void *ieee80211_priv(struct net_device *dev)
2796+extern inline void *ieee80211_priv_rtl7(struct net_device *dev)
2797 {
2798 	return ((struct ieee80211_device *)netdev_priv(dev))->priv;
2799 }
2800
2801-extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
2802+extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len)
2803 {
2804 	/* Single white space is for Linksys APs */
2805 	if (essid_len == 1 && essid[0] == ' ')
2806@@ -1175,7 +1197,7 @@
2807 	return 1;
2808 }
2809
2810-extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
2811+extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode)
2812 {
2813 	/*
2814 	 * It is possible for both access points and our device to support
2815@@ -1201,7 +1223,7 @@
2816 	return 0;
2817 }
2818
2819-extern inline int ieee80211_get_hdrlen(u16 fc)
2820+extern inline int ieee80211_get_hdrlen_rtl7(u16 fc)
2821 {
2822 	int hdrlen = 24;
2823
2824@@ -1229,140 +1251,144 @@
2825
2826
2827 /* ieee80211.c */
2828-extern void free_ieee80211(struct net_device *dev);
2829-extern struct net_device *alloc_ieee80211(int sizeof_priv);
2830+extern void free_ieee80211_rtl7(struct net_device *dev);
2831+extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv);
2832
2833-extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
2834+extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee);
2835
2836 /* ieee80211_tx.c */
2837
2838-extern int ieee80211_encrypt_fragment(
2839+extern int ieee80211_encrypt_fragment_rtl7(
2840 	struct ieee80211_device *ieee,
2841 	struct sk_buff *frag,
2842 	int hdr_len);
2843
2844-extern int ieee80211_xmit(struct sk_buff *skb,
2845+extern int ieee80211_xmit_rtl7(struct sk_buff *skb,
2846 			  struct net_device *dev);
2847-extern void ieee80211_txb_free(struct ieee80211_txb *);
2848+extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *);
2849
2850
2851 /* ieee80211_rx.c */
2852-extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
2853+extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
2854 			struct ieee80211_rx_stats *rx_stats);
2855-extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
2856+extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
2857 			     struct ieee80211_hdr *header,
2858 			     struct ieee80211_rx_stats *stats);
2859
2860 /* ieee80211_wx.c */
2861-extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
2862+extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
2863 				 struct iw_request_info *info,
2864 				 union iwreq_data *wrqu, char *key);
2865-extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
2866+extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
2867 				   struct iw_request_info *info,
2868 				   union iwreq_data *wrqu, char *key);
2869-extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
2870+extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
2871 				   struct iw_request_info *info,
2872 				   union iwreq_data *wrqu, char *key);
2873 /* ieee80211_softmac.c */
2874-extern short ieee80211_is_54g(struct ieee80211_network net);
2875-extern short ieee80211_is_shortslot(struct ieee80211_network net);
2876-extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
2877+extern short ieee80211_is_54g_rtl7(struct ieee80211_network net);
2878+extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net);
2879+extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
2880 			struct ieee80211_rx_stats *rx_stats, u16 type,
2881 			u16 stype);
2882-extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
2883+extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net);
2884
2885-extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
2886-extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
2887-extern void ieee80211_start_bss(struct ieee80211_device *ieee);
2888-extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
2889-extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
2890-extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
2891-extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
2892-extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
2893-extern void ieee80211_disassociate(struct ieee80211_device *ieee);
2894-extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
2895-extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
2896-extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
2897-extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
2898-extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
2899-extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
2900-extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
2901-extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
2902-extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
2903-extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
2904-extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
2905-extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
2906-extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
2907-extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
2908-extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
2909-extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
2910+extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
2911+extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee);
2912+extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee);
2913+extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee);
2914+extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee);
2915+extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee);
2916+extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee);
2917+extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee);
2918+extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee);
2919+extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee);
2920+extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee);
2921+extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee);
2922+extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee);
2923+extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee);
2924+extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee);
2925+extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee);
2926+extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee);
2927+extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee);
2928+extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee);
2929+extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee);
2930+extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee);
2931+extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee);
2932+extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p);
2933+extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee);
2934+extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success);
2935
2936 /* ieee80211_softmac_wx.c */
2937
2938-extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
2939+extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
2940 			    struct iw_request_info *info,
2941 			    union iwreq_data *wrqu, char *ext);
2942
2943-extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
2944+extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
2945 			 struct iw_request_info *info,
2946 			 union iwreq_data *awrq,
2947 			 char *extra);
2948
2949-extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
2950+extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
2951
2952-extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
2953+extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
2954 			     struct iw_request_info *info,
2955 			     union iwreq_data *wrqu, char *extra);
2956
2957-extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
2958+extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
2959 			     struct iw_request_info *info,
2960 			     union iwreq_data *wrqu, char *extra);
2961
2962-extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
2963+extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
2964 			     union iwreq_data *wrqu, char *b);
2965
2966-extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
2967+extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
2968 			     union iwreq_data *wrqu, char *b);
2969
2970-extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
2971+extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
2972 			      struct iw_request_info *a,
2973 			      union iwreq_data *wrqu, char *extra);
2974
2975-extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
2976+extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
2977 			     union iwreq_data *wrqu, char *b);
2978
2979-extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
2980+extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
2981 			     union iwreq_data *wrqu, char *b);
2982
2983-extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
2984+extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
2985 			     union iwreq_data *wrqu, char *b);
2986
2987-extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
2988+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
2989+extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work);
2990+#else
2991+extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee);
2992+#endif
2993
2994-extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
2995+extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
2996 			       struct iw_request_info *info,
2997 			       union iwreq_data *wrqu, char *extra);
2998
2999-extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
3000+extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
3001 			     struct iw_request_info *info,
3002 			     union iwreq_data *wrqu, char *extra);
3003
3004-extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
3005+extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
3006 				 struct iw_request_info *info,
3007 				 union iwreq_data *wrqu, char *extra);
3008
3009-extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
3010+extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
3011 				 struct iw_request_info *info,
3012 				 union iwreq_data *wrqu, char *extra);
3013
3014-extern const long ieee80211_wlan_frequencies[];
3015+extern const long ieee80211_wlan_frequencies_rtl7[];
3016
3017-extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
3018+extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee)
3019 {
3020 	ieee->scans++;
3021 }
3022
3023-extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
3024+extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee)
3025 {
3026 	return ieee->scans;
3027 }
3028@@ -1372,7 +1398,7 @@
3029 	const char *s = essid;
3030 	char *d = escaped;
3031
3032-	if (ieee80211_is_empty_essid(essid, essid_len)) {
3033+	if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) {
3034 		memcpy(escaped, "<hidden>", sizeof("<hidden>"));
3035 		return escaped;
3036 	}
3037diff -Naur rtl8187_orig/ieee80211/ieee80211_module.c rtl8187_txpower/ieee80211/ieee80211_module.c
3038--- rtl8187_orig/ieee80211/ieee80211_module.c	2006-06-06 04:58:00.000000000 +0200
3039+++ rtl8187_txpower/ieee80211/ieee80211_module.c	2007-02-26 03:05:15.911547530 +0100
3040@@ -31,7 +31,6 @@
3041 *******************************************************************************/
3042
3043 #include <linux/compiler.h>
3044-#include <linux/config.h>
3045 #include <linux/errno.h>
3046 #include <linux/if_arp.h>
3047 #include <linux/in6.h>
3048@@ -52,6 +51,10 @@
3049 #include <asm/uaccess.h>
3050 #include <net/arp.h>
3051
3052+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3053+#include <linux/config.h>
3054+#endif
3055+
3056 #include "ieee80211.h"
3057
3058 MODULE_DESCRIPTION("802.11 data/management/control stack");
3059@@ -60,7 +63,7 @@
3060
3061 #define DRV_NAME "ieee80211"
3062
3063-static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee)
3064+static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee)
3065 {
3066 	if (ieee->networks)
3067 		return 0;
3068@@ -80,7 +83,7 @@
3069 	return 0;
3070 }
3071
3072-static inline void ieee80211_networks_free(struct ieee80211_device *ieee)
3073+static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee)
3074 {
3075 	if (!ieee->networks)
3076 		return;
3077@@ -88,7 +91,7 @@
3078 	ieee->networks = NULL;
3079 }
3080
3081-static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee)
3082+static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee)
3083 {
3084 	int i;
3085
3086@@ -99,7 +102,7 @@
3087 }
3088
3089
3090-struct net_device *alloc_ieee80211(int sizeof_priv)
3091+struct net_device *alloc_ieee80211_rtl7(int sizeof_priv)
3092 {
3093 	struct ieee80211_device *ieee;
3094 	struct net_device *dev;
3095@@ -113,17 +116,17 @@
3096 		goto failed;
3097 	}
3098 	ieee = netdev_priv(dev);
3099-	dev->hard_start_xmit = ieee80211_xmit;
3100+	dev->hard_start_xmit = ieee80211_xmit_rtl7;
3101
3102 	ieee->dev = dev;
3103
3104-	err = ieee80211_networks_allocate(ieee);
3105+	err = ieee80211_networks_allocate_rtl7(ieee);
3106 	if (err) {
3107 		IEEE80211_ERROR("Unable to allocate beacon storage: %d\n",
3108 				err);
3109 		goto failed;
3110 	}
3111-	ieee80211_networks_initialize(ieee);
3112+	ieee80211_networks_initialize_rtl7(ieee);
3113
3114 	/* Default fragmentation threshold is maximum payload size */
3115 	ieee->fts = DEFAULT_FTS;
3116@@ -138,7 +141,7 @@
3117 	INIT_LIST_HEAD(&ieee->crypt_deinit_list);
3118 	init_timer(&ieee->crypt_deinit_timer);
3119 	ieee->crypt_deinit_timer.data = (unsigned long)ieee;
3120-	ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler;
3121+	ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7;
3122
3123 	spin_lock_init(&ieee->lock);
3124
3125@@ -149,7 +152,7 @@
3126  	ieee->ieee802_1x = 1;
3127 	ieee->raw_tx = 0;
3128
3129-	ieee80211_softmac_init(ieee);
3130+	ieee80211_softmac_init_rtl7(ieee);
3131
3132 	for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
3133 		INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]);
3134@@ -167,7 +170,7 @@
3135 }
3136
3137
3138-void free_ieee80211(struct net_device *dev)
3139+void free_ieee80211_rtl7(struct net_device *dev)
3140 {
3141 	struct ieee80211_device *ieee = netdev_priv(dev);
3142
3143@@ -175,9 +178,9 @@
3144 	struct list_head *p, *q;
3145
3146
3147-	ieee80211_softmac_free(ieee);
3148+	ieee80211_softmac_free_rtl7(ieee);
3149 	del_timer_sync(&ieee->crypt_deinit_timer);
3150-	ieee80211_crypt_deinit_entries(ieee, 1);
3151+	ieee80211_crypt_deinit_entries_rtl7(ieee, 1);
3152
3153 	for (i = 0; i < WEP_KEYS; i++) {
3154 		struct ieee80211_crypt_data *crypt = ieee->crypt[i];
3155@@ -191,7 +194,7 @@
3156 		}
3157 	}
3158
3159-	ieee80211_networks_free(ieee);
3160+	ieee80211_networks_free_rtl7(ieee);
3161
3162 	for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) {
3163 		list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) {
3164@@ -210,13 +213,13 @@
3165 u32 ieee80211_debug_level = 0;
3166 struct proc_dir_entry *ieee80211_proc = NULL;
3167
3168-static int show_debug_level(char *page, char **start, off_t offset,
3169+static int show_debug_level_rtl7(char *page, char **start, off_t offset,
3170 			    int count, int *eof, void *data)
3171 {
3172 	return snprintf(page, count, "0x%08X\n", ieee80211_debug_level);
3173 }
3174
3175-static int store_debug_level(struct file *file, const char *buffer,
3176+static int store_debug_level_rtl7(struct file *file, const char *buffer,
3177 			     unsigned long count, void *data)
3178 {
3179 	char buf[] = "0x00000000";
3180@@ -243,7 +246,7 @@
3181 	return strnlen(buf, count);
3182 }
3183
3184-static int __init ieee80211_init(void)
3185+static int __init ieee80211_init_rtl7(void)
3186 {
3187 	struct proc_dir_entry *e;
3188
3189@@ -268,7 +271,7 @@
3190 	return 0;
3191 }
3192
3193-static void __exit ieee80211_exit(void)
3194+static void __exit ieee80211_exit_rtl7(void)
3195 {
3196 	if (ieee80211_proc) {
3197 		remove_proc_entry("debug_level", ieee80211_proc);
3198@@ -282,9 +285,9 @@
3199 MODULE_PARM_DESC(debug, "debug output mask");
3200
3201
3202-module_exit(ieee80211_exit);
3203-module_init(ieee80211_init);
3204+module_exit(ieee80211_exit_rtl7);
3205+module_init(ieee80211_init_rtl7);
3206 #endif
3207
3208-EXPORT_SYMBOL(alloc_ieee80211);
3209-EXPORT_SYMBOL(free_ieee80211);
3210+EXPORT_SYMBOL(alloc_ieee80211_rtl7);
3211+EXPORT_SYMBOL(free_ieee80211_rtl7);
3212diff -Naur rtl8187_orig/ieee80211/ieee80211_rx.c rtl8187_txpower/ieee80211/ieee80211_rx.c
3213--- rtl8187_orig/ieee80211/ieee80211_rx.c	2006-06-06 04:58:00.000000000 +0200
3214+++ rtl8187_txpower/ieee80211/ieee80211_rx.c	2007-02-26 03:05:15.941547983 +0100
3215@@ -22,7 +22,6 @@
3216
3217
3218 #include <linux/compiler.h>
3219-#include <linux/config.h>
3220 #include <linux/errno.h>
3221 #include <linux/if_arp.h>
3222 #include <linux/in6.h>
3223@@ -43,18 +42,83 @@
3224 #include <asm/uaccess.h>
3225 #include <linux/ctype.h>
3226
3227+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3228+#include <linux/config.h>
3229+#endif
3230+
3231+
3232 #include "ieee80211.h"
3233
3234-static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
3235+static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee,
3236 					struct sk_buff *skb,
3237 					struct ieee80211_rx_stats *rx_stats)
3238 {
3239-	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
3240-	u16 fc = le16_to_cpu(hdr->frame_ctl);
3241+	struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data;
3242+	u16 fc = le16_to_cpu(hdr1->frame_ctl);
3243+	int prism_header;
3244+	int hdrlen, phdrlen, head_need, tail_need;
3245+
3246+	if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) {
3247+		prism_header = 1;
3248+		phdrlen = sizeof(struct linux_wlan_ng_prism_hdr);
3249+	} else {
3250+		prism_header = 0;
3251+		phdrlen = 0;
3252+	}
3253+
3254+	hdrlen = ieee80211_get_hdrlen_rtl7(fc);
3255+
3256+	/* check if there is enough room for extra data; if not, expand skb
3257+	 * buffer to be large enough for the changes */
3258+	head_need = phdrlen;
3259+	tail_need = 0;
3260+#ifdef PRISM2_ADD_BOGUS_CRC
3261+	tail_need += 4;
3262+#endif /* PRISM2_ADD_BOGUS_CRC */
3263+
3264+	head_need -= skb_headroom(skb);
3265+	tail_need -= skb_tailroom(skb);
3266+
3267+	if (head_need > 0 || tail_need > 0) {
3268+		if (pskb_expand_head(skb, head_need > 0 ? head_need : 0,
3269+				     tail_need > 0 ? tail_need : 0,
3270+				     GFP_ATOMIC)) {
3271+			printk(KERN_DEBUG "%s: ieee80211_rx failed to "
3272+			       "reallocate skb buffer\n", ieee->dev->name);
3273+			dev_kfree_skb_any(skb);
3274+			return;
3275+		}
3276+	}
3277+
3278+	if (prism_header == 1) {
3279+		struct linux_wlan_ng_prism_hdr *hdr;
3280+		hdr = (struct linux_wlan_ng_prism_hdr *)
3281+			skb_push(skb, phdrlen);
3282+		memset(hdr, 0, phdrlen);
3283+		hdr->msgcode = LWNG_CAP_DID_BASE;
3284+		hdr->msglen = sizeof(*hdr);
3285+		memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname));
3286+#define LWNG_SETVAL(f,i,s,l,d) \
3287+hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \
3288+hdr->f.status = s; hdr->f.len = l; hdr->f.data = d
3289+		LWNG_SETVAL(hosttime, 1, 0, 4, jiffies);
3290+		LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time));
3291+		LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0);
3292+		LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0);
3293+		LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0);
3294+		LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal);
3295+		LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise);
3296+		LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5);
3297+		LWNG_SETVAL(istx, 9, 0, 4, 0);
3298+		LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen);
3299+#undef LWNG_SETVAL
3300+	}
3301
3302 	skb->dev = ieee->dev;
3303 	skb->mac.raw = skb->data;
3304-	skb_pull(skb, ieee80211_get_hdrlen(fc));
3305+	skb_pull(skb, hdrlen);
3306+	if (prism_header)
3307+		skb_pull(skb, phdrlen);
3308 	skb->pkt_type = PACKET_OTHERHOST;
3309 	skb->protocol = __constant_htons(ETH_P_80211_RAW);
3310 	memset(skb->cb, 0, sizeof(skb->cb));
3311@@ -64,7 +128,7 @@
3312
3313 /* Called only as a tasklet (software IRQ) */
3314 static struct ieee80211_frag_entry *
3315-ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
3316+ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq,
3317 			  unsigned int frag, u8 *src, u8 *dst)
3318 {
3319 	struct ieee80211_frag_entry *entry;
3320@@ -94,7 +158,7 @@
3321
3322 /* Called only as a tasklet (software IRQ) */
3323 static struct sk_buff *
3324-ieee80211_frag_cache_get(struct ieee80211_device *ieee,
3325+ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee,
3326 			 struct ieee80211_hdr *hdr)
3327 {
3328 	struct sk_buff *skb = NULL;
3329@@ -133,7 +197,7 @@
3330 	} else {
3331 		/* received a fragment of a frame for which the head fragment
3332 		 * should have already been received */
3333-		entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2,
3334+		entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2,
3335 						  hdr->addr1);
3336 		if (entry != NULL) {
3337 			entry->last_frag = frag;
3338@@ -146,7 +210,7 @@
3339
3340
3341 /* Called only as a tasklet (software IRQ) */
3342-static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
3343+static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee,
3344 					   struct ieee80211_hdr *hdr)
3345 {
3346 	u16 sc;
3347@@ -156,7 +220,7 @@
3348 	sc = le16_to_cpu(hdr->seq_ctl);
3349 	seq = WLAN_GET_SEQ_SEQ(sc);
3350
3351-	entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2,
3352+	entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2,
3353 					  hdr->addr1);
3354
3355 	if (entry == NULL) {
3356@@ -178,7 +242,7 @@
3357  *
3358  * Called by ieee80211_rx */
3359 static inline int
3360-ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
3361+ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
3362 			struct ieee80211_rx_stats *rx_stats, u16 type,
3363 			u16 stype)
3364 {
3365@@ -187,8 +251,8 @@
3366 	 * response parser uses it
3367 	 */
3368 	rx_stats->len = skb->len;
3369-	ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats);
3370-	ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype);
3371+	ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats);
3372+	ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype);
3373
3374 	dev_kfree_skb_any(skb);
3375
3376@@ -253,7 +317,7 @@
3377 /* No encapsulation header if EtherType < 0x600 (=length) */
3378
3379 /* Called by ieee80211_rx_frame_decrypt */
3380-static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
3381+static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee,
3382 				    struct sk_buff *skb)
3383 {
3384 	struct net_device *dev = ieee->dev;
3385@@ -294,7 +358,7 @@
3386
3387 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
3388 static inline int
3389-ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
3390+ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb,
3391 			   struct ieee80211_crypt_data *crypt)
3392 {
3393 	struct ieee80211_hdr *hdr;
3394@@ -304,7 +368,7 @@
3395 		return 0;
3396
3397 	hdr = (struct ieee80211_hdr *) skb->data;
3398-	hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
3399+	hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl));
3400
3401 #ifdef CONFIG_IEEE80211_CRYPT_TKIP
3402 	if (ieee->tkip_countermeasures &&
3403@@ -339,7 +403,7 @@
3404
3405 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
3406 static inline int
3407-ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb,
3408+ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb,
3409 			     int keyidx, struct ieee80211_crypt_data *crypt)
3410 {
3411 	struct ieee80211_hdr *hdr;
3412@@ -349,7 +413,7 @@
3413 		return 0;
3414
3415 	hdr = (struct ieee80211_hdr *) skb->data;
3416-	hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
3417+	hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl));
3418
3419 	atomic_inc(&crypt->refcnt);
3420 	res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
3421@@ -367,7 +431,7 @@
3422
3423 /* this function is stolen from ipw2200 driver*/
3424 #define IEEE_PACKET_RETRY_TIME (5*HZ)
3425-static int is_duplicate_packet(struct ieee80211_device *ieee,
3426+static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee,
3427 				      struct ieee80211_hdr *header)
3428 {
3429 //	u16 fc = le16_to_cpu(header->frame_ctl);
3430@@ -444,7 +508,7 @@
3431 /* All received frames are sent to this function. @skb contains the frame in
3432  * IEEE 802.11 format, i.e., in the format it was sent over air.
3433  * This function is called only as a tasklet (software IRQ). */
3434-int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
3435+int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
3436 		 struct ieee80211_rx_stats *rx_stats)
3437 {
3438 	struct net_device *dev = ieee->dev;
3439@@ -483,7 +547,7 @@
3440 	sc = le16_to_cpu(hdr->seq_ctl);
3441
3442 	frag = WLAN_GET_SEQ_FRAG(sc);
3443-	hdrlen = ieee80211_get_hdrlen(fc);
3444+	hdrlen = ieee80211_get_hdrlen_rtl7(fc);
3445
3446 #ifdef NOT_YET
3447 #if WIRELESS_EXT > 15
3448@@ -501,12 +565,12 @@
3449 	}
3450 #endif /* IW_WIRELESS_SPY */
3451 #endif /* WIRELESS_EXT > 15 */
3452-	hostap_update_rx_stats(local->ap, hdr, rx_stats);
3453+	hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats);
3454 #endif
3455
3456 #if WIRELESS_EXT > 15
3457 	if (ieee->iw_mode == IW_MODE_MONITOR) {
3458-		ieee80211_monitor_rx(ieee, skb, rx_stats);
3459+		ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats);
3460 		stats->rx_packets++;
3461 		stats->rx_bytes += skb->len;
3462 		return 1;
3463@@ -529,7 +593,7 @@
3464 		 * stations that do not support WEP key mapping). */
3465
3466 		if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
3467-			(void) hostap_handle_sta_crypto(local, hdr, &crypt,
3468+			(void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt,
3469 							&sta);
3470 #endif
3471
3472@@ -555,7 +619,7 @@
3473 	if (skb->len < IEEE80211_DATA_HDR3_LEN)
3474 		goto rx_dropped;
3475
3476-	if (is_duplicate_packet(ieee, hdr))
3477+	if (is_duplicate_packet_rtl7(ieee, hdr))
3478 		goto rx_dropped;
3479
3480
3481@@ -575,7 +639,7 @@
3482 	#endif
3483
3484
3485-		if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
3486+		if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype))
3487 			goto rx_dropped;
3488 		else
3489 			goto rx_exit;
3490@@ -606,7 +670,7 @@
3491 	}
3492
3493 #ifdef NOT_YET
3494-	if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
3495+	if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds))
3496 		goto rx_dropped;
3497 	if (wds) {
3498 		skb->dev = dev = wds;
3499@@ -619,7 +683,7 @@
3500 	    memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) {
3501 		/* Frame from BSSID of the AP for which we are a client */
3502 		skb->dev = dev = ieee->stadev;
3503-		stats = hostap_get_stats(dev);
3504+		stats = hostap_get_stats_rtl7(dev);
3505 		from_assoc_ap = 1;
3506 	}
3507 #endif
3508@@ -630,7 +694,7 @@
3509 	if ((ieee->iw_mode == IW_MODE_MASTER ||
3510 	     ieee->iw_mode == IW_MODE_REPEAT) &&
3511 	    !from_assoc_ap) {
3512-		switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
3513+		switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats,
3514 					     wds != NULL)) {
3515 		case AP_RX_CONTINUE_NOT_AUTHORIZED:
3516 			frame_authorized = 0;
3517@@ -664,7 +728,7 @@
3518 	/* skb: hdr + (possibly fragmented, possibly encrypted) payload */
3519
3520 	if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
3521-	    (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
3522+	    (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0)
3523 		goto rx_dropped;
3524
3525 	hdr = (struct ieee80211_hdr *) skb->data;
3526@@ -674,7 +738,7 @@
3527 	// ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
3528 	if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
3529 		int flen;
3530-		struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
3531+		struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr);
3532 		IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
3533
3534 		if (!frag_skb) {
3535@@ -694,7 +758,7 @@
3536 			printk(KERN_WARNING "%s: host decrypted and "
3537 			       "reassembled frame did not fit skb\n",
3538 			       dev->name);
3539-			ieee80211_frag_cache_invalidate(ieee, hdr);
3540+			ieee80211_frag_cache_invalidate_rtl7(ieee, hdr);
3541 			goto rx_dropped;
3542 		}
3543
3544@@ -722,19 +786,19 @@
3545 		 * delivered, so remove skb from fragment cache */
3546 		skb = frag_skb;
3547 		hdr = (struct ieee80211_hdr *) skb->data;
3548-		ieee80211_frag_cache_invalidate(ieee, hdr);
3549+		ieee80211_frag_cache_invalidate_rtl7(ieee, hdr);
3550 	}
3551
3552 	/* skb: hdr + (possible reassembled) full MSDU payload; possibly still
3553 	 * encrypted/authenticated */
3554 	if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
3555-	    ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
3556+	    ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt))
3557 		goto rx_dropped;
3558
3559 	hdr = (struct ieee80211_hdr *) skb->data;
3560 	if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) {
3561 		if (/*ieee->ieee802_1x &&*/
3562-		    ieee80211_is_eapol_frame(ieee, skb)) {
3563+		    ieee80211_is_eapol_frame_rtl7(ieee, skb)) {
3564 #ifdef CONFIG_IEEE80211_DEBUG
3565 			/* pass unencrypted EAPOL frames even if encryption is
3566 			 * configured */
3567@@ -763,7 +827,7 @@
3568 #endif
3569
3570 	if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep &&
3571-	    !ieee80211_is_eapol_frame(ieee, skb)) {
3572+	    !ieee80211_is_eapol_frame_rtl7(ieee, skb)) {
3573 		IEEE80211_DEBUG_DROP(
3574 			"dropped unencrypted RX data "
3575 			"frame from " MAC_FMT
3576@@ -896,7 +960,7 @@
3577
3578 #define MGMT_FRAME_FIXED_PART_LENGTH		0x24
3579
3580-static inline int ieee80211_is_ofdm_rate(u8 rate)
3581+static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate)
3582 {
3583 	switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
3584 	case IEEE80211_OFDM_RATE_6MB:
3585@@ -913,7 +977,7 @@
3586 }
3587
3588
3589-static inline int ieee80211_network_init(
3590+static inline int ieee80211_network_init_rtl7(
3591 	struct ieee80211_device *ieee,
3592 	struct ieee80211_probe_response *beacon,
3593 	struct ieee80211_network *network,
3594@@ -964,7 +1028,7 @@
3595
3596 		switch (info_element->id) {
3597 		case MFIE_TYPE_SSID:
3598-			if (ieee80211_is_empty_essid(info_element->data,
3599+			if (ieee80211_is_empty_essid_rtl7(info_element->data,
3600 						     info_element->len)) {
3601 				network->flags |= NETWORK_EMPTY_ESSID;
3602 				break;
3603@@ -991,7 +1055,7 @@
3604 #ifdef CONFIG_IEEE80211_DEBUG
3605 				p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
3606 #endif
3607-				if (ieee80211_is_ofdm_rate(info_element->data[i])) {
3608+				if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) {
3609 					network->flags |= NETWORK_HAS_OFDM;
3610 					if (info_element->data[i] &
3611 					    IEEE80211_BASIC_RATE_MASK)
3612@@ -1014,7 +1078,7 @@
3613 #ifdef CONFIG_IEEE80211_DEBUG
3614 				p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
3615 #endif
3616-				if (ieee80211_is_ofdm_rate(info_element->data[i])) {
3617+				if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) {
3618 					network->flags |= NETWORK_HAS_OFDM;
3619 					if (info_element->data[i] &
3620 					    IEEE80211_BASIC_RATE_MASK)
3621@@ -1147,7 +1211,7 @@
3622 		return 1;
3623 	}
3624
3625-	if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
3626+	if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len))
3627 		network->flags |= NETWORK_EMPTY_ESSID;
3628
3629 	memcpy(&network->stats, stats, sizeof(network->stats));
3630@@ -1155,7 +1219,7 @@
3631 	return 0;
3632 }
3633
3634-static inline int is_same_network(struct ieee80211_network *src,
3635+static inline int is_same_network_rtl7(struct ieee80211_network *src,
3636 				  struct ieee80211_network *dst)
3637 {
3638 	/* A network is only a duplicate if the channel, BSSID, ESSID
3639@@ -1172,7 +1236,7 @@
3640 		(dst->capability & WLAN_CAPABILITY_BSS)));
3641 }
3642
3643-static inline void update_network(struct ieee80211_network *dst,
3644+static inline void update_network_rtl7(struct ieee80211_network *dst,
3645 				  struct ieee80211_network *src)
3646 {
3647 	memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
3648@@ -1204,7 +1268,7 @@
3649 	/* dst->last_associate is not overwritten */
3650 }
3651
3652-static inline void ieee80211_process_probe_response(
3653+static inline void ieee80211_process_probe_response_rtl7(
3654 	struct ieee80211_device *ieee,
3655 	struct ieee80211_probe_response *beacon,
3656 	struct ieee80211_rx_stats *stats)
3657@@ -1239,7 +1303,7 @@
3658 		(beacon->capability & (1<<0x1)) ? '1' : '0',
3659 		(beacon->capability & (1<<0x0)) ? '1' : '0');
3660
3661-	if (ieee80211_network_init(ieee, beacon, &network, stats)) {
3662+	if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) {
3663 		IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n",
3664 				     escape_essid(info_element->data,
3665 						  info_element->len),
3666@@ -1262,11 +1326,11 @@
3667
3668 	spin_lock_irqsave(&ieee->lock, flags);
3669
3670-	if(is_same_network(&ieee->current_network, &network))
3671-		update_network(&ieee->current_network, &network);
3672+	if(is_same_network_rtl7(&ieee->current_network, &network))
3673+		update_network_rtl7(&ieee->current_network, &network);
3674
3675 	list_for_each_entry(target, &ieee->network_list, list) {
3676-		if (is_same_network(target, &network))
3677+		if (is_same_network_rtl7(target, &network))
3678 			break;
3679
3680 		if ((oldest == NULL) ||
3681@@ -1306,7 +1370,7 @@
3682 		memcpy(target, &network, sizeof(*target));
3683 		list_add_tail(&target->list, &ieee->network_list);
3684 		if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
3685-			ieee80211_softmac_new_net(ieee,&network);
3686+			ieee80211_softmac_new_net_rtl7(ieee,&network);
3687 	} else {
3688 		IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n",
3689 				     escape_essid(target->ssid,
3690@@ -1321,15 +1385,15 @@
3691 		 * net and call the new_net handler
3692 		 */
3693 		renew = !time_after(target->last_scanned + ieee->scan_age, jiffies);
3694-		update_network(target, &network);
3695+		update_network_rtl7(target, &network);
3696 		if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
3697-			ieee80211_softmac_new_net(ieee,&network);
3698+			ieee80211_softmac_new_net_rtl7(ieee,&network);
3699 	}
3700
3701 	spin_unlock_irqrestore(&ieee->lock, flags);
3702 }
3703
3704-void ieee80211_rx_mgt(struct ieee80211_device *ieee,
3705+void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
3706 		      struct ieee80211_hdr *header,
3707 		      struct ieee80211_rx_stats *stats)
3708 {
3709@@ -1339,7 +1403,7 @@
3710 		IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
3711 				     WLAN_FC_GET_STYPE(header->frame_ctl));
3712 		IEEE80211_DEBUG_SCAN("Beacon\n");
3713-		ieee80211_process_probe_response(
3714+		ieee80211_process_probe_response_rtl7(
3715 			ieee, (struct ieee80211_probe_response *)header, stats);
3716 		break;
3717
3718@@ -1347,7 +1411,7 @@
3719 		IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
3720 				     WLAN_FC_GET_STYPE(header->frame_ctl));
3721 		IEEE80211_DEBUG_SCAN("Probe response\n");
3722-		ieee80211_process_probe_response(
3723+		ieee80211_process_probe_response_rtl7(
3724 			ieee, (struct ieee80211_probe_response *)header, stats);
3725 		break;
3726
3727@@ -1355,5 +1419,5 @@
3728 }
3729
3730
3731-EXPORT_SYMBOL(ieee80211_rx_mgt);
3732-EXPORT_SYMBOL(ieee80211_rx);
3733+EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7);
3734+EXPORT_SYMBOL(ieee80211_rx_rtl7);
3735diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac.c rtl8187_txpower/ieee80211/ieee80211_softmac.c
3736--- rtl8187_orig/ieee80211/ieee80211_softmac.c	2006-06-19 03:27:33.000000000 +0200
3737+++ rtl8187_txpower/ieee80211/ieee80211_softmac.c	2007-02-26 03:05:15.981548586 +0100
3738@@ -20,12 +20,12 @@
3739 #include <linux/delay.h>
3740 #include <linux/version.h>
3741
3742-short ieee80211_is_54g(struct ieee80211_network net)
3743+short ieee80211_is_54g_rtl7(struct ieee80211_network net)
3744 {
3745 	return ((net.rates_ex_len > 0) || (net.rates_len > 4));
3746 }
3747
3748-short ieee80211_is_shortslot(struct ieee80211_network net)
3749+short ieee80211_is_shortslot_rtl7(struct ieee80211_network net)
3750 {
3751 	return (net.capability & WLAN_CAPABILITY_SHORT_SLOT);
3752 }
3753@@ -34,7 +34,7 @@
3754  * tag and the EXTENDED RATE MFIE tag if needed.
3755  * It encludes two bytes per tag for the tag itself and its len
3756  */
3757-unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee)
3758+unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee)
3759 {
3760 	unsigned int rate_len = 0;
3761
3762@@ -52,7 +52,7 @@
3763  * Then it updates the pointer so that
3764  * it points after the new MFIE tag added.
3765  */
3766-void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p)
3767+void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p)
3768 {
3769 	u8 *tag = *tag_p;
3770
3771@@ -69,7 +69,7 @@
3772 	*tag_p = tag;
3773 }
3774
3775-void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p)
3776+void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p)
3777 {
3778 	u8 *tag = *tag_p;
3779
3780@@ -92,7 +92,7 @@
3781 	*tag_p = tag;
3782 }
3783
3784-void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb)
3785+void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
3786 {
3787 	int nh;
3788 	nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM;
3789@@ -110,7 +110,7 @@
3790 	//return 0;
3791 }
3792
3793-struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee)
3794+struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee)
3795 {
3796 	struct sk_buff *ret;
3797
3798@@ -125,15 +125,15 @@
3799 	return ret;
3800 }
3801
3802-void init_mgmt_queue(struct ieee80211_device *ieee)
3803+void init_mgmt_queue_rtl7(struct ieee80211_device *ieee)
3804 {
3805 	ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0;
3806 }
3807
3808
3809-void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl);
3810+void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl);
3811
3812-inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
3813+inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee)
3814 {
3815 	unsigned long flags;
3816 	short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
3817@@ -144,13 +144,13 @@
3818 	spin_lock_irqsave(&ieee->lock, flags);
3819
3820 	/* called with 2nd param 0, no mgmt lock required */
3821-	ieee80211_sta_wakeup(ieee,0);
3822+	ieee80211_sta_wakeup_rtl7(ieee,0);
3823
3824 	if(single){
3825
3826 		if(ieee->queue_stop){
3827
3828-			enqueue_mgmt(ieee,skb);
3829+			enqueue_mgmt_rtl7(ieee,skb);
3830
3831 		}else{
3832 			header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
3833@@ -184,7 +184,7 @@
3834 }
3835
3836
3837-inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
3838+inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee)
3839 {
3840
3841 	short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
3842@@ -219,7 +219,7 @@
3843 	}
3844 }
3845
3846-inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee)
3847+inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee)
3848 {
3849 	unsigned int len,rate_len;
3850 	u8 *tag;
3851@@ -228,7 +228,7 @@
3852
3853 	len = ieee->current_network.ssid_len;
3854
3855-	rate_len = ieee80211_MFIE_rate_len(ieee);
3856+	rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
3857
3858 	skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) +
3859 			    2 + len + rate_len);
3860@@ -251,21 +251,21 @@
3861 	memcpy(tag, ieee->current_network.ssid, len);
3862 	tag += len;
3863
3864-	ieee80211_MFIE_Brate(ieee,&tag);
3865-	ieee80211_MFIE_Grate(ieee,&tag);
3866+	ieee80211_MFIE_Brate_rtl7(ieee,&tag);
3867+	ieee80211_MFIE_Grate_rtl7(ieee,&tag);
3868 	return skb;
3869 }
3870
3871-struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee);
3872-void ieee80211_send_beacon(struct ieee80211_device *ieee)
3873+struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee);
3874+void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee)
3875 {
3876 	struct sk_buff *skb;
3877
3878 	unsigned long flags;
3879
3880-	skb = ieee80211_get_beacon_(ieee);
3881+	skb = ieee80211_get_beacon__rtl7(ieee);
3882 	if (skb){
3883-		softmac_mgmt_xmit(skb, ieee);
3884+		softmac_mgmt_xmit_rtl7(skb, ieee);
3885 		ieee->softmac_stats.tx_beacons++;
3886 	}
3887
3888@@ -279,37 +279,37 @@
3889 }
3890
3891
3892-void ieee80211_send_beacon_cb(unsigned long _ieee)
3893+void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee)
3894 {
3895 	struct ieee80211_device *ieee =
3896 		(struct ieee80211_device *) _ieee;
3897-	ieee80211_send_beacon(ieee);
3898+	ieee80211_send_beacon_rtl7(ieee);
3899 }
3900
3901
3902-void ieee80211_send_probe(struct ieee80211_device *ieee)
3903+void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee)
3904 {
3905 	struct sk_buff *skb;
3906
3907-	skb = ieee80211_probe_req(ieee);
3908+	skb = ieee80211_probe_req_rtl7(ieee);
3909 	if (skb){
3910-		softmac_mgmt_xmit(skb, ieee);
3911+		softmac_mgmt_xmit_rtl7(skb, ieee);
3912 		ieee->softmac_stats.tx_probe_rq++;
3913 	}
3914 }
3915
3916-void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
3917+void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee)
3918 {
3919 	if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){
3920-		ieee80211_send_probe(ieee);
3921-		ieee80211_send_probe(ieee);
3922+		ieee80211_send_probe_rtl7(ieee);
3923+		ieee80211_send_probe_rtl7(ieee);
3924 	}
3925 }
3926
3927 /* this performs syncro scan blocking the caller until all channels
3928  * in the allowed channel map has been checked.
3929  */
3930-void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
3931+void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee)
3932 {
3933 	short ch = 0;
3934
3935@@ -349,7 +349,7 @@
3936
3937 		ieee->set_chan(ieee->dev, ch);
3938
3939-		ieee80211_send_probe_requests(ieee);
3940+		ieee80211_send_probe_requests_rtl7(ieee);
3941
3942 		/* this prevent excessive time wait when we
3943 		 * need to wait for a syncro scan to end..
3944@@ -384,11 +384,17 @@
3945 }
3946 #endif
3947
3948-void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
3949-{
3950-	down(&ieee->scan_sem);
3951-
3952+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
3953+void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work)
3954+{
3955+	struct delayed_work *dwork = container_of(work, struct delayed_work, work);
3956+	struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);
3957+#else
3958+void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee)
3959+{
3960+#endif
3961 	short watchdog = 0;
3962+	down(&ieee->scan_sem);
3963
3964 	do{
3965 		ieee->current_network.channel =
3966@@ -402,7 +408,7 @@
3967 		goto out;
3968
3969 	ieee->set_chan(ieee->dev, ieee->current_network.channel);
3970-	ieee80211_send_probe_requests(ieee);
3971+	ieee80211_send_probe_requests_rtl7(ieee);
3972
3973 #if 0
3974 	ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME);
3975@@ -427,19 +433,19 @@
3976 #endif
3977
3978
3979-void ieee80211_beacons_start(struct ieee80211_device *ieee)
3980+void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee)
3981 {
3982 	unsigned long flags;
3983
3984 	spin_lock_irqsave(&ieee->beacon_lock,flags);
3985
3986 	ieee->beacon_txing = 1;
3987-	ieee80211_send_beacon(ieee);
3988+	ieee80211_send_beacon_rtl7(ieee);
3989
3990 	spin_unlock_irqrestore(&ieee->beacon_lock,flags);
3991 }
3992
3993-void ieee80211_beacons_stop(struct ieee80211_device *ieee)
3994+void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee)
3995 {
3996 	unsigned long flags;
3997
3998@@ -453,25 +459,25 @@
3999 }
4000
4001
4002-void ieee80211_stop_send_beacons(struct ieee80211_device *ieee)
4003+void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee)
4004 {
4005 	if(ieee->stop_send_beacons)
4006 		ieee->stop_send_beacons(ieee->dev);
4007 	if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
4008-		ieee80211_beacons_stop(ieee);
4009+		ieee80211_beacons_stop_rtl7(ieee);
4010 }
4011
4012
4013-void ieee80211_start_send_beacons(struct ieee80211_device *ieee)
4014+void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee)
4015 {
4016 	if(ieee->start_send_beacons)
4017 		ieee->start_send_beacons(ieee->dev);
4018 	if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
4019-		ieee80211_beacons_start(ieee);
4020+		ieee80211_beacons_start_rtl7(ieee);
4021 }
4022
4023
4024-void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee)
4025+void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee)
4026 {
4027 //	unsigned long flags;
4028
4029@@ -490,22 +496,22 @@
4030 	up(&ieee->scan_sem);
4031 }
4032
4033-void ieee80211_stop_scan(struct ieee80211_device *ieee)
4034+void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee)
4035 {
4036 	if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
4037-		ieee80211_softmac_stop_scan(ieee);
4038+		ieee80211_softmac_stop_scan_rtl7(ieee);
4039 	else
4040 		ieee->stop_scan(ieee->dev);
4041 }
4042
4043 /* called with ieee->lock held */
4044-void ieee80211_start_scan(struct ieee80211_device *ieee)
4045+void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee)
4046 {
4047 	if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
4048 		if (ieee->scanning == 0){
4049 			ieee->scanning = 1;
4050 			//ieee80211_softmac_scan(ieee);
4051-			queue_work(ieee->wq, &ieee->softmac_scan_wq);
4052+			queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0);
4053 		}
4054 	}else
4055 		ieee->start_scan(ieee->dev);
4056@@ -513,18 +519,18 @@
4057 }
4058
4059 /* called with wx_sem held */
4060-void ieee80211_start_scan_syncro(struct ieee80211_device *ieee)
4061+void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee)
4062 {
4063 	ieee->sync_scan_hurryup = 0;
4064
4065 	if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
4066-		ieee80211_softmac_scan_syncro(ieee);
4067+		ieee80211_softmac_scan_syncro_rtl7(ieee);
4068 	else
4069 		ieee->scan_syncro(ieee->dev);
4070
4071 }
4072
4073-inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon,
4074+inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon,
4075 	struct ieee80211_device *ieee, int challengelen)
4076 {
4077 	struct sk_buff *skb;
4078@@ -557,7 +563,7 @@
4079
4080 }
4081
4082-static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest)
4083+static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest)
4084 {
4085 	u8 *tag;
4086 	int beacon_size;
4087@@ -578,7 +584,7 @@
4088 	else
4089 		atim_len = 0;
4090
4091-	if(ieee80211_is_54g(ieee->current_network))
4092+	if(ieee80211_is_54g_rtl7(ieee->current_network))
4093 		erp_len = 3;
4094 	else
4095 		erp_len = 0;
4096@@ -664,7 +670,7 @@
4097 }
4098
4099
4100-struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest)
4101+struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest)
4102 {
4103 	struct sk_buff *skb;
4104 	u8* tag;
4105@@ -673,7 +679,7 @@
4106 	struct ieee80211_assoc_response_frame *assoc;
4107 	short encrypt;
4108
4109-	unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
4110+	unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
4111 	int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len;
4112
4113 	skb = dev_alloc_skb(len);
4114@@ -711,13 +717,13 @@
4115
4116 	tag = (u8*) skb_put(skb, rate_len);
4117
4118-	ieee80211_MFIE_Brate(ieee, &tag);
4119-	ieee80211_MFIE_Grate(ieee, &tag);
4120+	ieee80211_MFIE_Brate_rtl7(ieee, &tag);
4121+	ieee80211_MFIE_Grate_rtl7(ieee, &tag);
4122
4123 	return skb;
4124 }
4125
4126-struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest)
4127+struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest)
4128 {
4129 	struct sk_buff *skb;
4130 	struct ieee80211_authentication *auth;
4131@@ -744,7 +750,7 @@
4132
4133 }
4134
4135-struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr)
4136+struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr)
4137 {
4138 	struct sk_buff *skb;
4139 	struct ieee80211_hdr_3addr* hdr;
4140@@ -770,35 +776,35 @@
4141 }
4142
4143
4144-void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest)
4145+void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest)
4146 {
4147-	struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest);
4148+	struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest);
4149
4150 	if (buf)
4151-		softmac_mgmt_xmit(buf, ieee);
4152+		softmac_mgmt_xmit_rtl7(buf, ieee);
4153 }
4154
4155
4156-void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest)
4157+void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest)
4158 {
4159-	struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest);
4160+	struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest);
4161
4162 	if (buf)
4163-		softmac_mgmt_xmit(buf, ieee);
4164+		softmac_mgmt_xmit_rtl7(buf, ieee);
4165 }
4166
4167
4168-void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest)
4169+void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest)
4170 {
4171
4172-	struct sk_buff *buf = ieee80211_probe_resp(ieee, dest);
4173+	struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest);
4174
4175 	if (buf)
4176-		softmac_mgmt_xmit(buf, ieee);
4177+		softmac_mgmt_xmit_rtl7(buf, ieee);
4178 }
4179
4180
4181-inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
4182+inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
4183 {
4184 	struct sk_buff *skb;
4185
4186@@ -807,7 +813,7 @@
4187
4188 	unsigned int wpa_len = beacon->wpa_ie_len;
4189
4190-	unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
4191+	unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
4192
4193
4194
4195@@ -848,8 +854,8 @@
4196
4197 	tag = skb_put(skb, rate_len);
4198
4199-	ieee80211_MFIE_Brate(ieee, &tag);
4200-	ieee80211_MFIE_Grate(ieee, &tag);
4201+	ieee80211_MFIE_Brate_rtl7(ieee, &tag);
4202+	ieee80211_MFIE_Grate_rtl7(ieee, &tag);
4203
4204 	tag = skb_put(skb,wpa_len);
4205
4206@@ -858,7 +864,7 @@
4207 	return skb;
4208 }
4209
4210-void ieee80211_associate_abort(struct ieee80211_device *ieee)
4211+void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee)
4212 {
4213
4214 	unsigned long flags;
4215@@ -887,13 +893,13 @@
4216 	spin_unlock_irqrestore(&ieee->lock, flags);
4217 }
4218
4219-void ieee80211_associate_abort_cb(unsigned long dev)
4220+void ieee80211_associate_abort_cb_rtl7(unsigned long dev)
4221 {
4222-	ieee80211_associate_abort((struct ieee80211_device *) dev);
4223+	ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev);
4224 }
4225
4226
4227-void ieee80211_associate_step1(struct ieee80211_device *ieee)
4228+void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee)
4229 {
4230 	struct ieee80211_network *beacon = &ieee->current_network;
4231 	struct sk_buff *skb;
4232@@ -901,20 +907,20 @@
4233 	IEEE80211_DEBUG_MGMT("Stopping scan\n");
4234
4235 	ieee->softmac_stats.tx_auth_rq++;
4236-	skb=ieee80211_authentication_req(beacon, ieee, 0);
4237+	skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0);
4238
4239 	if (!skb)
4240-		ieee80211_associate_abort(ieee);
4241+		ieee80211_associate_abort_rtl7(ieee);
4242 	else{
4243 		ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ;
4244 		IEEE80211_DEBUG_MGMT("Sending authentication request\n");
4245-		softmac_mgmt_xmit(skb, ieee);
4246+		softmac_mgmt_xmit_rtl7(skb, ieee);
4247 		ieee->associate_timer.expires = jiffies + (HZ / 2);
4248 		add_timer(&ieee->associate_timer);
4249 	}
4250 }
4251
4252-void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
4253+void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen)
4254 {
4255 	u8 *c;
4256 	struct sk_buff *skb;
4257@@ -924,9 +930,9 @@
4258 	ieee->associate_seq++;
4259 	ieee->softmac_stats.tx_auth_rq++;
4260
4261-	skb = ieee80211_authentication_req(beacon, ieee, chlen+2);
4262+	skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2);
4263 	if (!skb)
4264-		ieee80211_associate_abort(ieee);
4265+		ieee80211_associate_abort_rtl7(ieee);
4266 	else{
4267 		c = skb_put(skb, chlen+2);
4268 		*(c++) = MFIE_TYPE_CHALLENGE;
4269@@ -935,16 +941,16 @@
4270
4271 		IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n");
4272
4273-		ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr  ));
4274+		ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr  ));
4275
4276-		softmac_mgmt_xmit(skb, ieee);
4277+		softmac_mgmt_xmit_rtl7(skb, ieee);
4278 		ieee->associate_timer.expires = jiffies + (HZ / 2);
4279 		add_timer(&ieee->associate_timer);
4280 	}
4281 	kfree(challenge);
4282 }
4283
4284-void ieee80211_associate_step2(struct ieee80211_device *ieee)
4285+void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee)
4286 {
4287 	struct sk_buff* skb;
4288 	struct ieee80211_network *beacon = &ieee->current_network;
4289@@ -954,20 +960,26 @@
4290 	IEEE80211_DEBUG_MGMT("Sending association request\n");
4291
4292 	ieee->softmac_stats.tx_ass_rq++;
4293-	skb=ieee80211_association_req(beacon, ieee);
4294+	skb=ieee80211_association_req_rtl7(beacon, ieee);
4295 	if (!skb)
4296-		ieee80211_associate_abort(ieee);
4297+		ieee80211_associate_abort_rtl7(ieee);
4298 	else{
4299-		softmac_mgmt_xmit(skb, ieee);
4300+		softmac_mgmt_xmit_rtl7(skb, ieee);
4301 		ieee->associate_timer.expires = jiffies + (HZ / 2);
4302 		add_timer(&ieee->associate_timer);
4303 	}
4304 }
4305
4306-void ieee80211_associate_complete_wq(struct ieee80211_device *ieee)
4307+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
4308+void ieee80211_associate_complete_wq_rtl7(struct work_struct *work)
4309+{
4310+	struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq);
4311+#else
4312+void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee)
4313 {
4314+#endif
4315 	printk(KERN_INFO "Associated successfully\n");
4316-	if(ieee80211_is_54g(ieee->current_network) &&
4317+	if(ieee80211_is_54g_rtl7(ieee->current_network) &&
4318 		(ieee->modulation & IEEE80211_OFDM_MODULATION)){
4319
4320 		ieee->rate = 540;
4321@@ -977,13 +989,13 @@
4322 		printk(KERN_INFO"Using B rates\n");
4323 	}
4324 	ieee->link_change(ieee->dev);
4325-	notify_wx_assoc_event(ieee);
4326+	notify_wx_assoc_event_rtl7(ieee);
4327 	if (ieee->data_hard_resume)
4328 		ieee->data_hard_resume(ieee->dev);
4329 	netif_carrier_on(ieee->dev);
4330 }
4331
4332-void ieee80211_associate_complete(struct ieee80211_device *ieee)
4333+void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee)
4334 {
4335
4336 	del_timer_sync(&ieee->associate_timer);
4337@@ -995,24 +1007,29 @@
4338 	queue_work(ieee->wq, &ieee->associate_complete_wq);
4339 }
4340
4341-void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee)
4342+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
4343+void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work)
4344+{
4345+	struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq);
4346+#else
4347+void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee)
4348 {
4349+#endif
4350 	ieee->sync_scan_hurryup = 1;
4351 	down(&ieee->wx_sem);
4352-
4353 	if (ieee->data_hard_stop)
4354 		ieee->data_hard_stop(ieee->dev);
4355
4356-	ieee80211_stop_scan(ieee);
4357+	ieee80211_stop_scan_rtl7(ieee);
4358 	ieee->set_chan(ieee->dev, ieee->current_network.channel);
4359
4360 	ieee->associate_seq = 1;
4361-	ieee80211_associate_step1(ieee);
4362+	ieee80211_associate_step1_rtl7(ieee);
4363
4364 	up(&ieee->wx_sem);
4365 }
4366
4367-inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net)
4368+inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net)
4369 {
4370
4371 	u8 tmp_ssid[IW_ESSID_MAX_SIZE+1];
4372@@ -1079,7 +1096,7 @@
4373 					ieee->state = IEEE80211_ASSOCIATING;
4374 					queue_work(ieee->wq, &ieee->associate_procedure_wq);
4375 				}else{
4376-					if(ieee80211_is_54g(ieee->current_network) &&
4377+					if(ieee80211_is_54g_rtl7(ieee->current_network) &&
4378 						(ieee->modulation & IEEE80211_OFDM_MODULATION)){
4379 						ieee->rate = 540;
4380 						printk(KERN_INFO"Using G rates\n");
4381@@ -1095,14 +1112,13 @@
4382
4383 }
4384
4385-void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee)
4386+void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee)
4387 {
4388
4389 	unsigned long flags;
4390 	struct ieee80211_network *target;
4391
4392 	spin_lock_irqsave(&ieee->lock, flags);
4393-
4394 	list_for_each_entry(target, &ieee->network_list, list) {
4395
4396 		/* if the state become different that NOLINK means
4397@@ -1112,7 +1128,7 @@
4398 			break;
4399
4400 		//if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies))
4401-			ieee80211_softmac_new_net(ieee, target);
4402+			ieee80211_softmac_new_net_rtl7(ieee, target);
4403 	}
4404
4405 	spin_unlock_irqrestore(&ieee->lock, flags);
4406@@ -1120,7 +1136,7 @@
4407 }
4408
4409
4410-static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
4411+static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen)
4412 {
4413 	struct ieee80211_authentication *a;
4414 	u8 *t;
4415@@ -1145,7 +1161,7 @@
4416 }
4417
4418
4419-int auth_rq_parse(struct sk_buff *skb,u8* dest)
4420+int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest)
4421 {
4422 	struct ieee80211_authentication *a;
4423
4424@@ -1163,7 +1179,7 @@
4425 	return WLAN_STATUS_SUCCESS;
4426 }
4427
4428-static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
4429+static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
4430 {
4431 	u8 *tag;
4432 	u8 *skbend;
4433@@ -1201,7 +1217,7 @@
4434
4435 }
4436
4437-int assoc_rq_parse(struct sk_buff *skb,u8* dest)
4438+int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest)
4439 {
4440 	struct ieee80211_assoc_request_frame *a;
4441
4442@@ -1219,7 +1235,7 @@
4443 	return 0;
4444 }
4445
4446-static inline u16 assoc_parse(struct sk_buff *skb, int *aid)
4447+static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid)
4448 {
4449 	struct ieee80211_assoc_response_frame *a;
4450 	if (skb->len <  sizeof(struct ieee80211_assoc_response_frame)){
4451@@ -1233,45 +1249,45 @@
4452 }
4453
4454 static inline void
4455-ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
4456+ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
4457 {
4458 	u8 dest[ETH_ALEN];
4459
4460 	//IEEE80211DMESG("Rx probe");
4461 	ieee->softmac_stats.rx_probe_rq++;
4462 	//DMESG("Dest is "MACSTR, MAC2STR(dest));
4463-	if (probe_rq_parse(ieee, skb, dest)){
4464+	if (probe_rq_parse_rtl7(ieee, skb, dest)){
4465 		//IEEE80211DMESG("Was for me!");
4466 		ieee->softmac_stats.tx_probe_rs++;
4467-		ieee80211_resp_to_probe(ieee, dest);
4468+		ieee80211_resp_to_probe_rtl7(ieee, dest);
4469 	}
4470 }
4471
4472 static inline void
4473-ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
4474+ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
4475 {
4476 	u8 dest[ETH_ALEN];
4477 	int status;
4478 	//IEEE80211DMESG("Rx probe");
4479 	ieee->softmac_stats.rx_auth_rq++;
4480
4481-	if ((status = auth_rq_parse(skb, dest))!= -1){
4482-		ieee80211_resp_to_auth(ieee, status, dest);
4483+	if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){
4484+		ieee80211_resp_to_auth_rtl7(ieee, status, dest);
4485 	}
4486 	//DMESG("Dest is "MACSTR, MAC2STR(dest));
4487
4488 }
4489
4490 static inline void
4491-ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
4492+ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
4493 {
4494
4495 	u8 dest[ETH_ALEN];
4496 	//unsigned long flags;
4497
4498 	ieee->softmac_stats.rx_ass_rq++;
4499-	if (assoc_rq_parse(skb,dest) != -1){
4500-		ieee80211_resp_to_assoc_rq(ieee, dest);
4501+	if (assoc_rq_parse_rtl7(skb,dest) != -1){
4502+		ieee80211_resp_to_assoc_rq_rtl7(ieee, dest);
4503 	}
4504
4505 	printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest));
4506@@ -1285,18 +1301,18 @@
4507
4508
4509
4510-void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr)
4511+void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr)
4512 {
4513
4514-	struct sk_buff *buf = ieee80211_null_func(ieee, pwr);
4515+	struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr);
4516
4517 	if (buf)
4518-		softmac_ps_mgmt_xmit(buf, ieee);
4519+		softmac_ps_mgmt_xmit_rtl7(buf, ieee);
4520
4521 }
4522
4523
4524-short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
4525+short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
4526 {
4527 	int timeout = ieee->ps_timeout;
4528 	u8 dtim;
4529@@ -1343,7 +1359,7 @@
4530
4531 }
4532
4533-inline void ieee80211_sta_ps(struct ieee80211_device *ieee)
4534+inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee)
4535 {
4536
4537 	u32 th,tl;
4538@@ -1360,12 +1376,12 @@
4539 		#warning CHECK_LOCK_HERE
4540 		spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
4541
4542-		ieee80211_sta_wakeup(ieee, 1);
4543+		ieee80211_sta_wakeup_rtl7(ieee, 1);
4544
4545 		spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
4546 	}
4547
4548-	sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl);
4549+	sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl);
4550 	/* 2 wake, 1 sleep, 0 do nothing */
4551 	if(sleep == 0)
4552 		goto out;
4553@@ -1386,7 +1402,7 @@
4554
4555 				ieee->ps_request_tx_ack(ieee->dev);
4556
4557-				ieee80211_sta_ps_send_null_frame(ieee,1);
4558+				ieee80211_sta_ps_send_null_frame_rtl7(ieee,1);
4559
4560 				ieee->ps_th = th;
4561 				ieee->ps_tl = tl;
4562@@ -1400,7 +1416,7 @@
4563 #warning CHECK_LOCK_HERE
4564 		spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
4565
4566-		ieee80211_sta_wakeup(ieee,1);
4567+		ieee80211_sta_wakeup_rtl7(ieee,1);
4568
4569 		spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
4570 	}
4571@@ -1410,13 +1426,13 @@
4572
4573 }
4574
4575-void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl)
4576+void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl)
4577 {
4578 	if(ieee->sta_sleep == 0){
4579 		if(nl){
4580 			printk("Warning: driver is probably failing to report TX ps error\n");
4581 			ieee->ps_request_tx_ack(ieee->dev);
4582-			ieee80211_sta_ps_send_null_frame(ieee, 0);
4583+			ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
4584 		}
4585 		return;
4586
4587@@ -1429,11 +1445,11 @@
4588
4589 	if(nl){
4590 		ieee->ps_request_tx_ack(ieee->dev);
4591-		ieee80211_sta_ps_send_null_frame(ieee, 0);
4592+		ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
4593 	}
4594 }
4595
4596-void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
4597+void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success)
4598 {
4599 	unsigned long flags,flags2;
4600
4601@@ -1454,7 +1470,7 @@
4602
4603 		if((ieee->sta_sleep == 0) && !success){
4604 			spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
4605-			ieee80211_sta_ps_send_null_frame(ieee, 0);
4606+			ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
4607 			spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
4608 		}
4609 	}
4610@@ -1462,17 +1478,18 @@
4611 }
4612
4613 inline int
4614-ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
4615+ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
4616 			struct ieee80211_rx_stats *rx_stats, u16 type,
4617 			u16 stype)
4618 {
4619 	struct ieee80211_hdr_3addr *header;
4620-	header = (struct ieee80211_hdr_3addr *) skb->data;
4621 	u16 errcode;
4622 	u8* challenge;
4623 	int chlen;
4624 	int aid;
4625
4626+	header = (struct ieee80211_hdr_3addr *) skb->data;
4627+
4628 	if(!ieee->proto_started)
4629 		return 0;
4630
4631@@ -1496,19 +1513,19 @@
4632 			if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
4633 				ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
4634 				ieee->iw_mode == IW_MODE_INFRA){
4635-				if (0 == (errcode=assoc_parse(skb, &aid))){
4636+				if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){
4637
4638 					ieee->state=IEEE80211_LINKED;
4639 					ieee->assoc_id = aid;
4640 					ieee->softmac_stats.rx_ass_ok++;
4641
4642-					ieee80211_associate_complete(ieee);
4643+					ieee80211_associate_complete_rtl7(ieee);
4644 				}else{
4645 					ieee->softmac_stats.rx_ass_err++;
4646 					IEEE80211_DEBUG_MGMT(
4647 						"Association response status code 0x%x\n",
4648 						errcode);
4649-					ieee80211_associate_abort(ieee);
4650+					ieee80211_associate_abort_rtl7(ieee);
4651 				}
4652 			}
4653 			break;
4654@@ -1519,7 +1536,7 @@
4655 			if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
4656 				ieee->iw_mode == IW_MODE_MASTER)
4657
4658-				ieee80211_rx_assoc_rq(ieee, skb);
4659+				ieee80211_rx_assoc_rq_rtl7(ieee, skb);
4660 			break;
4661
4662 		case IEEE80211_STYPE_AUTH:
4663@@ -1530,23 +1547,23 @@
4664
4665 						IEEE80211_DEBUG_MGMT("Received authentication response");
4666
4667-						if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){
4668+						if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){
4669 							if(ieee->open_wep || !challenge){
4670 								ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED;
4671 								ieee->softmac_stats.rx_auth_rs_ok++;
4672
4673-								ieee80211_associate_step2(ieee);
4674+								ieee80211_associate_step2_rtl7(ieee);
4675 							}else{
4676-								ieee80211_auth_challenge(ieee, challenge, chlen);
4677+								ieee80211_auth_challenge_rtl7(ieee, challenge, chlen);
4678 							}
4679 						}else{
4680 							ieee->softmac_stats.rx_auth_rs_err++;
4681 							IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode);
4682-							ieee80211_associate_abort(ieee);
4683+							ieee80211_associate_abort_rtl7(ieee);
4684 						}
4685
4686 					}else if (ieee->iw_mode == IW_MODE_MASTER){
4687-						ieee80211_rx_auth_rq(ieee, skb);
4688+						ieee80211_rx_auth_rq_rtl7(ieee, skb);
4689 					}
4690 				}
4691 			break;
4692@@ -1558,7 +1575,7 @@
4693 				ieee->iw_mode == IW_MODE_MASTER) &&
4694 				ieee->state == IEEE80211_LINKED))
4695
4696-				ieee80211_rx_probe_rq(ieee, skb);
4697+				ieee80211_rx_probe_rq_rtl7(ieee, skb);
4698 			break;
4699
4700 		case IEEE80211_STYPE_DISASSOC:
4701@@ -1573,8 +1590,8 @@
4702 				ieee->state = IEEE80211_ASSOCIATING;
4703 				ieee->softmac_stats.reassoc++;
4704
4705-				notify_wx_assoc_event(ieee);
4706-
4707+				notify_wx_assoc_event_rtl7(ieee);
4708+
4709 				queue_work(ieee->wq, &ieee->associate_procedure_wq);
4710 			}
4711
4712@@ -1610,7 +1627,7 @@
4713  * to the driver later, when it wakes the queue.
4714  */
4715
4716-void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
4717+void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
4718 {
4719
4720
4721@@ -1643,7 +1660,7 @@
4722 	#endif
4723
4724 	/* called with 2nd parm 0, no tx mgmt lock required */
4725-	ieee80211_sta_wakeup(ieee,0);
4726+	ieee80211_sta_wakeup_rtl7(ieee,0);
4727
4728 	for(i = 0; i < txb->nr_frags; i++) {
4729
4730@@ -1662,7 +1679,7 @@
4731 		}
4732 	}
4733
4734-	ieee80211_txb_free(txb);
4735+	ieee80211_txb_free_rtl7(txb);
4736
4737 	exit:
4738 	spin_unlock_irqrestore(&ieee->lock,flags);
4739@@ -1670,7 +1687,7 @@
4740 }
4741
4742 /* called with ieee->lock acquired */
4743-void ieee80211_resume_tx(struct ieee80211_device *ieee)
4744+void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee)
4745 {
4746 	int i;
4747 	for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) {
4748@@ -1690,19 +1707,19 @@
4749 	}
4750
4751
4752-	ieee80211_txb_free(ieee->tx_pending.txb);
4753+	ieee80211_txb_free_rtl7(ieee->tx_pending.txb);
4754 	ieee->tx_pending.txb = NULL;
4755 }
4756
4757
4758-void ieee80211_reset_queue(struct ieee80211_device *ieee)
4759+void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee)
4760 {
4761 	unsigned long flags;
4762
4763 	spin_lock_irqsave(&ieee->lock,flags);
4764-	init_mgmt_queue(ieee);
4765+	init_mgmt_queue_rtl7(ieee);
4766 	if (ieee->tx_pending.txb){
4767-		ieee80211_txb_free(ieee->tx_pending.txb);
4768+		ieee80211_txb_free_rtl7(ieee->tx_pending.txb);
4769 		ieee->tx_pending.txb = NULL;
4770 	}
4771 	ieee->queue_stop = 0;
4772@@ -1710,7 +1727,7 @@
4773
4774 }
4775
4776-void ieee80211_wake_queue(struct ieee80211_device *ieee)
4777+void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee)
4778 {
4779
4780 	unsigned long flags;
4781@@ -1723,7 +1740,7 @@
4782 	ieee->queue_stop = 0;
4783
4784 	if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){
4785-		while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){
4786+		while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){
4787
4788 			header = (struct ieee80211_hdr_3addr  *) skb->data;
4789
4790@@ -1738,7 +1755,7 @@
4791 		}
4792 	}
4793 	if (!ieee->queue_stop && ieee->tx_pending.txb)
4794-		ieee80211_resume_tx(ieee);
4795+		ieee80211_resume_tx_rtl7(ieee);
4796
4797 	if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){
4798 		ieee->softmac_stats.swtxawake++;
4799@@ -1750,7 +1767,7 @@
4800 }
4801
4802
4803-void ieee80211_stop_queue(struct ieee80211_device *ieee)
4804+void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee)
4805 {
4806 	//unsigned long flags;
4807 	//spin_lock_irqsave(&ieee->lock,flags);
4808@@ -1765,7 +1782,7 @@
4809 }
4810
4811
4812-inline void ieee80211_randomize_cell(struct ieee80211_device *ieee)
4813+inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee)
4814 {
4815
4816 	get_random_bytes(ieee->current_network.bssid, ETH_ALEN);
4817@@ -1778,7 +1795,7 @@
4818 }
4819
4820 /* called in user context only */
4821-void ieee80211_start_master_bss(struct ieee80211_device *ieee)
4822+void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee)
4823 {
4824 	ieee->assoc_id = 1;
4825
4826@@ -1796,7 +1813,7 @@
4827 	ieee->set_chan(ieee->dev, ieee->current_network.channel);
4828 	ieee->state = IEEE80211_LINKED;
4829 	ieee->link_change(ieee->dev);
4830-	notify_wx_assoc_event(ieee);
4831+	notify_wx_assoc_event_rtl7(ieee);
4832
4833 	if (ieee->data_hard_resume)
4834 		ieee->data_hard_resume(ieee->dev);
4835@@ -1804,7 +1821,7 @@
4836 	netif_carrier_on(ieee->dev);
4837 }
4838
4839-void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
4840+void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee)
4841 {
4842 	if(ieee->raw_tx){
4843
4844@@ -1814,8 +1831,15 @@
4845 		netif_carrier_on(ieee->dev);
4846 	}
4847 }
4848-void ieee80211_start_ibss_wq(struct ieee80211_device *ieee)
4849+
4850+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
4851+void ieee80211_start_ibss_wq_rtl7(struct work_struct *work)
4852 {
4853+	struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq);
4854+#else
4855+void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee)
4856+{
4857+#endif
4858
4859 	/* iwconfig mode ad-hoc will schedule this and return
4860 	 * on the other hand this will block further iwconfig SET
4861@@ -1834,7 +1858,7 @@
4862 	}
4863
4864 	/* check if we have this cell in our network list */
4865-	ieee80211_softmac_check_all_nets(ieee);
4866+	ieee80211_softmac_check_all_nets_rtl7(ieee);
4867
4868 	/* if not then the state is not linked. Maybe the user swithced to
4869 	 * ad-hoc mode just after being in monitor mode, or just after
4870@@ -1851,13 +1875,13 @@
4871 	 * associated.
4872 	 */
4873 	if (ieee->state == IEEE80211_NOLINK)
4874-		ieee80211_start_scan_syncro(ieee);
4875+		ieee80211_start_scan_syncro_rtl7(ieee);
4876
4877 	/* the network definitively is not here.. create a new cell */
4878 	if (ieee->state == IEEE80211_NOLINK){
4879 		printk("creating new IBSS cell\n");
4880 		if(!ieee->wap_set)
4881-			ieee80211_randomize_cell(ieee);
4882+			ieee80211_randomize_cell_rtl7(ieee);
4883
4884 		if(ieee->modulation & IEEE80211_CCK_MODULATION){
4885
4886@@ -1901,9 +1925,9 @@
4887 	ieee->set_chan(ieee->dev, ieee->current_network.channel);
4888 	ieee->link_change(ieee->dev);
4889
4890-	notify_wx_assoc_event(ieee);
4891+	notify_wx_assoc_event_rtl7(ieee);
4892
4893-	ieee80211_start_send_beacons(ieee);
4894+	ieee80211_start_send_beacons_rtl7(ieee);
4895
4896 	if (ieee->data_hard_resume)
4897 		ieee->data_hard_resume(ieee->dev);
4898@@ -1913,13 +1937,13 @@
4899 	up(&ieee->wx_sem);
4900 }
4901
4902-inline void ieee80211_start_ibss(struct ieee80211_device *ieee)
4903+inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee)
4904 {
4905 	queue_work(ieee->wq, &ieee->start_ibss_wq);
4906 }
4907
4908 /* this is called only in user context, with wx_sem held */
4909-void ieee80211_start_bss(struct ieee80211_device *ieee)
4910+void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee)
4911 {
4912 	unsigned long flags;
4913 	/* check if we have already found the net we
4914@@ -1927,7 +1951,7 @@
4915 	 * if not (we are disassociated and we are not
4916 	 * in associating / authenticating phase) start the background scanning.
4917 	 */
4918-	ieee80211_softmac_check_all_nets(ieee);
4919+	ieee80211_softmac_check_all_nets_rtl7(ieee);
4920
4921 	/* ensure no-one start an associating process (thus setting
4922 	 * the ieee->state to ieee80211_ASSOCIATING) while we
4923@@ -1937,34 +1961,42 @@
4924 	 * the rx path), so we cannot be in the middle of such function
4925 	 */
4926 	spin_lock_irqsave(&ieee->lock, flags);
4927-
4928 	if (ieee->state == IEEE80211_NOLINK)
4929-		ieee80211_start_scan(ieee);
4930+		ieee80211_start_scan_rtl7(ieee);
4931
4932 	spin_unlock_irqrestore(&ieee->lock, flags);
4933 }
4934
4935 /* called only in userspace context */
4936-void ieee80211_disassociate(struct ieee80211_device *ieee)
4937+void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee)
4938 {
4939 	netif_carrier_off(ieee->dev);
4940
4941 	if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)
4942-			ieee80211_reset_queue(ieee);
4943+			ieee80211_reset_queue_rtl7(ieee);
4944
4945 	if (ieee->data_hard_stop)
4946 			ieee->data_hard_stop(ieee->dev);
4947
4948 	ieee->state = IEEE80211_NOLINK;
4949 	ieee->link_change(ieee->dev);
4950-	notify_wx_assoc_event(ieee);
4951+	notify_wx_assoc_event_rtl7(ieee);
4952
4953 }
4954-void ieee80211_associate_retry_wq(struct ieee80211_device *ieee)
4955+
4956+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
4957+void ieee80211_associate_retry_wq_rtl7(struct work_struct *work)
4958+{
4959+	struct delayed_work *dwork = container_of(work, struct delayed_work, work);
4960+	struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);
4961+#else
4962+void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee)
4963 {
4964+#endif
4965 	unsigned long flags;
4966
4967 	down(&ieee->wx_sem);
4968+
4969 	if(!ieee->proto_started)
4970 		goto exit;
4971
4972@@ -1986,12 +2018,12 @@
4973 	*/
4974 	ieee->state = IEEE80211_NOLINK;
4975
4976-	ieee80211_softmac_check_all_nets(ieee);
4977+	ieee80211_softmac_check_all_nets_rtl7(ieee);
4978
4979 	spin_lock_irqsave(&ieee->lock, flags);
4980
4981 	if(ieee->state == IEEE80211_NOLINK)
4982-		ieee80211_start_scan(ieee);
4983+		ieee80211_start_scan_rtl7(ieee);
4984
4985 	spin_unlock_irqrestore(&ieee->lock, flags);
4986
4987@@ -1999,14 +2031,14 @@
4988 	up(&ieee->wx_sem);
4989 }
4990
4991-struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee)
4992+struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee)
4993 {
4994 	u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff};
4995
4996 	struct sk_buff *skb;
4997 	struct ieee80211_probe_response *b;
4998
4999-	skb = ieee80211_probe_resp(ieee, broadcast_addr);
5000+	skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr);
5001
5002 	if (!skb)
5003 		return NULL;
5004@@ -2018,12 +2050,12 @@
5005
5006 }
5007
5008-struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee)
5009+struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee)
5010 {
5011 	struct sk_buff *skb;
5012 	struct ieee80211_probe_response *b;
5013
5014-	skb = ieee80211_get_beacon_(ieee);
5015+	skb = ieee80211_get_beacon__rtl7(ieee);
5016 	if(!skb)
5017 		return NULL;
5018
5019@@ -2038,44 +2070,44 @@
5020 	return skb;
5021 }
5022
5023-void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee)
5024+void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee)
5025 {
5026 	ieee->sync_scan_hurryup = 1;
5027 	down(&ieee->wx_sem);
5028-	ieee80211_stop_protocol(ieee);
5029+
5030+	ieee80211_stop_protocol_rtl7(ieee);
5031 	up(&ieee->wx_sem);
5032 }
5033
5034
5035-void ieee80211_stop_protocol(struct ieee80211_device *ieee)
5036+void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee)
5037 {
5038 	if (!ieee->proto_started)
5039 		return;
5040
5041 	ieee->proto_started = 0;
5042
5043-	ieee80211_stop_send_beacons(ieee);
5044+	ieee80211_stop_send_beacons_rtl7(ieee);
5045
5046 	del_timer_sync(&ieee->associate_timer);
5047 	cancel_delayed_work(&ieee->associate_retry_wq);
5048
5049-	ieee80211_stop_scan(ieee);
5050+	ieee80211_stop_scan_rtl7(ieee);
5051
5052-	ieee80211_disassociate(ieee);
5053+	ieee80211_disassociate_rtl7(ieee);
5054 }
5055
5056-void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee)
5057+void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee)
5058 {
5059 	ieee->sync_scan_hurryup = 0;
5060 	down(&ieee->wx_sem);
5061-	ieee80211_start_protocol(ieee);
5062+	ieee80211_start_protocol_rtl7(ieee);
5063 	up(&ieee->wx_sem);
5064 }
5065
5066-void ieee80211_start_protocol(struct ieee80211_device *ieee)
5067+void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee)
5068 {
5069 	short ch = 0;
5070-
5071 	if (ieee->proto_started)
5072 		return;
5073
5074@@ -2094,9 +2126,7 @@
5075
5076 	if (ieee->current_network.beacon_interval == 0)
5077 		ieee->current_network.beacon_interval = 100;
5078-
5079 	ieee->set_chan(ieee->dev,ieee->current_network.channel);
5080-
5081 	ieee->last_seq_num = -1;
5082 	ieee->last_frag_num = -1;
5083 	ieee->last_packet_time = 0;
5084@@ -2109,21 +2139,18 @@
5085 	 */
5086
5087 	if (ieee->iw_mode == IW_MODE_INFRA)
5088-		ieee80211_start_bss(ieee);
5089-
5090+		ieee80211_start_bss_rtl7(ieee);
5091 	else if (ieee->iw_mode == IW_MODE_ADHOC)
5092-		ieee80211_start_ibss(ieee);
5093-
5094+		ieee80211_start_ibss_rtl7(ieee);
5095 	else if (ieee->iw_mode == IW_MODE_MASTER)
5096-		ieee80211_start_master_bss(ieee);
5097-
5098+		ieee80211_start_master_bss_rtl7(ieee);
5099 	else if(ieee->iw_mode == IW_MODE_MONITOR)
5100-		ieee80211_start_monitor_mode(ieee);
5101+		ieee80211_start_monitor_mode_rtl7(ieee);
5102 }
5103
5104
5105 #define DRV_NAME  "Ieee80211"
5106-void ieee80211_softmac_init(struct ieee80211_device *ieee)
5107+void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee)
5108 {
5109 	memset(&ieee->current_network, 0, sizeof(struct ieee80211_network));
5110
5111@@ -2143,7 +2170,7 @@
5112 	ieee->ps = IEEE80211_PS_DISABLED;
5113 	ieee->sta_sleep = 0;
5114
5115-	init_mgmt_queue(ieee);
5116+	init_mgmt_queue_rtl7(ieee);
5117 #if 0
5118 	init_timer(&ieee->scan_timer);
5119 	ieee->scan_timer.data = (unsigned long)ieee;
5120@@ -2153,25 +2180,34 @@
5121
5122 	init_timer(&ieee->associate_timer);
5123 	ieee->associate_timer.data = (unsigned long)ieee;
5124-	ieee->associate_timer.function = ieee80211_associate_abort_cb;
5125+	ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7;
5126
5127 	init_timer(&ieee->beacon_timer);
5128 	ieee->beacon_timer.data = (unsigned long) ieee;
5129-	ieee->beacon_timer.function = ieee80211_send_beacon_cb;
5130+	ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7;
5131
5132 #ifdef PF_SYNCTHREAD
5133 	ieee->wq = create_workqueue(DRV_NAME,0);
5134 #else
5135 	ieee->wq = create_workqueue(DRV_NAME);
5136 #endif
5137-
5138-	INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee);
5139-	INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee);
5140-	INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee);
5141-	INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee);
5142-	INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee);
5143-	INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee);
5144-
5145+
5146+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
5147+	INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee);
5148+	INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee);
5149+	INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee);
5150+	INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee);
5151+	INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee);
5152+	INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee);
5153+#else
5154+	INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7);
5155+	INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7);
5156+	INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7);
5157+	INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7);
5158+	INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7);
5159+	INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7);
5160+#endif
5161+
5162 	sema_init(&ieee->wx_sem, 1);
5163 	sema_init(&ieee->scan_sem, 1);
5164
5165@@ -2179,12 +2215,12 @@
5166 	spin_lock_init(&ieee->beacon_lock);
5167
5168 	tasklet_init(&ieee->ps_task,
5169-	     (void(*)(unsigned long)) ieee80211_sta_ps,
5170+	     (void(*)(unsigned long)) ieee80211_sta_ps_rtl7,
5171 	     (unsigned long)ieee);
5172
5173 }
5174
5175-void ieee80211_softmac_free(struct ieee80211_device *ieee)
5176+void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee)
5177 {
5178 	down(&ieee->wx_sem);
5179
5180@@ -2201,7 +2237,7 @@
5181  ********************************************************/
5182
5183
5184-static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value)
5185+static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value)
5186 {
5187 	/* This is called when wpa_supplicant loads and closes the driver
5188 	 * interface. */
5189@@ -2211,16 +2247,16 @@
5190 }
5191
5192
5193-void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
5194+void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
5195 {
5196 	/* make sure WPA is enabled */
5197-	ieee80211_wpa_enable(ieee, 1);
5198+	ieee80211_wpa_enable_rtl7(ieee, 1);
5199
5200-	ieee80211_disassociate(ieee);
5201+	ieee80211_disassociate_rtl7(ieee);
5202 }
5203
5204
5205-static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason)
5206+static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason)
5207 {
5208
5209 	int ret = 0;
5210@@ -2231,7 +2267,7 @@
5211 		break;
5212
5213 	case IEEE_MLME_STA_DISASSOC:
5214-		ieee80211_disassociate(ieee);
5215+		ieee80211_disassociate_rtl7(ieee);
5216 		break;
5217
5218 	default:
5219@@ -2243,7 +2279,7 @@
5220 }
5221
5222
5223-static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee,
5224+static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee,
5225 			      struct ieee_param *param, int plen)
5226 {
5227 	u8 *buf;
5228@@ -2267,14 +2303,14 @@
5229 		ieee->wpa_ie_len = 0;
5230 	}
5231
5232-	ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
5233+	ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
5234 	return 0;
5235 }
5236
5237 #define AUTH_ALG_OPEN_SYSTEM			0x1
5238 #define AUTH_ALG_SHARED_KEY			0x2
5239
5240-static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value)
5241+static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value)
5242 {
5243
5244 	struct ieee80211_security sec = {
5245@@ -2300,13 +2336,13 @@
5246
5247
5248
5249-static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value)
5250+static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value)
5251 {
5252 	int ret=0;
5253
5254 	switch (name) {
5255 	case IEEE_PARAM_WPA_ENABLED:
5256-		ret = ieee80211_wpa_enable(ieee, value);
5257+		ret = ieee80211_wpa_enable_rtl7(ieee, value);
5258 		break;
5259
5260 	case IEEE_PARAM_TKIP_COUNTERMEASURES:
5261@@ -2351,7 +2387,7 @@
5262 		break;
5263
5264 	case IEEE_PARAM_AUTH_ALGS:
5265-		ret = ieee80211_wpa_set_auth_algs(ieee, value);
5266+		ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value);
5267 		break;
5268
5269 	case IEEE_PARAM_IEEE_802_1X:
5270@@ -2368,7 +2404,7 @@
5271
5272 /* implementation borrowed from hostap driver */
5273
5274-static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
5275+static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee,
5276 				  struct ieee_param *param, int param_len)
5277 {
5278 	int ret = 0;
5279@@ -2407,7 +2443,7 @@
5280 			//sec.encrypt = 0;
5281 			sec.level = SEC_LEVEL_0;
5282 			sec.flags |= SEC_ENABLED | SEC_LEVEL;
5283-			ieee80211_crypt_delayed_deinit(ieee, crypt);
5284+			ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
5285 		}
5286 		goto done;
5287 	}
5288@@ -2421,16 +2457,16 @@
5289 	    strcmp(param->u.crypt.alg, "TKIP"))
5290 		goto skip_host_crypt;
5291
5292-	ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
5293+	ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
5294 	if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
5295-		request_module("ieee80211_crypt_wep");
5296-		ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
5297+		request_module("ieee80211_crypt_wep_rtl7");
5298+		ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
5299 	} else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
5300-		request_module("ieee80211_crypt_tkip");
5301-		ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
5302+		request_module("ieee80211_crypt_tkip_rtl7");
5303+		ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
5304 	} else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
5305-		request_module("ieee80211_crypt_ccmp");
5306-		ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
5307+		request_module("ieee80211_crypt_ccmp_rtl7");
5308+		ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
5309 	}
5310 	if (ops == NULL) {
5311 		printk("unknown crypto alg '%s'\n", param->u.crypt.alg);
5312@@ -2442,7 +2478,7 @@
5313 	if (*crypt == NULL || (*crypt)->ops != ops) {
5314 		struct ieee80211_crypt_data *new_crypt;
5315
5316-		ieee80211_crypt_delayed_deinit(ieee, crypt);
5317+		ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
5318
5319 		new_crypt = (struct ieee80211_crypt_data *)
5320 			kmalloc(sizeof(*new_crypt), GFP_KERNEL);
5321@@ -2525,7 +2561,7 @@
5322
5323
5324
5325-int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p)
5326+int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p)
5327 {
5328 	struct ieee_param *param;
5329 	int ret=0;
5330@@ -2552,20 +2588,20 @@
5331 	switch (param->cmd) {
5332
5333 	case IEEE_CMD_SET_WPA_PARAM:
5334-		ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name,
5335+		ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name,
5336 					param->u.wpa_param.value);
5337 		break;
5338
5339 	case IEEE_CMD_SET_WPA_IE:
5340-		ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length);
5341+		ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length);
5342 		break;
5343
5344 	case IEEE_CMD_SET_ENCRYPTION:
5345-		ret = ieee80211_wpa_set_encryption(ieee, param, p->length);
5346+		ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length);
5347 		break;
5348
5349 	case IEEE_CMD_MLME:
5350-		ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command,
5351+		ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command,
5352 				   param->u.mlme.reason_code);
5353 		break;
5354
5355@@ -2585,7 +2621,7 @@
5356 	return ret;
5357 }
5358
5359-void notify_wx_assoc_event(struct ieee80211_device *ieee)
5360+void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee)
5361 {
5362 	union iwreq_data wrqu;
5363 	wrqu.ap_addr.sa_family = ARPHRD_ETHER;
5364@@ -2597,14 +2633,14 @@
5365 }
5366
5367
5368-EXPORT_SYMBOL(ieee80211_get_beacon);
5369-EXPORT_SYMBOL(ieee80211_wake_queue);
5370-EXPORT_SYMBOL(ieee80211_stop_queue);
5371-EXPORT_SYMBOL(ieee80211_reset_queue);
5372-EXPORT_SYMBOL(ieee80211_softmac_stop_protocol);
5373-EXPORT_SYMBOL(ieee80211_softmac_start_protocol);
5374-EXPORT_SYMBOL(ieee80211_is_shortslot);
5375-EXPORT_SYMBOL(ieee80211_is_54g);
5376-EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl);
5377-EXPORT_SYMBOL(ieee80211_ps_tx_ack);
5378-//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame);
5379+EXPORT_SYMBOL(ieee80211_get_beacon_rtl7);
5380+EXPORT_SYMBOL(ieee80211_wake_queue_rtl7);
5381+EXPORT_SYMBOL(ieee80211_stop_queue_rtl7);
5382+EXPORT_SYMBOL(ieee80211_reset_queue_rtl7);
5383+EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7);
5384+EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7);
5385+EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7);
5386+EXPORT_SYMBOL(ieee80211_is_54g_rtl7);
5387+EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7);
5388+EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7);
5389+//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7);
5390diff -Naur rtl8187_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_txpower/ieee80211/ieee80211_softmac_wx.c
5391--- rtl8187_orig/ieee80211/ieee80211_softmac_wx.c	2006-06-06 04:57:54.000000000 +0200
5392+++ rtl8187_txpower/ieee80211/ieee80211_softmac_wx.c	2007-02-26 03:05:16.011549039 +0100
5393@@ -18,7 +18,7 @@
5394
5395 /* FIXME: add A freqs */
5396
5397-const long ieee80211_wlan_frequencies[] = {
5398+const long ieee80211_wlan_frequencies_rtl7[] = {
5399 	2412, 2417, 2422, 2427,
5400 	2432, 2437, 2442, 2447,
5401 	2452, 2457, 2462, 2467,
5402@@ -26,7 +26,7 @@
5403 };
5404
5405
5406-int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
5407+int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
5408 			     union iwreq_data *wrqu, char *b)
5409 {
5410 	int ret;
5411@@ -46,7 +46,7 @@
5412 			int f = fwrq->m / 100000;
5413 			int c = 0;
5414
5415-			while ((c < 14) && (f != ieee80211_wlan_frequencies[c]))
5416+			while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c]))
5417 				c++;
5418
5419 			/* hack to fall through */
5420@@ -68,8 +68,8 @@
5421 		if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
5422 			if(ieee->state == IEEE80211_LINKED){
5423
5424-			ieee80211_stop_send_beacons(ieee);
5425-			ieee80211_start_send_beacons(ieee);
5426+			ieee80211_stop_send_beacons_rtl7(ieee);
5427+			ieee80211_start_send_beacons_rtl7(ieee);
5428 			}
5429 	}
5430
5431@@ -80,7 +80,7 @@
5432 }
5433
5434
5435-int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
5436+int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee,
5437 			     struct iw_request_info *a,
5438 			     union iwreq_data *wrqu, char *b)
5439 {
5440@@ -95,7 +95,7 @@
5441 	return 0;
5442 }
5443
5444-int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
5445+int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
5446 			    struct iw_request_info *info,
5447 			    union iwreq_data *wrqu, char *extra)
5448 {
5449@@ -124,7 +124,7 @@
5450 }
5451
5452
5453-int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
5454+int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
5455 			 struct iw_request_info *info,
5456 			 union iwreq_data *awrq,
5457 			 char *extra)
5458@@ -134,14 +134,14 @@
5459 	u8 zero[] = {0,0,0,0,0,0};
5460 	unsigned long flags;
5461
5462+	struct sockaddr *temp = NULL;
5463 	short ifup = ieee->proto_started;//dev->flags & IFF_UP;
5464
5465 	ieee->sync_scan_hurryup = 1;
5466
5467 	down(&ieee->wx_sem);
5468
5469-	struct sockaddr *temp = (struct sockaddr *)awrq;
5470-
5471+	temp = (struct sockaddr *)awrq;
5472 	/* use ifconfig hw ether */
5473 	if (ieee->iw_mode == IW_MODE_MASTER){
5474 		ret = -1;
5475@@ -154,7 +154,7 @@
5476 	}
5477
5478 	if (ifup)
5479-		ieee80211_stop_protocol(ieee);
5480+		ieee80211_stop_protocol_rtl7(ieee);
5481
5482 	/* just to avoid to give inconsistent infos in the
5483 	 * get wx method. not really needed otherwise
5484@@ -167,14 +167,14 @@
5485 	spin_unlock_irqrestore(&ieee->lock, flags);
5486
5487 	if (ifup)
5488-		ieee80211_start_protocol(ieee);
5489+		ieee80211_start_protocol_rtl7(ieee);
5490
5491 out:
5492 	up(&ieee->wx_sem);
5493 	return ret;
5494 }
5495
5496- int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
5497+ int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
5498 {
5499 	int len,ret = 0;
5500 	unsigned long flags;
5501@@ -209,7 +209,7 @@
5502
5503 }
5504
5505-int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
5506+int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
5507 			     struct iw_request_info *info,
5508 			     union iwreq_data *wrqu, char *extra)
5509 {
5510@@ -223,7 +223,7 @@
5511
5512
5513
5514-int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
5515+int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
5516 			     struct iw_request_info *info,
5517 			     union iwreq_data *wrqu, char *extra)
5518 {
5519@@ -233,7 +233,7 @@
5520 	return 0;
5521 }
5522
5523-int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
5524+int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
5525 			     union iwreq_data *wrqu, char *b)
5526 {
5527
5528@@ -245,8 +245,7 @@
5529 		goto out;
5530
5531 	if (wrqu->mode == IW_MODE_MONITOR){
5532-
5533-		ieee->dev->type = ARPHRD_IEEE80211;
5534+		ieee->dev->type = ARPHRD_IEEE80211_PRISM;
5535 	}else{
5536 		ieee->dev->type = ARPHRD_ETHER;
5537 	}
5538@@ -254,9 +253,9 @@
5539 	if (!ieee->proto_started){
5540 		ieee->iw_mode = wrqu->mode;
5541 	}else{
5542-		ieee80211_stop_protocol(ieee);
5543+		ieee80211_stop_protocol_rtl7(ieee);
5544 		ieee->iw_mode = wrqu->mode;
5545-		ieee80211_start_protocol(ieee);
5546+		ieee80211_start_protocol_rtl7(ieee);
5547 	}
5548
5549 out:
5550@@ -264,8 +263,14 @@
5551 	return 0;
5552 }
5553
5554-void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee)
5555+# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
5556+void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work)
5557+{
5558+	struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
5559+#else
5560+void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee)
5561 {
5562+#endif
5563 	short chan;
5564
5565 	chan = ieee->current_network.channel;
5566@@ -275,12 +280,12 @@
5567 	if (ieee->data_hard_stop)
5568 		ieee->data_hard_stop(ieee->dev);
5569
5570-	ieee80211_stop_send_beacons(ieee);
5571+	ieee80211_stop_send_beacons_rtl7(ieee);
5572
5573 	ieee->state = IEEE80211_LINKED_SCANNING;
5574 	ieee->link_change(ieee->dev);
5575
5576-	ieee80211_start_scan_syncro(ieee);
5577+	ieee80211_start_scan_syncro_rtl7(ieee);
5578
5579 	ieee->set_chan(ieee->dev, chan);
5580
5581@@ -291,7 +296,7 @@
5582 		ieee->data_hard_resume(ieee->dev);
5583
5584 	if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
5585-		ieee80211_start_send_beacons(ieee);
5586+		ieee80211_start_send_beacons_rtl7(ieee);
5587
5588 	netif_carrier_on(ieee->dev);
5589
5590@@ -299,7 +304,7 @@
5591
5592 }
5593
5594-int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
5595+int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
5596 			     union iwreq_data *wrqu, char *b)
5597 {
5598 	int ret = 0;
5599@@ -322,7 +327,7 @@
5600 	return ret;
5601 }
5602
5603-int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
5604+int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
5605 			      struct iw_request_info *a,
5606 			      union iwreq_data *wrqu, char *extra)
5607 {
5608@@ -348,7 +353,7 @@
5609 	}
5610
5611 	if(proto_started)
5612-		ieee80211_stop_protocol(ieee);
5613+		ieee80211_stop_protocol_rtl7(ieee);
5614
5615 	/* this is just to be sure that the GET wx callback
5616 	 * has consisten infos. not needed otherwise
5617@@ -371,13 +376,13 @@
5618 	spin_unlock_irqrestore(&ieee->lock, flags);
5619
5620 	if (proto_started)
5621-		ieee80211_start_protocol(ieee);
5622+		ieee80211_start_protocol_rtl7(ieee);
5623 out:
5624 	up(&ieee->wx_sem);
5625 	return ret;
5626 }
5627
5628- int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
5629+ int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
5630 			     union iwreq_data *wrqu, char *b)
5631 {
5632
5633@@ -385,7 +390,7 @@
5634 	return 0;
5635 }
5636
5637- int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
5638+ int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
5639 			       struct iw_request_info *info,
5640 			       union iwreq_data *wrqu, char *extra)
5641 {
5642@@ -422,7 +427,7 @@
5643 	return 0;
5644 }
5645
5646-int ieee80211_wx_get_name(struct ieee80211_device *ieee,
5647+int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
5648 			     struct iw_request_info *info,
5649 			     union iwreq_data *wrqu, char *extra)
5650 {
5651@@ -446,7 +451,7 @@
5652
5653
5654 /* this is mostly stolen from hostap */
5655-int ieee80211_wx_set_power(struct ieee80211_device *ieee,
5656+int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
5657 				 struct iw_request_info *info,
5658 				 union iwreq_data *wrqu, char *extra)
5659 {
5660@@ -509,7 +514,7 @@
5661 }
5662
5663 /* this is stolen from hostap */
5664-int ieee80211_wx_get_power(struct ieee80211_device *ieee,
5665+int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
5666 				 struct iw_request_info *info,
5667 				 union iwreq_data *wrqu, char *extra)
5668 {
5669@@ -547,19 +552,19 @@
5670
5671 }
5672
5673-EXPORT_SYMBOL(ieee80211_wx_get_essid);
5674-EXPORT_SYMBOL(ieee80211_wx_set_essid);
5675-EXPORT_SYMBOL(ieee80211_wx_set_rate);
5676-EXPORT_SYMBOL(ieee80211_wx_get_rate);
5677-EXPORT_SYMBOL(ieee80211_wx_set_wap);
5678-EXPORT_SYMBOL(ieee80211_wx_get_wap);
5679-EXPORT_SYMBOL(ieee80211_wx_set_mode);
5680-EXPORT_SYMBOL(ieee80211_wx_get_mode);
5681-EXPORT_SYMBOL(ieee80211_wx_set_scan);
5682-EXPORT_SYMBOL(ieee80211_wx_get_freq);
5683-EXPORT_SYMBOL(ieee80211_wx_set_freq);
5684-EXPORT_SYMBOL(ieee80211_wx_set_rawtx);
5685-EXPORT_SYMBOL(ieee80211_wx_get_name);
5686-EXPORT_SYMBOL(ieee80211_wx_set_power);
5687-EXPORT_SYMBOL(ieee80211_wx_get_power);
5688-EXPORT_SYMBOL(ieee80211_wlan_frequencies);
5689+EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7);
5690+EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7);
5691+EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7);
5692+EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7);
5693+EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7);
5694+EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7);
5695+EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7);
5696+EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7);
5697+EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7);
5698+EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7);
5699+EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7);
5700+EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7);
5701+EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7);
5702+EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7);
5703+EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7);
5704+EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7);
5705diff -Naur rtl8187_orig/ieee80211/ieee80211_tx.c rtl8187_txpower/ieee80211/ieee80211_tx.c
5706--- rtl8187_orig/ieee80211/ieee80211_tx.c	2006-06-06 04:57:54.000000000 +0200
5707+++ rtl8187_txpower/ieee80211/ieee80211_tx.c	2007-02-26 03:05:16.011549039 +0100
5708@@ -32,7 +32,6 @@
5709 ******************************************************************************/
5710
5711 #include <linux/compiler.h>
5712-#include <linux/config.h>
5713 #include <linux/errno.h>
5714 #include <linux/if_arp.h>
5715 #include <linux/in6.h>
5716@@ -52,6 +51,10 @@
5717 #include <linux/etherdevice.h>
5718 #include <asm/uaccess.h>
5719
5720+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5721+#include <linux/config.h>
5722+#endif
5723+
5724 #include "ieee80211.h"
5725
5726
5727@@ -155,7 +158,7 @@
5728 static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
5729 static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
5730
5731-static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
5732+static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto)
5733 {
5734 	struct ieee80211_snap_hdr *snap;
5735 	u8 *oui;
5736@@ -178,7 +181,7 @@
5737 	return SNAP_SIZE + sizeof(u16);
5738 }
5739
5740-int ieee80211_encrypt_fragment(
5741+int ieee80211_encrypt_fragment_rtl7(
5742 	struct ieee80211_device *ieee,
5743 	struct sk_buff *frag,
5744 	int hdr_len)
5745@@ -225,7 +228,7 @@
5746 }
5747
5748
5749-void ieee80211_txb_free(struct ieee80211_txb *txb) {
5750+void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) {
5751 	int i;
5752 	if (unlikely(!txb))
5753 		return;
5754@@ -235,7 +238,7 @@
5755 	kfree(txb);
5756 }
5757
5758-struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
5759+struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size,
5760 					  int gfp_mask)
5761 {
5762 	struct ieee80211_txb *txb;
5763@@ -267,7 +270,7 @@
5764 }
5765
5766 /* SKBs are added to the ieee->tx_queue. */
5767-int ieee80211_xmit(struct sk_buff *skb,
5768+int ieee80211_xmit_rtl7(struct sk_buff *skb,
5769 		   struct net_device *dev)
5770 {
5771 	struct ieee80211_device *ieee = netdev_priv(dev);
5772@@ -397,7 +400,7 @@
5773 		/* When we allocate the TXB we allocate enough space for the reserve
5774 		* and full fragment bytes (bytes_per_frag doesn't include prefix,
5775 		* postfix, header, FCS, etc.) */
5776-		txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
5777+		txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC);
5778 		if (unlikely(!txb)) {
5779 			printk(KERN_WARNING "%s: Could not allocate TXB\n",
5780 			ieee->dev->name);
5781@@ -432,7 +435,7 @@
5782
5783 			/* Put a SNAP header on the first fragment */
5784 			if (i == 0) {
5785-				ieee80211_put_snap(
5786+				ieee80211_put_snap_rtl7(
5787 					skb_put(skb_frag, SNAP_SIZE + sizeof(u16)),
5788 					ether_type);
5789 				bytes -= SNAP_SIZE + sizeof(u16);
5790@@ -446,7 +449,7 @@
5791 			/* Encryption routine will move the header forward in order
5792 			* to insert the IV between the header and the payload */
5793 			if (encrypt)
5794-				ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
5795+				ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len);
5796 			if (ieee->config &
5797 			(CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
5798 				skb_put(skb_frag, 4);
5799@@ -458,13 +461,14 @@
5800 			ieee->seq_ctrl++;
5801 		//---
5802 	}else{
5803-		if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
5804+//		if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
5805+		if (unlikely(skb->len < 14)) {
5806 			printk(KERN_WARNING "%s: skb too small (%d).\n",
5807 			ieee->dev->name, skb->len);
5808 			goto success;
5809 		}
5810
5811-		txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC);
5812+		txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC);
5813 		if(!txb){
5814 			printk(KERN_WARNING "%s: Could not allocate TXB\n",
5815 			ieee->dev->name);
5816@@ -481,14 +485,14 @@
5817 	dev_kfree_skb_any(skb);
5818 	if (txb) {
5819 		if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){
5820-			ieee80211_softmac_xmit(txb, ieee);
5821+			ieee80211_softmac_xmit_rtl7(txb, ieee);
5822 		}else{
5823 			if ((*ieee->hard_start_xmit)(txb, dev) == 0) {
5824 				stats->tx_packets++;
5825 				stats->tx_bytes += txb->payload_size;
5826 				return 0;
5827 			}
5828-			ieee80211_txb_free(txb);
5829+			ieee80211_txb_free_rtl7(txb);
5830 		}
5831
5832
5833@@ -504,4 +508,4 @@
5834
5835 }
5836
5837-EXPORT_SYMBOL(ieee80211_txb_free);
5838+EXPORT_SYMBOL(ieee80211_txb_free_rtl7);
5839diff -Naur rtl8187_orig/ieee80211/ieee80211_wx.c rtl8187_txpower/ieee80211/ieee80211_wx.c
5840--- rtl8187_orig/ieee80211/ieee80211_wx.c	2006-06-06 04:57:56.000000000 +0200
5841+++ rtl8187_txpower/ieee80211/ieee80211_wx.c	2007-02-26 03:05:16.071549944 +0100
5842@@ -40,7 +40,7 @@
5843 };
5844
5845 #define MAX_CUSTOM_LEN 64
5846-static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
5847+static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee,
5848  					   char *start, char *stop,
5849 					   struct ieee80211_network *network)
5850 {
5851@@ -207,7 +207,7 @@
5852 	return start;
5853 }
5854
5855-int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
5856+int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
5857 			  struct iw_request_info *info,
5858 			  union iwreq_data *wrqu, char *extra)
5859 {
5860@@ -220,13 +220,14 @@
5861
5862 	IEEE80211_DEBUG_WX("Getting scan\n");
5863 	down(&ieee->wx_sem);
5864+	printk("GOT WX GET SCAN WX_SEM LOCK");
5865 	spin_lock_irqsave(&ieee->lock, flags);
5866
5867 	list_for_each_entry(network, &ieee->network_list, list) {
5868 		i++;
5869 		if (ieee->scan_age == 0 ||
5870 		    time_after(network->last_scanned + ieee->scan_age, jiffies))
5871-			ev = ipw2100_translate_scan(ieee, ev, stop, network);
5872+			ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network);
5873 		else
5874 			IEEE80211_DEBUG_SCAN(
5875 				"Not showing network '%s ("
5876@@ -247,7 +248,7 @@
5877 	return 0;
5878 }
5879
5880-int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
5881+int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
5882 			    struct iw_request_info *info,
5883 			    union iwreq_data *wrqu, char *keybuf)
5884 {
5885@@ -281,7 +282,7 @@
5886 		if (key_provided && *crypt) {
5887 			IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n",
5888 					   key);
5889-			ieee80211_crypt_delayed_deinit(ieee, crypt);
5890+			ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
5891 		} else
5892 			IEEE80211_DEBUG_WX("Disabling encryption.\n");
5893
5894@@ -291,7 +292,7 @@
5895 			if (ieee->crypt[i] != NULL) {
5896 				if (key_provided)
5897 					break;
5898-				ieee80211_crypt_delayed_deinit(
5899+				ieee80211_crypt_delayed_deinit_rtl7(
5900 					ieee, &ieee->crypt[i]);
5901 			}
5902 		}
5903@@ -314,7 +315,7 @@
5904 	    strcmp((*crypt)->ops->name, "WEP") != 0) {
5905 		/* changing to use WEP; deinit previously used algorithm
5906 		 * on this key */
5907-		ieee80211_crypt_delayed_deinit(ieee, crypt);
5908+		ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
5909 	}
5910
5911 	if (*crypt == NULL) {
5912@@ -326,10 +327,10 @@
5913 		if (new_crypt == NULL)
5914 			return -ENOMEM;
5915 		memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
5916-		new_crypt->ops = ieee80211_get_crypto_ops("WEP");
5917+		new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP");
5918 		if (!new_crypt->ops) {
5919 			request_module("ieee80211_crypt_wep");
5920-			new_crypt->ops = ieee80211_get_crypto_ops("WEP");
5921+			new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP");
5922 		}
5923
5924 		if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
5925@@ -418,7 +419,7 @@
5926 	return 0;
5927 }
5928
5929-int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
5930+int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
5931 			    struct iw_request_info *info,
5932 			    union iwreq_data *wrqu, char *keybuf)
5933 {
5934@@ -470,6 +471,6 @@
5935 }
5936
5937
5938-EXPORT_SYMBOL(ieee80211_wx_get_scan);
5939-EXPORT_SYMBOL(ieee80211_wx_set_encode);
5940-EXPORT_SYMBOL(ieee80211_wx_get_encode);
5941+EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7);
5942+EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7);
5943+EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7);
5944