[Debian-eeepc-devel] [SCM] Packaging of rt2860-source branch, kbuild, updated. 0702b00632b71138bfbec3102f9ba28ec9b469b5

Glenn Saberton gsaberton at foomagic.org
Fri Nov 7 12:20:00 UTC 2008


The following commit has been merged in the kbuild branch:
commit c848123dfc2fe134bbab9922793211072ffd2336
Author: Glenn Saberton <gsaberton at foomagic.org>
Date:   Fri Nov 7 19:47:24 2008 +0900

    Change upstream to Greg Kroah Hartman pending patch.
    
    This has been slightly cleaned up and has a much saner directory layout and Makefile, making building the modules using kbuild much easier.

diff --git a/os/linux/2860_main_dev.c b/2860_main_dev.c
similarity index 92%
rename from os/linux/2860_main_dev.c
rename to 2860_main_dev.c
index 1e1e7c7..c294536 100644
--- a/os/linux/2860_main_dev.c
+++ b/2860_main_dev.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
     Module Name:
@@ -35,7 +35,7 @@
     --------    ----------      ----------------------------------------------
 */
 
-#include <rt_config.h>
+#include "rt_config.h"
 
 
 #ifdef MULTIPLE_CARD_SUPPORT
@@ -60,7 +60,7 @@ static void fifo_statistic_full_tasklet(unsigned long data);
 /*---------------------------------------------------------------------*/
 /* Symbol & Macro Definitions                                          */
 /*---------------------------------------------------------------------*/
-#define RT2860_INT_RX_DLY				(1<<0)		// bit 0	
+#define RT2860_INT_RX_DLY				(1<<0)		// bit 0
 #define RT2860_INT_TX_DLY				(1<<1)		// bit 1
 #define RT2860_INT_RX_DONE				(1<<2)		// bit 2
 #define RT2860_INT_AC0_DMA_DONE			(1<<3)		// bit 3
@@ -203,7 +203,7 @@ static int rt2860_suspend(
 	retval = pci_enable_wake(pci_dev, pci_choose_state(pci_dev, state), 1);
 	// save the PCI configuration space of a device before suspending
 	pci_save_state(pci_dev);
-	// disable PCI device after use 
+	// disable PCI device after use
 	pci_disable_device(pci_dev);
 
 	retval = pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
@@ -347,7 +347,7 @@ static VOID __devexit rt2860_remove_one(
 			MC_CardUsed[pAd->MC_RowID] = 0; // not clear MAC address
 #endif // MULTIPLE_CARD_SUPPORT //
 
-    
+
 
 
 		// Unregister network device
@@ -385,7 +385,7 @@ static VOID __devexit rt2860_remove_one(
 // PCI device probe & initialization function
 //
 static INT __devinit   rt2860_probe(
-    IN  struct pci_dev              *pci_dev, 
+    IN  struct pci_dev              *pci_dev,
     IN  const struct pci_device_id  *ent)
 {
 	PRTMP_ADAPTER pAd;
@@ -402,7 +402,7 @@ void init_thread_task(IN PRTMP_ADAPTER pAd)
 	POS_COOKIE pObj;
 
 	pObj = (POS_COOKIE) pAd->OS_Cookie;
-	
+
 	tasklet_init(&pObj->rx_done_task, rx_done_tasklet, (unsigned long)pAd);
 	tasklet_init(&pObj->mgmt_dma_done_task, mgmt_dma_done_tasklet, (unsigned long)pAd);
 	tasklet_init(&pObj->ac0_dma_done_task, ac0_dma_done_tasklet, (unsigned long)pAd);
@@ -437,7 +437,7 @@ static void rt2860_int_enable(PRTMP_ADAPTER pAd, unsigned int mode)
 	u32 regValue;
 
 	pAd->int_disable_mask &= ~(mode);
-	regValue = pAd->int_enable_reg & ~(pAd->int_disable_mask);		
+	regValue = pAd->int_enable_reg & ~(pAd->int_disable_mask);
 	RTMP_IO_WRITE32(pAd, INT_MASK_CSR, regValue);     // 1:enable
 
 	if (regValue != 0)
@@ -451,11 +451,11 @@ static void rt2860_int_disable(PRTMP_ADAPTER pAd, unsigned int mode)
 
 	pAd->int_disable_mask |= mode;
 	regValue = 	pAd->int_enable_reg & ~(pAd->int_disable_mask);
-	RTMP_IO_WRITE32(pAd, INT_MASK_CSR, regValue);     // 0: disable 
-	
+	RTMP_IO_WRITE32(pAd, INT_MASK_CSR, regValue);     // 0: disable
+
 	if (regValue == 0)
 	{
-		RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);		
+		RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);
 	}
 }
 
@@ -465,18 +465,18 @@ static void mgmt_dma_done_tasklet(unsigned long data)
 	PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) data;
     INT_SOURCE_CSR_STRUC	IntSource;
 	POS_COOKIE pObj;
-	
+
 	// Do nothing if the driver is starting halt state.
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
 		return;
-	
+
     pObj = (POS_COOKIE) pAd->OS_Cookie;
 
 	IntSource.word = 0;
 	IntSource.field.MgmtDmaDone = 1;
 	pAd->int_pending &= ~INT_MGMT_DLY;
-	
+
 	RTMPHandleMgmtRingDmaDoneInterrupt(pAd);
 
 	// if you use RTMP_SEM_LOCK, sometimes kernel will hang up, no any
@@ -485,16 +485,16 @@ static void mgmt_dma_done_tasklet(unsigned long data)
 	/*
 	 * double check to avoid lose of interrupts
 	 */
-	if (pAd->int_pending & INT_MGMT_DLY) 
+	if (pAd->int_pending & INT_MGMT_DLY)
 	{
 		tasklet_hi_schedule(&pObj->mgmt_dma_done_task);
-		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 		return;
 	}
 
 	/* enable TxDataInt again */
 	rt2860_int_enable(pAd, INT_MGMT_DLY);
-	RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+	RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 }
 
 static void rx_done_tasklet(unsigned long data)
@@ -503,14 +503,14 @@ static void rx_done_tasklet(unsigned long data)
 	PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) data;
 	BOOLEAN	bReschedule = 0;
 	POS_COOKIE pObj;
-	
+
 	// Do nothing if the driver is starting halt state.
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
 		return;
-	
+
     pObj = (POS_COOKIE) pAd->OS_Cookie;
-	
+
 	pAd->int_pending &= ~(INT_RX);
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
@@ -519,12 +519,12 @@ static void rx_done_tasklet(unsigned long data)
 
 	RTMP_INT_LOCK(&pAd->irq_lock, flags);
 	/*
-	 * double check to avoid rotting packet 
+	 * double check to avoid rotting packet
 	 */
-	if (pAd->int_pending & INT_RX || bReschedule) 
+	if (pAd->int_pending & INT_RX || bReschedule)
 	{
 		tasklet_hi_schedule(&pObj->rx_done_task);
-		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 		return;
 	}
 
@@ -539,25 +539,25 @@ void fifo_statistic_full_tasklet(unsigned long data)
 	unsigned long flags;
 	PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) data;
 	POS_COOKIE pObj;
-	
+
 	// Do nothing if the driver is starting halt state.
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
 		return;
-	
+
     pObj = (POS_COOKIE) pAd->OS_Cookie;
 
-	pAd->int_pending &= ~(FifoStaFullInt); 
+	pAd->int_pending &= ~(FifoStaFullInt);
 	NICUpdateFifoStaCounters(pAd);
-	
-	RTMP_INT_LOCK(&pAd->irq_lock, flags);  
+
+	RTMP_INT_LOCK(&pAd->irq_lock, flags);
 	/*
-	 * double check to avoid rotting packet 
+	 * double check to avoid rotting packet
 	 */
-	if (pAd->int_pending & FifoStaFullInt) 
+	if (pAd->int_pending & FifoStaFullInt)
 	{
 		tasklet_hi_schedule(&pObj->fifo_statistic_full_task);
-		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 		return;
 	}
 
@@ -574,12 +574,12 @@ static void hcca_dma_done_tasklet(unsigned long data)
 	PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) data;
     INT_SOURCE_CSR_STRUC	IntSource;
 	POS_COOKIE pObj;
-	
+
 	// Do nothing if the driver is starting halt state.
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
 		return;
-	
+
     pObj = (POS_COOKIE) pAd->OS_Cookie;
 
 
@@ -596,13 +596,13 @@ static void hcca_dma_done_tasklet(unsigned long data)
 	if (pAd->int_pending & INT_HCCA_DLY)
 	{
 		tasklet_hi_schedule(&pObj->hcca_dma_done_task);
-		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 		return;
 	}
 
 	/* enable TxDataInt again */
 	rt2860_int_enable(pAd, INT_HCCA_DLY);
-	RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+	RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 }
 
 static void ac3_dma_done_tasklet(unsigned long data)
@@ -617,7 +617,7 @@ static void ac3_dma_done_tasklet(unsigned long data)
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
 		return;
-	
+
     pObj = (POS_COOKIE) pAd->OS_Cookie;
 
 	IntSource.word = 0;
@@ -633,13 +633,13 @@ static void ac3_dma_done_tasklet(unsigned long data)
 	if ((pAd->int_pending & INT_AC3_DLY) || bReschedule)
 	{
 		tasklet_hi_schedule(&pObj->ac3_dma_done_task);
-		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 		return;
 	}
 
 	/* enable TxDataInt again */
 	rt2860_int_enable(pAd, INT_AC3_DLY);
-	RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+	RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 }
 
 static void ac2_dma_done_tasklet(unsigned long data)
@@ -649,12 +649,12 @@ static void ac2_dma_done_tasklet(unsigned long data)
     INT_SOURCE_CSR_STRUC	IntSource;
 	POS_COOKIE pObj;
 	BOOLEAN bReschedule = 0;
-	
+
 	// Do nothing if the driver is starting halt state.
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
 		return;
-	
+
     pObj = (POS_COOKIE) pAd->OS_Cookie;
 
 	IntSource.word = 0;
@@ -668,16 +668,16 @@ static void ac2_dma_done_tasklet(unsigned long data)
 	/*
 	 * double check to avoid lose of interrupts
 	 */
-	if ((pAd->int_pending & INT_AC2_DLY) || bReschedule) 
+	if ((pAd->int_pending & INT_AC2_DLY) || bReschedule)
 	{
 		tasklet_hi_schedule(&pObj->ac2_dma_done_task);
-		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 		return;
 	}
 
 	/* enable TxDataInt again */
 	rt2860_int_enable(pAd, INT_AC2_DLY);
-	RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+	RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 }
 
 static void ac1_dma_done_tasklet(unsigned long data)
@@ -692,7 +692,7 @@ static void ac1_dma_done_tasklet(unsigned long data)
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
 		return;
-	
+
     pObj = (POS_COOKIE) pAd->OS_Cookie;
 
 	IntSource.word = 0;
@@ -705,16 +705,16 @@ static void ac1_dma_done_tasklet(unsigned long data)
 	/*
 	 * double check to avoid lose of interrupts
 	 */
-	if ((pAd->int_pending & INT_AC1_DLY) || bReschedule) 
+	if ((pAd->int_pending & INT_AC1_DLY) || bReschedule)
 	{
 		tasklet_hi_schedule(&pObj->ac1_dma_done_task);
-		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 		return;
 	}
 
 	/* enable TxDataInt again */
 	rt2860_int_enable(pAd, INT_AC1_DLY);
-	RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+	RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 }
 
 static void ac0_dma_done_tasklet(unsigned long data)
@@ -729,7 +729,7 @@ static void ac0_dma_done_tasklet(unsigned long data)
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
 		return;
-	
+
     pObj = (POS_COOKIE) pAd->OS_Cookie;
 
 	IntSource.word = 0;
@@ -737,7 +737,7 @@ static void ac0_dma_done_tasklet(unsigned long data)
 	pAd->int_pending &= ~INT_AC0_DLY;
 
 	bReschedule = RTMPHandleTxRingDmaDoneInterrupt(pAd, IntSource);
-	
+
 	RTMP_INT_LOCK(&pAd->irq_lock, flags);
 	/*
 	 * double check to avoid lose of interrupts
@@ -745,13 +745,13 @@ static void ac0_dma_done_tasklet(unsigned long data)
 	if ((pAd->int_pending & INT_AC0_DLY) || bReschedule)
 	{
 		tasklet_hi_schedule(&pObj->ac0_dma_done_task);
-		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+		RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 		return;
 	}
 
 	/* enable TxDataInt again */
 	rt2860_int_enable(pAd, INT_AC0_DLY);
-	RTMP_INT_UNLOCK(&pAd->irq_lock, flags);    
+	RTMP_INT_UNLOCK(&pAd->irq_lock, flags);
 }
 
 
@@ -768,7 +768,7 @@ rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 	PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) net_dev->priv;
 	INT_SOURCE_CSR_STRUC	IntSource;
 	POS_COOKIE pObj;
-		
+
 	pObj = (POS_COOKIE) pAd->OS_Cookie;
 
 
@@ -793,7 +793,7 @@ rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 	//
 	// Flag fOP_STATUS_DOZE On, means ASIC put to sleep, elase means ASICK WakeUp
 	// And at the same time, clock maybe turned off that say there is no DMA service.
-	// when ASIC get to sleep. 
+	// when ASIC get to sleep.
 	// To prevent system hang on power saving.
 	// We need to check it before handle the INT_SOURCE_CSR, ASIC must be wake up.
 	//
@@ -827,7 +827,7 @@ rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 	// If required spinlock, each interrupt service routine has to acquire
 	// and release itself.
 	//
-	
+
 	// Do nothing if NIC doesn't exist
 	if (IntSource.word == 0xffffffff)
 	{
@@ -837,8 +837,8 @@ rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 #else
         return;
 #endif
-	}	
-	
+	}
+
 	if (IntSource.word & TxCoherent)
 	{
 		DBGPRINT(RT_DEBUG_ERROR, (">>>TxCoherent<<<\n"));
@@ -851,103 +851,103 @@ rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 		RTMPHandleRxCoherentInterrupt(pAd);
 	}
 
-	if (IntSource.word & FifoStaFullInt) 
+	if (IntSource.word & FifoStaFullInt)
 	{
 #if 1
-		if ((pAd->int_disable_mask & FifoStaFullInt) == 0) 
+		if ((pAd->int_disable_mask & FifoStaFullInt) == 0)
 		{
 			/* mask FifoStaFullInt */
 			rt2860_int_disable(pAd, FifoStaFullInt);
 			tasklet_hi_schedule(&pObj->fifo_statistic_full_task);
 		}
-		pAd->int_pending |= FifoStaFullInt; 
+		pAd->int_pending |= FifoStaFullInt;
 #else
-		NICUpdateFifoStaCounters(pAd);		
+		NICUpdateFifoStaCounters(pAd);
 #endif
 	}
 
-	if (IntSource.word & INT_MGMT_DLY) 
+	if (IntSource.word & INT_MGMT_DLY)
 	{
 		if ((pAd->int_disable_mask & INT_MGMT_DLY) ==0 )
 		{
 			rt2860_int_disable(pAd, INT_MGMT_DLY);
-			tasklet_hi_schedule(&pObj->mgmt_dma_done_task);			
+			tasklet_hi_schedule(&pObj->mgmt_dma_done_task);
 		}
 		pAd->int_pending |= INT_MGMT_DLY ;
 	}
 
 	if (IntSource.word & INT_RX)
 	{
-		if ((pAd->int_disable_mask & INT_RX) == 0) 
+		if ((pAd->int_disable_mask & INT_RX) == 0)
 		{
 			/* mask RxINT */
 			rt2860_int_disable(pAd, INT_RX);
 			tasklet_hi_schedule(&pObj->rx_done_task);
 		}
-		pAd->int_pending |= INT_RX; 		
+		pAd->int_pending |= INT_RX;
 	}
 
 	if (IntSource.word & INT_HCCA_DLY)
 	{
 
-		if ((pAd->int_disable_mask & INT_HCCA_DLY) == 0) 
+		if ((pAd->int_disable_mask & INT_HCCA_DLY) == 0)
 		{
 			/* mask TxDataInt */
 			rt2860_int_disable(pAd, INT_HCCA_DLY);
 			tasklet_hi_schedule(&pObj->hcca_dma_done_task);
 		}
-		pAd->int_pending |= INT_HCCA_DLY;						
+		pAd->int_pending |= INT_HCCA_DLY;
 	}
 
 	if (IntSource.word & INT_AC3_DLY)
 	{
 
-		if ((pAd->int_disable_mask & INT_AC3_DLY) == 0) 
+		if ((pAd->int_disable_mask & INT_AC3_DLY) == 0)
 		{
 			/* mask TxDataInt */
 			rt2860_int_disable(pAd, INT_AC3_DLY);
 			tasklet_hi_schedule(&pObj->ac3_dma_done_task);
 		}
-		pAd->int_pending |= INT_AC3_DLY;						
+		pAd->int_pending |= INT_AC3_DLY;
 	}
 
 	if (IntSource.word & INT_AC2_DLY)
 	{
 
-		if ((pAd->int_disable_mask & INT_AC2_DLY) == 0) 
+		if ((pAd->int_disable_mask & INT_AC2_DLY) == 0)
 		{
 			/* mask TxDataInt */
 			rt2860_int_disable(pAd, INT_AC2_DLY);
 			tasklet_hi_schedule(&pObj->ac2_dma_done_task);
 		}
-		pAd->int_pending |= INT_AC2_DLY;						
+		pAd->int_pending |= INT_AC2_DLY;
 	}
 
 	if (IntSource.word & INT_AC1_DLY)
 	{
 
-		pAd->int_pending |= INT_AC1_DLY;						
+		pAd->int_pending |= INT_AC1_DLY;
 
-		if ((pAd->int_disable_mask & INT_AC1_DLY) == 0) 
+		if ((pAd->int_disable_mask & INT_AC1_DLY) == 0)
 		{
 			/* mask TxDataInt */
 			rt2860_int_disable(pAd, INT_AC1_DLY);
 			tasklet_hi_schedule(&pObj->ac1_dma_done_task);
 		}
-		
+
 	}
 
 	if (IntSource.word & INT_AC0_DLY)
 	{
 		pAd->int_pending |= INT_AC0_DLY;
 
-		if ((pAd->int_disable_mask & INT_AC0_DLY) == 0) 
+		if ((pAd->int_disable_mask & INT_AC0_DLY) == 0)
 		{
 			/* mask TxDataInt */
 			rt2860_int_disable(pAd, INT_AC0_DLY);
 			tasklet_hi_schedule(&pObj->ac0_dma_done_task);
 		}
-								
+
 	}
 
     if (IntSource.word & PreTBTTInt)
@@ -1063,7 +1063,7 @@ BOOLEAN RT28XXNetDevInit(
 
     net_dev->priv_flags = INT_MAIN;
 
-    DBGPRINT(RT_DEBUG_TRACE, ("%s: at 0x%lx, VA 0x%lx, IRQ %d. \n", 
+    DBGPRINT(RT_DEBUG_TRACE, ("%s: at 0x%lx, VA 0x%lx, IRQ %d. \n",
         	net_dev->name, (ULONG)pci_resource_start(pci_dev, 0),
 			(ULONG)csr_addr, pci_dev->irq));
 	return TRUE;
@@ -1150,27 +1150,27 @@ VOID RT28XXDMAEnable(
 {
 	WPDMA_GLO_CFG_STRUC	GloCfg;
 	int i = 0;
-	
+
 	RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x4);
 	do
 	{
 		RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
 		if ((GloCfg.field.TxDMABusy == 0)  && (GloCfg.field.RxDMABusy == 0))
 			break;
-		
+
 		DBGPRINT(RT_DEBUG_TRACE, ("==>  DMABusy\n"));
 		RTMPusecDelay(1000);
 		i++;
 	}while ( i <200);
 
 	RTMPusecDelay(50);
-	
+
 	GloCfg.field.EnTXWriteBackDDONE = 1;
 	GloCfg.field.WPDMABurstSIZE = 2;
 	GloCfg.field.EnableRxDMA = 1;
 	GloCfg.field.EnableTxDMA = 1;
 
-	DBGPRINT(RT_DEBUG_TRACE, ("<== WRITE DMA offset 0x208 = 0x%x\n", GloCfg.word));	
+	DBGPRINT(RT_DEBUG_TRACE, ("<== WRITE DMA offset 0x208 = 0x%x\n", GloCfg.word));
 	RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
 
 }
@@ -1192,7 +1192,7 @@ Note:
 VOID RT28xx_UpdateBeaconToAsic(
 	IN RTMP_ADAPTER		*pAd,
 	IN INT				apidx,
-	IN ULONG			FrameLen, 
+	IN ULONG			FrameLen,
 	IN ULONG			UpdatePos)
 {
 	ULONG				CapInfoPos = 0;
@@ -1229,7 +1229,7 @@ VOID RT28xx_UpdateBeaconToAsic(
 		// Update CapabilityInfo in Beacon
 		for (i = CapInfoPos; i < (CapInfoPos+2); i++)
 		{
-			RTMP_IO_WRITE8(pAd, pAd->BeaconOffset[bcn_idx] + TXWI_SIZE + i, *ptr_capinfo); 
+			RTMP_IO_WRITE8(pAd, pAd->BeaconOffset[bcn_idx] + TXWI_SIZE + i, *ptr_capinfo);
 			ptr_capinfo ++;
 		}
 
@@ -1237,13 +1237,13 @@ VOID RT28xx_UpdateBeaconToAsic(
 		{
 			for (i= UpdatePos; i< (FrameLen); i++)
 			{
-				RTMP_IO_WRITE8(pAd, pAd->BeaconOffset[bcn_idx] + TXWI_SIZE + i, *ptr_update); 
+				RTMP_IO_WRITE8(pAd, pAd->BeaconOffset[bcn_idx] + TXWI_SIZE + i, *ptr_update);
 				ptr_update ++;
 			}
 		}
-		
+
 	}
-	
+
 }
 
 #ifdef CONFIG_STA_SUPPORT
@@ -1259,7 +1259,7 @@ VOID RTMPFindHostPCIDev(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 
 	Arguments:
@@ -1276,13 +1276,13 @@ VOID RTMPPCIeLinkCtrlValueRestore(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 
 	Arguments:
-		Max : limit Host PCI and Ralink PCIe device's LINK CONTROL field's value. 
+		Max : limit Host PCI and Ralink PCIe device's LINK CONTROL field's value.
 		Because now frequently set our device to mode 1 or mode 3 will cause problem.
-		
+
 	========================================================================
 */
 VOID RTMPPCIeLinkCtrlSetting(
@@ -1301,7 +1301,7 @@ VOID rt2860_stop(struct net_device *net_dev)
 	}
 	else
 		pAd = (PRTMP_ADAPTER)net_dev->priv;
- 
+
 	if (pAd != NULL)
 	{
 	    // stop interface
@@ -1323,24 +1323,24 @@ VOID rt2860_stop(struct net_device *net_dev)
 }
 
 /*
- * invaild or writeback cache 
- * and convert virtual address to physical address 
+ * invaild or writeback cache
+ * and convert virtual address to physical address
  */
 dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction)
 {
 	PRTMP_ADAPTER pAd;
 	POS_COOKIE pObj;
-	
-	/* 
+
+	/*
 		------ Porting Information ------
 		> For Tx Alloc:
 			mgmt packets => sd_idx = 0
 			SwIdx: pAd->MgmtRing.TxCpuIdx
 			pTxD : pAd->MgmtRing.Cell[SwIdx].AllocVa;
-	 
+
 			data packets => sd_idx = 1
-	 		TxIdx : pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx 
-	 		QueIdx: pTxBlk->QueIdx 
+	 		TxIdx : pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx
+	 		QueIdx: pTxBlk->QueIdx
 	 		pTxD  : pAd->TxRing[pTxBlk->QueIdx].Cell[TxIdx].AllocVa;
 
 	 	> For Rx Alloc:
@@ -1349,7 +1349,7 @@ dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx
 
 	pAd = (PRTMP_ADAPTER)handle;
 	pObj = (POS_COOKIE)pAd->OS_Cookie;
-	
+
 	if (sd_idx == 1)
 	{
 		PTX_BLK		pTxBlk;
@@ -1370,8 +1370,8 @@ void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int
 
 	pAd=(PRTMP_ADAPTER)handle;
 	pObj = (POS_COOKIE)pAd->OS_Cookie;
-	
+
 	pci_unmap_single(pObj->pci_dev, dma_addr, size, direction);
-	
+
 }
 
diff --git a/Kconfig b/Kconfig
new file mode 100644
index 0000000..7f44e5e
--- /dev/null
+++ b/Kconfig
@@ -0,0 +1,5 @@
+config RT2860
+	tristate "Ralink 2860 wireless support"
+	depends on PCI && X86 && WLAN_80211
+	---help---
+	  This is an experimental driver for the Ralink 2860 wireless chip.
diff --git a/Makefile b/Makefile
index 7c820a0..3496a64 100644
--- a/Makefile
+++ b/Makefile
@@ -1,189 +1,41 @@
-#MODE - STA or AP or APSTA.
-RT28xx_MODE = STA
-
-#TARTET - LINUX or UCOS.
-TARGET = LINUX
-
-#CHIPSET - 2860 or 2870.
-CHIPSET = 2860
-
-#RT28xx_DIR = home directory of RT28xx source code
-RT28xx_DIR = $(shell pwd)
-RTMP_SRC_DIR = $(RT28xx_DIR)/RT$(CHIPSET)
-#PLATFORM = 5VT
-PLATFORM = PC
-#PLATFORM = IKANOS_V160
-#PLATFORM = IKANOS_V180
-#PLATFORM = SIGMA
-#PLATFORM = SIGMA_8622
-#PLATFORM = INIC
-#PLATFORM = STAR
-#PLATFORM = IXP
-#PLATFORM = INF_TWINPASS
-#PLATFORM = INF_DANUBE
-#PLATFORM = BRCM_6358
-#PLATFORM = INF_AMAZON_SE
-#PLATFORM = CAVM_OCTEON
-RELEASE = DPO
-ifeq ($(PLATFORM),5VT)
-LINUX_SRC = /opt/fvt_11N_SDK_0807/fvt131x_SDK_11n/linux-2.6.17
-CROSS_COMPILE = /opt/crosstool/uClibc_v5te_le_gcc_4_1_1/bin/arm-linux-
-endif
-
-ifeq ($(PLATFORM),IKANOS_V160)
-LINUX_SRC = /home/sample/projects/LX_2618_RG_5_3_00r4_SRC/linux-2.6.18
-CROSS_COMPILE = mips-linux-
-endif
-
-ifeq ($(PLATFORM),IKANOS_V180)
-LINUX_SRC = /home/sample/projects/LX_BSP_VX180_5_4_0r1_ALPHA_26DEC07/linux-2.6.18
-CROSS_COMPILE = mips-linux-
-endif
-
-ifeq ($(PLATFORM),SIGMA)
-LINUX_SRC = /root/sigma/smp86xx_kernel_source_2.7.172.0/linux-2.6.15
-CROSS_COMPILE = /root/sigma/smp86xx_toolchain_2.7.172.0/build_mipsel_nofpu/staging_dir/bin/mipsel-linux-
-endif
-
-ifeq ($(PLATFORM),SIGMA_8622)
-LINUX_SRC = /home/snowpin/armutils_2.5.120.1/build_arm/linux-2.4.22-em86xx
-CROSS_COMPILE = /home/snowpin/armutils_2.5.120.1/toolchain/bin/arm-elf-
-CROSS_COMPILE_INCLUDE = /home/snowpin/armutils_2.5.120.1/toolchain/lib/gcc-lib/arm-elf/2.95.3
-endif
-
-ifeq ($(PLATFORM),INIC)
-UCOS_SRC = /opt/uCOS/iNIC_rt2880
-CROSS_COMPILE = /usr/bin/mipsel-linux-
-endif
-
-ifeq ($(PLATFORM),STAR)
-LINUX_SRC = /opt/star/kernel/linux-2.4.27-star
-CROSS_COMPILE = /opt/star/tools/arm-linux/bin/arm-linux-
-endif
-
-ifeq ($(PLATFORM),PC)
-# Linux 2.6
-LINUX_SRC = /lib/modules/$(shell uname -r)/build
-# Linux 2.4 Change to your local setting
-#LINUX_SRC = /usr/src/linux-2.4
-LINUX_SRC_MODULE = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless/
-CROSS_COMPILE = 
-endif
-
-ifeq ($(PLATFORM),IXP)
-LINUX_SRC = /project/stable/Gmtek/snapgear-uclibc/linux-2.6.x
-CROSS_COMPILE = arm-linux-
-endif
-
-ifeq ($(PLATFORM),INF_TWINPASS)
-# Linux 2.6
-#LINUX_SRC = /lib/modules/$(shell uname -r)/build
-# Linux 2.4 Change to your local setting
-LINUX_SRC = /project/stable/twinpass/release/2.0.1/source/kernel/opensource/linux-2.4.31/
-CROSS_COMPILE = mips-linux-
-endif
-
-ifeq ($(PLATFORM),INF_DANUBE)
-LINUX_SRC = /opt/danube/sdk/linux-2.6.16.x
-CROSS_COMPILE = mips-linux-
-ROOTDIR = /opt/danube/sdk
-export ROOTDIR
-endif
-
-ifeq ($(PLATFORM),BRCM_6358)
-LINUX_SRC = 
-CROSS_COMPILE = 
-endif
-
-ifeq ($(PLATFORM),INF_AMAZON_SE)
-# Linux 2.6
-#LINUX_SRC = /lib/modules/$(shell uname -r)/build
-# Linux 2.4 Change to your local setting
-LINUX_SRC = /backup/ifx/3.6.2.2/source/kernel/opensource/linux-2.4.31
-#CROSS_COMPILE = mips-linux-
-#LINUX_SRC = /project/Infineon/3.6.2.2/source/kernel/opensource/linux-2.4.31
-CROSS_COMPILE = /opt/uclibc-toolchain/ifx-lxdb-1-2-3-external/gcc-3.3.6/toolchain-mips/R0208V35/mips-linux-uclibc/bin/
-endif
-
-ifeq ($(PLATFORM),CAVM_OCTEON)
-OCTEON_ROOT = /usr/local/Cavium_Networks/OCTEON-SDK
-LINUX_SRC = $(OCTEON_ROOT)/linux/kernel_2.6/linux
-CROSS_COMPILE = mips64-octeon-linux-gnu-
-endif
-
-export RT28xx_DIR RT28xx_MODE LINUX_SRC CROSS_COMPILE CROSS_COMPILE_INCLUDE PLATFORM RELEASE CHIPSET RTMP_SRC_DIR LINUX_SRC_MODULE
-
-ifneq ($(KERNELRELEASE),)
-ifeq ($(obj),)
-obj=    .
-endif
-
-RT28xx_DIR = $(obj)
-
-include $(RT28xx_DIR)/os/linux/Makefile.kbuild
-else
-
-all: build_tools $(TARGET)
-
-
-build_tools:
-	make -C tools
-	$(RT28xx_DIR)/tools/bin2h
-
-
-LINUX:
-ifneq (,$(findstring 2.4,$(LINUX_SRC)))
-	cp -f os/linux/Makefile.4 $(RT28xx_DIR)/os/linux/Makefile
-	make -C $(RT28xx_DIR)/os/linux/
-ifeq ($(RT28xx_MODE),AP)
-	cp -f $(RT28xx_DIR)/os/linux/rt$(CHIPSET)ap.o /tftpboot
-else	
-ifeq ($(RT28xx_MODE),APSTA)
-	cp -f $(RT28xx_DIR)/os/linux/rt$(CHIPSET)apsta.o /tftpboot
-else
-	cp -f $(RT28xx_DIR)/os/linux/rt$(CHIPSET)sta.o /tftpboot
-endif	
-endif	
-else
-	cp -f os/linux/Makefile.6 $(RT28xx_DIR)/os/linux/Makefile
-	make  -C  $(LINUX_SRC) SUBDIRS=$(RT28xx_DIR)/os/linux modules
-ifeq ($(RT28xx_MODE),AP)
-	cp -f $(RT28xx_DIR)/os/linux/rt$(CHIPSET)ap.ko /tftpboot
-else	
-ifeq ($(RT28xx_MODE),APSTA)
-	cp -f $(RT28xx_DIR)/os/linux/rt$(CHIPSET)apsta.ko /tftpboot
-else
-	cp -f $(RT28xx_DIR)/os/linux/rt$(CHIPSET)sta.ko /tftpboot
-endif	
-endif
-endif
-
-clean:
-ifeq ($(TARGET), LINUX)
-ifneq (,$(findstring 2.4,$(LINUX_SRC)))
-	cp -f os/linux/Makefile.4 os/linux/Makefile
-else
-	cp -f os/linux/Makefile.6 os/linux/Makefile
-endif
-	make -C os/linux clean
-	rm -rf os/linux/Makefile
-endif	
-
-uninstall:
-ifeq ($(TARGET), LINUX)
-ifneq (,$(findstring 2.4,$(LINUX_SRC)))
-	make -C $(RT28xx_DIR)/os/linux -f Makefile.4 uninstall
-else
-	make -C $(RT28xx_DIR)/os/linux -f Makefile.6 uninstall
-endif
-endif
-
-install:
-ifeq ($(TARGET), LINUX)
-ifneq (,$(findstring 2.4,$(LINUX_SRC)))
-	make -C $(RT28xx_DIR)/os/linux -f Makefile.4 install
-else
-	make -C $(RT28xx_DIR)/os/linux -f Makefile.6 install
-endif
-endif
-endif #kbuild
+obj-$(CONFIG_RT2860)	+= rt2860sta.o
+
+# TODO: all of these should be removed
+EXTRA_CFLAGS += -DLINUX -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT
+EXTRA_CFLAGS += -DRT2860
+EXTRA_CFLAGS += -DCONFIG_STA_SUPPORT
+EXTRA_CFLAGS += -DDBG
+EXTRA_CFLAGS += -DDOT11_N_SUPPORT
+
+rt2860sta-objs :=	\
+	common/md5.o		\
+	common/mlme.o		\
+	common/rtmp_wep.o	\
+	common/action.o		\
+	common/cmm_data.o	\
+	common/rtmp_init.o	\
+	common/rtmp_tkip.o	\
+	common/cmm_sync.o	\
+	common/eeprom.o		\
+	common/cmm_sanity.o	\
+	common/cmm_info.o	\
+	common/cmm_wpa.o	\
+	common/dfs.o		\
+	common/spectrum.o	\
+	sta/assoc.o		\
+	sta/aironet.o		\
+	sta/auth.o		\
+	sta/auth_rsp.o		\
+	sta/sync.o		\
+	sta/sanity.o		\
+	sta/rtmp_data.o		\
+	sta/connect.o		\
+	sta/wpa.o		\
+	rt_linux.o		\
+	rt_profile.o		\
+	rt_main_dev.o		\
+	sta_ioctl.o		\
+	common/ba_action.o	\
+	common/2860_rtmp_init.o	\
+	2860_main_dev.o		\
+	common/cmm_data_2860.o
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..2f70b0f
--- /dev/null
+++ b/TODO
@@ -0,0 +1,17 @@
+I'm hesitant to add a TODO file here, as the wireless developers would
+really have people help them out on the "clean" rt2860 driver that can
+be found at the rt2860.sf.net site.
+
+But, if you wish to clean up this driver instead, here's a short list of
+things that need to be done to get it into a more mergable shape:
+
+TODO:
+	- checkpatch.pl clean
+	- sparse clean
+	- port to in-kernel 80211 stack
+	- remove reading from /etc/ config files
+	- review by the wireless developer community
+
+Please send any patches or complaints about this driver to Greg
+Kroah-Hartman <greg at kroah.com> and don't bother the upstream wireless
+kernel developers about it, they want nothing to do with it.
diff --git a/include/aironet.h b/aironet.h
similarity index 97%
rename from include/aironet.h
rename to aironet.h
index 2cd069b..1e07b19 100644
--- a/include/aironet.h
+++ b/aironet.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -93,7 +93,7 @@ typedef	struct	_BEACON_REPORT	{
 	UCHAR	BSSID[6];
 	UCHAR	ParentTSF[4];
 	UCHAR	TargetTSF[8];
-	USHORT	BeaconInterval;	
+	USHORT	BeaconInterval;
 	USHORT	CapabilityInfo;
 }	BEACON_REPORT, *PBEACON_REPORT;
 
diff --git a/include/ap.h b/ap.h
similarity index 81%
rename from include/ap.h
rename to ap.h
index fce3209..df6db28 100644
--- a/include/ap.h
+++ b/ap.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
     Module Name:
@@ -91,7 +91,7 @@ NDIS_STATUS APCheckRxError(
 
 BOOLEAN APCheckClass2Class3Error(
     IN  PRTMP_ADAPTER   pAd,
-	IN ULONG Wcid, 
+	IN ULONG Wcid,
 	IN  PHEADER_802_11  pHeader);
 
 VOID APHandleRxPsPoll(
@@ -103,7 +103,7 @@ VOID APHandleRxPsPoll(
 VOID    RTMPDescriptorEndianChange(
     IN  PUCHAR          pData,
     IN  ULONG           DescriptorType);
-    
+
 VOID    RTMPFrameEndianChange(
     IN  PRTMP_ADAPTER   pAd,
     IN  PUCHAR          pData,
@@ -113,20 +113,20 @@ VOID    RTMPFrameEndianChange(
 // ap_assoc.c
 
 VOID APAssocStateMachineInit(
-    IN  PRTMP_ADAPTER   pAd, 
-    IN  STATE_MACHINE *S, 
+    IN  PRTMP_ADAPTER   pAd,
+    IN  STATE_MACHINE *S,
     OUT STATE_MACHINE_FUNC Trans[]);
 
 VOID  APPeerAssocReqAction(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
     IN  MLME_QUEUE_ELEM *Elem);
 
 VOID  APPeerReassocReqAction(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
     IN  MLME_QUEUE_ELEM *Elem);
 
 VOID  APPeerDisassocReqAction(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
     IN  MLME_QUEUE_ELEM *Elem);
 
 VOID MbssKickOutStas(
@@ -135,17 +135,17 @@ VOID MbssKickOutStas(
 	IN USHORT Reason);
 
 VOID APMlmeKickOutSta(
-    IN PRTMP_ADAPTER pAd, 
-	IN PUCHAR pStaAddr, 
+    IN PRTMP_ADAPTER pAd,
+	IN PUCHAR pStaAddr,
 	IN UCHAR Wcid,
 	IN USHORT Reason);
 
 VOID APMlmeDisassocReqAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 
 VOID  APCls3errAction(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
 	IN 	ULONG Wcid,
     IN	PHEADER_802_11	pHeader);
 
@@ -156,7 +156,7 @@ USHORT APBuildAssociation(
     IN USHORT CapabilityInfo,
     IN UCHAR  MaxSupportedRateIn500Kbps,
     IN UCHAR  *RSN,
-    IN UCHAR  *pRSNLen, 
+    IN UCHAR  *pRSNLen,
     IN BOOLEAN bWmmCapable,
     IN ULONG  RalinkIe,
 #ifdef DOT11N_DRAFT3
@@ -169,39 +169,39 @@ USHORT APBuildAssociation(
 // ap_auth.c
 
 void APAuthStateMachineInit(
-    IN PRTMP_ADAPTER pAd, 
-    IN STATE_MACHINE *Sm, 
+    IN PRTMP_ADAPTER pAd,
+    IN STATE_MACHINE *Sm,
     OUT STATE_MACHINE_FUNC Trans[]);
 
 VOID APMlmeDeauthReqAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 
 VOID APCls2errAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
 	IN 	ULONG Wcid,
     IN	PHEADER_802_11	pHeader);
 
 // ap_authrsp.c
 
 VOID APAuthRspStateMachineInit(
-    IN PRTMP_ADAPTER pAd, 
-    IN PSTATE_MACHINE Sm, 
+    IN PRTMP_ADAPTER pAd,
+    IN PSTATE_MACHINE Sm,
     IN STATE_MACHINE_FUNC Trans[]);
 
 VOID APPeerAuthAtAuthRspIdleAction(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
     IN  MLME_QUEUE_ELEM *Elem);
 
 VOID APPeerDeauthReqAction(
-    IN PRTMP_ADAPTER	pAd, 
+    IN PRTMP_ADAPTER	pAd,
     IN MLME_QUEUE_ELEM *Elem);
 
 VOID APPeerAuthSimpleRspGenAndSend(
-    IN  PRTMP_ADAPTER   pAd, 
-    IN  PHEADER_802_11 pHdr80211, 
-    IN  USHORT Alg, 
-    IN  USHORT Seq, 
+    IN  PRTMP_ADAPTER   pAd,
+    IN  PHEADER_802_11 pHdr80211,
+    IN  USHORT Alg,
+    IN  USHORT Seq,
     IN  USHORT StatusCode);
 
 // ap_connect.c
@@ -247,11 +247,11 @@ VOID APScanTimeoutAction(
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID APPeerProbeReqAction(
-    IN  PRTMP_ADAPTER pAd, 
+    IN  PRTMP_ADAPTER pAd,
     IN  MLME_QUEUE_ELEM *Elem);
 
 VOID APPeerBeaconAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 
 VOID APMlmeScanReqAction(
@@ -263,7 +263,7 @@ VOID APPeerBeaconAtScanAction(
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID APScanCnclAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID ApSiteSurvey(
@@ -281,7 +281,7 @@ VOID SupportRate(
 
 BOOLEAN ApScanRunning(
 	IN PRTMP_ADAPTER pAd);
-	
+
 #ifdef DOT11N_DRAFT3
 VOID APOverlappingBSSScan(
 	IN RTMP_ADAPTER *pAd);
@@ -290,8 +290,8 @@ VOID APOverlappingBSSScan(
 // ap_wpa.c
 
 VOID APWpaStateMachineInit(
-    IN  PRTMP_ADAPTER   pAd, 
-    IN  STATE_MACHINE *Sm, 
+    IN  PRTMP_ADAPTER   pAd,
+    IN  STATE_MACHINE *Sm,
     OUT STATE_MACHINE_FUNC Trans[]);
 
 // ap_mlme.c
@@ -315,21 +315,21 @@ VOID APMlmeDynamicTxRateSwitching(
     IN PRTMP_ADAPTER pAd);
 
 VOID APQuickResponeForRateUpExec(
-    IN PVOID SystemSpecific1, 
-    IN PVOID FunctionContext, 
-    IN PVOID SystemSpecific2, 
+    IN PVOID SystemSpecific1,
+    IN PVOID FunctionContext,
+    IN PVOID SystemSpecific2,
     IN PVOID SystemSpecific3);
 
 BOOLEAN APMsgTypeSubst(
     IN PRTMP_ADAPTER pAd,
-    IN PFRAME_802_11 pFrame, 
-    OUT INT *Machine, 
+    IN PFRAME_802_11 pFrame,
+    OUT INT *Machine,
     OUT INT *MsgType);
 
 VOID APQuickResponeForRateUpExec(
-    IN PVOID SystemSpecific1, 
-    IN PVOID FunctionContext, 
-    IN PVOID SystemSpecific2, 
+    IN PVOID SystemSpecific1,
+    IN PVOID FunctionContext,
+    IN PVOID SystemSpecific2,
     IN PVOID SystemSpecific3);
 
 
@@ -369,18 +369,18 @@ VOID MacTableReset(
     IN  PRTMP_ADAPTER   pAd);
 
 MAC_TABLE_ENTRY *MacTableInsertEntry(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
     IN  PUCHAR          pAddr,
 	IN	UCHAR			apidx,
-	IN BOOLEAN	CleanAll); 
+	IN BOOLEAN	CleanAll);
 
 BOOLEAN MacTableDeleteEntry(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
 	IN USHORT wcid,
     IN  PUCHAR          pAddr);
 
 MAC_TABLE_ENTRY *MacTableLookup(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
     IN  PUCHAR          pAddr);
 
 VOID MacTableMaintenance(
@@ -390,17 +390,17 @@ UINT32 MacTableAssocStaNumGet(
 	IN PRTMP_ADAPTER pAd);
 
 MAC_TABLE_ENTRY *APSsPsInquiry(
-    IN  PRTMP_ADAPTER   pAd, 
-    IN  PUCHAR          pAddr, 
-    OUT SST             *Sst, 
+    IN  PRTMP_ADAPTER   pAd,
+    IN  PUCHAR          pAddr,
+    OUT SST             *Sst,
     OUT USHORT          *Aid,
     OUT UCHAR           *PsMode,
-    OUT UCHAR           *Rate); 
+    OUT UCHAR           *Rate);
 
 BOOLEAN APPsIndicate(
-    IN  PRTMP_ADAPTER   pAd, 
-    IN  PUCHAR          pAddr, 
-	IN ULONG Wcid, 
+    IN  PRTMP_ADAPTER   pAd,
+    IN  PUCHAR          pAddr,
+	IN ULONG Wcid,
     IN  UCHAR           Psm);
 
 VOID ApLogEvent(
@@ -456,13 +456,13 @@ UCHAR APAutoSelectChannel(
 
 
 BOOLEAN PeerAssocReqCmmSanity(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
 	IN BOOLEAN isRessoc,
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
+    IN VOID *Msg,
+    IN ULONG MsgLen,
     OUT PUCHAR pAddr2,
-    OUT USHORT *pCapabilityInfo, 
-    OUT USHORT *pListenInterval, 
+    OUT USHORT *pCapabilityInfo,
+    OUT USHORT *pListenInterval,
     OUT PUCHAR pApAddr,
     OUT UCHAR *pSsidLen,
     OUT char *Ssid,
@@ -479,52 +479,52 @@ BOOLEAN PeerAssocReqCmmSanity(
     OUT HT_CAPABILITY_IE *pHtCapability);
 
 BOOLEAN PeerDisassocReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
-    OUT PUCHAR pAddr2, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
+    OUT PUCHAR pAddr2,
     OUT USHORT *Reason);
 
 BOOLEAN PeerDeauthReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
-    OUT PUCHAR pAddr2, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
+    OUT PUCHAR pAddr2,
     OUT USHORT *Reason);
 
 BOOLEAN APPeerAuthSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
-	OUT PUCHAR pAddr1, 
-    OUT PUCHAR pAddr2, 
-    OUT USHORT *Alg, 
-    OUT USHORT *Seq, 
-    OUT USHORT *Status, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
+	OUT PUCHAR pAddr1,
+    OUT PUCHAR pAddr2,
+    OUT USHORT *Alg,
+    OUT USHORT *Seq,
+    OUT USHORT *Status,
     CHAR *ChlgText);
 
 BOOLEAN APPeerProbeReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
     OUT PUCHAR pAddr2,
-    OUT CHAR Ssid[], 
+    OUT CHAR Ssid[],
     OUT UCHAR *SsidLen);
 
 BOOLEAN APPeerBeaconAndProbeRspSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
-    OUT PUCHAR pAddr2, 
-    OUT PUCHAR pBssid, 
-    OUT CHAR Ssid[], 
-    OUT UCHAR *SsidLen, 
-    OUT UCHAR *BssType, 
-    OUT USHORT *BeaconPeriod, 
-    OUT UCHAR *Channel, 
-    OUT LARGE_INTEGER *Timestamp, 
-    OUT USHORT *CapabilityInfo, 
-    OUT UCHAR Rate[], 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
+    OUT PUCHAR pAddr2,
+    OUT PUCHAR pBssid,
+    OUT CHAR Ssid[],
+    OUT UCHAR *SsidLen,
+    OUT UCHAR *BssType,
+    OUT USHORT *BeaconPeriod,
+    OUT UCHAR *Channel,
+    OUT LARGE_INTEGER *Timestamp,
+    OUT USHORT *CapabilityInfo,
+    OUT UCHAR Rate[],
     OUT UCHAR *RateLen,
     OUT BOOLEAN *ExtendedRateIeExist,
     OUT UCHAR *Erp);
diff --git a/include/chlist.h b/chlist.h
similarity index 99%
rename from include/chlist.h
rename to chlist.h
index 4533e8a..9e15b9d 100644
--- a/include/chlist.h
+++ b/chlist.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -56,7 +56,7 @@ typedef struct _CH_DESP {
 	CHAR MaxTxPwr;			// dBm
 	UCHAR Geography;			// 0:out door, 1:in door, 2:both
 	BOOLEAN DfsReq;			// Dfs require, 0: No, 1: yes.
-} CH_DESP, *PCH_DESP; 
+} CH_DESP, *PCH_DESP;
 
 typedef struct _CH_REGION {
 	UCHAR CountReg[3];
@@ -979,7 +979,7 @@ static inline VOID ChBandCheck(
 static inline UCHAR FillChList(
 	IN PRTMP_ADAPTER pAd,
 	IN PCH_DESP pChDesp,
-	IN UCHAR Offset, 
+	IN UCHAR Offset,
 	IN UCHAR increment)
 {
 	INT i, j, l;
diff --git a/common/2860_rtmp_init.c b/common/2860_rtmp_init.c
index f8c0965..546f304 100644
--- a/common/2860_rtmp_init.c
+++ b/common/2860_rtmp_init.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -37,14 +37,14 @@
     John Chang  2004-08-20    RT2561/2661 use scatter-gather scheme
     Jan Lee  2006-09-15    RT2860. Change for 802.11n , EEPROM, Led, BA, HT.
 */
-#include	"rt_config.h"
+#include "../rt_config.h"
 
 
 
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Allocate DMA memory blocks for send, receive
 
@@ -59,7 +59,7 @@
 	IRQL = PASSIVE_LEVEL
 
 	Note:
-	
+
 	========================================================================
 */
 NDIS_STATUS	RTMPAllocTxRxRingMemory(
@@ -90,8 +90,8 @@ NDIS_STATUS	RTMPAllocTxRxRingMemory(
 			ULONG  BufBasePaHigh;
 			ULONG  BufBasePaLow;
 			PVOID  BufBaseVa;
-			
-			// 
+
+			//
 			// Allocate Tx ring descriptor's memory (5 TX rings = 4 ACs + 1 HCCA)
 			//
 			pAd->TxDescRing[num].AllocSize = TX_RING_SIZE * TXD_SIZE;
@@ -119,7 +119,7 @@ NDIS_STATUS	RTMPAllocTxRxRingMemory(
 			RingBasePaLow  = RTMP_GetPhysicalAddressLow (pAd->TxDescRing[num].AllocPa);
 			RingBaseVa     = pAd->TxDescRing[num].AllocVa;
 
-			// 
+			//
 			// Allocate all 1st TXBuf's memory for this TxRing
 			//
 			pAd->TxBufSpace[num].AllocSize = TX_RING_SIZE * TX_DMA_1ST_BUFFER_SIZE;
@@ -298,7 +298,7 @@ NDIS_STATUS	RTMPAllocTxRxRingMemory(
 				FALSE,
 				&pDmaBuf->AllocVa,
 				&pDmaBuf->AllocPa);
-			
+
 			/* keep allocated rx packet */
 			pAd->RxRing.Cell[index].pNdisPacket = pPacket;
 
@@ -354,7 +354,7 @@ NDIS_STATUS	RTMPAllocTxRxRingMemory(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Initialize transmit data structures
 
@@ -369,7 +369,7 @@ NDIS_STATUS	RTMPAllocTxRxRingMemory(
 	Note:
 		Initialize all transmit releated private buffer, include those define
 		in RTMP_ADAPTER structure and all private data structures.
-		
+
 	========================================================================
 */
 VOID	NICInitTxRxRingAndBacklogQueue(
@@ -377,7 +377,7 @@ VOID	NICInitTxRxRingAndBacklogQueue(
 {
 	//WPDMA_GLO_CFG_STRUC	GloCfg;
 	int i;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("<--> NICInitTxRxRingAndBacklogQueue\n"));
 
 	// Initialize all transmit related software queues
@@ -390,7 +390,7 @@ VOID	NICInitTxRxRingAndBacklogQueue(
 	// Init RX Ring index pointer
 	pAd->RxRing.RxSwReadIdx = 0;
 	pAd->RxRing.RxCpuIdx = RX_RING_SIZE - 1;
-	
+
 	// Init TX rings index pointer
 		for (i=0; i<NUM_OF_TX_RING; i++)
 		{
@@ -408,7 +408,7 @@ VOID	NICInitTxRxRingAndBacklogQueue(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Reset NIC Asics. Call after rest DMA. So reset TX_CTX_IDX to zero.
 
@@ -420,10 +420,10 @@ VOID	NICInitTxRxRingAndBacklogQueue(
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
 		Reset NIC to initial state AS IS system boot up time.
-		
+
 	========================================================================
 */
 VOID	RTMPRingCleanUp(
@@ -437,7 +437,7 @@ VOID	RTMPRingCleanUp(
 	int				i;
 	PRTMP_TX_RING	pTxRing;
 	unsigned long	IrqFlags;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE,("RTMPRingCleanUp(RingIdx=%d, Pending-NDIS=%ld)\n", RingType, pAd->RalinkCounters.PendingNdisPacketCount));
 	switch (RingType)
 	{
@@ -448,7 +448,7 @@ VOID	RTMPRingCleanUp(
 		case QID_HCCA:
 			RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
 			pTxRing = &pAd->TxRing[RingType];
-			
+
 			// We have to clean all descriptors in case some error happened with reset
 			for (i=0; i<TX_RING_SIZE; i++) // We have to scan all TX ring
 			{
@@ -475,7 +475,7 @@ VOID	RTMPRingCleanUp(
 			pTxRing->TxSwFreeIdx = pTxRing->TxDmaIdx;
 			pTxRing->TxCpuIdx = pTxRing->TxDmaIdx;
 			RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + RingType * 0x10, pTxRing->TxCpuIdx);
-			
+
 			RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
 			RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
 			while (pAd->TxSwQueue[RingType].Head != NULL)
@@ -491,7 +491,7 @@ VOID	RTMPRingCleanUp(
 		case QID_MGMT:
 			// We have to clean all descriptors in case some error happened with reset
 			NdisAcquireSpinLock(&pAd->MgmtRingLock);
-			
+
 			for (i=0; i<MGMT_RING_SIZE; i++)
 			{
 				pTxD  = (PTXD_STRUC) pAd->MgmtRing.Cell[i].AllocVa;
@@ -509,7 +509,7 @@ VOID	RTMPRingCleanUp(
 				// release scatter-and-gather NDIS_PACKET
 				if (pPacket)
 				{
-					PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1, PCI_DMA_TODEVICE);			
+					PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1, PCI_DMA_TODEVICE);
 					RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
 				}
 				pAd->MgmtRing.Cell[i].pNextNdisPacket = NULL;
@@ -520,26 +520,26 @@ VOID	RTMPRingCleanUp(
 			pAd->MgmtRing.TxSwFreeIdx = pAd->MgmtRing.TxDmaIdx;
 			pAd->MgmtRing.TxCpuIdx = pAd->MgmtRing.TxDmaIdx;
 			RTMP_IO_WRITE32(pAd, TX_MGMTCTX_IDX, pAd->MgmtRing.TxCpuIdx);
-			
+
 			NdisReleaseSpinLock(&pAd->MgmtRingLock);
 			pAd->RalinkCounters.MgmtRingFullCount = 0;
 			break;
-			
+
 		case QID_RX:
 			// We have to clean all descriptors in case some error happened with reset
 			NdisAcquireSpinLock(&pAd->RxRingLock);
-			   
+
 			for (i=0; i<RX_RING_SIZE; i++)
 			{
 				pRxD  = (PRXD_STRUC) pAd->RxRing.Cell[i].AllocVa;
 				pRxD->DDONE = 0 ;
 			}
-			 
+
 			RTMP_IO_READ32(pAd, RX_DRX_IDX, &pAd->RxRing.RxDmaIdx);
 			pAd->RxRing.RxSwReadIdx = pAd->RxRing.RxDmaIdx;
 			pAd->RxRing.RxCpuIdx = ((pAd->RxRing.RxDmaIdx == 0) ? (RX_RING_SIZE-1) : (pAd->RxRing.RxDmaIdx-1));
 			RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx);
-			 
+
 			NdisReleaseSpinLock(&pAd->RxRingLock);
 			break;
 
@@ -556,13 +556,13 @@ NDIS_STATUS AdapterBlockAllocateMemory(
 	PPCI_DEV pci_dev;
 	dma_addr_t	*phy_addr;
 	POS_COOKIE pObj = (POS_COOKIE) handle;
-	
+
 	pci_dev = pObj->pci_dev;
 	phy_addr = &pObj->pAd_pa;
-	
+
 	*ppAd = (PVOID)vmalloc(sizeof(RTMP_ADAPTER)); //pci_alloc_consistent(pci_dev, sizeof(RTMP_ADAPTER), phy_addr);
-    
-	if (*ppAd) 
+
+	if (*ppAd)
 	{
 		NdisZeroMemory(*ppAd, sizeof(RTMP_ADAPTER));
 		((PRTMP_ADAPTER)*ppAd)->OS_Cookie = handle;
@@ -620,7 +620,7 @@ void RTMP_FreeRxDescMemory(
 	IN	NDIS_PHYSICAL_ADDRESS PhysicalAddress)
 {
 	POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
-	
+
 	PCI_FREE_CONSISTENT(pObj->pci_dev, Length, VirtualAddress, PhysicalAddress);
 }
 
@@ -657,7 +657,7 @@ void RTMP_AllocateSharedMemory(
 {
 	POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
 
-	*VirtualAddress = (PVOID)PCI_ALLOC_CONSISTENT(pObj->pci_dev,sizeof(char)*Length, PhysicalAddress);	
+	*VirtualAddress = (PVOID)PCI_ALLOC_CONSISTENT(pObj->pci_dev,sizeof(char)*Length, PhysicalAddress);
 }
 
 VOID RTMPFreeTxRxRingMemory(
@@ -668,9 +668,9 @@ VOID RTMPFreeTxRxRingMemory(
 	PTXD_STRUC	  pTxD;
 	PNDIS_PACKET  pPacket;
 	unsigned int  IrqFlags;
-		
+
 	POS_COOKIE pObj =(POS_COOKIE) pAd->OS_Cookie;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("--> RTMPFreeTxRxRingMemory\n"));
 
 	// Free TxSwQueue Packet
@@ -695,9 +695,9 @@ VOID RTMPFreeTxRxRingMemory(
 	for (index=0;index< NUM_OF_TX_RING;index++)
 	{
 		pTxRing = &pAd->TxRing[index];
-		
+
 		for (j=0; j< TX_RING_SIZE; j++)
-		{	
+		{
 			pTxD = (PTXD_STRUC) (pTxRing->Cell[j].AllocVa);
 			pPacket = pTxRing->Cell[j].pNdisPacket;
 
@@ -705,12 +705,12 @@ VOID RTMPFreeTxRxRingMemory(
 			{
             	PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr0, pTxD->SDLen0, PCI_DMA_TODEVICE);
 				RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
-			}		
+			}
 			//Always assign pNdisPacket as NULL after clear
 			pTxRing->Cell[j].pNdisPacket = NULL;
-					
+
 			pPacket = pTxRing->Cell[j].pNextNdisPacket;
-			
+
 			if (pPacket)
 			{
             	PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1, PCI_DMA_TODEVICE);
@@ -720,8 +720,8 @@ VOID RTMPFreeTxRxRingMemory(
 			pTxRing->Cell[pTxRing->TxSwFreeIdx].pNextNdisPacket = NULL;
 
 		}
-	}	
-	
+	}
+
 	for (index = RX_RING_SIZE - 1 ; index >= 0; index--)
 	{
 		if ((pAd->RxRing.Cell[index].DmaBuf.AllocVa) && (pAd->RxRing.Cell[index].pNdisPacket))
@@ -731,7 +731,7 @@ VOID RTMPFreeTxRxRingMemory(
 		}
 	}
 	NdisZeroMemory(pAd->RxRing.Cell, RX_RING_SIZE * sizeof(RTMP_DMACB));
-	
+
 	if (pAd->RxDescRing.AllocVa)
     {
     	PCI_FREE_CONSISTENT(pObj->pci_dev, pAd->RxDescRing.AllocSize, pAd->RxDescRing.AllocVa, pAd->RxDescRing.AllocPa);
@@ -751,7 +751,7 @@ VOID RTMPFreeTxRxRingMemory(
 	    	PCI_FREE_CONSISTENT(pObj->pci_dev, pAd->TxBufSpace[num].AllocSize, pAd->TxBufSpace[num].AllocVa, pAd->TxBufSpace[num].AllocPa);
 	    }
 	    NdisZeroMemory(&pAd->TxBufSpace[num], sizeof(RTMP_DMABUF));
-	    
+
     	if (pAd->TxDescRing[num].AllocVa)
 	    {
 	    	PCI_FREE_CONSISTENT(pObj->pci_dev, pAd->TxDescRing[num].AllocSize, pAd->TxDescRing[num].AllocVa, pAd->TxDescRing[num].AllocPa);
@@ -763,7 +763,7 @@ VOID RTMPFreeTxRxRingMemory(
 		RELEASE_NDIS_PACKET(pAd, pAd->FragFrame.pFragPacket, NDIS_STATUS_SUCCESS);
 
 	DBGPRINT(RT_DEBUG_TRACE, ("<-- RTMPFreeTxRxRingMemory\n"));
-}	
+}
 
 
 /*
@@ -794,12 +794,12 @@ PNDIS_PACKET RTMP_AllocateRxPacketBuffer(
 
 	if (pkt) {
 		RTMP_SET_PACKET_SOURCE(pkt, PKTSRC_NDIS);
-		*VirtualAddress = (PVOID) RTPKT_TO_OSPKT(pkt)->data;	
+		*VirtualAddress = (PVOID) RTPKT_TO_OSPKT(pkt)->data;
 		*PhysicalAddress = PCI_MAP_SINGLE(pAd, *VirtualAddress, Length, -1, PCI_DMA_FROMDEVICE);
 	} else {
 		*VirtualAddress = (PVOID) NULL;
 		*PhysicalAddress = (NDIS_PHYSICAL_ADDRESS) NULL;
-	}	
+	}
 
 	return (PNDIS_PACKET) pkt;
 }
@@ -890,8 +890,8 @@ PNDIS_PACKET GetPacketFromRxRing(
 		pAd->RxRing.Cell[pAd->RxRing.RxSwReadIdx].DmaBuf.AllocPa	= AllocPa;
 		/* update SDP0 to new buffer of rx packet */
 		pRxD->SDP0 = AllocPa;
-	} 
-	else 
+	}
+	else
 	{
 		//printk("No Rx Buffer\n");
 		pRxPacket = NULL;
@@ -901,9 +901,9 @@ PNDIS_PACKET GetPacketFromRxRing(
 	pRxD->DDONE = 0;
 
 	// had handled one rx packet
-	*pRxPending = *pRxPending - 1;	
+	*pRxPending = *pRxPending - 1;
 
-	// update rx descriptor and kick rx 
+	// update rx descriptor and kick rx
 #ifdef RT_BIG_ENDIAN
 	RTMPDescriptorEndianChange((PUCHAR)pRxD, TYPE_RXD);
 	WriteBackToDescriptor((PUCHAR)pDestRxD, (PUCHAR)pRxD, FALSE, TYPE_RXD);
diff --git a/common/action.c b/common/action.c
index a065af0..d6f530f 100644
--- a/common/action.c
+++ b/common/action.c
@@ -7,64 +7,64 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
     Module Name:
 	action.c
- 
+
     Abstract:
     Handle association related requests either from WSTA or from local MLME
- 
+
     Revision History:
     Who         When          What
     --------    ----------    ----------------------------------------------
 	Jan Lee		2006	  	created for rt2860
  */
 
-#include "rt_config.h"
+#include "../rt_config.h"
 #include "action.h"
 
 
 static VOID ReservedAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
-/*  
+/*
     ==========================================================================
-    Description: 
+    Description:
         association state machine init, including state transition and timer init
-    Parameters: 
+    Parameters:
         S - pointer to the association state machine
     Note:
-        The state machine looks like the following 
-        
-                                    ASSOC_IDLE             
-        MT2_MLME_DISASSOC_REQ    mlme_disassoc_req_action 
-        MT2_PEER_DISASSOC_REQ    peer_disassoc_action     
-        MT2_PEER_ASSOC_REQ       drop                     
-        MT2_PEER_REASSOC_REQ     drop                     
-        MT2_CLS3ERR              cls3err_action           
+        The state machine looks like the following
+
+                                    ASSOC_IDLE
+        MT2_MLME_DISASSOC_REQ    mlme_disassoc_req_action
+        MT2_PEER_DISASSOC_REQ    peer_disassoc_action
+        MT2_PEER_ASSOC_REQ       drop
+        MT2_PEER_REASSOC_REQ     drop
+        MT2_CLS3ERR              cls3err_action
     ==========================================================================
  */
 VOID ActionStateMachineInit(
-    IN	PRTMP_ADAPTER	pAd, 
-    IN  STATE_MACHINE *S, 
-    OUT STATE_MACHINE_FUNC Trans[]) 
+    IN	PRTMP_ADAPTER	pAd,
+    IN  STATE_MACHINE *S,
+    OUT STATE_MACHINE_FUNC Trans[])
 {
 	StateMachineInit(S, (STATE_MACHINE_FUNC *)Trans, MAX_ACT_STATE, MAX_ACT_MSG, (STATE_MACHINE_FUNC)Drop, ACT_IDLE, ACT_MACHINE_BASE);
 
@@ -86,7 +86,7 @@ VOID ActionStateMachineInit(
 
 	StateMachineSetAction(S, ACT_IDLE, MT2_PEER_PUBLIC_CATE, (STATE_MACHINE_FUNC)PeerPublicAction);
 	StateMachineSetAction(S, ACT_IDLE, MT2_PEER_RM_CATE, (STATE_MACHINE_FUNC)PeerRMAction);
-	
+
 	StateMachineSetAction(S, ACT_IDLE, MT2_MLME_QOS_CATE, (STATE_MACHINE_FUNC)MlmeQOSAction);
 	StateMachineSetAction(S, ACT_IDLE, MT2_MLME_DLS_CATE, (STATE_MACHINE_FUNC)MlmeDLSAction);
 	StateMachineSetAction(S, ACT_IDLE, MT2_ACT_INVALID, (STATE_MACHINE_FUNC)MlmeInvalidAction);
@@ -94,8 +94,8 @@ VOID ActionStateMachineInit(
 
 #ifdef DOT11_N_SUPPORT
 VOID MlmeADDBAAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 
 {
 	MLME_ADDBA_REQ_STRUCT *pInfo;
@@ -109,11 +109,11 @@ VOID MlmeADDBAAction(
 
 	pInfo = (MLME_ADDBA_REQ_STRUCT *)Elem->Msg;
 	NdisZeroMemory(&Frame, sizeof(FRAME_ADDBA_REQ));
-	
-	if(MlmeAddBAReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr)) 
+
+	if(MlmeAddBAReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr))
 	{
 		NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-		if(NStatus != NDIS_STATUS_SUCCESS) 
+		if(NStatus != NDIS_STATUS_SUCCESS)
 		{
 			DBGPRINT(RT_DEBUG_TRACE,("BA - MlmeADDBAAction() allocate memory failed \n"));
 			return;
@@ -125,12 +125,12 @@ VOID MlmeADDBAAction(
 			MlmeFreeMemory(pAd, pOutBuffer);
 			DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() can't find BAOriEntry \n"));
 			return;
-		} 
+		}
 		else
 		{
 			pBAEntry =&pAd->BATable.BAOriEntry[Idx];
 		}
-		
+
 #ifdef CONFIG_STA_SUPPORT
 		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 		{
@@ -145,7 +145,7 @@ VOID MlmeADDBAAction(
 				ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pInfo->pAddr);
 
 		}
-#endif // CONFIG_STA_SUPPORT // 
+#endif // CONFIG_STA_SUPPORT //
 
 		Frame.Category = CATEGORY_BA;
 		Frame.Action = ADDBA_REQ;
@@ -167,7 +167,7 @@ VOID MlmeADDBAAction(
 		              END_OF_ARGS);
 		MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
 		MlmeFreeMemory(pAd, pOutBuffer);
-		
+
 		DBGPRINT(RT_DEBUG_TRACE, ("BA - Send ADDBA request. StartSeq = %x,  FrameLen = %ld. BufSize = %d\n", Frame.BaStartSeq.field.StartSeq, FrameLen, Frame.BaParm.BufSize));
     }
 }
@@ -178,14 +178,14 @@ VOID MlmeADDBAAction(
         send DELBA and delete BaEntry if any
     Parametrs:
         Elem - MLME message MLME_DELBA_REQ_STRUCT
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID MlmeDELBAAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
 	MLME_DELBA_REQ_STRUCT *pInfo;
 	PUCHAR         pOutBuffer = NULL;
@@ -195,23 +195,23 @@ VOID MlmeDELBAAction(
 	FRAME_DELBA_REQ  Frame;
 	ULONG		FrameLen;
 	FRAME_BAR	FrameBar;
-	
-	pInfo = (MLME_DELBA_REQ_STRUCT *)Elem->Msg;	
-	// must send back DELBA 
+
+	pInfo = (MLME_DELBA_REQ_STRUCT *)Elem->Msg;
+	// must send back DELBA
 	NdisZeroMemory(&Frame, sizeof(FRAME_DELBA_REQ));
 	DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeDELBAAction(), Initiator(%d) \n", pInfo->Initiator));
-	
-	if(MlmeDelBAReqSanity(pAd, Elem->Msg, Elem->MsgLen)) 
+
+	if(MlmeDelBAReqSanity(pAd, Elem->Msg, Elem->MsgLen))
 	{
 		NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-		if(NStatus != NDIS_STATUS_SUCCESS) 
+		if(NStatus != NDIS_STATUS_SUCCESS)
 		{
 			DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeDELBAAction() allocate memory failed 1. \n"));
 			return;
 		}
 
 		NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2);  //Get an unused nonpaged memory
-		if(NStatus != NDIS_STATUS_SUCCESS) 
+		if(NStatus != NDIS_STATUS_SUCCESS)
 		{
 			MlmeFreeMemory(pAd, pOutBuffer);
 			DBGPRINT(RT_DEBUG_ERROR, ("BA - MlmeDELBAAction() allocate memory failed 2. \n"));
@@ -262,7 +262,7 @@ VOID MlmeDELBAAction(
 		Frame.ReasonCode = 39; // Time Out
 		*(USHORT *)(&Frame.DelbaParm) = cpu2le16(*(USHORT *)(&Frame.DelbaParm));
 		Frame.ReasonCode = cpu2le16(Frame.ReasonCode);
-		
+
 		MakeOutgoingFrame(pOutBuffer,               &FrameLen,
 		              sizeof(FRAME_DELBA_REQ),    &Frame,
 		              END_OF_ARGS);
@@ -274,35 +274,35 @@ VOID MlmeDELBAAction(
 #endif // DOT11_N_SUPPORT //
 
 VOID MlmeQOSAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
 }
 
 VOID MlmeDLSAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
 }
 
 VOID MlmeInvalidAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
 	//PUCHAR		   pOutBuffer = NULL;
 	//Return the receiving frame except the MSB of category filed set to 1.  7.3.1.11
 }
 
 VOID PeerQOSAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 }
 
 #ifdef QOS_DLS_SUPPORT
 VOID PeerDLSAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR	Action = Elem->Msg[LENGTH_802_11+1];
 
@@ -334,11 +334,11 @@ VOID PeerDLSAction(
 
 #ifdef DOT11_N_SUPPORT
 VOID PeerBAAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR	Action = Elem->Msg[LENGTH_802_11+1];
-	
+
 	switch(Action)
 	{
 		case ADDBA_REQ:
@@ -358,14 +358,14 @@ VOID PeerBAAction(
 
 #ifdef CONFIG_STA_SUPPORT
 VOID StaPublicAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN UCHAR Bss2040Coexist) 
+	IN PRTMP_ADAPTER pAd,
+	IN UCHAR Bss2040Coexist)
 {
 	BSS_2040_COEXIST_IE		BssCoexist;
 	MLME_SCAN_REQ_STRUCT			ScanReq;
 
 	BssCoexist.word = Bss2040Coexist;
-	// AP asks Station to return a 20/40 BSS Coexistence mgmt frame.  So we first starts a scan, then send back 20/40 BSS Coexistence mgmt frame 
+	// AP asks Station to return a 20/40 BSS Coexistence mgmt frame.  So we first starts a scan, then send back 20/40 BSS Coexistence mgmt frame
 	if ((BssCoexist.field.InfoReq == 1) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SCAN_2040)))
 	{
 		// Clear record first.  After scan , will update those bit and send back to transmiter.
@@ -382,18 +382,18 @@ VOID StaPublicAction(
 
 /*
 Description : Build Intolerant Channel Rerpot from Trigger event table.
-return : how many bytes copied. 
+return : how many bytes copied.
 */
 ULONG BuildIntolerantChannelRep(
 	IN	PRTMP_ADAPTER	pAd,
-	IN    PUCHAR  pDest) 
+	IN    PUCHAR  pDest)
 {
 	ULONG			FrameLen = 0;
 	ULONG			ReadOffset = 0;
 	UCHAR			i;
 	UCHAR			LastRegClass = 0xff;
 	PUCHAR			pLen;
-	
+
 	for ( i = 0;i < MAX_TRIGGER_EVENT;i++)
 	{
 		if (pAd->CommonCfg.TriggerEventTab.EventA[i].bValid == TRUE)
@@ -416,7 +416,7 @@ ULONG BuildIntolerantChannelRep(
 				FrameLen += 4;
 				ReadOffset += 4;
 			}
-			
+
 		}
 	}
 	return FrameLen;
@@ -429,7 +429,7 @@ Description : Send 20/40 BSS Coexistence Action frame If one trigger event is tr
 VOID Send2040CoexistAction(
 	IN	PRTMP_ADAPTER	pAd,
 	IN    UCHAR  Wcid,
-	IN	BOOLEAN	bAddIntolerantCha) 
+	IN	BOOLEAN	bAddIntolerantCha)
 {
 	PUCHAR			pOutBuffer = NULL;
 	NDIS_STATUS 	NStatus;
@@ -439,7 +439,7 @@ VOID Send2040CoexistAction(
 
 	IntolerantChaRepLen = 0;
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-	if(NStatus != NDIS_STATUS_SUCCESS) 
+	if(NStatus != NDIS_STATUS_SUCCESS)
 	{
 		DBGPRINT(RT_DEBUG_ERROR,("ACT - Send2040CoexistAction() allocate memory failed \n"));
 		return;
@@ -447,36 +447,36 @@ VOID Send2040CoexistAction(
 	ActHeaderInit(pAd, &Frame.Hdr, pAd->MacTab.Content[Wcid].Addr, pAd->CommonCfg.Bssid);
 	Frame.Category = CATEGORY_PUBLIC;
 	Frame.Action = ACTION_BSS_2040_COEXIST;
-	
+
 	MakeOutgoingFrame(pOutBuffer,				&FrameLen,
 				  sizeof(FRAME_ACTION_HDR),	  &Frame,
 				  END_OF_ARGS);
 
 	*(pOutBuffer + FrameLen) = pAd->CommonCfg.BSSCoexist2040.word;
 	FrameLen++;
-	
+
 	if (bAddIntolerantCha == TRUE)
 		IntolerantChaRepLen = BuildIntolerantChannelRep(pAd, pOutBuffer + FrameLen);
 
 	MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen + IntolerantChaRepLen);
 	DBGPRINT(RT_DEBUG_ERROR,("ACT - Send2040CoexistAction( BSSCoexist2040 = 0x%x )  \n", pAd->CommonCfg.BSSCoexist2040.word));
-		
+
 }
 
 
-/*	
+/*
 	==========================================================================
-	Description: 
+	Description:
 	After scan, Update 20/40 BSS Coexistence IE and send out.
 	According to 802.11n D3.03 11.14.10
-		
-	Parameters: 
+
+	Parameters:
 	==========================================================================
  */
 VOID Update2040CoexistFrameAndNotify(
 	IN	PRTMP_ADAPTER	pAd,
 	IN    UCHAR  Wcid,
-	IN	BOOLEAN	bAddIntolerantCha) 
+	IN	BOOLEAN	bAddIntolerantCha)
 {
 	BSS_2040_COEXIST_IE	OldValue;
 
@@ -499,10 +499,10 @@ BOOLEAN ChannelSwitchSanityCheck(
 	IN	PRTMP_ADAPTER	pAd,
 	IN    UCHAR  Wcid,
 	IN    UCHAR  NewChannel,
-	IN    UCHAR  Secondary) 
+	IN    UCHAR  Secondary)
 {
 	UCHAR		i;
-	
+
 	if (Wcid >= MAX_LEN_OF_MAC_TABLE)
 		return FALSE;
 
@@ -523,7 +523,7 @@ BOOLEAN ChannelSwitchSanityCheck(
 
 	if (i == pAd->ChannelListNum)
 		return FALSE;
-	
+
 	return TRUE;
 }
 
@@ -532,16 +532,16 @@ VOID ChannelSwitchAction(
 	IN	PRTMP_ADAPTER	pAd,
 	IN    UCHAR  Wcid,
 	IN    UCHAR  NewChannel,
-	IN    UCHAR  Secondary) 
+	IN    UCHAR  Secondary)
 {
 	UCHAR		BBPValue = 0;
 	ULONG		MACValue;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE,("SPECTRUM - ChannelSwitchAction(NewChannel = %d , Secondary = %d)  \n", NewChannel, Secondary));
 
 	if (ChannelSwitchSanityCheck(pAd, Wcid, NewChannel, Secondary) == FALSE)
 		return;
-	
+
 	// 1.  Switches to BW = 20.
 	if (Secondary == 0)
 	{
@@ -612,13 +612,13 @@ VOID ChannelSwitchAction(
 #endif // DOT11_N_SUPPORT //
 
 VOID PeerPublicAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 #ifdef DOT11N_DRAFT3
 	UCHAR	Action = Elem->Msg[LENGTH_802_11+1];
 #endif // DOT11N_DRAFT3 //
-	
+
 	if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
 		return;
 
@@ -631,16 +631,16 @@ VOID PeerPublicAction(
 				BSS_2040_COEXIST_ELEMENT		*pCoexistInfo;
 				BSS_2040_COEXIST_IE 			*pBssCoexistIe;
 				BSS_2040_INTOLERANT_CH_REPORT	*pIntolerantReport = NULL;
-				
+
 				if (Elem->MsgLen <= (LENGTH_802_11 + sizeof(BSS_2040_COEXIST_ELEMENT)) )
 				{
 					DBGPRINT(RT_DEBUG_ERROR, ("ACTION - 20/40 BSS Coexistence Management Frame length too short! len = %ld!\n", Elem->MsgLen));
 					break;
-				}			
+				}
 				DBGPRINT(RT_DEBUG_TRACE, ("ACTION - 20/40 BSS Coexistence Management action----> \n"));
 				hex_dump("CoexistenceMgmtFrame", Elem->Msg, Elem->MsgLen);
 
-				
+
 				pCoexistInfo = (BSS_2040_COEXIST_ELEMENT *) &Elem->Msg[LENGTH_802_11+2];
 				//hex_dump("CoexistInfo", (PUCHAR)pCoexistInfo, sizeof(BSS_2040_COEXIST_ELEMENT));
 				if (Elem->MsgLen >= (LENGTH_802_11 + sizeof(BSS_2040_COEXIST_ELEMENT) + sizeof(BSS_2040_INTOLERANT_CH_REPORT)))
@@ -648,7 +648,7 @@ VOID PeerPublicAction(
 					pIntolerantReport = (BSS_2040_INTOLERANT_CH_REPORT *)((PUCHAR)pCoexistInfo + sizeof(BSS_2040_COEXIST_ELEMENT));
 				}
 				//hex_dump("IntolerantReport ", (PUCHAR)pIntolerantReport, sizeof(BSS_2040_INTOLERANT_CH_REPORT));
-				
+
 				pBssCoexistIe = (BSS_2040_COEXIST_IE *)(&pCoexistInfo->BssCoexistIe);
 
 #ifdef CONFIG_STA_SUPPORT
@@ -667,11 +667,11 @@ VOID PeerPublicAction(
 
 #endif // DOT11N_DRAFT3 //
 
-}	
+}
 
 
 static VOID ReservedAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR Category;
@@ -687,8 +687,8 @@ static VOID ReservedAction(
 }
 
 VOID PeerRMAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 
 {
 	return;
@@ -697,7 +697,7 @@ VOID PeerRMAction(
 #ifdef DOT11_N_SUPPORT
 static VOID respond_ht_information_exchange_action(
 	IN PRTMP_ADAPTER pAd,
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	PUCHAR			pOutBuffer = NULL;
 	NDIS_STATUS		NStatus;
@@ -706,7 +706,7 @@ static VOID respond_ht_information_exchange_action(
 	UCHAR   		*pAddr;
 
 
-	// 2. Always send back ADDBA Response 
+	// 2. Always send back ADDBA Response
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);	 //Get an unused nonpaged memory
 
 	if (NStatus != NDIS_STATUS_SUCCESS)
@@ -735,7 +735,7 @@ static VOID respond_ht_information_exchange_action(
 	HTINFOframe.Action = HT_INFO_EXCHANGE;
 	HTINFOframe.HT_Info.Request = 0;
 	HTINFOframe.HT_Info.Forty_MHz_Intolerant = pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant;
-	HTINFOframe.HT_Info.STA_Channel_Width	 = pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;	
+	HTINFOframe.HT_Info.STA_Channel_Width	 = pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
 
 	MakeOutgoingFrame(pOutBuffer,					&FrameLen,
 					  sizeof(FRAME_HT_INFO),	&HTINFOframe,
@@ -758,9 +758,9 @@ VOID SendNotifyBWActionFrame(
 	ULONG			FrameLen;
 	PUCHAR			pAddr1;
 
-	
+
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-	if(NStatus != NDIS_STATUS_SUCCESS) 
+	if(NStatus != NDIS_STATUS_SUCCESS)
 	{
 		DBGPRINT(RT_DEBUG_ERROR,("ACT - SendNotifyBWAction() allocate memory failed \n"));
 		return;
@@ -771,17 +771,17 @@ VOID SendNotifyBWActionFrame(
 	else
 		pAddr1 = pAd->MacTab.Content[Wcid].Addr;
 	ActHeaderInit(pAd, &Frame.Hdr, pAddr1, pAd->ApCfg.MBSSID[apidx].Bssid, pAd->ApCfg.MBSSID[apidx].Bssid);
-	
+
 	Frame.Category = CATEGORY_HT;
 	Frame.Action = NOTIFY_BW_ACTION;
-	
+
 	MakeOutgoingFrame(pOutBuffer,				&FrameLen,
 				  sizeof(FRAME_ACTION_HDR),	  &Frame,
 				  END_OF_ARGS);
 
 	*(pOutBuffer + FrameLen) = pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
 	FrameLen++;
-	
+
 
 	MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
 	DBGPRINT(RT_DEBUG_TRACE,("ACT - SendNotifyBWAction(NotifyBW= %d)!\n", pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth));
@@ -791,14 +791,14 @@ VOID SendNotifyBWActionFrame(
 
 
 VOID PeerHTAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR	Action = Elem->Msg[LENGTH_802_11+1];
-	
+
 	if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
 		return;
-	
+
 	switch(Action)
 	{
 		case NOTIFY_BW_ACTION:
@@ -806,18 +806,18 @@ VOID PeerHTAction(
 #ifdef CONFIG_STA_SUPPORT
 			if(pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
 			{
-				// Note, this is to patch DIR-1353 AP. When the AP set to Wep, it will use legacy mode. But AP still keeps 
-				// sending BW_Notify Action frame, and cause us to linkup and linkdown. 
+				// Note, this is to patch DIR-1353 AP. When the AP set to Wep, it will use legacy mode. But AP still keeps
+				// sending BW_Notify Action frame, and cause us to linkup and linkdown.
 				// In legacy mode, don't need to parse HT action frame.
-				DBGPRINT(RT_DEBUG_TRACE,("ACTION -Ignore HT Notify Channel BW when link as legacy mode. BW = %d---> \n", 
+				DBGPRINT(RT_DEBUG_TRACE,("ACTION -Ignore HT Notify Channel BW when link as legacy mode. BW = %d---> \n",
 								Elem->Msg[LENGTH_802_11+2] ));
 				break;
 			}
 #endif // CONFIG_STA_SUPPORT //
 
-			if (Elem->Msg[LENGTH_802_11+2] == 0)	// 7.4.8.2. if value is 1, keep the same as supported channel bandwidth. 
+			if (Elem->Msg[LENGTH_802_11+2] == 0)	// 7.4.8.2. if value is 1, keep the same as supported channel bandwidth.
 				pAd->MacTab.Content[Elem->Wcid].HTPhyMode.field.BW = 0;
-			
+
 			break;
 		case SMPS_ACTION:
 			// 7.3.1.25
@@ -831,20 +831,20 @@ VOID PeerHTAction(
 				pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_STATIC;
 			}
 			else
-			{			
+			{
 				pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_DYNAMIC;
 			}
 
 			DBGPRINT(RT_DEBUG_TRACE,("Aid(%d) MIMO PS = %d\n", Elem->Wcid, pAd->MacTab.Content[Elem->Wcid].MmpsMode));
 			// rt2860c : add something for smps change.
 			break;
- 
+
 		case SETPCO_ACTION:
 			break;
 		case MIMO_CHA_MEASURE_ACTION:
 			break;
 		case HT_INFO_EXCHANGE:
-			{			
+			{
 				HT_INFORMATION_OCTET	*pHT_info;
 
 				pHT_info = (HT_INFORMATION_OCTET *) &Elem->Msg[LENGTH_802_11+2];
@@ -855,7 +855,7 @@ VOID PeerHTAction(
     					respond_ht_information_exchange_action(pAd, Elem);
     				}
 			}
-    			break;	
+    			break;
 	}
 }
 
@@ -864,18 +864,18 @@ VOID PeerHTAction(
 	==========================================================================
 	Description:
 		Retry sending ADDBA Reqest.
-		
+
 	IRQL = DISPATCH_LEVEL
-	
+
 	Parametrs:
 	p8023Header: if this is already 802.3 format, p8023Header is NULL
-	
+
 	Return	: TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
 				FALSE , then continue indicaterx at this moment.
 	==========================================================================
  */
 VOID ORIBATimerTimeout(
-	IN	PRTMP_ADAPTER	pAd) 
+	IN	PRTMP_ADAPTER	pAd)
 {
 	MAC_TABLE_ENTRY	*pEntry;
 	INT			i, total;
@@ -904,7 +904,7 @@ VOID ORIBATimerTimeout(
 
 VOID SendRefreshBAR(
 	IN	PRTMP_ADAPTER	pAd,
-	IN	MAC_TABLE_ENTRY	*pEntry) 
+	IN	MAC_TABLE_ENTRY	*pEntry)
 {
 	FRAME_BAR		FrameBar;
 	ULONG			FrameLen;
@@ -931,12 +931,12 @@ VOID SendRefreshBAR(
 			ASSERT(pBAEntry->Wcid < MAX_LEN_OF_MAC_TABLE);
 
 			NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-			if(NStatus != NDIS_STATUS_SUCCESS) 
+			if(NStatus != NDIS_STATUS_SUCCESS)
 			{
 				DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() allocate memory failed \n"));
 				return;
 			}
-				
+
 			Sequence = pEntry->TxSeq[TID];
 #ifdef CONFIG_STA_SUPPORT
 			IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
@@ -961,11 +961,11 @@ VOID SendRefreshBAR(
 #endif // DOT11_N_SUPPORT //
 
 VOID ActHeaderInit(
-    IN	PRTMP_ADAPTER	pAd, 
-    IN OUT PHEADER_802_11 pHdr80211, 
-    IN PUCHAR Addr1, 
+    IN	PRTMP_ADAPTER	pAd,
+    IN OUT PHEADER_802_11 pHdr80211,
+    IN PUCHAR Addr1,
     IN PUCHAR Addr2,
-    IN PUCHAR Addr3) 
+    IN PUCHAR Addr3)
 {
     NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
     pHdr80211->FC.Type = BTYPE_MGMT;
@@ -977,10 +977,10 @@ VOID ActHeaderInit(
 }
 
 VOID BarHeaderInit(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN OUT PFRAME_BAR pCntlBar, 
+	IN	PRTMP_ADAPTER	pAd,
+	IN OUT PFRAME_BAR pCntlBar,
 	IN PUCHAR pDA,
-	IN PUCHAR pSA) 
+	IN PUCHAR pSA)
 {
 	NdisZeroMemory(pCntlBar, sizeof(FRAME_BAR));
 	pCntlBar->FC.Type = BTYPE_CNTL;
@@ -1001,13 +1001,13 @@ VOID BarHeaderInit(
 	==========================================================================
 	Description:
 		Insert Category and action code into the action frame.
-		
+
 	Parametrs:
 		1. frame buffer pointer.
 		2. frame length.
 		3. category code of the frame.
 		4. action code of the frame.
-	
+
 	Return	: None.
 	==========================================================================
  */
diff --git a/include/action.h b/common/action.h
similarity index 91%
rename from include/action.h
rename to common/action.h
index aef1f3f..ce3877d 100644
--- a/include/action.h
+++ b/common/action.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
diff --git a/common/ba_action.c b/common/ba_action.c
index 28a6e79..8247aeb 100644
--- a/common/ba_action.c
+++ b/common/ba_action.c
@@ -7,27 +7,27 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
  */
 
 #ifdef DOT11_N_SUPPORT
 
-#include "rt_config.h"
+#include "../rt_config.h"
 
 
 
@@ -54,15 +54,15 @@ BA_REC_ENTRY *BATableAllocRecEntry(
 								  OUT USHORT          *Idx);
 
 VOID BAOriSessionSetupTimeout(
-    IN PVOID SystemSpecific1, 
-    IN PVOID FunctionContext, 
-    IN PVOID SystemSpecific2, 
+    IN PVOID SystemSpecific1,
+    IN PVOID FunctionContext,
+    IN PVOID SystemSpecific2,
     IN PVOID SystemSpecific3);
 
 VOID BARecSessionIdleTimeout(
-    IN PVOID SystemSpecific1, 
-    IN PVOID FunctionContext, 
-    IN PVOID SystemSpecific2, 
+    IN PVOID SystemSpecific1,
+    IN PVOID FunctionContext,
+    IN PVOID SystemSpecific2,
     IN PVOID SystemSpecific3);
 
 
@@ -102,12 +102,12 @@ VOID BA_MaxWinSizeReasign(
 	else
 		MaxSize = 7;
 
-	DBGPRINT(RT_DEBUG_TRACE, ("ba> Win Size = %d, Max Size = %d\n", 
+	DBGPRINT(RT_DEBUG_TRACE, ("ba> Win Size = %d, Max Size = %d\n",
 			*pWinSize, MaxSize));
 
 	if ((*pWinSize) > MaxSize)
 	{
-		DBGPRINT(RT_DEBUG_TRACE, ("ba> reassign max win size from %d to %d\n", 
+		DBGPRINT(RT_DEBUG_TRACE, ("ba> reassign max win size from %d to %d\n",
 				*pWinSize, MaxSize));
 
 		*pWinSize = MaxSize;
@@ -130,7 +130,7 @@ void Announce_Reordering_Packet(IN PRTMP_ADAPTER			pAd,
 	{
 		//
 		// pass this 802.3 packet to upper layer or forward this packet to WM directly
-		// 
+		//
 
 #ifdef CONFIG_STA_SUPPORT
 		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
@@ -151,12 +151,12 @@ BOOLEAN ba_reordering_mpdu_insertsorted(struct reordering_list *list, struct reo
 	{
 		if (SEQ_SMALLER((*ppScan)->Sequence, mpdu->Sequence, MAXSEQ))
 		{
-			ppScan = &(*ppScan)->next;          
+			ppScan = &(*ppScan)->next;
 		}
 		else if ((*ppScan)->Sequence == mpdu->Sequence)
 		{
 			/* give up this duplicated frame */
-			return(FALSE);         
+			return(FALSE);
 		}
 		else
 		{
@@ -219,10 +219,10 @@ static inline struct reordering_mpdu  *ba_reordering_mpdu_probe(struct reorderin
 	}
 
 
-/* 
- * free all resource for reordering mechanism 
+/*
+ * free all resource for reordering mechanism
  */
-void ba_reordering_resource_release(PRTMP_ADAPTER pAd) 
+void ba_reordering_resource_release(PRTMP_ADAPTER pAd)
 {
 	BA_TABLE        *Tab;
 	PBA_REC_ENTRY   pBAEntry;
@@ -243,7 +243,7 @@ void ba_reordering_resource_release(PRTMP_ADAPTER pAd)
 				ASSERT(mpdu_blk->pPacket);
 				RELEASE_NDIS_PACKET(pAd, mpdu_blk->pPacket, NDIS_STATUS_FAILURE);
 				ba_mpdu_blk_free(pAd, mpdu_blk);
-			}           
+			}
 		}
 	}
 	NdisReleaseSpinLock(&pAd->BATabLock);
@@ -257,8 +257,8 @@ void ba_reordering_resource_release(PRTMP_ADAPTER pAd)
 
 
 
-/* 
- * Allocate all resource for reordering mechanism 
+/*
+ * Allocate all resource for reordering mechanism
  */
 BOOLEAN ba_reordering_resource_init(PRTMP_ADAPTER pAd, int num)
 {
@@ -334,7 +334,7 @@ static void ba_mpdu_blk_free(PRTMP_ADAPTER pAd, struct reordering_mpdu *mpdu_blk
 
 
 static USHORT ba_indicate_reordering_mpdus_in_order(
-												   IN PRTMP_ADAPTER    pAd, 
+												   IN PRTMP_ADAPTER    pAd,
 												   IN PBA_REC_ENTRY    pBAEntry,
 												   IN USHORT           StartSeq)
 {
@@ -368,7 +368,7 @@ static USHORT ba_indicate_reordering_mpdus_in_order(
 }
 
 static void ba_indicate_reordering_mpdus_le_seq(
-											   IN PRTMP_ADAPTER    pAd, 
+											   IN PRTMP_ADAPTER    pAd,
 											   IN PBA_REC_ENTRY    pBAEntry,
 											   IN USHORT           Sequence)
 {
@@ -385,19 +385,19 @@ static void ba_indicate_reordering_mpdus_le_seq(
 			/* pass this frame up */
 			ANNOUNCE_REORDERING_PACKET(pAd, mpdu_blk);
 			/* free mpdu_blk */
-			ba_mpdu_blk_free(pAd, mpdu_blk);            
+			ba_mpdu_blk_free(pAd, mpdu_blk);
 		}
 		else
 			{
 				break;
 			}
 	}
-	NdisReleaseSpinLock(&pBAEntry->RxReRingLock);   
+	NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
 }
 
 
 static void ba_refresh_reordering_mpdus(
-									   IN PRTMP_ADAPTER    pAd, 
+									   IN PRTMP_ADAPTER    pAd,
 									   PBA_REC_ENTRY       pBAEntry)
 {
 	struct reordering_mpdu *mpdu_blk;
@@ -412,18 +412,18 @@ static void ba_refresh_reordering_mpdus(
 
 		pBAEntry->LastIndSeq = mpdu_blk->Sequence;
 			ba_mpdu_blk_free(pAd, mpdu_blk);
-			
-		/* update last indicated sequence */                    
+
+		/* update last indicated sequence */
 	}
 	ASSERT(pBAEntry->list.qlen == 0);
 	pBAEntry->LastIndSeq = RESET_RCV_SEQ;
-	NdisReleaseSpinLock(&pBAEntry->RxReRingLock);   
+	NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
 }
 
 
-//static 
+//static
 void ba_flush_reordering_timeout_mpdus(
-									IN PRTMP_ADAPTER    pAd, 
+									IN PRTMP_ADAPTER    pAd,
 									IN PBA_REC_ENTRY    pBAEntry,
 									IN ULONG            Now32)
 
@@ -434,11 +434,11 @@ void ba_flush_reordering_timeout_mpdus(
 //		 (pBAEntry->list.qlen > ((pBAEntry->BAWinSize*7)/8))) //||
 //		(RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(10*REORDERING_PACKET_TIMEOUT))) &&
 //		 (pBAEntry->list.qlen > (pBAEntry->BAWinSize/8)))
-	if (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(MAX_REORDERING_PACKET_TIMEOUT/6))) 
+	if (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer+(MAX_REORDERING_PACKET_TIMEOUT/6)))
 		 &&(pBAEntry->list.qlen > 1)
 		)
 	{
-		DBGPRINT(RT_DEBUG_TRACE,("timeout[%d] (%08lx-%08lx = %d > %d): %x, flush all!\n ", pBAEntry->list.qlen, Now32, (pBAEntry->LastIndSeqAtTimer), 
+		DBGPRINT(RT_DEBUG_TRACE,("timeout[%d] (%08lx-%08lx = %d > %d): %x, flush all!\n ", pBAEntry->list.qlen, Now32, (pBAEntry->LastIndSeqAtTimer),
 			   (int)((long) Now32 - (long)(pBAEntry->LastIndSeqAtTimer)), MAX_REORDERING_PACKET_TIMEOUT,
 			   pBAEntry->LastIndSeq));
 		ba_refresh_reordering_mpdus(pAd, pBAEntry);
@@ -449,19 +449,19 @@ void ba_flush_reordering_timeout_mpdus(
 		&& (pBAEntry->list.qlen > 0)
 	   )
 		{
-//		printk("timeout[%d] (%lx-%lx = %d > %d): %x, ", pBAEntry->list.qlen, Now32, (pBAEntry->LastIndSeqAtTimer), 
+//		printk("timeout[%d] (%lx-%lx = %d > %d): %x, ", pBAEntry->list.qlen, Now32, (pBAEntry->LastIndSeqAtTimer),
 //			   (int)((long) Now32 - (long)(pBAEntry->LastIndSeqAtTimer)), REORDERING_PACKET_TIMEOUT,
 //			   pBAEntry->LastIndSeq);
     		//
 		// force LastIndSeq to shift to LastIndSeq+1
-    		// 
+    		//
     		Sequence = (pBAEntry->LastIndSeq+1) & MAXSEQ;
     		ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, Sequence);
     		pBAEntry->LastIndSeqAtTimer = Now32;
 			pBAEntry->LastIndSeq = Sequence;
     		//
     		// indicate in-order mpdus
-    		// 
+    		//
     		Sequence = ba_indicate_reordering_mpdus_in_order(pAd, pBAEntry, Sequence);
     		if (Sequence != RESET_RCV_SEQ)
     		{
@@ -477,7 +477,7 @@ void ba_flush_reordering_timeout_mpdus(
 			  (pBAEntry->list.qlen > 1))
 			)
 		{
-		DBGPRINT(RT_DEBUG_TRACE,("timeout[%d] (%lx-%lx = %d > %d): %x\n ", pBAEntry->list.qlen, Now32, (pBAEntry->LastIndSeqAtTimer), 
+		DBGPRINT(RT_DEBUG_TRACE,("timeout[%d] (%lx-%lx = %d > %d): %x\n ", pBAEntry->list.qlen, Now32, (pBAEntry->LastIndSeqAtTimer),
 			   (int)((long) Now32 - (long)(pBAEntry->LastIndSeqAtTimer)), MAX_REORDERING_PACKET_TIMEOUT,
 			   pBAEntry->LastIndSeq));
 		ba_refresh_reordering_mpdus(pAd, pBAEntry);
@@ -487,12 +487,12 @@ void ba_flush_reordering_timeout_mpdus(
 }
 
 
-/* 
- * generate ADDBA request to 
+/*
+ * generate ADDBA request to
  * set up BA agreement
  */
 VOID BAOriSessionSetUp(
-					  IN PRTMP_ADAPTER    pAd, 
+					  IN PRTMP_ADAPTER    pAd,
 					  IN MAC_TABLE_ENTRY  *pEntry,
 					  IN UCHAR            TID,
 					  IN USHORT           TimeOut,
@@ -504,28 +504,28 @@ VOID BAOriSessionSetUp(
 	BA_ORI_ENTRY            *pBAEntry = NULL;
 	USHORT                  Idx;
 	BOOLEAN                 Cancelled;
-	
+
 	if ((pAd->CommonCfg.BACapability.field.AutoBA != TRUE)  &&  (isForced == FALSE))
 		return;
 
-	// if this entry is limited to use legacy tx mode, it doesn't generate BA.  
+	// if this entry is limited to use legacy tx mode, it doesn't generate BA.
 	if (RTMPStaFixedTxMode(pAd, pEntry) != FIXED_TXMODE_HT)
 		return;
 
 	if ((pEntry->BADeclineBitmap & (1<<TID)) && (isForced == FALSE))
 	{
 		// try again after 3 secs
-		DelayTime = 3000; 
+		DelayTime = 3000;
 //		printk("DeCline BA from Peer\n");
 //		return;
 	}
 
-	
-	Idx = pEntry->BAOriWcidArray[TID];  
+
+	Idx = pEntry->BAOriWcidArray[TID];
 	if (Idx == 0)
 	{
 		// allocate a BA session
-		pBAEntry = BATableAllocOriEntry(pAd, &Idx);     
+		pBAEntry = BATableAllocOriEntry(pAd, &Idx);
 		if (pBAEntry == NULL)
 		{
 			DBGPRINT(RT_DEBUG_TRACE,("ADDBA - MlmeADDBAAction() allocate BA session failed \n"));
@@ -544,16 +544,16 @@ VOID BAOriSessionSetUp(
 
 	pEntry->BAOriWcidArray[TID] = Idx;
 
-	// Initialize BA session 
-	pBAEntry->ORI_BA_Status = Originator_WaitRes;       
+	// Initialize BA session
+	pBAEntry->ORI_BA_Status = Originator_WaitRes;
 	pBAEntry->Wcid = pEntry->Aid;
-	pBAEntry->BAWinSize = pAd->CommonCfg.BACapability.field.RxBAWinLimit;   
+	pBAEntry->BAWinSize = pAd->CommonCfg.BACapability.field.RxBAWinLimit;
 	pBAEntry->Sequence = BA_ORI_INIT_SEQ;
 	pBAEntry->Token = 1;	// (2008-01-21) Jan Lee recommends it - this token can't be 0
 	pBAEntry->TID = TID;
-	pBAEntry->TimeOutValue = TimeOut;   
+	pBAEntry->TimeOutValue = TimeOut;
 	pBAEntry->pAdapter = pAd;
-	
+
 	if (!(pEntry->TXBAbitmap & (1<<TID)))
 	{
 		RTMPInitTimer(pAd, &pBAEntry->ORIBATimer, GET_TIMER_FUNCTION(BAOriSessionSetupTimeout), pBAEntry, FALSE);
@@ -561,12 +561,12 @@ VOID BAOriSessionSetUp(
 	else
 		RTMPCancelTimer(&pBAEntry->ORIBATimer, &Cancelled);
 
-	// set timer to send ADDBA request 
+	// set timer to send ADDBA request
 	RTMPSetTimer(&pBAEntry->ORIBATimer, DelayTime);
 }
 
 VOID BAOriSessionAdd(
-			IN PRTMP_ADAPTER    pAd, 
+			IN PRTMP_ADAPTER    pAd,
 					IN MAC_TABLE_ENTRY  *pEntry,
 			IN PFRAME_ADDBA_RSP pFrame)
 {
@@ -580,7 +580,7 @@ VOID BAOriSessionAdd(
 	FRAME_BAR       FrameBar;
 
 	TID = pFrame->BaParm.TID;
-	Idx = pEntry->BAOriWcidArray[TID];  
+	Idx = pEntry->BAOriWcidArray[TID];
 	pBAEntry =&pAd->BATable.BAOriEntry[Idx];
 
 	// Start fill in parameters.
@@ -591,7 +591,7 @@ VOID BAOriSessionAdd(
 
 		pBAEntry->TimeOutValue = pFrame->TimeOutValue;
 		pBAEntry->ORI_BA_Status = Originator_Done;
-		// reset sequence number 
+		// reset sequence number
 		pBAEntry->Sequence = BA_ORI_INIT_SEQ;
 		// Set Bitmap flag.
 		pEntry->TXBAbitmap |= (1<<TID);
@@ -599,7 +599,7 @@ VOID BAOriSessionAdd(
 
 		pBAEntry->ORIBATimer.TimerValue = 0;	//pFrame->TimeOutValue;
 
-		DBGPRINT(RT_DEBUG_TRACE,("%s : TXBAbitmap = %x, BAWinSize = %d, TimeOut = %ld\n", __FUNCTION__, pEntry->TXBAbitmap, 
+		DBGPRINT(RT_DEBUG_TRACE,("%s : TXBAbitmap = %x, BAWinSize = %d, TimeOut = %ld\n", __FUNCTION__, pEntry->TXBAbitmap,
 								 pBAEntry->BAWinSize, pBAEntry->ORIBATimer.TimerValue));
 
 		// SEND BAR ;
@@ -627,12 +627,12 @@ VOID BAOriSessionAdd(
 
 
 		if (pBAEntry->ORIBATimer.TimerValue)
-			RTMPSetTimer(&pBAEntry->ORIBATimer, pBAEntry->ORIBATimer.TimerValue); // in mSec 
+			RTMPSetTimer(&pBAEntry->ORIBATimer, pBAEntry->ORIBATimer.TimerValue); // in mSec
 	}
 }
 
 BOOLEAN BARecSessionAdd(
-					   IN PRTMP_ADAPTER    pAd, 
+					   IN PRTMP_ADAPTER    pAd,
 					   IN MAC_TABLE_ENTRY  *pEntry,
 					   IN PFRAME_ADDBA_REQ pFrame)
 {
@@ -664,7 +664,7 @@ BOOLEAN BARecSessionAdd(
 
 	if (Idx == 0)
 	{
-		pBAEntry = BATableAllocRecEntry(pAd, &Idx);     
+		pBAEntry = BATableAllocRecEntry(pAd, &Idx);
 	}
 	else
 	{
@@ -673,7 +673,7 @@ BOOLEAN BARecSessionAdd(
 		ba_refresh_reordering_mpdus(pAd, pBAEntry);
 	}
 
-	DBGPRINT(RT_DEBUG_TRACE,("%s(%ld): Idx = %d, BAWinSize(req %d) = %d\n", __FUNCTION__, pAd->BATable.numAsRecipient, Idx, 
+	DBGPRINT(RT_DEBUG_TRACE,("%s(%ld): Idx = %d, BAWinSize(req %d) = %d\n", __FUNCTION__, pAd->BATable.numAsRecipient, Idx,
 							 pFrame->BaParm.BufSize, BAWinSize));
 
 	// Start fill in parameters.
@@ -687,7 +687,7 @@ BOOLEAN BARecSessionAdd(
 		pBAEntry->TID = TID;
 		pBAEntry->TimeOutValue = pFrame->TimeOutValue;
 		pBAEntry->REC_BA_Status = Recipient_Accept;
-		// initial sequence number 
+		// initial sequence number
 		pBAEntry->LastIndSeq = RESET_RCV_SEQ; //pFrame->BaStartSeq.field.StartSeq;
 
 		printk("Start Seq = %08x\n",  pFrame->BaStartSeq.field.StartSeq);
@@ -701,9 +701,9 @@ BOOLEAN BARecSessionAdd(
 			RTMPInitTimer(pAd, &pBAEntry->RECBATimer, GET_TIMER_FUNCTION(BARecSessionIdleTimeout), pBAEntry, TRUE);
 		}
 
-#if 0	// for debugging 
+#if 0	// for debugging
 		RTMPSetTimer(&pBAEntry->RECBATimer, REC_BA_SESSION_IDLE_TIMEOUT);
-#endif 
+#endif
 
 		// Set Bitmap flag.
 		pEntry->RXBAbitmap |= (1<<TID);
@@ -714,13 +714,13 @@ BOOLEAN BARecSessionAdd(
 		// Set BA session mask in WCID table.
 		RT28XX_ADD_BA_SESSION_TO_ASIC(pAd, pEntry->Aid, TID);
 
-		DBGPRINT(RT_DEBUG_TRACE,("MACEntry[%d]RXBAbitmap = 0x%x. BARecWcidArray=%d\n", 
+		DBGPRINT(RT_DEBUG_TRACE,("MACEntry[%d]RXBAbitmap = 0x%x. BARecWcidArray=%d\n",
 				pEntry->Aid, pEntry->RXBAbitmap, pEntry->BARecWcidArray[TID]));
 	}
 	else
 	{
 		Status = FALSE;
-		DBGPRINT(RT_DEBUG_TRACE,("Can't Accept ADDBA for %02x:%02x:%02x:%02x:%02x:%02x TID = %d\n", 
+		DBGPRINT(RT_DEBUG_TRACE,("Can't Accept ADDBA for %02x:%02x:%02x:%02x:%02x:%02x TID = %d\n",
 				PRINT_MAC(pEntry->Addr), TID));
 	}
 	return(Status);
@@ -750,7 +750,7 @@ BA_REC_ENTRY *BATableAllocRecEntry(
 		pBAEntry =&pAd->BATable.BARecEntry[i];
 		if ((pBAEntry->REC_BA_Status == Recipient_NONE))
 		{
-			// get one 
+			// get one
 			pAd->BATable.numAsRecipient++;
 			pBAEntry->REC_BA_Status = Recipient_USED;
 			*Idx = i;
@@ -776,14 +776,14 @@ BA_ORI_ENTRY *BATableAllocOriEntry(
 	{
 		goto done;
 	}
-		
+
 	// reserve idx 0 to identify BAWcidArray[TID] as empty
 	for (i=1; i<MAX_LEN_OF_BA_ORI_TABLE; i++)
 	{
 		pBAEntry =&pAd->BATable.BAOriEntry[i];
 		if ((pBAEntry->ORI_BA_Status == Originator_NONE))
 		{
-			// get one 
+			// get one
 			pAd->BATable.numAsOriginator++;
 			pBAEntry->ORI_BA_Status = Originator_USED;
 			pBAEntry->pAdapter = pAd;
@@ -824,11 +824,11 @@ VOID BATableFreeOriEntry(
 			DBGPRINT(RT_DEBUG_TRACE, ("BATableFreeOriEntry numAsOriginator= %ld\n", pAd->BATable.numAsRecipient));
 			// Erase Bitmap flag.
 		}
-	
+
 		ASSERT(pAd->BATable.numAsOriginator != 0);
 
 		pAd->BATable.numAsOriginator -= 1;
-		
+
 		pBAEntry->ORI_BA_Status = Originator_NONE;
 		pBAEntry->Token = 0;
 		NdisReleaseSpinLock(&pAd->BATabLock);
@@ -855,7 +855,7 @@ VOID BATableFreeRecEntry(
 		pEntry->BARecWcidArray[pBAEntry->TID] = 0;
 
 		NdisAcquireSpinLock(&pAd->BATabLock);
-		
+
 		ASSERT(pAd->BATable.numAsRecipient != 0);
 
 		pAd->BATable.numAsRecipient -= 1;
@@ -867,7 +867,7 @@ VOID BATableFreeRecEntry(
 
 
 VOID BAOriSessionTearDown(
-						 IN OUT  PRTMP_ADAPTER   pAd, 
+						 IN OUT  PRTMP_ADAPTER   pAd,
 						 IN      UCHAR           Wcid,
 						 IN      UCHAR           TID,
 						 IN      BOOLEAN         bPassive,
@@ -891,25 +891,25 @@ VOID BAOriSessionTearDown(
 		if (bForceSend == TRUE)
 		{
 			// force send specified TID DelBA
-			MLME_DELBA_REQ_STRUCT   DelbaReq;   
+			MLME_DELBA_REQ_STRUCT   DelbaReq;
 			MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
 
 			NdisZeroMemory(&DelbaReq, sizeof(DelbaReq));
 			NdisZeroMemory(Elem, sizeof(MLME_QUEUE_ELEM));
-			
+
 			COPY_MAC_ADDR(DelbaReq.Addr, pAd->MacTab.Content[Wcid].Addr);
 			DelbaReq.Wcid = Wcid;
 			DelbaReq.TID = TID;
 			DelbaReq.Initiator = ORIGINATOR;
-#if 1		
-			Elem->MsgLen  = sizeof(DelbaReq);			
+#if 1
+			Elem->MsgLen  = sizeof(DelbaReq);
 			NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
 			MlmeDELBAAction(pAd, Elem);
 			kfree(Elem);
-#else				
+#else
 			MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ORI_DELBA_CATE, sizeof(MLME_DELBA_REQ_STRUCT), (PVOID)&DelbaReq);
 			RT28XX_MLME_HANDLER(pAd);
-#endif			
+#endif
 		}
 
 		return;
@@ -924,22 +924,22 @@ VOID BAOriSessionTearDown(
 	//
 	if ((bPassive == FALSE) && (TID == pBAEntry->TID) && (pBAEntry->ORI_BA_Status == Originator_Done))
 	{
-		MLME_DELBA_REQ_STRUCT   DelbaReq;   
+		MLME_DELBA_REQ_STRUCT   DelbaReq;
 		MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
 
 		NdisZeroMemory(&DelbaReq, sizeof(DelbaReq));
 		NdisZeroMemory(Elem, sizeof(MLME_QUEUE_ELEM));
-		
+
 		COPY_MAC_ADDR(DelbaReq.Addr, pAd->MacTab.Content[Wcid].Addr);
 		DelbaReq.Wcid = Wcid;
 		DelbaReq.TID = pBAEntry->TID;
 		DelbaReq.Initiator = ORIGINATOR;
-#if 1		
-		Elem->MsgLen  = sizeof(DelbaReq);			
+#if 1
+		Elem->MsgLen  = sizeof(DelbaReq);
 		NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
 		MlmeDELBAAction(pAd, Elem);
 		kfree(Elem);
-#else		
+#else
 		MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ORI_DELBA_CATE, sizeof(MLME_DELBA_REQ_STRUCT), (PVOID)&DelbaReq);
 		RT28XX_MLME_HANDLER(pAd);
 #endif
@@ -954,7 +954,7 @@ VOID BAOriSessionTearDown(
 }
 
 VOID BARecSessionTearDown(
-						 IN OUT  PRTMP_ADAPTER   pAd, 
+						 IN OUT  PRTMP_ADAPTER   pAd,
 						 IN      UCHAR           Wcid,
 						 IN      UCHAR           TID,
 						 IN      BOOLEAN         bPassive)
@@ -975,7 +975,7 @@ VOID BARecSessionTearDown(
 		return;
 
 	DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __FUNCTION__, Wcid, TID));
-	
+
 
 	pBAEntry = &pAd->BATable.BARecEntry[Idx];
 	DBGPRINT(RT_DEBUG_TRACE,("\t===>Idx = %ld, Wcid=%d.TID=%d, REC_BA_Status = %d \n", Idx, Wcid, TID, pBAEntry->REC_BA_Status));
@@ -987,10 +987,10 @@ VOID BARecSessionTearDown(
 		MLME_DELBA_REQ_STRUCT   DelbaReq;
 		BOOLEAN 				Cancelled;
 		MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-		//ULONG   offset; 
+		//ULONG   offset;
 		//UINT32  VALUE;
-				
-		RTMPCancelTimer(&pBAEntry->RECBATimer, &Cancelled);         
+
+		RTMPCancelTimer(&pBAEntry->RECBATimer, &Cancelled);
 
 		//
 		// 1. Send DELBA Action Frame
@@ -999,27 +999,27 @@ VOID BARecSessionTearDown(
 		{
 			NdisZeroMemory(&DelbaReq, sizeof(DelbaReq));
 			NdisZeroMemory(Elem, sizeof(MLME_QUEUE_ELEM));
-			
+
 			COPY_MAC_ADDR(DelbaReq.Addr, pAd->MacTab.Content[Wcid].Addr);
 			DelbaReq.Wcid = Wcid;
 			DelbaReq.TID = TID;
 			DelbaReq.Initiator = RECIPIENT;
 #if 1
-			Elem->MsgLen  = sizeof(DelbaReq);			
+			Elem->MsgLen  = sizeof(DelbaReq);
 			NdisMoveMemory(Elem->Msg, &DelbaReq, sizeof(DelbaReq));
 			MlmeDELBAAction(pAd, Elem);
 			kfree(Elem);
 #else
 			MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ORI_DELBA_CATE, sizeof(MLME_DELBA_REQ_STRUCT), (PVOID)&DelbaReq);
 			RT28XX_MLME_HANDLER(pAd);
-#endif 
+#endif
 		}
 
 
 		//
 		// 2. Free resource of BA session
 		//
-		// flush all pending reordering mpdus 
+		// flush all pending reordering mpdus
 		ba_refresh_reordering_mpdus(pAd, pBAEntry);
 
 		NdisAcquireSpinLock(&pAd->BATabLock);
@@ -1041,7 +1041,7 @@ VOID BARecSessionTearDown(
 }
 
 VOID BASessionTearDownALL(
-						 IN OUT  PRTMP_ADAPTER pAd, 
+						 IN OUT  PRTMP_ADAPTER pAd,
 						 IN      UCHAR Wcid)
 {
 	int i;
@@ -1058,26 +1058,26 @@ VOID BASessionTearDownALL(
 	==========================================================================
 	Description:
 		Retry sending ADDBA Reqest.
-		
+
 	IRQL = DISPATCH_LEVEL
-	
+
 	Parametrs:
 	p8023Header: if this is already 802.3 format, p8023Header is NULL
-	
+
 	Return	: TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
 				FALSE , then continue indicaterx at this moment.
 	==========================================================================
  */
 VOID BAOriSessionSetupTimeout(
-    IN PVOID SystemSpecific1, 
-    IN PVOID FunctionContext, 
-    IN PVOID SystemSpecific2, 
-    IN PVOID SystemSpecific3) 
+    IN PVOID SystemSpecific1,
+    IN PVOID FunctionContext,
+    IN PVOID SystemSpecific2,
+    IN PVOID SystemSpecific3)
 {
 	BA_ORI_ENTRY    *pBAEntry = (BA_ORI_ENTRY *)FunctionContext;
 	MAC_TABLE_ENTRY *pEntry;
 	PRTMP_ADAPTER   pAd;
-	
+
 	if (pBAEntry == NULL)
 		return;
 
@@ -1091,9 +1091,9 @@ VOID BAOriSessionSetupTimeout(
 			return;
 	}
 #endif // CONFIG_STA_SUPPORT //
-    
+
 #ifdef RALINK_ATE
-	// Nothing to do in ATE mode. 
+	// Nothing to do in ATE mode.
 	if (ATE_ON(pAd))
 		return;
 #endif // RALINK_ATE //
@@ -1102,15 +1102,15 @@ VOID BAOriSessionSetupTimeout(
 
 	if ((pBAEntry->ORI_BA_Status == Originator_WaitRes) && (pBAEntry->Token < ORI_SESSION_MAX_RETRY))
 	{
-		MLME_ADDBA_REQ_STRUCT    AddbaReq;  
-	
+		MLME_ADDBA_REQ_STRUCT    AddbaReq;
+
 		NdisZeroMemory(&AddbaReq, sizeof(AddbaReq));
 		COPY_MAC_ADDR(AddbaReq.pAddr, pEntry->Addr);
 		AddbaReq.Wcid = (UCHAR)(pEntry->Aid);
 		AddbaReq.TID = pBAEntry->TID;
 		AddbaReq.BaBufSize = pAd->CommonCfg.BACapability.field.RxBAWinLimit;
 		AddbaReq.TimeOutValue = 0;
-		AddbaReq.Token = pBAEntry->Token;       
+		AddbaReq.Token = pBAEntry->Token;
 		MlmeEnqueue(pAd, ACTION_STATE_MACHINE, MT2_MLME_ADD_BA_CATE, sizeof(MLME_ADDBA_REQ_STRUCT), (PVOID)&AddbaReq);
 		RT28XX_MLME_HANDLER(pAd);
 		DBGPRINT(RT_DEBUG_TRACE,("BA Ori Session Timeout(%d) : Send ADD BA again\n", pBAEntry->Token));
@@ -1128,27 +1128,27 @@ VOID BAOriSessionSetupTimeout(
 	==========================================================================
 	Description:
 		Retry sending ADDBA Reqest.
-		
+
 	IRQL = DISPATCH_LEVEL
-	
+
 	Parametrs:
 	p8023Header: if this is already 802.3 format, p8023Header is NULL
-	
+
 	Return	: TRUE if put into rx reordering buffer, shouldn't indicaterxhere.
 				FALSE , then continue indicaterx at this moment.
 	==========================================================================
  */
 VOID BARecSessionIdleTimeout(
-    IN PVOID SystemSpecific1, 
-    IN PVOID FunctionContext, 
-    IN PVOID SystemSpecific2, 
-    IN PVOID SystemSpecific3) 
+    IN PVOID SystemSpecific1,
+    IN PVOID FunctionContext,
+    IN PVOID SystemSpecific2,
+    IN PVOID SystemSpecific3)
 {
-	
+
 	BA_REC_ENTRY    *pBAEntry = (BA_REC_ENTRY *)FunctionContext;
 	PRTMP_ADAPTER   pAd;
 	ULONG           Now32;
-	
+
 	if (pBAEntry == NULL)
 		return;
 
@@ -1159,8 +1159,8 @@ VOID BARecSessionIdleTimeout(
 		if (RTMP_TIME_AFTER((unsigned long)Now32, (unsigned long)(pBAEntry->LastIndSeqAtTimer + REC_BA_SESSION_IDLE_TIMEOUT)))
 		{
 			pAd = pBAEntry->pAdapter;
-			// flush all pending reordering mpdus 
-			ba_refresh_reordering_mpdus(pAd, pBAEntry); 
+			// flush all pending reordering mpdus
+			ba_refresh_reordering_mpdus(pAd, pBAEntry);
 			printk("%ld: REC BA session Timeout\n", Now32);
 		}
 	}
@@ -1168,8 +1168,8 @@ VOID BARecSessionIdleTimeout(
 
 
 VOID PeerAddBAReqAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 
 {
 	//	7.4.4.1
@@ -1192,7 +1192,7 @@ VOID PeerAddBAReqAction(
 	//ADDBA Request from unknown peer, ignore this.
 	if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
 		return;
-	
+
 	pMacEntry = &pAd->MacTab.Content[Elem->Wcid];
 	DBGPRINT(RT_DEBUG_TRACE,("BA - PeerAddBAReqAction----> \n"));
 	ptemp = (PULONG)Elem->Msg;
@@ -1220,7 +1220,7 @@ VOID PeerAddBAReqAction(
 		ASSERT(pAd->MacTab.Content[Elem->Wcid].Sst == SST_ASSOC);
 
 	pAddreqFrame = (PFRAME_ADDBA_REQ)(&Elem->Msg[0]);
-	// 2. Always send back ADDBA Response 
+	// 2. Always send back ADDBA Response
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);	 //Get an unused nonpaged memory
 	if (NStatus != NDIS_STATUS_SUCCESS)
 	{
@@ -1255,7 +1255,7 @@ VOID PeerAddBAReqAction(
 	ADDframe.BaParm.BufSize = min(((UCHAR)pAddreqFrame->BaParm.BufSize), (UCHAR)pAd->CommonCfg.BACapability.field.RxBAWinLimit);
 	if (ADDframe.BaParm.BufSize == 0)
 	{
-		ADDframe.BaParm.BufSize = 64; 
+		ADDframe.BaParm.BufSize = 64;
 	}
 	ADDframe.TimeOutValue = 0; //pAddreqFrame->TimeOutValue;
 
@@ -1269,27 +1269,27 @@ VOID PeerAddBAReqAction(
 	MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
 	MlmeFreeMemory(pAd, pOutBuffer);
 
-	DBGPRINT(RT_DEBUG_TRACE, ("%s(%d): TID(%d), BufSize(%d) <== \n", __FUNCTION__, Elem->Wcid, ADDframe.BaParm.TID, 
+	DBGPRINT(RT_DEBUG_TRACE, ("%s(%d): TID(%d), BufSize(%d) <== \n", __FUNCTION__, Elem->Wcid, ADDframe.BaParm.TID,
 							  ADDframe.BaParm.BufSize));
 }
 
 
 VOID PeerAddBARspAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 
 {
 	//UCHAR		Idx, i;
 	//PUCHAR		   pOutBuffer = NULL;
 	PFRAME_ADDBA_RSP    pFrame = NULL;
 	//PBA_ORI_ENTRY		pBAEntry;
-	
+
 	//ADDBA Response from unknown peer, ignore this.
 	if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
 		return;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("%s ==> Wcid(%d)\n", __FUNCTION__, Elem->Wcid));
-	
+
 	//hex_dump("PeerAddBARspAction()", Elem->Msg, Elem->MsgLen);
 
 	if (PeerAddBARspActionSanity(pAd, Elem->Msg, Elem->MsgLen))
@@ -1300,20 +1300,20 @@ VOID PeerAddBARspAction(
 		switch (pFrame->StatusCode)
 		{
 			case 0:
-				// I want a BAsession with this peer as an originator. 
+				// I want a BAsession with this peer as an originator.
 				BAOriSessionAdd(pAd, &pAd->MacTab.Content[Elem->Wcid], pFrame);
 				break;
 			default:
-				// check status == USED ??? 
+				// check status == USED ???
 				BAOriSessionTearDown(pAd, Elem->Wcid, pFrame->BaParm.TID, TRUE, FALSE);
 				break;
 		}
 		// Rcv Decline StatusCode
-		if ((pFrame->StatusCode == 37) 
-#ifdef CONFIG_STA_SUPPORT            
+		if ((pFrame->StatusCode == 37)
+#ifdef CONFIG_STA_SUPPORT
             || ((pAd->OpMode == OPMODE_STA) && STA_TGN_WIFI_ON(pAd) && (pFrame->StatusCode != 0))
-#endif // CONFIG_STA_SUPPORT //            
-            ) 
+#endif // CONFIG_STA_SUPPORT //
+            )
 		{
 			pAd->MacTab.Content[Elem->Wcid].BADeclineBitmap |= 1<<pFrame->BaParm.TID;
 		}
@@ -1321,14 +1321,14 @@ VOID PeerAddBARspAction(
 }
 
 VOID PeerDelBAAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 
 {
 	//UCHAR				Idx;
 	//PUCHAR				pOutBuffer = NULL;
 	PFRAME_DELBA_REQ    pDelFrame = NULL;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE,("%s ==>\n", __FUNCTION__));
 	//DELBA Request from unknown peer, ignore this.
 	if (PeerDelBAActionSanity(pAd, Elem->Wcid, Elem->Msg, Elem->MsgLen))
@@ -1350,10 +1350,10 @@ VOID PeerDelBAAction(
 
 
 BOOLEAN CntlEnqueueForRecv(
-						  IN PRTMP_ADAPTER		pAd, 
-						  IN ULONG				Wcid, 
-						  IN ULONG				MsgLen, 
-						  IN PFRAME_BA_REQ		pMsg) 
+						  IN PRTMP_ADAPTER		pAd,
+						  IN ULONG				Wcid,
+						  IN ULONG				MsgLen,
+						  IN PFRAME_BA_REQ		pMsg)
 {
 	PFRAME_BA_REQ   pFrame = pMsg;
 	//PRTMP_REORDERBUF	pBuffer;
@@ -1363,7 +1363,7 @@ BOOLEAN CntlEnqueueForRecv(
 	ULONG   Idx;
 	//UCHAR	NumRxPkt;
 	UCHAR	TID;//, i;
-	
+
 	TID = (UCHAR)pFrame->BARControl.TID;
 
 	DBGPRINT(RT_DEBUG_TRACE, ("%s(): BAR-Wcid(%ld), Tid (%d)\n", __FUNCTION__, Wcid, TID));
@@ -1389,7 +1389,7 @@ BOOLEAN CntlEnqueueForRecv(
 		DBGPRINT_ERR(("CntlEnqueueForRecv: BlockAck Request frame length size = %ld incorrect\n", MsgLen));
 		return FALSE;
 	}
-		
+
 	if ((Wcid < MAX_LEN_OF_MAC_TABLE) && (TID < 8))
 		{
 		// if this receiving packet is from SA that is in our OriEntry. Since WCID <9 has direct mapping. no need search.
@@ -1419,7 +1419,7 @@ Description : Send PSMP Action frame If PSMP mode switches.
 VOID SendPSMPAction(
 				   IN PRTMP_ADAPTER		pAd,
 				   IN UCHAR				Wcid,
-				   IN UCHAR				Psmp) 
+				   IN UCHAR				Psmp)
 {
 	PUCHAR          pOutBuffer = NULL;
 	NDIS_STATUS     NStatus;
@@ -1489,7 +1489,7 @@ typedef struct PACKED
 
 
 void convert_reordering_packet_to_preAMSDU_or_802_3_packet(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	RX_BLK			*pRxBlk,
 	IN  UCHAR			FromWhichBSSID)
 {
@@ -1497,8 +1497,8 @@ void convert_reordering_packet_to_preAMSDU_or_802_3_packet(
 	UCHAR			Header802_3[LENGTH_802_3];
 
 	// 1. get 802.3 Header
-	// 2. remove LLC 
-	// 		a. pointer pRxBlk->pData to payload 
+	// 2. remove LLC
+	// 		a. pointer pRxBlk->pData to payload
 	//      b. modify pRxBlk->DataSize
 
 #ifdef CONFIG_STA_SUPPORT
@@ -1509,14 +1509,14 @@ void convert_reordering_packet_to_preAMSDU_or_802_3_packet(
 	ASSERT(pRxBlk->pRxPacket);
 	pRxPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
 
-	RTPKT_TO_OSPKT(pRxPkt)->dev = get_netdev_from_bssid(pAd, FromWhichBSSID); 
+	RTPKT_TO_OSPKT(pRxPkt)->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
 	RTPKT_TO_OSPKT(pRxPkt)->data = pRxBlk->pData;
 	RTPKT_TO_OSPKT(pRxPkt)->len = pRxBlk->DataSize;
 	RTPKT_TO_OSPKT(pRxPkt)->tail = RTPKT_TO_OSPKT(pRxPkt)->data + RTPKT_TO_OSPKT(pRxPkt)->len;
 
 	//
 	// copy 802.3 header, if necessary
-	// 
+	//
 	if (!RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU))
 	{
 
@@ -1528,7 +1528,7 @@ void convert_reordering_packet_to_preAMSDU_or_802_3_packet(
 #endif
 #ifdef UCOS
 			NdisMoveMemory(net_pkt_push(pRxPkt, LENGTH_802_3), Header802_3, LENGTH_802_3);
-#endif 
+#endif
 		}
 #endif // CONFIG_STA_SUPPORT //
 	}
@@ -1578,9 +1578,9 @@ static VOID ba_enqueue_reordering_packet(
 		STATS_INC_RX_PACKETS(pAd, FromWhichBSSID);
 
         //
-		// it is necessary for reordering packet to record 
+		// it is necessary for reordering packet to record
 		// which BSS it come from
-		// 
+		//
 		RTMP_SET_PACKET_IF(pRxBlk->pRxPacket, FromWhichBSSID);
 
 		mpdu_blk->pPacket = pRxBlk->pRxPacket;
@@ -1588,8 +1588,8 @@ static VOID ba_enqueue_reordering_packet(
 		if (ba_reordering_mpdu_insertsorted(&pBAEntry->list, mpdu_blk) == FALSE)
 		{
 			// had been already within reordering list
-			// don't indicate 
-			RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_SUCCESS);                     
+			// don't indicate
+			RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_SUCCESS);
 			ba_mpdu_blk_free(pAd, mpdu_blk);
 		}
 
@@ -1605,8 +1605,8 @@ static VOID ba_enqueue_reordering_packet(
 		DBGPRINT(RT_DEBUG_ERROR,  ("!!! (%d) Can't allocate reordering mpdu blk\n",
 								   pBAEntry->list.qlen));
 #endif
-		/* 
-		 * flush all pending reordering mpdus 
+		/*
+		 * flush all pending reordering mpdus
 		 * and receving mpdu to upper layer
 		 * make tcp/ip to take care reordering mechanism
 		 */
@@ -1622,17 +1622,17 @@ static VOID ba_enqueue_reordering_packet(
 /*
 	==========================================================================
 	Description:
-		Indicate this packet to upper layer or put it into reordering buffer	
-	
+		Indicate this packet to upper layer or put it into reordering buffer
+
 	Parametrs:
 		pRxBlk         : carry necessary packet info 802.11 format
 		FromWhichBSSID : the packet received from which BSS
 
-	Return	: 
+	Return	:
 			  none
 
 	Note    :
-	          the packet queued into reordering buffer need to cover to 802.3 format 
+	          the packet queued into reordering buffer need to cover to 802.3 format
 			  or pre_AMSDU format
 	==========================================================================
  */
@@ -1671,7 +1671,7 @@ VOID Indicate_AMPDU_Packet(
 
 #if 0 // test
 	/* Rec BA Session had been torn down */
-	INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID); 
+	INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
 	return;
 #endif
 
@@ -1681,7 +1681,7 @@ VOID Indicate_AMPDU_Packet(
 		if (Idx == 0)
 		{
 			/* Rec BA Session had been torn down */
-			INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID); 
+			INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
 			return;
 		}
 		pBAEntry = &pAd->BATable.BARecEntry[Idx];
@@ -1708,12 +1708,12 @@ VOID Indicate_AMPDU_Packet(
 
 	//
 	// Reset Last Indicate Sequence
-	// 
+	//
 	if (pBAEntry->LastIndSeq == RESET_RCV_SEQ)
 	{
 		ASSERT((pBAEntry->list.qlen == 0) && (pBAEntry->list.next == NULL));
 
-		// reset rcv sequence of BA session 
+		// reset rcv sequence of BA session
 		pBAEntry->LastIndSeq = Sequence;
 		pBAEntry->LastIndSeqAtTimer = Now32;
 		INDICATE_LEGACY_OR_AMSDU(pAd, pRxBlk, FromWhichBSSID);
@@ -1723,7 +1723,7 @@ VOID Indicate_AMPDU_Packet(
 
 	//
 	// I. Check if in order.
-	// 
+	//
 	if (SEQ_STEPONE(Sequence, pBAEntry->LastIndSeq, MAXSEQ))
 	{
 		USHORT  LastIndSeq;
@@ -1739,34 +1739,34 @@ VOID Indicate_AMPDU_Packet(
 	}
 	//
 	// II. Drop Duplicated Packet
-	// 
+	//
 	else if (Sequence == pBAEntry->LastIndSeq)
 	{
-		
+
 		// drop and release packet
 		pBAEntry->nDropPacket++;
 		RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
 	}
 	//
 	// III. Drop Old Received Packet
-	// 
+	//
 	else if (SEQ_SMALLER(Sequence, pBAEntry->LastIndSeq, MAXSEQ))
 	{
-		
+
 		// drop and release packet
 		pBAEntry->nDropPacket++;
 		RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
 	}
 	//
 	// IV. Receive Sequence within Window Size
-	// 
+	//
 	else if (SEQ_SMALLER(Sequence, (((pBAEntry->LastIndSeq+pBAEntry->BAWinSize+1)) & MAXSEQ), MAXSEQ))
 	{
 		ba_enqueue_reordering_packet(pAd, pBAEntry, pRxBlk, FromWhichBSSID);
 	}
 	//
 	// V. Receive seq surpasses Win(lastseq + nMSDU). So refresh all reorder buffer
-	// 
+	//
 	else
 	{
 #if 0
@@ -1775,7 +1775,7 @@ VOID Indicate_AMPDU_Packet(
 #else
 		LONG WinStartSeq, TmpSeq;
 
-		
+
 		TmpSeq = Sequence - (pBAEntry->BAWinSize) -1;
 		if (TmpSeq < 0)
 		{
@@ -1783,7 +1783,7 @@ VOID Indicate_AMPDU_Packet(
 		}
 		WinStartSeq = (TmpSeq+1) & MAXSEQ;
 		ba_indicate_reordering_mpdus_le_seq(pAd, pBAEntry, WinStartSeq);
-		pBAEntry->LastIndSeq = WinStartSeq; //TmpSeq;          
+		pBAEntry->LastIndSeq = WinStartSeq; //TmpSeq;
 
 		pBAEntry->LastIndSeqAtTimer = Now32;
 
diff --git a/common/cmm_data.c b/common/cmm_data.c
index 4262d37..292d34b 100644
--- a/common/cmm_data.c
+++ b/common/cmm_data.c
@@ -7,25 +7,25 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
-*/ 
+*/
 
-#include "rt_config.h"
+#include "../rt_config.h"
 
 #define MAX_TX_IN_TBTT		(16)
 
@@ -41,7 +41,7 @@ UCHAR   TPID[] = {0x81, 0x00}; /* VLAN related */
 
 UCHAR	IPX[] = {0x81, 0x37};
 UCHAR	APPLE_TALK[] = {0x80, 0xf3};
-UCHAR	RateIdToPlcpSignal[12] = { 
+UCHAR	RateIdToPlcpSignal[12] = {
 	 0, /* RATE_1 */	1, /* RATE_2 */ 	2, /* RATE_5_5 */	3, /* RATE_11 */	// see BBP spec
 	11, /* RATE_6 */   15, /* RATE_9 */    10, /* RATE_12 */   14, /* RATE_18 */	// see IEEE802.11a-1999 p.14
 	 9, /* RATE_24 */  13, /* RATE_36 */	8, /* RATE_48 */   12  /* RATE_54 */ }; // see IEEE802.11a-1999 p.14
@@ -54,12 +54,12 @@ UCHAR	 OfdmSignalToRateId[16] = {
 };
 
 UCHAR	 OfdmRateToRxwiMCS[12] = {
-	0,  0,	0,  0,	 
+	0,  0,	0,  0,
 	0,  1,	2,  3,	// OFDM rate 6,9,12,18 = rxwi mcs 0,1,2,3
 	4,  5,	6,  7,	// OFDM rate 24,36,48,54 = rxwi mcs 4,5,6,7
 };
 UCHAR	 RxwiMCSToOfdmRate[12] = {
-	RATE_6,  RATE_9,	RATE_12,  RATE_18,	 
+	RATE_6,  RATE_9,	RATE_12,  RATE_18,
 	RATE_24,  RATE_36,	RATE_48,  RATE_54,	// OFDM rate 6,9,12,18 = rxwi mcs 0,1,2,3
 	4,  5,	6,  7,	// OFDM rate 24,36,48,54 = rxwi mcs 4,5,6,7
 };
@@ -78,12 +78,12 @@ UCHAR MapUserPriorityToAccessCategory[8] = {QID_AC_BE, QID_AC_BK, QID_AC_BK, QID
 	Routine Description:
 		API for MLME to transmit management frame to AP (BSS Mode)
 	or station (IBSS Mode)
-		
+
 	Arguments:
 		pAd Pointer to our adapter
 		pData		Pointer to the outgoing 802.11 frame
 		Length		Size of outgoing management frame
-		
+
 	Return Value:
 		NDIS_STATUS_FAILURE
 		NDIS_STATUS_PENDING
@@ -91,9 +91,9 @@ UCHAR MapUserPriorityToAccessCategory[8] = {QID_AC_BE, QID_AC_BK, QID_AC_BK, QID
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 NDIS_STATUS MiniportMMRequest(
@@ -110,20 +110,20 @@ NDIS_STATUS MiniportMMRequest(
 #endif // RT2860 //
 	UCHAR			IrqState;
 	UCHAR			rtmpHwHdr[TXINFO_SIZE + TXWI_SIZE]; //RTMP_HW_HDR_LEN];
-	
+
 	ASSERT(Length <= MGMT_DMA_BUFFER_SIZE);
-	
+
 	QueIdx=3;
-	
+
 	// 2860C use Tx Ring
-	
+
 	IrqState = pAd->irq_disabled;
 #ifdef RT2860
 	if ((pAd->MACVersion == 0x28600100) && (!IrqState))
 		RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
 #endif // RT2860 //
 
-	do 
+	do
 	{
 		// Reset is in progress, stop immediately
 		if ( RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
@@ -136,7 +136,7 @@ NDIS_STATUS MiniportMMRequest(
 
 		// Check Free priority queue
 		// Since we use PBF Queue2 for management frame.  Its corresponding DMA ring should be using TxRing.
-	
+
 		// 2860C use Tx Ring
 		if (pAd->MACVersion == 0x28600100)
 		{
@@ -146,7 +146,7 @@ NDIS_STATUS MiniportMMRequest(
 		{
 			FreeNum = GET_MGMTRING_FREENO(pAd);
 		}
-		
+
 		if ((FreeNum > 0))
 		{
 			// We need to reserve space for rtmp hardware header. i.e., TxWI for RT2860 and TxInfo+TxWI for RT2870
@@ -159,7 +159,7 @@ NDIS_STATUS MiniportMMRequest(
 			}
 
 			//pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_CCK;
-			//pAd->CommonCfg.MlmeRate = RATE_2; 			
+			//pAd->CommonCfg.MlmeRate = RATE_2;
 
 
 			Status = MlmeHardTransmit(pAd, QueIdx, pPacket);
@@ -174,7 +174,7 @@ NDIS_STATUS MiniportMMRequest(
 		}
 
 	} while (FALSE);
-	
+
 #ifdef RT2860
 	// 2860C use Tx Ring
 	if ((pAd->MACVersion == 0x28600100) && (!IrqState))
@@ -196,13 +196,13 @@ NDIS_STATUS MiniportMMRequestUnlock(
 	NDIS_STATUS  Status = NDIS_STATUS_SUCCESS;
 	ULONG	 FreeNum;
 	TXWI_STRUC		TXWI;
-	ULONG	SW_TX_IDX; 
+	ULONG	SW_TX_IDX;
 	PTXD_STRUC		pTxD;
 
 	QueIdx = 3;
 	ASSERT(Length <= MGMT_DMA_BUFFER_SIZE);
 
-	do 
+	do
 	{
 		// Reset is in progress, stop immediately
 		if ( RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS) ||
@@ -217,14 +217,14 @@ NDIS_STATUS MiniportMMRequestUnlock(
 		// Since we use PBF Queue2 for management frame.  Its corresponding DMA ring should be using TxRing.
 		// 2860C use Tx Ring
 		if (pAd->MACVersion == 0x28600100)
-		{	
+		{
 			FreeNum = GET_TXRING_FREENO(pAd, QueIdx);
 			SW_TX_IDX = pAd->TxRing[QueIdx].TxCpuIdx;
 			pTxD  = (PTXD_STRUC) pAd->TxRing[QueIdx].Cell[SW_TX_IDX].AllocVa;
 		}
 		else
 		{
-			FreeNum = GET_MGMTRING_FREENO(pAd);		
+			FreeNum = GET_MGMTRING_FREENO(pAd);
 			SW_TX_IDX = pAd->MgmtRing.TxCpuIdx;
 			pTxD  = (PTXD_STRUC) pAd->MgmtRing.Cell[SW_TX_IDX].AllocVa;
 		}
@@ -233,7 +233,7 @@ NDIS_STATUS MiniportMMRequestUnlock(
 			NdisZeroMemory(&TXWI, TXWI_SIZE);
 			Status = RTMPAllocateNdisPacket(pAd, &pPacket, (PUCHAR)&TXWI, TXWI_SIZE, pData, Length);
 			if (Status != NDIS_STATUS_SUCCESS)
-			{					
+			{
 				DBGPRINT(RT_DEBUG_WARN, ("MiniportMMRequest (error:: can't allocate NDIS PACKET)\n"));
 				break;
 			}
@@ -260,14 +260,14 @@ NDIS_STATUS MiniportMMRequestUnlock(
 	========================================================================
 
 	Routine Description:
-		Copy frame from waiting queue into relative ring buffer and set 
+		Copy frame from waiting queue into relative ring buffer and set
 	appropriate ASIC register to kick hardware transmit function
-	
+
 	Arguments:
 		pAd Pointer to our adapter
 		pBuffer 	Pointer to	memory of outgoing frame
 		Length		Size of outgoing management frame
-		
+
 	Return Value:
 		NDIS_STATUS_FAILURE
 		NDIS_STATUS_PENDING
@@ -275,9 +275,9 @@ NDIS_STATUS MiniportMMRequestUnlock(
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 NDIS_STATUS MlmeHardTransmit(
@@ -324,7 +324,7 @@ NDIS_STATUS MlmeHardTransmitTxRing(
 	MAC_TABLE_ENTRY	*pMacEntry = NULL;
 
 
-	RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);	
+	RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
 
 	if (pSrcBufVA == NULL)
 	{
@@ -345,7 +345,7 @@ NDIS_STATUS MlmeHardTransmitTxRing(
 
 	SwIdx = pAd->TxRing[QueIdx].TxCpuIdx;
 
-#ifndef RT_BIG_ENDIAN	
+#ifndef RT_BIG_ENDIAN
 	pTxD  = (PTXD_STRUC) pAd->TxRing[QueIdx].Cell[SwIdx].AllocVa;
 #else
     pDestTxD  = (PTXD_STRUC)pAd->TxRing[QueIdx].Cell[SwIdx].AllocVa;
@@ -364,13 +364,13 @@ NDIS_STATUS MlmeHardTransmitTxRing(
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 	{
-		// outgoing frame always wakeup PHY to prevent frame lost 
+		// outgoing frame always wakeup PHY to prevent frame lost
 		if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
 			AsicForceWakeup(pAd, TRUE);
 	}
 #endif // CONFIG_STA_SUPPORT //
 	pFirstTxWI	=(PTXWI_STRUC)pSrcBufVA;
-	
+
 	pHeader_802_11 = (PHEADER_802_11) (pSrcBufVA + TXWI_SIZE);
 	if (pHeader_802_11->Addr1[0] & 0x01)
 	{
@@ -387,7 +387,7 @@ NDIS_STATUS MlmeHardTransmitTxRing(
 		pMacEntry = MacTableLookup(pAd, pHeader_802_11->Addr1);
 	}
 
-	// Verify Mlme rate for a / g bands.	
+	// Verify Mlme rate for a / g bands.
 	if ((pAd->LatchRfRegs.Channel > 14) && (MlmeRate < RATE_6)) // 11A band
 		MlmeRate = RATE_6;
 
@@ -395,7 +395,7 @@ NDIS_STATUS MlmeHardTransmitTxRing(
 	// Should not be hard code to set PwrMgmt to 0 (PWR_ACTIVE)
 	// Snice it's been set to 0 while on MgtMacHeaderInit
 	// By the way this will cause frame to be send on PWR_SAVE failed.
-	// 
+	//
 	//
 	// In WMM-UAPSD, mlme frame should be set psm as power saving but probe request frame
 #ifdef CONFIG_STA_SUPPORT
@@ -412,7 +412,7 @@ NDIS_STATUS MlmeHardTransmitTxRing(
     	}
     }
 #endif // CONFIG_STA_SUPPORT //
-	
+
 	bInsertTimestamp = FALSE;
 	if (pHeader_802_11->FC.Type == BTYPE_CNTL) // must be PS-POLL
 	{
@@ -460,12 +460,12 @@ NDIS_STATUS MlmeHardTransmitTxRing(
 	// Initialize TX Descriptor
 	// For inter-frame gap, the number is for this frame and next frame
 	// For MLME rate, we will fix as 2Mb to match other vendor's implement
-	
+
 // management frame doesn't need encryption. so use RESERVED_WCID no matter u are sending to specific wcid or not.
 	// Only beacon use Nseq=TRUE. So here we use Nseq=FALSE.
 	if (pMacEntry == NULL)
 	{
-		RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE, bInsertTimestamp, FALSE, bAckRequired, FALSE, 
+		RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE, bInsertTimestamp, FALSE, bAckRequired, FALSE,
 		0, RESERVED_WCID, (SrcBufLen - TXWI_SIZE), PID_MGMT, 0,  (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
 	}
 	else
@@ -505,7 +505,7 @@ NDIS_STATUS MlmeHardTransmitTxRing(
    	// Increase TX_CTX_IDX, but write to register later.
 	INC_RING_INDEX(pAd->TxRing[QueIdx].TxCpuIdx, TX_RING_SIZE);
 
-	RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QueIdx*0x10,  pAd->TxRing[QueIdx].TxCpuIdx);	
+	RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QueIdx*0x10,  pAd->TxRing[QueIdx].TxCpuIdx);
 
 	return NDIS_STATUS_SUCCESS;
 }
@@ -526,7 +526,7 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
 	PTXWI_STRUC 	pFirstTxWI;
 	MAC_TABLE_ENTRY	*pMacEntry = NULL;
 
-	RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);	
+	RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
 		RTMP_SEM_LOCK(&pAd->MgmtRingLock);
 
 
@@ -539,7 +539,7 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 	{
-		// outgoing frame always wakeup PHY to prevent frame lost 
+		// outgoing frame always wakeup PHY to prevent frame lost
 		if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
 			AsicForceWakeup(pAd, TRUE);
 	}
@@ -547,7 +547,7 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
 
 	pFirstTxWI = (PTXWI_STRUC)(pSrcBufVA +  TXINFO_SIZE);
 	pHeader_802_11 = (PHEADER_802_11) (pSrcBufVA + TXINFO_SIZE + TXWI_SIZE); //TXWI_SIZE);
-	
+
 	if (pHeader_802_11->Addr1[0] & 0x01)
 	{
 		MlmeRate = pAd->CommonCfg.BasicMlmeRate;
@@ -557,7 +557,7 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
 		MlmeRate = pAd->CommonCfg.MlmeRate;
 	}
 
-	// Verify Mlme rate for a / g bands.	
+	// Verify Mlme rate for a / g bands.
 	if ((pAd->LatchRfRegs.Channel > 14) && (MlmeRate < RATE_6)) // 11A band
 		MlmeRate = RATE_6;
 
@@ -570,8 +570,8 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 	{
-		// Fixed W52 with Activity scan issue in ABG_MIXED and ABGN_MIXED mode.    
-		if (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED 
+		// Fixed W52 with Activity scan issue in ABG_MIXED and ABGN_MIXED mode.
+		if (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED
 #ifdef DOT11_N_SUPPORT
 			|| pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED
 #endif // DOT11_N_SUPPORT //
@@ -589,22 +589,22 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
 	// Should not be hard code to set PwrMgmt to 0 (PWR_ACTIVE)
 	// Snice it's been set to 0 while on MgtMacHeaderInit
 	// By the way this will cause frame to be send on PWR_SAVE failed.
-	// 
+	//
 	// pHeader_802_11->FC.PwrMgmt = 0; // (pAd->StaCfg.Psm == PWR_SAVE);
 	//
 	// In WMM-UAPSD, mlme frame should be set psm as power saving but probe request frame
-#ifdef CONFIG_STA_SUPPORT	
-    // Data-Null packets alse pass through MMRequest in RT2860, however, we hope control the psm bit to pass APSD    
+#ifdef CONFIG_STA_SUPPORT
+    // Data-Null packets alse pass through MMRequest in RT2860, however, we hope control the psm bit to pass APSD
 	if ((pHeader_802_11->FC.Type != BTYPE_DATA) && (pHeader_802_11->FC.Type != BTYPE_CNTL))
 	{
 		if ((pAd->StaCfg.Psm == PWR_SAVE) &&
-			(pHeader_802_11->FC.SubType == SUBTYPE_ACTION))	
+			(pHeader_802_11->FC.SubType == SUBTYPE_ACTION))
 			pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
 		else
 			pHeader_802_11->FC.PwrMgmt = PWR_ACTIVE;
 	}
 #endif // CONFIG_STA_SUPPORT //
-	
+
 	bInsertTimestamp = FALSE;
 	if (pHeader_802_11->FC.Type == BTYPE_CNTL) // must be PS-POLL
 	{
@@ -663,11 +663,11 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
 	// Initialize TX Descriptor
 	// For inter-frame gap, the number is for this frame and next frame
 	// For MLME rate, we will fix as 2Mb to match other vendor's implement
-	
+
 // management frame doesn't need encryption. so use RESERVED_WCID no matter u are sending to specific wcid or not.
 	if (pMacEntry == NULL)
 	{
-		RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE, bInsertTimestamp, FALSE, bAckRequired, FALSE, 
+		RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE, bInsertTimestamp, FALSE, bAckRequired, FALSE,
 		0, RESERVED_WCID, (SrcBufLen - TXINFO_SIZE - TXWI_SIZE), PID_MGMT, 0,  (UCHAR)pAd->CommonCfg.MlmeTransmit.field.MCS, IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit);
 	}
 	else
@@ -692,13 +692,13 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
 	return NDIS_STATUS_SUCCESS;
 }
 
-	
+
 /********************************************************************************
-		
+
 	New DeQueue Procedures.
 
  ********************************************************************************/
-	
+
 #define DEQUEUE_LOCK(lock, bIntContext, IrqFlags) 				\
 			do{													\
 				if (bIntContext == FALSE)						\
@@ -714,7 +714,7 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
 /*
 	========================================================================
 	Tx Path design algorithm:
-		Basically, we divide the packets into four types, Broadcast/Multicast, 11N Rate(AMPDU, AMSDU, Normal), B/G Rate(ARALINK, Normal), 
+		Basically, we divide the packets into four types, Broadcast/Multicast, 11N Rate(AMPDU, AMSDU, Normal), B/G Rate(ARALINK, Normal),
 		Specific Packet Type. Following show the classification rule and policy for each kinds of packets.
 				Classification Rule=>
 					Multicast: (*addr1 & 0x01) == 0x01
@@ -724,40 +724,40 @@ NDIS_STATUS MlmeHardTransmitMgmtRing(
 								(2).AMSDU  -- If AMSDU is capable for both peer and ourself.
 											*). AMSDU can embedded in a AMPDU, but now we didn't support it.
 								(3).Normal -- Other packets which send as 11n rate.
-								
+
 					B/G Rate : If peer is b/g only.
 								(1).ARALINK-- If both of peer/us supprot Ralink proprietary Aggregation and the TxRate is large than RATE_6
 								(2).Normal -- Other packets which send as b/g rate.
 					Fragment:
 								The packet must be unicast, NOT A-RALINK, NOT A-MSDU, NOT 11n, then can consider about fragment.
-								
+
 				Classified Packet Handle Rule=>
 					Multicast:
 								No ACK, 		//pTxBlk->bAckRequired = FALSE;
 								No WMM, 		//pTxBlk->bWMM = FALSE;
 								No piggyback,   //pTxBlk->bPiggyBack = FALSE;
 								Force LowRate,  //pTxBlk->bForceLowRate = TRUE;
-					Specific :	Basically, for specific packet, we should handle it specifically, but now all specific packets are use 
+					Specific :	Basically, for specific packet, we should handle it specifically, but now all specific packets are use
 									the same policy to handle it.
 								Force LowRate,  //pTxBlk->bForceLowRate = TRUE;
-								
+
 					11N Rate :
 								No piggyback,	//pTxBlk->bPiggyBack = FALSE;
-								
+
 								(1).AMSDU
 									pTxBlk->bWMM = TRUE;
 								(2).AMPDU
 									pTxBlk->bWMM = TRUE;
 								(3).Normal
-									
+
 					B/G Rate :
 								(1).ARALINK
-									
+
 								(2).Normal
 	========================================================================
 */
 static UCHAR TxPktClassification(
-	IN RTMP_ADAPTER *pAd, 
+	IN RTMP_ADAPTER *pAd,
 	IN PNDIS_PACKET  pPacket)
 {
 	UCHAR			TxFrameType = TX_UNKOWN_FRAME;
@@ -800,10 +800,10 @@ static UCHAR TxPktClassification(
 			TxFrameType = TX_LEGACY_FRAME;
 	}
 #endif // DOT11_N_SUPPORT //
-	else 
+	else
 	{	// it's a legacy b/g packet.
 		if ((CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE) && pAd->CommonCfg.bAggregationCapable) &&
-			(RTMP_GET_PACKET_TXRATE(pPacket) >= RATE_6) && 
+			(RTMP_GET_PACKET_TXRATE(pPacket) >= RATE_6) &&
 			(!(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) && CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_WMM_CAPABLE))))
 		{	// if peer support Ralink Aggregation, we use it.
 			TxFrameType = TX_RALINK_FRAME;
@@ -823,7 +823,7 @@ static UCHAR TxPktClassification(
 
 
 BOOLEAN RTMP_FillTxBlkInfo(
-	IN RTMP_ADAPTER *pAd, 
+	IN RTMP_ADAPTER *pAd,
 	IN TX_BLK *pTxBlk)
 {
 	PACKET_INFO			PacketInfo;
@@ -836,17 +836,17 @@ BOOLEAN RTMP_FillTxBlkInfo(
 	pTxBlk->Wcid	 	 		= RTMP_GET_PACKET_WCID(pPacket);
 	pTxBlk->apidx		 		= RTMP_GET_PACKET_IF(pPacket);
 	pTxBlk->UserPriority 		= RTMP_GET_PACKET_UP(pPacket);
-	pTxBlk->FrameGap = IFS_HTTXOP;		// ASIC determine Frame Gap 
+	pTxBlk->FrameGap = IFS_HTTXOP;		// ASIC determine Frame Gap
 
 	if (RTMP_GET_PACKET_CLEAR_EAP_FRAME(pTxBlk->pPacket))
 		TX_BLK_SET_FLAG(pTxBlk, fTX_bClearEAPFrame);
 	else
 		TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bClearEAPFrame);
-	
+
 	// Default to clear this flag
 	TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bForceNonQoS);
-	
-	
+
+
 	if (pTxBlk->Wcid == MCAST_WCID)
 	{
 		pTxBlk->pMacEntry = NULL;
@@ -867,8 +867,8 @@ BOOLEAN RTMP_FillTxBlkInfo(
 		if (RTMP_GET_PACKET_MOREDATA(pPacket))
 		{
 			TX_BLK_SET_FLAG(pTxBlk, fTX_bMoreData);
-		}	
-		
+		}
+
 	}
 	else
 	{
@@ -876,8 +876,8 @@ BOOLEAN RTMP_FillTxBlkInfo(
 		pTxBlk->pTransmit = &pTxBlk->pMacEntry->HTPhyMode;
 
 		pMacEntry = pTxBlk->pMacEntry;
-		
-		
+
+
 		// For all unicast packets, need Ack unless the Ack Policy is not set as NORMAL_ACK.
 		if (pAd->CommonCfg.AckPolicy[pTxBlk->QueIdx] != NORMAL_ACK)
 			TX_BLK_CLEAR_FLAG(pTxBlk, fTX_bAckRequired);
@@ -905,7 +905,7 @@ BOOLEAN RTMP_FillTxBlkInfo(
 				pTxBlk->pTransmit = &pAd->MacTab.Content[MCAST_WCID].HTPhyMode;
 #ifdef DOT11_N_SUPPORT
 				// Modify the WMM bit for ICV issue. If we have a packet with EOSP field need to set as 1, how to handle it???
-				if (IS_HT_STA(pTxBlk->pMacEntry) && 
+				if (IS_HT_STA(pTxBlk->pMacEntry) &&
 					(CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_RALINK_CHIPSET)) &&
 					((pAd->CommonCfg.bRdg == TRUE) && CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_RDG_CAPABLE)))
 				{
@@ -914,9 +914,9 @@ BOOLEAN RTMP_FillTxBlkInfo(
 				}
 #endif // DOT11_N_SUPPORT //
 			}
-			
-#ifdef DOT11_N_SUPPORT	
-			if ( (IS_HT_RATE(pMacEntry) == FALSE) && 
+
+#ifdef DOT11_N_SUPPORT
+			if ( (IS_HT_RATE(pMacEntry) == FALSE) &&
 				(CLIENT_STATUS_TEST_FLAG(pMacEntry, fCLIENT_STATUS_PIGGYBACK_CAPABLE)))
 			{	// Currently piggy-back only support when peer is operate in b/g mode.
 				TX_BLK_SET_FLAG(pTxBlk, fTX_bPiggyBack);
@@ -938,9 +938,9 @@ BOOLEAN RTMP_FillTxBlkInfo(
 		{
 			TX_BLK_SET_FLAG(pTxBlk, fTX_bAllowFrag);
 		}
-		
+
 		pMacEntry->DebugTxCount++;
-	}	
+	}
 
 	return TRUE;
 
@@ -956,22 +956,22 @@ BOOLEAN CanDoAggregateTransmit(
 {
 
 	//printk("Check if can do aggregation! TxFrameType=%d!\n", pTxBlk->TxFrameType);
-	
+
 	if (RTMP_GET_PACKET_WCID(pPacket) == MCAST_WCID)
 		return FALSE;
 
-	if (RTMP_GET_PACKET_DHCP(pPacket) || 
-		RTMP_GET_PACKET_EAPOL(pPacket) || 
+	if (RTMP_GET_PACKET_DHCP(pPacket) ||
+		RTMP_GET_PACKET_EAPOL(pPacket) ||
 		RTMP_GET_PACKET_WAI(pPacket))
 		return FALSE;
-	
+
 	if ((pTxBlk->TxFrameType == TX_AMSDU_FRAME) &&
 		((pTxBlk->TotalFrameLen + GET_OS_PKT_LEN(pPacket))> (RX_BUFFER_AGGRESIZE - 100)))
 	{	// For AMSDU, allow the packets with total length < max-amsdu size
 		return FALSE;
 	}
-	
-	if ((pTxBlk->TxFrameType == TX_RALINK_FRAME) && 
+
+	if ((pTxBlk->TxFrameType == TX_RALINK_FRAME) &&
 		(pTxBlk->TxPacketList.Number == 2))
 	{	// For RALINK-Aggregation, allow two frames in one batch.
 		return FALSE;
@@ -980,10 +980,10 @@ BOOLEAN CanDoAggregateTransmit(
 #ifdef CONFIG_STA_SUPPORT
 	if ((INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA)) // must be unicast to AP
 		return TRUE;
-	else 
+	else
 #endif // CONFIG_STA_SUPPORT //
 		return FALSE;
-	
+
 }
 
 
@@ -991,22 +991,22 @@ BOOLEAN CanDoAggregateTransmit(
 	========================================================================
 
 	Routine Description:
-		To do the enqueue operation and extract the first item of waiting 
-		list. If a number of available shared memory segments could meet 
+		To do the enqueue operation and extract the first item of waiting
+		list. If a number of available shared memory segments could meet
 		the request of extracted item, the extracted item will be fragmented
 		into shared memory segments.
-	
+
 	Arguments:
 		pAd Pointer to our adapter
 		pQueue		Pointer to Waiting Queue
-		
+
 	Return Value:
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 VOID RTMPDeQueuePacket(
@@ -1035,14 +1035,14 @@ VOID RTMPDeQueuePacket(
 
 	if (QIdx == NUM_OF_TX_RING)
 	{
-		sQIdx = 0; 
+		sQIdx = 0;
 		eQIdx = 3;	// 4 ACs, start from 0.
 	}
 	else
 	{
 		sQIdx = eQIdx = QIdx;
 	}
-	
+
 	for (QueIdx=sQIdx; QueIdx <= eQIdx; QueIdx++)
 	{
 		Count=0;
@@ -1055,7 +1055,7 @@ VOID RTMPDeQueuePacket(
 
 		while (1)
 		{
-			if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS | 
+			if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS |
 										fRTMP_ADAPTER_RADIO_OFF |
 										fRTMP_ADAPTER_RESET_IN_PROGRESS |
 										fRTMP_ADAPTER_HALT_IN_PROGRESS |
@@ -1064,10 +1064,10 @@ VOID RTMPDeQueuePacket(
 				RT28XX_STOP_DEQUEUE(pAd, QueIdx, IrqFlags);
 				return;
 			}
-			
+
 			if (Count >= Max_Tx_Packets)
 				break;
-			
+
 			DEQUEUE_LOCK(&pAd->irq_lock, bIntContext, IrqFlags);
 			if (&pAd->TxSwQueue[QueIdx] == NULL)
 			{
@@ -1106,7 +1106,7 @@ VOID RTMPDeQueuePacket(
 			}
 #endif // RT2860 //
 
-			// probe the Queue Head						
+			// probe the Queue Head
 			pQueue = &pAd->TxSwQueue[QueIdx];
 			if ((pEntry = pQueue->Head) == NULL)
 			{
@@ -1117,9 +1117,9 @@ VOID RTMPDeQueuePacket(
 			pTxBlk = &TxBlk;
 			NdisZeroMemory((PUCHAR)pTxBlk, sizeof(TX_BLK));
 			pTxBlk->QueIdx = QueIdx;
-	
+
 			pPacket = QUEUE_ENTRY_TO_PKT(pEntry);
-			
+
 			// Early check to make sure we have enoguh Tx Resource.
 			hasTxDesc = RT28XX_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, FreeNumber[QueIdx], pPacket);
 			if (!hasTxDesc)
@@ -1127,7 +1127,7 @@ VOID RTMPDeQueuePacket(
 				pAd->PrivateInfo.TxRingFullCnt++;
 
 				DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags);
-				
+
 				break;
 			}
 
@@ -1138,7 +1138,7 @@ VOID RTMPDeQueuePacket(
 			pTxBlk->TotalFrameLen += GET_OS_PKT_LEN(pPacket);
 			pTxBlk->pPacket = pPacket;
 			InsertTailQueue(&pTxBlk->TxPacketList, PACKET_TO_QUEUE_ENTRY(pPacket));
-			
+
 			if (pTxBlk->TxFrameType == TX_RALINK_FRAME || pTxBlk->TxFrameType == TX_AMSDU_FRAME)
 			{
 				// Enhance SW Aggregation Mechanism
@@ -1174,7 +1174,7 @@ VOID RTMPDeQueuePacket(
 					pTxBlk->TxFrameType = TX_LEGACY_FRAME;
 			}
 
-					
+
 			Count += pTxBlk->TxPacketList.Number;
 
 				// Do HardTransmit now.
@@ -1193,7 +1193,7 @@ VOID RTMPDeQueuePacket(
 
 		RT28XX_STOP_DEQUEUE(pAd, QueIdx, IrqFlags);
 
-		
+
 #ifdef BLOCK_NET_IF
 		if ((pAd->blockQueueTab[QueIdx].SwTxQueueBlockFlag == TRUE)
 			&& (pAd->TxSwQueue[QueIdx].Number < 1))
@@ -1211,22 +1211,22 @@ VOID RTMPDeQueuePacket(
 	========================================================================
 
 	Routine Description:
-		Calculates the duration which is required to transmit out frames 
+		Calculates the duration which is required to transmit out frames
 	with given size and specified rate.
-		
+
 	Arguments:
 		pAd 	Pointer to our adapter
 		Rate			Transmit rate
 		Size			Frame size in units of byte
-		
+
 	Return Value:
 		Duration number in units of usec
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 USHORT	RTMPCalcDuration(
@@ -1258,18 +1258,18 @@ USHORT	RTMPCalcDuration(
 	{
 		Duration = 20 + 6;		// 16+4 preamble+plcp + Signal Extension
 	}
-	
+
 	return (USHORT)Duration;
 }
 
 
 /*
 	========================================================================
-	
+
 	Routine Description:
-		Calculates the duration which is required to transmit out frames 
+		Calculates the duration which is required to transmit out frames
 	with given size and specified rate.
-					  
+
 	Arguments:
 		pTxWI		Pointer to head of each MPDU to HW.
 		Ack 		Setting for Ack requirement bit
@@ -1281,21 +1281,21 @@ USHORT	RTMPCalcDuration(
 		Length		Frame length
 		TxPreamble	Short or Long preamble when using CCK rates
 		QueIdx - 0-3, according to 802.11e/d4.4 June/2003
-		
+
 	Return Value:
 		None
-		
+
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
     See also : BASmartHardTransmit()    !!!
-	
+
 	========================================================================
 */
 VOID RTMPWriteTxWI(
 	IN	PRTMP_ADAPTER	pAd,
-	IN	PTXWI_STRUC 	pOutTxWI,	
-	IN	BOOLEAN			FRAG,	
+	IN	PTXWI_STRUC 	pOutTxWI,
+	IN	BOOLEAN			FRAG,
 	IN	BOOLEAN			CFACK,
 	IN	BOOLEAN			InsTimestamp,
 	IN	BOOLEAN 		AMPDU,
@@ -1307,8 +1307,8 @@ VOID RTMPWriteTxWI(
 	IN	UCHAR 			PID,
 	IN	UCHAR			TID,
 	IN	UCHAR			TxRate,
-	IN	UCHAR			Txopmode,	
-	IN	BOOLEAN			CfAck,	
+	IN	UCHAR			Txopmode,
+	IN	BOOLEAN			CfAck,
 	IN	HTTRANSMIT_SETTING	*pTransmit)
 {
 	PMAC_TABLE_ENTRY	pMac = NULL;
@@ -1333,7 +1333,7 @@ VOID RTMPWriteTxWI(
 	pTxWI->AMPDU = AMPDU;
 	pTxWI->ACK = Ack;
 	pTxWI->txop= Txopmode;
-	
+
 	pTxWI->NSEQ = NSeq;
 	// John tune the performace with Intel Client in 20 MHz performance
 #ifdef DOT11_N_SUPPORT
@@ -1347,35 +1347,35 @@ VOID RTMPWriteTxWI(
 #endif // DOT11_N_SUPPORT //
 
 	pTxWI->WirelessCliID = WCID;
-	pTxWI->MPDUtotalByteCount = Length; 
-	pTxWI->PacketId = PID; 
-	
+	pTxWI->MPDUtotalByteCount = Length;
+	pTxWI->PacketId = PID;
+
 	// If CCK or OFDM, BW must be 20
 	pTxWI->BW = (pTransmit->field.MODE <= MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
 #ifdef DOT11N_DRAFT3
 	if (pTxWI->BW)
-		pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);	
+		pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);
 #endif // DOT11N_DRAFT3 //
-	
+
 	pTxWI->MCS = pTransmit->field.MCS;
 	pTxWI->PHYMODE = pTransmit->field.MODE;
 	pTxWI->CFACK = CfAck;
 
 #ifdef DOT11_N_SUPPORT
 	if (pMac)
-	{		
+	{
 		if (pAd->CommonCfg.bMIMOPSEnable)
 		{
 			if ((pMac->MmpsMode == MMPS_DYNAMIC) && (pTransmit->field.MCS > 7))
 			{
 				// Dynamic MIMO Power Save Mode
 				pTxWI->MIMOps = 1;
-			} 
+			}
 			else if (pMac->MmpsMode == MMPS_STATIC)
 			{
 				// Static MIMO Power Save Mode
 				if (pTransmit->field.MODE >= MODE_HTMIX && pTransmit->field.MCS > 7)
-				{			
+				{
 					pTxWI->MCS = 7;
 					pTxWI->MIMOps = 0;
 				}
@@ -1386,7 +1386,7 @@ VOID RTMPWriteTxWI(
 		{
 			pTxWI->MpduDensity = 7;
 		}
-		else 
+		else
 		{
 			pTxWI->MpduDensity = pMac->MpduDensity;
 		}
@@ -1422,15 +1422,15 @@ VOID RTMPWriteTxWI_Data(
 	//
 	OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
 	NdisZeroMemory(pTxWI, TXWI_SIZE);
-	
+
 	pTxWI->FRAG		= TX_BLK_TEST_FLAG(pTxBlk, fTX_bAllowFrag);
 	pTxWI->ACK		= TX_BLK_TEST_FLAG(pTxBlk, fTX_bAckRequired);
 	pTxWI->txop		= pTxBlk->FrameGap;
-	
+
 #ifdef CONFIG_STA_SUPPORT
 #ifdef QOS_DLS_SUPPORT
-	if (pMacEntry &&		
-		(pAd->StaCfg.BssType == BSS_INFRA) &&		
+	if (pMacEntry &&
+		(pAd->StaCfg.BssType == BSS_INFRA) &&
 		(pMacEntry->ValidAsDls == TRUE))
 		pTxWI->WirelessCliID = BSSID_WCID;
 	else
@@ -1438,7 +1438,7 @@ VOID RTMPWriteTxWI_Data(
 #endif // CONFIG_STA_SUPPORT //
 		pTxWI->WirelessCliID		= pTxBlk->Wcid;
 
-	pTxWI->MPDUtotalByteCount	= pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen; 
+	pTxWI->MPDUtotalByteCount	= pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
 	pTxWI->CFACK				= TX_BLK_TEST_FLAG(pTxBlk, fTX_bPiggyBack);
 
 	// If CCK or OFDM, BW must be 20
@@ -1446,7 +1446,7 @@ VOID RTMPWriteTxWI_Data(
 #ifdef DOT11_N_SUPPORT
 #ifdef DOT11N_DRAFT3
 	if (pTxWI->BW)
-		pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);	
+		pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);
 #endif // DOT11N_DRAFT3 //
 	pTxWI->AMPDU	= ((pTxBlk->TxFrameType == TX_AMPDU_FRAME) ? TRUE : FALSE);
 
@@ -1454,8 +1454,8 @@ VOID RTMPWriteTxWI_Data(
 	BASize = pAd->CommonCfg.TxBASize;
 	if((pTxBlk->TxFrameType == TX_AMPDU_FRAME) && (pMacEntry))
 	{
-		UCHAR		RABAOriIdx = 0;	//The RA's BA Originator table index. 
-					
+		UCHAR		RABAOriIdx = 0;	//The RA's BA Originator table index.
+
 		RABAOriIdx = pTxBlk->pMacEntry->BAOriWcidArray[pTxBlk->UserPriority];
 		BASize = pAd->BATable.BAOriEntry[RABAOriIdx].BAWinSize;
 	}
@@ -1471,27 +1471,27 @@ VOID RTMPWriteTxWI_Data(
 
 #ifdef DOT11_N_SUPPORT
 	if (pMacEntry)
-	{		
+	{
 		if ((pMacEntry->MmpsMode == MMPS_DYNAMIC) && (pTransmit->field.MCS > 7))
 		{
 			// Dynamic MIMO Power Save Mode
 			pTxWI->MIMOps = 1;
-		} 
+		}
 		else if (pMacEntry->MmpsMode == MMPS_STATIC)
 		{
 			// Static MIMO Power Save Mode
 			if (pTransmit->field.MODE >= MODE_HTMIX && pTransmit->field.MCS > 7)
-			{			
+			{
 				pTxWI->MCS = 7;
 				pTxWI->MIMOps = 0;
 			}
 		}
-		
+
 		if (pMacEntry->bIAmBadAtheros && (pMacEntry->WepStatus != Ndis802_11WEPDisabled))
 		{
 			pTxWI->MpduDensity = 7;
 		}
-		else 
+		else
 		{
 			pTxWI->MpduDensity = pMacEntry->MpduDensity;
 		}
@@ -1518,13 +1518,13 @@ VOID RTMPWriteTxWI_Cache(
 {
 	PHTTRANSMIT_SETTING	pTransmit;
 	PMAC_TABLE_ENTRY	pMacEntry;
-	
+
 	//
 	// update TXWI
-	// 
+	//
 	pMacEntry = pTxBlk->pMacEntry;
 	pTransmit = pTxBlk->pTransmit;
-	
+
 	if (pMacEntry->bAutoTxRateSwitch)
 	{
 		pTxWI->txop = IFS_HTTXOP;
@@ -1547,7 +1547,7 @@ VOID RTMPWriteTxWI_Cache(
 
 #ifdef DOT11N_DRAFT3
 	if (pTxWI->BW)
-		pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);	
+		pTxWI->BW = (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth == 0) ? (BW_20) : (pTransmit->field.BW);
 #endif // DOT11N_DRAFT3 //
 
 	if (pAd->CommonCfg.bMIMOPSEnable)
@@ -1578,18 +1578,18 @@ VOID RTMPWriteTxWI_Cache(
 	}
 #endif // DBG_DIAGNOSE //
 
-	pTxWI->MPDUtotalByteCount = pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen; 
-	
+	pTxWI->MPDUtotalByteCount = pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
+
 }
 
 
 /*
 	========================================================================
-	
+
 	Routine Description:
-		Calculates the duration which is required to transmit out frames 
+		Calculates the duration which is required to transmit out frames
 	with given size and specified rate.
-		
+
 	Arguments:
 		pTxD		Pointer to transmit descriptor
 		Ack 		Setting for Ack requirement bit
@@ -1601,13 +1601,13 @@ VOID RTMPWriteTxWI_Cache(
 		Length		Frame length
 		TxPreamble	Short or Long preamble when using CCK rates
 		QueIdx - 0-3, according to 802.11e/d4.4 June/2003
-		
+
 	Return Value:
 		None
-		
+
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	========================================================================
 */
 VOID RTMPWriteTxDescriptor(
@@ -1665,13 +1665,13 @@ BOOLEAN TxFrameIsAggregatible(
 	   Check the MSDU Aggregation policy
 	1.HT aggregation is A-MSDU
 	2.legaacy rate aggregation is software aggregation by Ralink.
-	
+
 	Arguments:
-		
+
 	Return Value:
-	
+
 	Note:
-	
+
 	========================================================================
 */
 BOOLEAN PeerIsAggreOn(
@@ -1680,12 +1680,12 @@ BOOLEAN PeerIsAggreOn(
 	IN	PMAC_TABLE_ENTRY pMacEntry)
 {
 	ULONG	AFlags = (fCLIENT_STATUS_AMSDU_INUSED | fCLIENT_STATUS_AGGREGATION_CAPABLE);
-	
+
 	if (pMacEntry != NULL && CLIENT_STATUS_TEST_FLAG(pMacEntry, AFlags))
-	{		
+	{
 #ifdef DOT11_N_SUPPORT
 		if (pMacEntry->HTPhyMode.field.MODE >= MODE_HTMIX)
-		{			
+		{
 			return TRUE;
 		}
 #endif // DOT11_N_SUPPORT //
@@ -1699,7 +1699,7 @@ BOOLEAN PeerIsAggreOn(
 	}
 
 	return FALSE;
-		
+
 }
 
 
@@ -1708,17 +1708,17 @@ BOOLEAN PeerIsAggreOn(
 
 	Routine Description:
 		Check and fine the packet waiting in SW queue with highest priority
-		
+
 	Arguments:
 		pAd Pointer to our adapter
-		
+
 	Return Value:
 		pQueue		Pointer to Waiting Queue
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 PQUEUE_HEADER	RTMPCheckTxSwQueue(
@@ -1728,9 +1728,9 @@ PQUEUE_HEADER	RTMPCheckTxSwQueue(
 
 	ULONG	Number;
 
-	Number = pAd->TxSwQueue[QID_AC_BK].Number 
-			 + pAd->TxSwQueue[QID_AC_BE].Number 
-			 + pAd->TxSwQueue[QID_AC_VI].Number 
+	Number = pAd->TxSwQueue[QID_AC_BK].Number
+			 + pAd->TxSwQueue[QID_AC_BE].Number
+			 + pAd->TxSwQueue[QID_AC_VI].Number
 			 + pAd->TxSwQueue[QID_AC_VO].Number
 			 + pAd->TxSwQueue[QID_HCCA].Number;
 
@@ -1762,14 +1762,14 @@ PQUEUE_HEADER	RTMPCheckTxSwQueue(
 
 	// No packet pending in Tx Sw queue
 	*pQueIdx = QID_AC_BK;
-	
+
 	return (NULL);
 }
 
 
 #ifdef RT2860
 BOOLEAN  RTMPFreeTXDUponTxDmaDone(
-	IN PRTMP_ADAPTER	pAd, 
+	IN PRTMP_ADAPTER	pAd,
 	IN UCHAR			QueIdx)
 {
 	PRTMP_TX_RING pTxRing;
@@ -1806,7 +1806,7 @@ BOOLEAN  RTMPFreeTXDUponTxDmaDone(
 				ASSERT(pAd->ate.QID == 0);
 				pAd->ate.TxAc0++;
 
-				FREE++;    
+				FREE++;
 #ifndef RT_BIG_ENDIAN
 				pTxD = (PTXD_STRUC) (pTxRing->Cell[pTxRing->TxSwFreeIdx].AllocVa);
 				pOriTxD = pTxD;
@@ -1822,7 +1822,7 @@ BOOLEAN  RTMPFreeTXDUponTxDmaDone(
 				pTxD->DMADONE = 0;
 
 				pHeader80211 = pTxRing->Cell[pTxRing->TxSwFreeIdx].DmaBuf.AllocVa + sizeof(TXWI_STRUC);
-#ifdef RT_BIG_ENDIAN 
+#ifdef RT_BIG_ENDIAN
 				RTMPFrameEndianChange(pAd, (PUCHAR)pHeader80211, DIR_READ, FALSE);
 #endif
 				pHeader80211->Sequence = ++pAd->ate.seq;
@@ -1836,7 +1836,7 @@ BOOLEAN  RTMPFreeTXDUponTxDmaDone(
 					pAd->RalinkCounters.OneSecDmaDoneCount[QueIdx] ++;
 					INC_RING_INDEX(pTxRing->TxSwFreeIdx, TX_RING_SIZE);
 					/* get tx_tdx_idx again */
-					RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QueIdx * RINGREG_DIFF ,  &pTxRing->TxDmaIdx);					
+					RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QueIdx * RINGREG_DIFF ,  &pTxRing->TxDmaIdx);
 					goto kick_out;
 				}
 				else if ((pAd->ate.TxStatus == 1)/* or (pAd->ate.bQATxStart == TRUE) ??? */ && (pAd->ate.TxDoneCount == pAd->ate.TxCount))//<========================PETER
@@ -1846,7 +1846,7 @@ BOOLEAN  RTMPFreeTXDUponTxDmaDone(
 					pAd->ate.TxStatus = 0;
 				}
 				else if (!(pAd->ate.Mode & ATE_TXFRAME))
-				{ 
+				{
 					/* not complete sending yet, but someone press the Stop TX botton. */
 					DBGPRINT(RT_DEBUG_ERROR,("not complete sending yet, but someone pressed the Stop TX bottom\n"));
 					DBGPRINT(RT_DEBUG_ERROR,("pAd->ate.Mode = 0x%02x\n", pAd->ate.Mode));
@@ -1862,7 +1862,7 @@ BOOLEAN  RTMPFreeTXDUponTxDmaDone(
         		*pDestTxD = TxD;
 #endif // RT_BIG_ENDIAN //
 
-				INC_RING_INDEX(pTxRing->TxSwFreeIdx, TX_RING_SIZE); 
+				INC_RING_INDEX(pTxRing->TxSwFreeIdx, TX_RING_SIZE);
 				continue;
 			}
 		}
@@ -1874,7 +1874,7 @@ BOOLEAN  RTMPFreeTXDUponTxDmaDone(
 			NICUpdateFifoStaCounters(pAd);
 
 		/* Note : If (pAd->ate.bQATxStart == TRUE), we will never reach here. */
-		FREE++;       
+		FREE++;
 #ifndef RT_BIG_ENDIAN
                 pTxD = (PTXD_STRUC) (pTxRing->Cell[pTxRing->TxSwFreeIdx].AllocVa);
 		pOriTxD = pTxD;
@@ -1989,10 +1989,10 @@ kick_out:
 #endif // RALINK_ATE //
 	}
 
-	
+
 	return  bReschedule;
 
-}	
+}
 
 
 /*
@@ -2008,7 +2008,7 @@ kick_out:
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	========================================================================
 */
 BOOLEAN	RTMPHandleTxRingDmaDoneInterrupt(
@@ -2017,9 +2017,9 @@ BOOLEAN	RTMPHandleTxRingDmaDoneInterrupt(
 {
     unsigned long	IrqFlags;
 	BOOLEAN			bReschedule = FALSE;
-	
+
 	// Make sure Tx ring resource won't be used by other threads
-	 
+
 	RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags);
 
 	if (TxRingBitmap.field.Ac0DmaDone)
@@ -2039,7 +2039,7 @@ BOOLEAN	RTMPHandleTxRingDmaDoneInterrupt(
 
 	// Make sure to release Tx ring resource
 	RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
-	
+
 	// Dequeue outgoing frames from TxSwQueue[] and process it
 	RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
 
@@ -2060,7 +2060,7 @@ BOOLEAN	RTMPHandleTxRingDmaDoneInterrupt(
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
 
 	========================================================================
@@ -2079,7 +2079,7 @@ VOID	RTMPHandleMgmtRingDmaDoneInterrupt(
 
 	NdisAcquireSpinLock(&pAd->MgmtRingLock);
 
-	RTMP_IO_READ32(pAd, TX_MGMTDTX_IDX, &pMgmtRing->TxDmaIdx);  
+	RTMP_IO_READ32(pAd, TX_MGMTDTX_IDX, &pMgmtRing->TxDmaIdx);
 	while (pMgmtRing->TxSwFreeIdx!= pMgmtRing->TxDmaIdx)
 	{
 		FREE++;
@@ -2114,7 +2114,7 @@ VOID	RTMPHandleMgmtRingDmaDoneInterrupt(
 #ifdef RT_BIG_ENDIAN
         RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
         WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, TRUE, TYPE_TXD);
-#endif	
+#endif
 	}
 	NdisReleaseSpinLock(&pAd->MgmtRingLock);
 
@@ -2129,7 +2129,7 @@ VOID	RTMPHandleMgmtRingDmaDoneInterrupt(
 		Adapter 	Pointer to our adapter. Dequeue all power safe delayed braodcast frames after beacon.
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	========================================================================
 */
 VOID	RTMPHandleTBTTInterrupt(
@@ -2151,7 +2151,7 @@ VOID	RTMPHandleTBTTInterrupt(
 		Adapter 	Pointer to our adapter. Rewrite beacon content before next send-out.
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	========================================================================
 */
 VOID	RTMPHandlePreTBTTInterrupt(
@@ -2177,9 +2177,9 @@ VOID	RTMPHandleRxCoherentInterrupt(
 		DBGPRINT(RT_DEBUG_TRACE, ("====> pAd is NULL, return.\n"));
 		return;
 	}
-	
-	DBGPRINT(RT_DEBUG_TRACE, ("==> RTMPHandleRxCoherentInterrupt \n"));	
-	
+
+	DBGPRINT(RT_DEBUG_TRACE, ("==> RTMPHandleRxCoherentInterrupt \n"));
+
 	RTMP_IO_READ32(pAd, WPDMA_GLO_CFG , &GloCfg.word);
 
 	GloCfg.field.EnTXWriteBackDDONE = 0;
@@ -2196,8 +2196,8 @@ VOID	RTMPHandleRxCoherentInterrupt(
 	RTMPRingCleanUp(pAd, QID_RX);
 
 	RTMPEnableRxTx(pAd);
-	
-	DBGPRINT(RT_DEBUG_TRACE, ("<== RTMPHandleRxCoherentInterrupt \n"));	
+
+	DBGPRINT(RT_DEBUG_TRACE, ("<== RTMPHandleRxCoherentInterrupt \n"));
 }
 
 
@@ -2273,7 +2273,7 @@ VOID DBGPRINT_TX_RING(
 			}
 			DBGPRINT_RAW(RT_DEBUG_TRACE, ("  \n "  ));
 			break;
-			
+
 		default:
 			DBGPRINT_ERR(("DBGPRINT_TX_RING(Ring %d) not supported\n", QueIdx));
 			break;
@@ -2284,7 +2284,7 @@ VOID DBGPRINT_TX_RING(
 	DBGPRINT_RAW(RT_DEBUG_TRACE,(" 	TxSwFreeIdx[%d]", AC0freeIdx));
 	DBGPRINT_RAW(RT_DEBUG_TRACE,("	pending-NDIS=%ld\n", pAd->RalinkCounters.PendingNdisPacketCount));
 
-	
+
 }
 
 
@@ -2295,7 +2295,7 @@ VOID DBGPRINT_RX_RING(
 	UINT32		Ac0HwIdx = 0, Ac0SwIdx = 0, AC0freeIdx;
 	int			i;
 	UINT32	*ptemp;
-	
+
 	DBGPRINT_RAW(RT_DEBUG_TRACE, ("=====================================================\n "  ));
 	RTMP_IO_READ32(pAd, RX_BASE_PTR, &Ac0Base);
 	RTMP_IO_READ32(pAd, RX_CRX_IDX, &Ac0SwIdx);
@@ -2319,15 +2319,15 @@ VOID DBGPRINT_RX_RING(
 
 	Routine Description:
 		Suspend MSDU transmission
-		
+
 	Arguments:
 		pAd 	Pointer to our adapter
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-	
+
 	========================================================================
 */
 VOID	RTMPSuspendMsduTransmission(
@@ -2341,10 +2341,10 @@ VOID	RTMPSuspendMsduTransmission(
 	// use Lowbound as R66 value on ScanNextChannel(...)
 	//
 	RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &pAd->BbpTuning.R66CurrentValue);
-	
+
 	// set BBP_R66 to 0x30/0x40 when scanning (AsicSwitchChannel will set R66 according to channel when scanning)
 	RTMPSetAGCInitValue(pAd, BW_20);
-	
+
 	RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
 }
 
@@ -2354,17 +2354,17 @@ VOID	RTMPSuspendMsduTransmission(
 
 	Routine Description:
 		Resume MSDU transmission
-		
+
 	Arguments:
 		pAd 	Pointer to our adapter
-		
+
 	Return Value:
 		None
-		
+
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 VOID RTMPResumeMsduTransmission(
@@ -2384,11 +2384,11 @@ UINT deaggregate_AMSDU_announce(
 	IN	PRTMP_ADAPTER	pAd,
 	PNDIS_PACKET		pPacket,
 	IN	PUCHAR			pData,
-	IN	ULONG			DataSize)	
+	IN	ULONG			DataSize)
 {
 	USHORT 			PayloadSize;
-	USHORT 			SubFrameSize; 	
-	PHEADER_802_3 	pAMSDUsubheader;	
+	USHORT 			SubFrameSize;
+	PHEADER_802_3 	pAMSDUsubheader;
 	UINT			nMSDU;
     UCHAR			Header802_3[14];
 
@@ -2418,7 +2418,7 @@ UINT deaggregate_AMSDU_announce(
 		pDA = pData;
 		pSA = pData + MAC_ADDR_LEN;
 
-		// convert to 802.3 header 
+		// convert to 802.3 header
         CONVERT_TO_802_3(Header802_3, pDA, pSA, pPayload, PayloadSize, pRemovedLLCSNAP);
 
 #ifdef CONFIG_STA_SUPPORT
@@ -2426,8 +2426,8 @@ UINT deaggregate_AMSDU_announce(
 		{
 		    // avoid local heap overflow, use dyanamic allocation
 		   MLME_QUEUE_ELEM *Elem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-		   memmove(Elem->Msg+(LENGTH_802_11 + LENGTH_802_1_H), pPayload, PayloadSize);             
-		   Elem->MsgLen = LENGTH_802_11 + LENGTH_802_1_H + PayloadSize;             
+		   memmove(Elem->Msg+(LENGTH_802_11 + LENGTH_802_1_H), pPayload, PayloadSize);
+		   Elem->MsgLen = LENGTH_802_11 + LENGTH_802_1_H + PayloadSize;
 		   WpaEAPOLKeyAction(pAd, Elem);
 		   kfree(Elem);
 		}
@@ -2456,7 +2456,7 @@ UINT deaggregate_AMSDU_announce(
 
 
 		// A-MSDU has padding to multiple of 4 including subframe header.
-		// align SubFrameSize up to multiple of 4 
+		// align SubFrameSize up to multiple of 4
 		SubFrameSize = (SubFrameSize+3)&(~0x3);
 
 
@@ -2471,13 +2471,13 @@ UINT deaggregate_AMSDU_announce(
 			DataSize -= SubFrameSize;
 		}
 		else
-		{   
+		{
 			// end of A-MSDU
 			DataSize = 0;
 		}
 	}
-	
-	// finally release original rx packet 
+
+	// finally release original rx packet
 	RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS);
 
 	return nMSDU;
@@ -2485,14 +2485,14 @@ UINT deaggregate_AMSDU_announce(
 
 
 UINT BA_Reorder_AMSDU_Annnounce(
-	IN	PRTMP_ADAPTER	pAd, 	
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PNDIS_PACKET	pPacket)
 {
 	PUCHAR			pData;
-	USHORT			DataSize;	
+	USHORT			DataSize;
 	UINT			nMSDU = 0;
 
-	pData = (PUCHAR) GET_OS_PKT_DATAPTR(pPacket);	
+	pData = (PUCHAR) GET_OS_PKT_DATAPTR(pPacket);
 	DataSize = (USHORT) GET_OS_PKT_LEN(pPacket);
 
 	nMSDU = deaggregate_AMSDU_announce(pAd, pPacket, pData, DataSize);
@@ -2510,18 +2510,18 @@ UINT BA_Reorder_AMSDU_Annnounce(
 	==========================================================================
 */
 MAC_TABLE_ENTRY *MacTableLookup(
-	IN PRTMP_ADAPTER pAd, 
-	PUCHAR pAddr) 
+	IN PRTMP_ADAPTER pAd,
+	PUCHAR pAddr)
 {
 	ULONG HashIdx;
 	MAC_TABLE_ENTRY *pEntry = NULL;
-	
+
 	HashIdx = MAC_ADDR_HASH_INDEX(pAddr);
 	pEntry = pAd->MacTab.Hash[HashIdx];
 
 	while (pEntry && (pEntry->ValidAsCLI || pEntry->ValidAsWDS || pEntry->ValidAsApCli || pEntry->ValidAsMesh))
 	{
-		if (MAC_ADDR_EQUAL(pEntry->Addr, pAddr)) 
+		if (MAC_ADDR_EQUAL(pEntry->Addr, pAddr))
 		{
 			break;
 		}
@@ -2533,17 +2533,17 @@ MAC_TABLE_ENTRY *MacTableLookup(
 }
 
 MAC_TABLE_ENTRY *MacTableInsertEntry(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  PUCHAR			pAddr,
 	IN	UCHAR			apidx,
-	IN BOOLEAN	CleanAll) 
+	IN BOOLEAN	CleanAll)
 {
 	UCHAR HashIdx;
 	int i, FirstWcid;
 	MAC_TABLE_ENTRY *pEntry = NULL, *pCurrEntry;
 
 	// if FULL, return
-	if (pAd->MacTab.Size >= MAX_LEN_OF_MAC_TABLE) 
+	if (pAd->MacTab.Size >= MAX_LEN_OF_MAC_TABLE)
 		return NULL;
 
 	FirstWcid = 1;
@@ -2558,7 +2558,7 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
 	for (i = FirstWcid; i< MAX_LEN_OF_MAC_TABLE; i++)   // skip entry#0 so that "entry index == AID" for fast lookup
 	{
 		// pick up the first available vacancy
-		if ((pAd->MacTab.Content[i].ValidAsCLI == FALSE) && 
+		if ((pAd->MacTab.Content[i].ValidAsCLI == FALSE) &&
 			(pAd->MacTab.Content[i].ValidAsWDS == FALSE) &&
 			(pAd->MacTab.Content[i].ValidAsApCli== FALSE) &&
 			(pAd->MacTab.Content[i].ValidAsMesh == FALSE)
@@ -2594,7 +2594,7 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
 #endif // CONFIG_STA_SUPPORT //
 			{
 
-#ifdef CONFIG_STA_SUPPORT	
+#ifdef CONFIG_STA_SUPPORT
 				IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 				{
 					pEntry->ValidAsCLI = TRUE;
@@ -2631,7 +2631,7 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
 
 			{
 
-#ifdef CONFIG_STA_SUPPORT	
+#ifdef CONFIG_STA_SUPPORT
 				IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 				{
 					pEntry->AuthMode = pAd->StaCfg.AuthMode;
@@ -2655,7 +2655,7 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
 #ifdef QOS_DLS_SUPPORT
 			if (pEntry->ValidAsDls == TRUE)
 				pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
-			else 
+			else
 #endif //QOS_DLS_SUPPORT
 #endif // CONFIG_STA_SUPPORT //
 			pEntry->PortSecured = WPA_802_1X_PORT_NOT_SECURED;
@@ -2711,9 +2711,9 @@ MAC_TABLE_ENTRY *MacTableInsertEntry(
 	==========================================================================
  */
 BOOLEAN MacTableDeleteEntry(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN USHORT wcid,
-	IN PUCHAR pAddr) 
+	IN PUCHAR pAddr)
 {
 	USHORT HashIdx;
 	MAC_TABLE_ENTRY *pEntry, *pPrevEntry, *pProbeEntry;
@@ -2778,9 +2778,9 @@ BOOLEAN MacTableDeleteEntry(
 
 
 		if (pEntry->EnqueueEapolStartTimerRunning != EAPOL_START_DISABLE)
-		{                
+		{
 			RTMPCancelTimer(&pEntry->EnqueueStartForPSKTimer, &Cancelled);
-			pEntry->EnqueueEapolStartTimerRunning = EAPOL_START_DISABLE;             
+			pEntry->EnqueueEapolStartTimerRunning = EAPOL_START_DISABLE;
 		}
 
 
@@ -2854,16 +2854,16 @@ VOID MacTableReset(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID AssocParmFill(
-	IN PRTMP_ADAPTER pAd, 
-	IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq, 
-	IN PUCHAR                     pAddr, 
-	IN USHORT                     CapabilityInfo, 
-	IN ULONG                      Timeout, 
-	IN USHORT                     ListenIntv) 
+	IN PRTMP_ADAPTER pAd,
+	IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq,
+	IN PUCHAR                     pAddr,
+	IN USHORT                     CapabilityInfo,
+	IN ULONG                      Timeout,
+	IN USHORT                     ListenIntv)
 {
 	COPY_MAC_ADDR(AssocReq->Addr, pAddr);
 	// Add mask to support 802.11b mode only
@@ -2878,14 +2878,14 @@ VOID AssocParmFill(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID DisassocParmFill(
-	IN PRTMP_ADAPTER pAd, 
-	IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq, 
-	IN PUCHAR pAddr, 
-	IN USHORT Reason) 
+	IN PRTMP_ADAPTER pAd,
+	IN OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq,
+	IN PUCHAR pAddr,
+	IN USHORT Reason)
 {
 	COPY_MAC_ADDR(DisassocReq->Addr, pAddr);
 	DisassocReq->Reason = Reason;
@@ -2898,49 +2898,49 @@ VOID DisassocParmFill(
 	Routine Description:
 		Check the out going frame, if this is an DHCP or ARP datagram
 	will be duplicate another frame at low data rate transmit.
-		
+
 	Arguments:
 		pAd 		Pointer to our adapter
 		pPacket 	Pointer to outgoing Ndis frame
-		
-	Return Value:		
+
+	Return Value:
 		TRUE		To be duplicate at Low data rate transmit. (1mb)
 		FALSE		Do nothing.
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
 
 		MAC header + IP Header + UDP Header
 		  14 Bytes	  20 Bytes
-		  
+
 		UDP Header
 		00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|
 						Source Port
 		16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|
 					Destination Port
 
-		port 0x43 means Bootstrap Protocol, server. 
-		Port 0x44 means Bootstrap Protocol, client. 
+		port 0x43 means Bootstrap Protocol, server.
+		Port 0x44 means Bootstrap Protocol, client.
 
 	========================================================================
 */
 
 BOOLEAN RTMPCheckDHCPFrame(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PNDIS_PACKET	pPacket)
 {
 	PACKET_INFO 	PacketInfo;
 	ULONG			NumberOfBytesRead = 0;
-	ULONG			CurrentOffset = 0;	
-	PVOID			pVirtualAddress = NULL; 
+	ULONG			CurrentOffset = 0;
+	PVOID			pVirtualAddress = NULL;
 	UINT			NdisBufferLength;
 	PUCHAR			pSrc;
-	USHORT			Protocol;	
+	USHORT			Protocol;
 	UCHAR			ByteOffset36 = 0;
 	UCHAR			ByteOffset38 = 0;
 	BOOLEAN 		ReadFirstParm = TRUE;
-		
+
 	RTMP_QueryPacketInfo(pPacket, &PacketInfo, (PUCHAR *)&pVirtualAddress, &NdisBufferLength);
 
 	NumberOfBytesRead += NdisBufferLength;
@@ -2954,25 +2954,25 @@ BOOLEAN RTMPCheckDHCPFrame(
 	{
 		if ((NumberOfBytesRead >= 35) && (ReadFirstParm == TRUE))
 		{
-			CurrentOffset = 35 - (NumberOfBytesRead - NdisBufferLength); 
+			CurrentOffset = 35 - (NumberOfBytesRead - NdisBufferLength);
 			ByteOffset36 = *(pSrc + CurrentOffset);
 			ReadFirstParm = FALSE;
 		}
-		
+
 		if (NumberOfBytesRead >= 37)
 		{
-			CurrentOffset = 37 - (NumberOfBytesRead - NdisBufferLength); 
+			CurrentOffset = 37 - (NumberOfBytesRead - NdisBufferLength);
 			ByteOffset38 = *(pSrc + CurrentOffset);
 			//End of Read
-			break; 
+			break;
 		}
 		return FALSE;
 	}
 
 	// Check for DHCP & BOOTP protocol
 	if ((ByteOffset36 != 0x44) || (ByteOffset38 != 0x43))
-		{			
-		// 
+		{
+		//
 		// 2054 (hex 0806) for ARP datagrams
 		// if this packet is not ARP datagrams, then do nothing
 		// ARP datagrams will also be duplicate at 1mb broadcast frames
@@ -2986,7 +2986,7 @@ BOOLEAN RTMPCheckDHCPFrame(
 
 
 BOOLEAN RTMPCheckEtherType(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PNDIS_PACKET	pPacket)
 {
 	USHORT	TypeLen;
@@ -2996,23 +2996,23 @@ BOOLEAN RTMPCheckEtherType(
 	UINT16 	srcPort, dstPort;
 	BOOLEAN	status = TRUE;
 
-					
+
 	pSrcBuf = GET_OS_PKT_DATAPTR(pPacket);
 	pktLen = GET_OS_PKT_LEN(pPacket);
 
 	ASSERT(pSrcBuf);
 
 	RTMP_SET_PACKET_SPECIFIC(pPacket, 0);
-	
+
 	// get Ethernet protocol field
 	TypeLen = (pSrcBuf[12] << 8) + pSrcBuf[13];
 
 	pSrcBuf += LENGTH_802_3;	// Skip the Ethernet Header.
-	
+
 	if (TypeLen <= 1500)
 	{	// 802.3, 802.3 LLC
 		/*
-			DestMAC(6) + SrcMAC(6) + Lenght(2) + 
+			DestMAC(6) + SrcMAC(6) + Lenght(2) +
 			DSAP(1) + SSAP(1) + Control(1) +
 			if the DSAP = 0xAA, SSAP=0xAA, Contorl = 0x03, it has a 5-bytes SNAP header.
 				=> + SNAP (5, OriginationID(3) + etherType(2))
@@ -3029,7 +3029,7 @@ BOOLEAN RTMPCheckEtherType(
 			//It just has 3-byte LLC header, maybe a legacy ether type frame. we didn't handle it.
 		}
 	}
-	
+
 	// If it's a VLAN packet, get the real Type/Length field.
 	if (TypeLen == 0x8100)
 	{
@@ -3043,7 +3043,7 @@ BOOLEAN RTMPCheckEtherType(
 		   data payload (0-n bytes) +
 		   Pad (0-p bytes) +
 		   Frame Check Sequence (4-bytes) */
-				   
+
 		RTMP_SET_PACKET_VLAN(pPacket, 1);
 		Sniff2BytesFromNdisBuffer(pSrcBuf, 2, &Byte0, &Byte1);
 		TypeLen = (USHORT)((Byte0 << 8) + Byte1);
@@ -3056,15 +3056,15 @@ BOOLEAN RTMPCheckEtherType(
 		case 0x0800:
 			{
 				ASSERT((pktLen > 34));
-				if (*(pSrcBuf + 9) == 0x11) 
+				if (*(pSrcBuf + 9) == 0x11)
 				{	// udp packet
 					ASSERT((pktLen > 34));	// 14 for ethernet header, 20 for IP header
-					
+
 					pSrcBuf += 20;	// Skip the IP header
 					srcPort = OS_NTOHS(*((UINT16 *)pSrcBuf));
 					dstPort = OS_NTOHS(*((UINT16 *)(pSrcBuf +2)));
-		
-					if ((srcPort==0x44 && dstPort==0x43) || (srcPort==0x43 && dstPort==0x44)) 
+
+					if ((srcPort==0x44 && dstPort==0x43) || (srcPort==0x43 && dstPort==0x44))
 					{	//It's a BOOTP/DHCP packet
 						RTMP_SET_PACKET_DHCP(pPacket, 1);
 					}
@@ -3074,7 +3074,7 @@ BOOLEAN RTMPCheckEtherType(
 		case 0x0806:
 			{
 				//ARP Packet.
-				RTMP_SET_PACKET_DHCP(pPacket, 1);	
+				RTMP_SET_PACKET_DHCP(pPacket, 1);
 			}
 			break;
 		case 0x888e:
@@ -3089,7 +3089,7 @@ BOOLEAN RTMPCheckEtherType(
 	}
 
 	return status;
-	
+
 }
 
 
@@ -3111,7 +3111,7 @@ VOID Update_Rssi_Sample(
 	}
 
 	if (rssi1 != 0)
-	{   
+	{
 		pRssi->LastRssi1	= ConvertToRssi(pAd, (CHAR)rssi1, RSSI_1);
 		pRssi->AvgRssi1X8	= (pRssi->AvgRssi1X8 - pRssi->AvgRssi1) + pRssi->LastRssi1;
 		pRssi->AvgRssi1	= pRssi->AvgRssi1X8 >> 3;
@@ -3137,8 +3137,8 @@ VOID Indicate_Legacy_Packet(
 	UCHAR			Header802_3[LENGTH_802_3];
 
 	// 1. get 802.3 Header
-	// 2. remove LLC 
-	// 		a. pointer pRxBlk->pData to payload 
+	// 2. remove LLC
+	// 		a. pointer pRxBlk->pData to payload
 	//      b. modify pRxBlk->DataSize
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
@@ -3159,7 +3159,7 @@ VOID Indicate_Legacy_Packet(
 
 	wlan_802_11_to_802_3_packet(pAd, pRxBlk, Header802_3, FromWhichBSSID);
 
-	// 
+	//
 	// pass this 802.3 packet to upper layer or forward this packet to WM directly
 	//
 #ifdef CONFIG_STA_SUPPORT
@@ -3177,22 +3177,22 @@ VOID CmmRxnonRalinkFrameIndicate(
 	IN	UCHAR			FromWhichBSSID)
 {
 #ifdef DOT11_N_SUPPORT
-	if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU) && (pAd->CommonCfg.bDisableReordering == 0)) 
+	if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU) && (pAd->CommonCfg.bDisableReordering == 0))
 	{
 		Indicate_AMPDU_Packet(pAd, pRxBlk, FromWhichBSSID);
-	} 
-	else 
+	}
+	else
 #endif // DOT11_N_SUPPORT //
 	{
 #ifdef DOT11_N_SUPPORT
 		if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMSDU))
-		{  
+		{
 			// handle A-MSDU
 			Indicate_AMSDU_Packet(pAd, pRxBlk, FromWhichBSSID);
 		}
 		else
 #endif // DOT11_N_SUPPORT //
-		{						 
+		{
 			Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
 		}
 	}
@@ -3237,7 +3237,7 @@ VOID CmmRxRalinkFrameIndicate(
 
 	ASSERT(pRxBlk->pRxPacket);
 
-	// Ralink Aggregation frame	
+	// Ralink Aggregation frame
 	pAd->RalinkCounters.OneSecRxAggregationCount ++;
 	Payload1Size = pRxBlk->DataSize - Msdu2Size;
 	Payload2Size = Msdu2Size - LENGTH_802_3;
@@ -3343,20 +3343,20 @@ PNDIS_PACKET RTMPDeFragmentDataFrame(
 		//
 		if (NdisEqualMemory(pData, SNAP_802_1H, sizeof(SNAP_802_1H)))
 		{
-			DBGPRINT(RT_DEBUG_ERROR, ("Find another LLC at Middle or End fragment(SN=%d, Frag=%d)\n", pHeader->Sequence, pHeader->Frag));	
-			goto done; // give up this frame					
+			DBGPRINT(RT_DEBUG_ERROR, ("Find another LLC at Middle or End fragment(SN=%d, Frag=%d)\n", pHeader->Sequence, pHeader->Frag));
+			goto done; // give up this frame
 		}
 
 		pFragBuffer = GET_OS_PKT_DATAPTR(pAd->FragFrame.pFragPacket);
 
-		// concatenate this fragment into the re-assembly buffer			
+		// concatenate this fragment into the re-assembly buffer
 		NdisMoveMemory((pFragBuffer + pAd->FragFrame.RxSize), pData, DataSize);
 		pAd->FragFrame.RxSize  += DataSize;
 		pAd->FragFrame.LastFrag = pHeader->Frag;	   // Update fragment number
 
 		// Last fragment
 		if (pHeader->FC.MoreFrag == FALSE)
-		{           
+		{
 			bReassDone = TRUE;
 		}
 	}
@@ -3409,10 +3409,10 @@ VOID Indicate_EAPOL_Packet(
 	IN	PRTMP_ADAPTER	pAd,
 	IN	RX_BLK			*pRxBlk,
 	IN	UCHAR			FromWhichBSSID)
-{		
+{
 	MAC_TABLE_ENTRY *pEntry = NULL;
 
-	
+
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 	{
@@ -3427,14 +3427,14 @@ VOID Indicate_EAPOL_Packet(
 		DBGPRINT(RT_DEBUG_WARN, ("Indicate_EAPOL_Packet: drop and release the invalid packet.\n"));
 		// release packet
 		RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
-		return;		
-	}				
+		return;
+	}
 }
 
 #define BCN_TBTT_OFFSET		64	//defer 64 us
 VOID ReSyncBeaconTime(
 	IN  PRTMP_ADAPTER   pAd)
-{	
+{
 
 	UINT32  Offset;
 
@@ -3446,7 +3446,7 @@ VOID ReSyncBeaconTime(
 	//
 	// The updated BeaconInterval Value will affect Beacon Interval after two TBTT
 	// beacasue the original BeaconInterval had been loaded into next TBTT_TIMER
-	// 
+	//
 	if (Offset == (BCN_TBTT_OFFSET-2))
 	{
 		BCN_TIME_CFG_STRUC csr;
diff --git a/common/cmm_data_2860.c b/common/cmm_data_2860.c
index 2c3c0a3..4f414ed 100644
--- a/common/cmm_data_2860.c
+++ b/common/cmm_data_2860.c
@@ -7,30 +7,30 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
-*/ 
+*/
 
 /*
    All functions in this file must be PCI-depended, or you should out your function
 	in other files.
 
 */
-#include	"rt_config.h"
+#include "../rt_config.h"
 
 extern RTMP_RF_REGS RF2850RegTable[];
 extern UCHAR	NUM_OF_2850_CHNL;
@@ -51,7 +51,7 @@ USHORT RtmpPCI_WriteTxResource(
 
 	//
 	// get Tx Ring Resource
-	// 
+	//
 	pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
 	TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx;
 	pDMAHeaderBufVA = (PUCHAR) pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
@@ -73,7 +73,7 @@ USHORT RtmpPCI_WriteTxResource(
 
 	//
 	// build Tx Descriptor
-	// 
+	//
 
 	pTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
 	NdisZeroMemory(pTxD, TXD_SIZE);
@@ -90,7 +90,7 @@ USHORT RtmpPCI_WriteTxResource(
 	RetTxIdx = TxIdx;
 	//
 	// Update Tx index
-	// 
+	//
 	INC_RING_INDEX(TxIdx, TX_RING_SIZE);
 	pTxRing->TxCpuIdx = TxIdx;
 
@@ -115,12 +115,12 @@ USHORT RtmpPCI_WriteSingleTxResource(
     TXD_STRUC       TxD;
 #endif
 	UINT32			BufBasePaLow;
-	PRTMP_TX_RING	pTxRing;	
+	PRTMP_TX_RING	pTxRing;
 	USHORT			hwHeaderLen;
 
 	//
 	// get Tx Ring Resource
-	// 
+	//
 	pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
 	TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx;
 	pDMAHeaderBufVA = (PUCHAR) pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
@@ -136,7 +136,7 @@ USHORT RtmpPCI_WriteSingleTxResource(
 
 	//
 	// build Tx Descriptor
-	// 
+	//
 #ifndef RT_BIG_ENDIAN
 	pTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
 #else
@@ -158,13 +158,13 @@ USHORT RtmpPCI_WriteSingleTxResource(
 	RTMPWIEndianChange((PUCHAR)(pDMAHeaderBufVA + TXINFO_SIZE), TYPE_TXWI);
 	RTMPFrameEndianChange(pAd, (PUCHAR)(pDMAHeaderBufVA + TXINFO_SIZE + TXWI_SIZE), DIR_WRITE, FALSE);
 	RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-    WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);	
+    WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
 #endif // RT_BIG_ENDIAN //
 
 	RetTxIdx = TxIdx;
 	//
 	// Update Tx index
-	// 
+	//
 	INC_RING_INDEX(TxIdx, TX_RING_SIZE);
 	pTxRing->TxCpuIdx = TxIdx;
 
@@ -189,15 +189,15 @@ USHORT RtmpPCI_WriteMultiTxResource(
     TXD_STRUC       TxD;
 #endif
 	UINT32			BufBasePaLow;
-	PRTMP_TX_RING	pTxRing;	
+	PRTMP_TX_RING	pTxRing;
 	USHORT			hwHdrLen;
 	UINT32			firstDMALen;
 
-	bIsLast = ((frameNum == (pTxBlk->TotalFrameNum - 1)) ? 1 : 0);		
+	bIsLast = ((frameNum == (pTxBlk->TotalFrameNum - 1)) ? 1 : 0);
 
 	//
 	// get Tx Ring Resource
-	// 
+	//
 	pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
 	TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx;
 	pDMAHeaderBufVA = (PUCHAR) pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
@@ -223,14 +223,14 @@ USHORT RtmpPCI_WriteMultiTxResource(
 		firstDMALen = pTxBlk->MpduHeaderLen;
 	}
 
-	NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, firstDMALen); 
-		
+	NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, firstDMALen);
+
 	pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket;
 	pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
-	
+
 	//
 	// build Tx Descriptor
-	// 
+	//
 #ifndef RT_BIG_ENDIAN
 	pTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
 #else
@@ -252,25 +252,25 @@ USHORT RtmpPCI_WriteMultiTxResource(
 #ifdef RT_BIG_ENDIAN
 	if (frameNum == 0)
 		RTMPFrameEndianChange(pAd, (PUCHAR)(pDMAHeaderBufVA+ TXINFO_SIZE + TXWI_SIZE), DIR_WRITE, FALSE);
-	
+
 	if (frameNum != 0)
 		RTMPWIEndianChange((PUCHAR)(pDMAHeaderBufVA + TXINFO_SIZE), TYPE_TXWI);
-	
+
 	RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
 	WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
 #endif // RT_BIG_ENDIAN //
-	
+
 	RetTxIdx = TxIdx;
 	//
 	// Update Tx index
-	// 
+	//
 	INC_RING_INDEX(TxIdx, TX_RING_SIZE);
 	pTxRing->TxCpuIdx = TxIdx;
 
 	*FreeNumber -= 1;
 
 	return RetTxIdx;
-	
+
 }
 
 
@@ -286,7 +286,7 @@ VOID RtmpPCI_FinalWriteTxResource(
 
 	//
 	// get Tx Ring Resource
-	// 
+	//
 	pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
 	pTxWI = (PTXWI_STRUC) pTxRing->Cell[FirstTxIdx].DmaBuf.AllocVa;
 	pTxWI->MPDUtotalByteCount = totalMPDUSize;
@@ -311,12 +311,12 @@ VOID RtmpPCIDataLastTxIdx(
 
 	//
 	// get Tx Ring Resource
-	// 
+	//
 	pTxRing = &pAd->TxRing[QueIdx];
 
 	//
 	// build Tx Descriptor
-	// 
+	//
 #ifndef RT_BIG_ENDIAN
 	pTxD = (PTXD_STRUC) pTxRing->Cell[LastTxIdx].AllocVa;
 #else
@@ -355,7 +355,7 @@ USHORT	RtmpPCI_WriteFragTxResource(
 
 	//
 	// Get Tx Ring Resource
-	// 
+	//
 	pTxRing = &pAd->TxRing[pTxBlk->QueIdx];
 	TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx;
 	pDMAHeaderBufVA = (PUCHAR) pTxRing->Cell[TxIdx].DmaBuf.AllocVa;
@@ -367,12 +367,12 @@ USHORT	RtmpPCI_WriteFragTxResource(
 	hwHeaderLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen;
 
 	firstDMALen = TXINFO_SIZE + TXWI_SIZE + hwHeaderLen;
-	NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, firstDMALen); 
-		
+	NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, firstDMALen);
+
 
 	//
 	// Build Tx Descriptor
-	// 
+	//
 #ifndef RT_BIG_ENDIAN
 	pTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
 #else
@@ -380,14 +380,14 @@ USHORT	RtmpPCI_WriteFragTxResource(
 	TxD = *pDestTxD;
 	pTxD = &TxD;
 #endif
-	NdisZeroMemory(pTxD, TXD_SIZE);	
-	
+	NdisZeroMemory(pTxD, TXD_SIZE);
+
 	if (fragNum == pTxBlk->TotalFragNum)
 	{
 		pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket;
 		pTxRing->Cell[TxIdx].pNextNdisPacket = NULL;
 	}
-	
+
 	pTxD->SDPtr0 = BufBasePaLow;
 	pTxD->SDLen0 = firstDMALen; // include padding
 	pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE);
@@ -401,22 +401,22 @@ USHORT	RtmpPCI_WriteFragTxResource(
 	RTMPWIEndianChange((PUCHAR)(pDMAHeaderBufVA + TXINFO_SIZE), TYPE_TXWI);
 	RTMPFrameEndianChange(pAd, (PUCHAR)(pDMAHeaderBufVA + TXINFO_SIZE + TXWI_SIZE), DIR_WRITE, FALSE);
 	RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
-    WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);	
+    WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
 #endif // RT_BIG_ENDIAN //
 
 	RetTxIdx = TxIdx;
 	pTxBlk->Priv += pTxBlk->SrcBufLen;
-	
+
 	//
 	// Update Tx index
-	// 
+	//
 	INC_RING_INDEX(TxIdx, TX_RING_SIZE);
 	pTxRing->TxCpuIdx = TxIdx;
 
 	*FreeNumber -= 1;
 
 	return RetTxIdx;
-	
+
 }
 
 /*
@@ -424,7 +424,7 @@ USHORT	RtmpPCI_WriteFragTxResource(
 	This function handle PCI specific TxDesc and cpu index update and kick the packet out.
  */
 int RtmpPCIMgmtKickOut(
-	IN RTMP_ADAPTER 	*pAd, 
+	IN RTMP_ADAPTER 	*pAd,
 	IN UCHAR 			QueIdx,
 	IN PNDIS_PACKET		pPacket,
 	IN PUCHAR			pSrcBufVA,
@@ -436,7 +436,7 @@ int RtmpPCIMgmtKickOut(
     TXD_STRUC       TxD;
 #endif
 	ULONG			SwIdx = pAd->MgmtRing.TxCpuIdx;
-	
+
 #ifdef RT_BIG_ENDIAN
     pDestTxD  = (PTXD_STRUC)pAd->MgmtRing.Cell[SwIdx].AllocVa;
     TxD = *pDestTxD;
@@ -447,12 +447,12 @@ int RtmpPCIMgmtKickOut(
 #endif
 
 	pAd->MgmtRing.Cell[SwIdx].pNdisPacket = pPacket;
-	pAd->MgmtRing.Cell[SwIdx].pNextNdisPacket = NULL;	
-	
+	pAd->MgmtRing.Cell[SwIdx].pNextNdisPacket = NULL;
+
 	RTMPWriteTxDescriptor(pAd, pTxD, TRUE, FIFO_MGMT);
 	pTxD->LastSec0 = 1;
 	pTxD->LastSec1 = 1;
-	pTxD->DMADONE = 0;	
+	pTxD->DMADONE = 0;
 	pTxD->SDLen1 = 0;
 	pTxD->SDPtr0 = PCI_MAP_SINGLE(pAd, pSrcBufVA, SrcBufLen, 0, PCI_DMA_TODEVICE);;
 	pTxD->SDLen0 = SrcBufLen;
@@ -461,7 +461,7 @@ int RtmpPCIMgmtKickOut(
 	RTMPDescriptorEndianChange((PUCHAR)pTxD, TYPE_TXD);
     WriteBackToDescriptor((PUCHAR)pDestTxD, (PUCHAR)pTxD, FALSE, TYPE_TXD);
 #endif
-	
+
 	pAd->RalinkCounters.KickTxCount++;
 	pAd->RalinkCounters.OneSecTxDoneCount++;
 
@@ -480,27 +480,27 @@ int RtmpPCIMgmtKickOut(
 
 	Routine Description:
 		Check Rx descriptor, return NDIS_STATUS_FAILURE if any error dound
-		
+
 	Arguments:
 		pRxD		Pointer to the Rx descriptor
-		
+
 	Return Value:
 		NDIS_STATUS_SUCCESS 	No err
 		NDIS_STATUS_FAILURE 	Error
-		
+
 	Note:
-	
+
 	========================================================================
 */
 NDIS_STATUS RTMPCheckRxError(
-	IN	PRTMP_ADAPTER		pAd, 
+	IN	PRTMP_ADAPTER		pAd,
 	IN	PHEADER_802_11		pHeader,
 	IN	PRXWI_STRUC 		pRxWI,
 	IN  PRT28XX_RXD_STRUC 	pRxD)
 {
 	PCIPHER_KEY pWpaKey;
 	INT dBm;
-	
+
 	// Phy errors & CRC errors
 	if (/*(pRxD->PhyErr) ||*/ (pRxD->Crc))
 	{
@@ -522,10 +522,10 @@ NDIS_STATUS RTMPCheckRxError(
 			pAd->StaCfg.RPIDensity[6] += 1;
 		else if (dBm > -57)
 			pAd->StaCfg.RPIDensity[7] += 1;
-		
+
 		return(NDIS_STATUS_FAILURE);
 	}
-		
+
 	// Add Rx size to channel load counter, we should ignore error counts
 	pAd->StaCfg.CLBusyBytes += (pRxD->SDL0 + 14);
 
@@ -552,30 +552,30 @@ NDIS_STATUS RTMPCheckRxError(
 			{DBGPRINT_RAW(RT_DEBUG_TRACE,("pRxD ERROR: ICV Err "));}
 		else if (pRxD->CipherErr == 3)
 			DBGPRINT_RAW(RT_DEBUG_TRACE,("pRxD ERROR: Key not valid "));
-		
+
         if (((pRxD->CipherErr & 1) == 1) && pAd->CommonCfg.bWirelessEvent && INFRA_ON(pAd))
-            RTMPSendWirelessEvent(pAd, IW_ICV_ERROR_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); 
-        
-		DBGPRINT_RAW(RT_DEBUG_TRACE,(" %d (len=%d, Mcast=%d, MyBss=%d, Wcid=%d, KeyId=%d)\n", 
+            RTMPSendWirelessEvent(pAd, IW_ICV_ERROR_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
+
+		DBGPRINT_RAW(RT_DEBUG_TRACE,(" %d (len=%d, Mcast=%d, MyBss=%d, Wcid=%d, KeyId=%d)\n",
 			pRxD->CipherErr,
-			pRxD->SDL0, 
+			pRxD->SDL0,
 			pRxD->Mcast | pRxD->Bcast,
-			pRxD->MyBss, 
-			pRxWI->WirelessCliID, 
+			pRxD->MyBss,
+			pRxWI->WirelessCliID,
 			pRxWI->KeyIndex));
 
 		//
 		// MIC Error
 		//
 		if (pRxD->CipherErr == 2)
-		{			
+		{
 			pWpaKey = &pAd->SharedKey[BSS0][pRxWI->KeyIndex];
-#ifdef WPA_SUPPLICANT_SUPPORT                                    
+#ifdef WPA_SUPPLICANT_SUPPORT
             if (pAd->StaCfg.WpaSupplicantUP)
-                WpaSendMicFailureToWpaSupplicant(pAd, 
+                WpaSendMicFailureToWpaSupplicant(pAd,
                                    (pWpaKey->Type == PAIRWISEKEY) ? TRUE:FALSE);
             else
-#endif // WPA_SUPPLICANT_SUPPORT //                             
+#endif // WPA_SUPPLICANT_SUPPORT //
 			    RTMPReportMicError(pAd, pWpaKey);
 
             if (((pRxD->CipherErr & 2) == 2) && pAd->CommonCfg.bWirelessEvent && INFRA_ON(pAd))
@@ -583,13 +583,13 @@ NDIS_STATUS RTMPCheckRxError(
 
 			DBGPRINT_RAW(RT_DEBUG_ERROR,("Rx MIC Value error\n"));
 		}
-		
+
 		if (pHeader == NULL)
 			return(NDIS_STATUS_SUCCESS);
-		
+
 		return(NDIS_STATUS_FAILURE);
 	}
-	
+
 	return(NDIS_STATUS_SUCCESS);
 }
 
@@ -600,15 +600,15 @@ NDIS_STATUS RTMPCheckRxError(
 		Both RadioOff and .11 power save function needs to call this routine.
 	Input:
 		Level = GUIRADIO_OFF  : GUI Radio Off mode
-		Level = DOT11POWERSAVE  : 802.11 power save mode 
-		Level = RTMP_HALT  : When Disable device. 
-		
+		Level = DOT11POWERSAVE  : 802.11 power save mode
+		Level = RTMP_HALT  : When Disable device.
+
 	==========================================================================
  */
 VOID RT28xxPciAsicRadioOff(
 	IN PRTMP_ADAPTER    pAd,
-	IN UCHAR            Level, 
-	IN USHORT           TbttNumToNextWakeUp) 
+	IN UCHAR            Level,
+	IN USHORT           TbttNumToNextWakeUp)
 {
 	WPDMA_GLO_CFG_STRUC	DmaCfg;
 	UCHAR		i, tempBBP_R3 = 0;
@@ -662,13 +662,13 @@ VOID RT28xxPciAsicRadioOff(
 	            BeaconPeriodTime = pAd->CommonCfg.BeaconPeriod*102/100;
 				if (TbttNumToNextWakeUp > 0)
 					PsPollTime += ((TbttNumToNextWakeUp -1) * BeaconPeriodTime);
-	            
+
 	            pAd->Mlme.bPsPollTimerRunning = TRUE;
 				RTMPSetTimer(&pAd->Mlme.PsPollTimer, PsPollTime);
 			}
 		}
 	}
-    
+
     // 0. Disable Tx DMA.
 	RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &DmaCfg.word);
 	DmaCfg.field.EnableTxDMA = 0;
@@ -696,49 +696,49 @@ VOID RT28xxPciAsicRadioOff(
 	}
 
     RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
-    
+
     // Set to 1R.
     tempBBP_R3 = (pAd->StaCfg.BBPR3 & 0xE7);
 	RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, tempBBP_R3);
-    
+
 	// In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again.
-	if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel) 
+	if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
 		&& (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
-	{	
+	{
 		// Must using 40MHz.
 		AsicTurnOffRFClk(pAd, pAd->CommonCfg.CentralChannel);
 	}
 	else
-	{	
+	{
 		// Must using 20MHz.
 		AsicTurnOffRFClk(pAd, pAd->CommonCfg.Channel);
 	}
 
     // When PCI clock is off, don't want to service interrupt.
 	RTMP_IO_WRITE32(pAd, INT_MASK_CSR, AutoWakeupInt);
-    
+
     RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx);
 	// Disable MAC Rx
 	RTMP_IO_READ32(pAd, MAC_SYS_CTRL , &MACValue);
 	MACValue &= 0xf7;
 	RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL , MACValue);
-    
-	//  2. Send Sleep command 
+
+	//  2. Send Sleep command
 	RTMP_IO_WRITE32(pAd, H2M_MAILBOX_STATUS, 0xffffffff);
-	RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CID, 0xffffffff);    
+	RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CID, 0xffffffff);
 	AsicSendCommandToMcu(pAd, 0x30, PowerSafeCID, 0xff, 0x00);   // send POWER-SAVE command to MCU. Timeout unit:40us.
 	//  2-1. Wait command success
 	// Status = 1 : success, Status = 2, already sleep, Status = 3, Maybe MAC is busy so can't finish this task.
-	brc = AsicCheckCommanOk(pAd, PowerSafeCID);	
+	brc = AsicCheckCommanOk(pAd, PowerSafeCID);
 
     if (brc == FALSE)
     {
         // try again
     	AsicSendCommandToMcu(pAd, 0x30, PowerSafeCID, 0xff, 0x00);   // send POWER-SAVE command to MCU. Timeout unit:40us.
     	//RTMPusecDelay(200);
-    	brc = AsicCheckCommanOk(pAd, PowerSafeCID);	
+    	brc = AsicCheckCommanOk(pAd, PowerSafeCID);
     }
-	
+
 	//  3. After 0x30 command is ok, send radio off command. lowbyte = 0 for power safe.
 	// If 0x30 command is not ok this time, we can ignore 0x35 command. It will make sure not cause firmware'r problem.
 	if ((Level == DOT11POWERSAVE) && (brc == TRUE))
@@ -775,12 +775,12 @@ VOID RT28xxPciAsicRadioOff(
 		DmaCfg.field.EnableRxDMA = 0;
 		RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, DmaCfg.word);
 	}
-    
+
 	if (Level == DOT11POWERSAVE)
 	{
 		AUTO_WAKEUP_STRUC	AutoWakeupCfg;
 		//RTMPSetTimer(&pAd->Mlme.PsPollTimer, 90);
-			
+
 		// we have decided to SLEEP, so at least do it for a BEACON period.
 		if (TbttNumToNextWakeUp == 0)
 			TbttNumToNextWakeUp = 1;
@@ -794,7 +794,7 @@ VOID RT28xxPciAsicRadioOff(
 		AutoWakeupCfg.field.AutoLeadTime = LEAD_TIME;
 		RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
 	}
-	
+
 	//  4-1. If it's to disable our device. Need to restore PCI Configuration Space to its original value.
 	if (Level == RTMP_HALT)
 	{
@@ -828,7 +828,7 @@ BOOLEAN RT28xxPciAsicRadioOn(
 	IN UCHAR     Level)
 {
     WPDMA_GLO_CFG_STRUC	DmaCfg;
-	BOOLEAN				Cancelled, brv = TRUE;   
+	BOOLEAN				Cancelled, brv = TRUE;
     UINT32			    MACValue;
 
 	if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
@@ -843,19 +843,19 @@ BOOLEAN RT28xxPciAsicRadioOn(
 			RTMPusecDelay(6000);
 		}
 	}
-    
+
     pAd->bPCIclkOff = FALSE;
-    
+
 	// 2. Send wake up command.
 	AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x00);
-    
+
 	// 2-1. wait command ok.
-	brv = AsicCheckCommanOk(pAd, PowerWakeCID);	
+	brv = AsicCheckCommanOk(pAd, PowerWakeCID);
     if (brv)
     {
     	//RTMP_IO_WRITE32(pAd, INT_MASK_CSR, (DELAYINTMASK|RxINT));
     	NICEnableInterrupt(pAd);
-        
+
     	// 3. Enable Tx DMA.
     	RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &DmaCfg.word);
     	DmaCfg.field.EnableTxDMA = 1;
@@ -871,15 +871,15 @@ BOOLEAN RT28xxPciAsicRadioOn(
     	if (Level == GUI_IDLE_POWER_SAVE)
     	{
     		// In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again.
-    		if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel) 
+    		if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
     			&& (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
-    		{	
+    		{
     			// Must using 40MHz.
     			AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
     			AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
     		}
     		else
-    		{	
+    		{
     			// Must using 20MHz.
     			AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
     			AsicLockChannel(pAd, pAd->CommonCfg.Channel);
@@ -887,7 +887,7 @@ BOOLEAN RT28xxPciAsicRadioOn(
     	}
         return TRUE;
     }
-    else 
+    else
         return FALSE;
 }
 
@@ -907,7 +907,7 @@ VOID RT28xxPciStaAsicForceWakeup(
     }
 
     OPSTATUS_SET_FLAG(pAd, fOP_STATUS_WAKEUP_NOW);
-    
+
     if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
     {
         // Support PCIe Advance Power Save
@@ -921,19 +921,19 @@ VOID RT28xxPciStaAsicForceWakeup(
 
 		AutoWakeupCfg.word = 0;
 		RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
-	
+
         if (RT28xxPciAsicRadioOn(pAd, DOT11POWERSAVE))
         {
             // In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again.
-        	if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel) 
+        	if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
         		&& (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
-        	{	
+        	{
         		// Must using 40MHz.
         		AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
         		AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
         	}
         	else
-        	{	
+        	{
         		// Must using 20MHz.
         		AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
         		AsicLockChannel(pAd, pAd->CommonCfg.Channel);
@@ -947,15 +947,15 @@ VOID RT28xxPciStaAsicForceWakeup(
 		AutoWakeupCfg.word = 0;
 		RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
     }
-    
+
     OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
     OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_WAKEUP_NOW);
     DBGPRINT(RT_DEBUG_TRACE, ("<=======RT28xxPciStaAsicForceWakeup\n"));
 }
 
 VOID RT28xxPciStaAsicSleepThenAutoWakeup(
-	IN PRTMP_ADAPTER pAd, 
-	IN USHORT TbttNumToNextWakeUp) 
+	IN PRTMP_ADAPTER pAd,
+	IN USHORT TbttNumToNextWakeUp)
 {
     if (pAd->StaCfg.bRadio == FALSE)
 	{
@@ -975,32 +975,32 @@ VOID RT28xxPciStaAsicSleepThenAutoWakeup(
 		NdisGetSystemUpTime(&Now);
 		// If last send NULL fram time is too close to this receiving beacon (within 8ms), don't go to sleep for this DTM.
 		// Because Some AP can't queuing outgoing frames immediately.
-		if (((pAd->Mlme.LastSendNULLpsmTime + 8) >= Now) && (pAd->Mlme.LastSendNULLpsmTime <= Now))		
+		if (((pAd->Mlme.LastSendNULLpsmTime + 8) >= Now) && (pAd->Mlme.LastSendNULLpsmTime <= Now))
 		{
 			DBGPRINT(RT_DEBUG_TRACE, ("Now = %lu, LastSendNULLpsmTime=%lu :  RxCountSinceLastNULL = %lu. \n", Now, pAd->Mlme.LastSendNULLpsmTime, pAd->RalinkCounters.RxCountSinceLastNULL));
 			return;
 		}
-		else if ((pAd->RalinkCounters.RxCountSinceLastNULL > 0) && ((pAd->Mlme.LastSendNULLpsmTime + pAd->CommonCfg.BeaconPeriod) >= Now))		
+		else if ((pAd->RalinkCounters.RxCountSinceLastNULL > 0) && ((pAd->Mlme.LastSendNULLpsmTime + pAd->CommonCfg.BeaconPeriod) >= Now))
 		{
-			DBGPRINT(RT_DEBUG_TRACE, ("Now = %lu, LastSendNULLpsmTime=%lu: RxCountSinceLastNULL = %lu > 0 \n", Now, pAd->Mlme.LastSendNULLpsmTime,  pAd->RalinkCounters.RxCountSinceLastNULL));			
+			DBGPRINT(RT_DEBUG_TRACE, ("Now = %lu, LastSendNULLpsmTime=%lu: RxCountSinceLastNULL = %lu > 0 \n", Now, pAd->Mlme.LastSendNULLpsmTime,  pAd->RalinkCounters.RxCountSinceLastNULL));
 			return;
 		}
-		
+
         RT28xxPciAsicRadioOff(pAd, DOT11POWERSAVE, TbttNumToNextWakeUp);
     }
     else
     {
-        AUTO_WAKEUP_STRUC	AutoWakeupCfg;	
-        // we have decided to SLEEP, so at least do it for a BEACON period.	
+        AUTO_WAKEUP_STRUC	AutoWakeupCfg;
+        // we have decided to SLEEP, so at least do it for a BEACON period.
         if (TbttNumToNextWakeUp == 0)
-            TbttNumToNextWakeUp = 1; 
-        
-        AutoWakeupCfg.word = 0; 
-        RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);  
-        AutoWakeupCfg.field.NumofSleepingTbtt = TbttNumToNextWakeUp - 1;    
-        AutoWakeupCfg.field.EnableAutoWakeup = 1;   
-        AutoWakeupCfg.field.AutoLeadTime = 5;   
-        RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);  
+            TbttNumToNextWakeUp = 1;
+
+        AutoWakeupCfg.word = 0;
+        RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
+        AutoWakeupCfg.field.NumofSleepingTbtt = TbttNumToNextWakeUp - 1;
+        AutoWakeupCfg.field.EnableAutoWakeup = 1;
+        AutoWakeupCfg.field.AutoLeadTime = 5;
+        RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
         AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x00);   // send POWER-SAVE command to MCU. Timeout 40us.
         DBGPRINT(RT_DEBUG_TRACE, ("<-- %s, TbttNumToNextWakeUp=%d \n", __FUNCTION__, TbttNumToNextWakeUp));
     }
@@ -1008,10 +1008,10 @@ VOID RT28xxPciStaAsicSleepThenAutoWakeup(
 }
 
 VOID PsPollWakeExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
-	IN PVOID SystemSpecific3) 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
+	IN PVOID SystemSpecific3)
 {
 	RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
 	unsigned long flags;
@@ -1027,10 +1027,10 @@ VOID PsPollWakeExec(
 }
 
 VOID  RadioOnExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
-	IN PVOID SystemSpecific3) 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
+	IN PVOID SystemSpecific3)
 {
 	RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
 	WPDMA_GLO_CFG_STRUC	DmaCfg;
@@ -1042,7 +1042,7 @@ VOID  RadioOnExec(
 		RTMPSetTimer(&pAd->Mlme.RadioOnOffTimer, 10);
 		return;
 	}
-	
+
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
 	{
 		DBGPRINT(RT_DEBUG_TRACE,("-->RadioOnExec() return on SCAN_IN_PROGRESS; \n"));
@@ -1063,28 +1063,28 @@ VOID  RadioOnExec(
 		RTMPRingCleanUp(pAd, QID_RX);
 
 		// 2. Send wake up command.
-		AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x02);   
+		AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x02);
 		// 2-1. wait command ok.
-		AsicCheckCommanOk(pAd, PowerWakeCID);	
-        
+		AsicCheckCommanOk(pAd, PowerWakeCID);
+
 		// When PCI clock is off, don't want to service interrupt. So when back to clock on, enable interrupt.
 		NICEnableInterrupt(pAd);
-		
+
 		// 3. Enable Tx DMA.
 		RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &DmaCfg.word);
 		DmaCfg.field.EnableTxDMA = 1;
 		RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, DmaCfg.word);
-		
+
 		// In Radio Off, we turn off RF clk, So now need to call ASICSwitchChannel again.
-		if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel) 
+		if (INFRA_ON(pAd) && (pAd->CommonCfg.CentralChannel != pAd->CommonCfg.Channel)
 			&& (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
-		{	
+		{
 			// Must using 40MHz.
 			AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
 			AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
 		}
 		else
-		{	
+		{
 			// Must using 20MHz.
 			AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
 			AsicLockChannel(pAd, pAd->CommonCfg.Channel);
@@ -1111,28 +1111,28 @@ VOID  RadioOnExec(
 
 VOID RT28xxPciMlmeRadioOn(
 	IN PRTMP_ADAPTER pAd)
-{    
+{
     if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
    		return;
-    
-    DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __FUNCTION__));   
-    
+
+    DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __FUNCTION__));
+
     if ((pAd->OpMode == OPMODE_AP) ||
         ((pAd->OpMode == OPMODE_STA) && (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))))
     {
     	NICResetFromError(pAd);
-		
+
     	RTMPRingCleanUp(pAd, QID_AC_BK);
     	RTMPRingCleanUp(pAd, QID_AC_BE);
     	RTMPRingCleanUp(pAd, QID_AC_VI);
     	RTMPRingCleanUp(pAd, QID_AC_VO);
     	RTMPRingCleanUp(pAd, QID_HCCA);
     	RTMPRingCleanUp(pAd, QID_MGMT);
-    	RTMPRingCleanUp(pAd, QID_RX);		
+    	RTMPRingCleanUp(pAd, QID_RX);
 
     	// Enable Tx/Rx
     	RTMPEnableRxTx(pAd);
-    	
+
     	// Clear Radio off flag
     	RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF);
 
@@ -1145,7 +1145,7 @@ VOID RT28xxPciMlmeRadioOn(
         (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)))
     {
         BOOLEAN		Cancelled;
-    	
+
     	RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_WAKEUP);
 
         pAd->Mlme.bPsPollTimerRunning = FALSE;
@@ -1161,12 +1161,12 @@ VOID RT28xxPciMlmeRadioOFF(
 {
     WPDMA_GLO_CFG_STRUC	GloCfg;
 	UINT32	i;
-    
+
     if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
     	return;
-    
+
     DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __FUNCTION__));
-            
+
 	// Set LED
 	RTMPSetLED(pAd, LED_RADIO_OFF);
 	// Set Radio off flag
@@ -1181,7 +1181,7 @@ VOID RT28xxPciMlmeRadioOFF(
 			RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &Cancelled);
 			RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
     	}
-		
+
 		if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
         {
             BOOLEAN Cancelled;
@@ -1190,39 +1190,39 @@ VOID RT28xxPciMlmeRadioOFF(
 	        RTMPCancelTimer(&pAd->Mlme.RadioOnOffTimer,	&Cancelled);
         }
 
-        // Link down first if any association exists	
-        if (INFRA_ON(pAd) || ADHOC_ON(pAd))		
-            LinkDown(pAd, FALSE);   
-        RTMPusecDelay(10000);   
-        //==========================================    
-        // Clean up old bss table   
+        // Link down first if any association exists
+        if (INFRA_ON(pAd) || ADHOC_ON(pAd))
+            LinkDown(pAd, FALSE);
+        RTMPusecDelay(10000);
+        //==========================================
+        // Clean up old bss table
         BssTableInit(&pAd->ScanTab);
     }
 #endif // CONFIG_STA_SUPPORT //
 
 	// Disable Tx/Rx DMA
-	RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);	   // disable DMA 
+	RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);	   // disable DMA
 	GloCfg.field.EnableTxDMA = 0;
 	GloCfg.field.EnableRxDMA = 0;
 	RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);	   // abort all TX rings
 
-	
+
 	// MAC_SYS_CTRL => value = 0x0 => 40mA
 	RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0);
-	
+
 	// PWR_PIN_CFG => value = 0x0 => 40mA
 	RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0);
-	
+
 	// TX_PIN_CFG => value = 0x0 => 20mA
 	RTMP_IO_WRITE32(pAd, TX_PIN_CFG, 0);
 
 	if (pAd->CommonCfg.BBPCurrentBW == BW_40)
-	{	
+	{
 		// Must using 40MHz.
 		AsicTurnOffRFClk(pAd, pAd->CommonCfg.CentralChannel);
 	}
 	else
-	{	
+	{
 		// Must using 20MHz.
 		AsicTurnOffRFClk(pAd, pAd->CommonCfg.Channel);
 	}
@@ -1234,7 +1234,7 @@ VOID RT28xxPciMlmeRadioOFF(
 		RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
 		if ((GloCfg.field.TxDMABusy == 0) && (GloCfg.field.RxDMABusy == 0))
 			break;
-		
+
 		RTMPusecDelay(1000);
 	}while (i++ < 100);
 }
diff --git a/common/cmm_info.c b/common/cmm_info.c
index 9e712aa..0aadf8a 100644
--- a/common/cmm_info.c
+++ b/common/cmm_info.c
@@ -7,183 +7,183 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
-*/ 
+*/
 
-#include	"rt_config.h"
+#include "../rt_config.h"
 
 INT	Show_SSID_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_WirelessMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_TxBurst_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_TxPreamble_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_TxPower_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_Channel_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_BGProtection_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_RTSThreshold_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_FragThreshold_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 #ifdef DOT11_N_SUPPORT
 INT	Show_HtBw_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_HtMcs_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_HtGi_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_HtOpMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_HtExtcha_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_HtMpduDensity_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_HtBaWinSize_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_HtRdg_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_HtAmsdu_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_HtAutoBa_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 #endif // DOT11_N_SUPPORT //
 
 INT	Show_CountryRegion_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_CountryRegionABand_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_CountryCode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 #ifdef AGGREGATION_SUPPORT
 INT	Show_PktAggregate_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 #endif // AGGREGATION_SUPPORT //
 
 #ifdef WMM_SUPPORT
 INT	Show_WmmCapable_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 #endif // WMM_SUPPORT //
 
 INT	Show_IEEE80211H_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 #ifdef CONFIG_STA_SUPPORT
 INT	Show_NetworkType_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 #endif // CONFIG_STA_SUPPORT //
 
 INT	Show_AuthMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_EncrypType_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_DefaultKeyID_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_Key1_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_Key2_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_Key3_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_Key4_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 INT	Show_WPAPSK_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf);
 
 static struct {
 	CHAR *name;
 	INT (*show_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
 } *PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC, RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC[] = {
-	{"SSID",					Show_SSID_Proc}, 
-	{"WirelessMode",			Show_WirelessMode_Proc},       
+	{"SSID",					Show_SSID_Proc},
+	{"WirelessMode",			Show_WirelessMode_Proc},
 	{"TxBurst",					Show_TxBurst_Proc},
 	{"TxPreamble",				Show_TxPreamble_Proc},
 	{"TxPower",					Show_TxPower_Proc},
-	{"Channel",					Show_Channel_Proc},            
+	{"Channel",					Show_Channel_Proc},
 	{"BGProtection",			Show_BGProtection_Proc},
-	{"RTSThreshold",			Show_RTSThreshold_Proc},       
-	{"FragThreshold",			Show_FragThreshold_Proc},      
+	{"RTSThreshold",			Show_RTSThreshold_Proc},
+	{"FragThreshold",			Show_FragThreshold_Proc},
 #ifdef DOT11_N_SUPPORT
 	{"HtBw",					Show_HtBw_Proc},
 	{"HtMcs",					Show_HtMcs_Proc},
@@ -200,23 +200,23 @@ static struct {
 	{"CountryRegionABand",		Show_CountryRegionABand_Proc},
 	{"CountryCode",				Show_CountryCode_Proc},
 #ifdef AGGREGATION_SUPPORT
-	{"PktAggregate",			Show_PktAggregate_Proc},       
+	{"PktAggregate",			Show_PktAggregate_Proc},
 #endif
 
 #ifdef WMM_SUPPORT
-	{"WmmCapable",				Show_WmmCapable_Proc},         
-#endif         
+	{"WmmCapable",				Show_WmmCapable_Proc},
+#endif
 	{"IEEE80211H",				Show_IEEE80211H_Proc},
-#ifdef CONFIG_STA_SUPPORT	
-    {"NetworkType",				Show_NetworkType_Proc},        
+#ifdef CONFIG_STA_SUPPORT
+    {"NetworkType",				Show_NetworkType_Proc},
 #endif // CONFIG_STA_SUPPORT //
-	{"AuthMode",				Show_AuthMode_Proc},           
-	{"EncrypType",				Show_EncrypType_Proc},         
-	{"DefaultKeyID",			Show_DefaultKeyID_Proc},       
-	{"Key1",					Show_Key1_Proc},               
-	{"Key2",					Show_Key2_Proc},               
-	{"Key3",					Show_Key3_Proc},               
-	{"Key4",					Show_Key4_Proc},               
+	{"AuthMode",				Show_AuthMode_Proc},
+	{"EncrypType",				Show_EncrypType_Proc},
+	{"DefaultKeyID",			Show_DefaultKeyID_Proc},
+	{"Key1",					Show_Key1_Proc},
+	{"Key2",					Show_Key2_Proc},
+	{"Key3",					Show_Key3_Proc},
+	{"Key4",					Show_Key4_Proc},
 	{"WPAPSK",					Show_WPAPSK_Proc},
 	{NULL, NULL}
 };
@@ -230,7 +230,7 @@ static struct {
     ==========================================================================
 */
 INT Set_DriverVersion_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 
@@ -242,7 +242,7 @@ INT Set_DriverVersion_Proc(
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set Country Region.
@@ -252,11 +252,11 @@ INT Set_DriverVersion_Proc(
     ==========================================================================
 */
 INT Set_CountryRegion_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG region;
-		
+
 	region = simple_strtol(arg, 0, 10);
 
 #ifdef EXT_BUILD_CHANNEL_LIST
@@ -269,7 +269,7 @@ INT Set_CountryRegion_Proc(
 		DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegion_Proc::parameter of CountryRegion in eeprom is programmed \n"));
 		return FALSE;
 	}
-	
+
 	if((region >= 0) && (region <= REGION_MAXIMUM_BG_BAND))
 	{
 		pAd->CommonCfg.CountryRegion = (UCHAR) region;
@@ -288,11 +288,11 @@ INT Set_CountryRegion_Proc(
 	BuildChannelList(pAd);
 
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegion_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegion));
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set Country Region for A band.
@@ -302,11 +302,11 @@ INT Set_CountryRegion_Proc(
     ==========================================================================
 */
 INT Set_CountryRegionABand_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG region;
-		
+
 	region = simple_strtol(arg, 0, 10);
 
 #ifdef EXT_BUILD_CHANNEL_LIST
@@ -319,7 +319,7 @@ INT Set_CountryRegionABand_Proc(
 		DBGPRINT(RT_DEBUG_ERROR, ("Set_CountryRegionABand_Proc::parameter of CountryRegion in eeprom is programmed \n"));
 		return FALSE;
 	}
-	
+
 	if((region >= 0) && (region <= REGION_MAXIMUM_A_BAND))
 	{
 		pAd->CommonCfg.CountryRegionForABand = (UCHAR) region;
@@ -334,11 +334,11 @@ INT Set_CountryRegionABand_Proc(
 	BuildChannelList(pAd);
 
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_CountryRegionABand_Proc::(CountryRegion=%d)\n", pAd->CommonCfg.CountryRegionForABand));
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set Wireless Mode
@@ -347,7 +347,7 @@ INT Set_CountryRegionABand_Proc(
     ==========================================================================
 */
 INT	Set_WirelessMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG	WirelessMode;
@@ -360,7 +360,7 @@ INT	Set_WirelessMode_Proc(
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 	{
 		INT MaxPhyMode = PHY_11G;
-		
+
 #ifdef DOT11_N_SUPPORT
 		MaxPhyMode = PHY_11N_5G;
 #endif // DOT11_N_SUPPORT //
@@ -407,11 +407,11 @@ INT	Set_WirelessMode_Proc(
 	{
 		DBGPRINT(RT_DEBUG_ERROR, ("Set_WirelessMode_Proc::parameters out of range\n"));
 	}
-	
+
 	return success;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set Channel
@@ -420,11 +420,11 @@ INT	Set_WirelessMode_Proc(
     ==========================================================================
 */
 INT	Set_Channel_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
  	INT		success = TRUE;
-	UCHAR	Channel;	
+	UCHAR	Channel;
 
 	Channel = (UCHAR) simple_strtol(arg, 0, 10);
 
@@ -434,7 +434,7 @@ INT	Set_Channel_Proc(
 #ifdef CONFIG_STA_SUPPORT
 		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 		{
-			pAd->CommonCfg.Channel = Channel;        
+			pAd->CommonCfg.Channel = Channel;
 
 			if (MONITOR_ON(pAd))
 			{
@@ -446,7 +446,7 @@ INT	Set_Channel_Proc(
 					N_SetCenCh(pAd);
 					AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
 					AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-					DBGPRINT(RT_DEBUG_TRACE, ("BW_40, control_channel(%d), CentralChannel(%d) \n", 
+					DBGPRINT(RT_DEBUG_TRACE, ("BW_40, control_channel(%d), CentralChannel(%d) \n",
 								pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
 				}
 				else
@@ -477,7 +477,7 @@ INT	Set_Channel_Proc(
 	return success;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set Short Slot Time Enable or Disable
@@ -486,7 +486,7 @@ INT	Set_Channel_Proc(
     ==========================================================================
 */
 INT	Set_ShortSlot_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG ShortSlot;
@@ -498,14 +498,14 @@ INT	Set_ShortSlot_Proc(
 	else if (ShortSlot == 0)
 		pAd->CommonCfg.bUseShortSlotTime = FALSE;
 	else
-		return FALSE;  //Invalid argument 
-	
+		return FALSE;  //Invalid argument
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_ShortSlot_Proc::(ShortSlot=%d)\n", pAd->CommonCfg.bUseShortSlotTime));
 
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set Tx power
@@ -514,7 +514,7 @@ INT	Set_ShortSlot_Proc(
     ==========================================================================
 */
 INT	Set_TxPower_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG TxPower;
@@ -541,7 +541,7 @@ INT	Set_TxPower_Proc(
 	return success;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set 11B/11G Protection
@@ -550,7 +550,7 @@ INT	Set_TxPower_Proc(
     ==========================================================================
 */
 INT	Set_BGProtection_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	switch (simple_strtol(arg, 0, 10))
@@ -563,18 +563,18 @@ INT	Set_BGProtection_Proc(
 			break;
 		case 2: //Always OFF
 			pAd->CommonCfg.UseBGProtection = 2;
-			break;		
-		default:  //Invalid argument 
+			break;
+		default:  //Invalid argument
 			return FALSE;
 	}
 
 
-	DBGPRINT(RT_DEBUG_TRACE, ("Set_BGProtection_Proc::(BGProtection=%ld)\n", pAd->CommonCfg.UseBGProtection));	
+	DBGPRINT(RT_DEBUG_TRACE, ("Set_BGProtection_Proc::(BGProtection=%ld)\n", pAd->CommonCfg.UseBGProtection));
 
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set TxPreamble
@@ -583,7 +583,7 @@ INT	Set_BGProtection_Proc(
     ==========================================================================
 */
 INT	Set_TxPreamble_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	RT_802_11_PREAMBLE	Preamble;
@@ -612,7 +612,7 @@ INT	Set_TxPreamble_Proc(
 				MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
 #endif // CONFIG_STA_SUPPORT //
 			break;
-		default: //Invalid argument 
+		default: //Invalid argument
 			return FALSE;
 	}
 
@@ -621,7 +621,7 @@ INT	Set_TxPreamble_Proc(
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set RTS Threshold
@@ -630,7 +630,7 @@ INT	Set_TxPreamble_Proc(
     ==========================================================================
 */
 INT	Set_RTSThreshold_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	 NDIS_802_11_RTS_THRESHOLD           RtsThresh;
@@ -644,14 +644,14 @@ INT	Set_RTSThreshold_Proc(
 		pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
 #endif // CONFIG_STA_SUPPORT //
 	else
-		return FALSE; //Invalid argument 
+		return FALSE; //Invalid argument
 
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_RTSThreshold_Proc::(RTSThreshold=%d)\n", pAd->CommonCfg.RtsThreshold));
 
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set Fragment Threshold
@@ -660,7 +660,7 @@ INT	Set_RTSThreshold_Proc(
     ==========================================================================
 */
 INT	Set_FragThreshold_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	 NDIS_802_11_FRAGMENTATION_THRESHOLD     FragThresh;
@@ -668,7 +668,7 @@ INT	Set_FragThreshold_Proc(
 	FragThresh = simple_strtol(arg, 0, 10);
 
 	if (FragThresh > MAX_FRAG_THRESHOLD || FragThresh < MIN_FRAG_THRESHOLD)
-	{ 
+	{
 		//Illegal FragThresh so we set it to default
 		pAd->CommonCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
 	}
@@ -698,7 +698,7 @@ INT	Set_FragThreshold_Proc(
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set TxBurst
@@ -707,7 +707,7 @@ INT	Set_FragThreshold_Proc(
     ==========================================================================
 */
 INT	Set_TxBurst_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG TxBurst;
@@ -718,15 +718,15 @@ INT	Set_TxBurst_Proc(
 	else if (TxBurst == 0)
 		pAd->CommonCfg.bEnableTxBurst = FALSE;
 	else
-		return FALSE;  //Invalid argument 
-	
+		return FALSE;  //Invalid argument
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_TxBurst_Proc::(TxBurst=%d)\n", pAd->CommonCfg.bEnableTxBurst));
 
 	return TRUE;
 }
 
 #ifdef AGGREGATION_SUPPORT
-/* 
+/*
     ==========================================================================
     Description:
         Set TxBurst
@@ -735,7 +735,7 @@ INT	Set_TxBurst_Proc(
     ==========================================================================
 */
 INT	Set_PktAggregate_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG aggre;
@@ -747,7 +747,7 @@ INT	Set_PktAggregate_Proc(
 	else if (aggre == 0)
 		pAd->CommonCfg.bAggregationCapable = FALSE;
 	else
-		return FALSE;  //Invalid argument 
+		return FALSE;  //Invalid argument
 
 
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_PktAggregate_Proc::(AGGRE=%d)\n", pAd->CommonCfg.bAggregationCapable));
@@ -756,7 +756,7 @@ INT	Set_PktAggregate_Proc(
 }
 #endif
 
-/* 
+/*
     ==========================================================================
     Description:
         Set IEEE80211H.
@@ -766,7 +766,7 @@ INT	Set_PktAggregate_Proc(
     ==========================================================================
 */
 INT	Set_IEEE80211H_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
     ULONG ieee80211h;
@@ -778,8 +778,8 @@ INT	Set_IEEE80211H_Proc(
 	else if (ieee80211h == 0)
 		pAd->CommonCfg.bIEEE80211H = FALSE;
 	else
-		return FALSE;  //Invalid argument 
-	
+		return FALSE;  //Invalid argument
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_IEEE80211H_Proc::(IEEE80211H=%d)\n", pAd->CommonCfg.bIEEE80211H));
 
 	return TRUE;
@@ -787,7 +787,7 @@ INT	Set_IEEE80211H_Proc(
 
 
 #ifdef DBG
-/* 
+/*
     ==========================================================================
     Description:
         For Debug information
@@ -796,7 +796,7 @@ INT	Set_IEEE80211H_Proc(
     ==========================================================================
 */
 INT	Set_Debug_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	DBGPRINT(RT_DEBUG_TRACE, ("==> Set_Debug_Proc *******************\n"));
@@ -811,35 +811,35 @@ INT	Set_Debug_Proc(
 #endif
 
 INT	Show_DescInfo_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 #ifdef RT2860
 	INT i, QueIdx=0;
 	PRT28XX_RXD_STRUC pRxD;
     PTXD_STRUC pTxD;
-	PRTMP_TX_RING	pTxRing = &pAd->TxRing[QueIdx];	
-	PRTMP_MGMT_RING	pMgmtRing = &pAd->MgmtRing;	
-	PRTMP_RX_RING	pRxRing = &pAd->RxRing;	
-	
+	PRTMP_TX_RING	pTxRing = &pAd->TxRing[QueIdx];
+	PRTMP_MGMT_RING	pMgmtRing = &pAd->MgmtRing;
+	PRTMP_RX_RING	pRxRing = &pAd->RxRing;
+
 	for(i=0;i<TX_RING_SIZE;i++)
-	{	
+	{
 	    pTxD = (PTXD_STRUC) pTxRing->Cell[i].AllocVa;
 	    printk("Desc #%d\n",i);
 	    hex_dump("Tx Descriptor", (char *)pTxD, 16);
 	    printk("pTxD->DMADONE = %x\n", pTxD->DMADONE);
-	}    
+	}
 	printk("---------------------------------------------------\n");
 	for(i=0;i<MGMT_RING_SIZE;i++)
-	{	
+	{
 	    pTxD = (PTXD_STRUC) pMgmtRing->Cell[i].AllocVa;
 	    printk("Desc #%d\n",i);
 	    hex_dump("Mgmt Descriptor", (char *)pTxD, 16);
 	    printk("pMgmt->DMADONE = %x\n", pTxD->DMADONE);
-	}    
+	}
 	printk("---------------------------------------------------\n");
 	for(i=0;i<RX_RING_SIZE;i++)
-	{	
+	{
 	    pRxD = (PRT28XX_RXD_STRUC) pRxRing->Cell[i].AllocVa;
 	    printk("Desc #%d\n",i);
 	    hex_dump("Rx Descriptor", (char *)pRxD, 16);
@@ -850,28 +850,28 @@ INT	Show_DescInfo_Proc(
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Reset statistics counter
 
     Arguments:
         pAdapter            Pointer to our adapter
-        arg                 
+        arg
 
     Return:
         TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
 */
 INT	Set_ResetStatCounter_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	DBGPRINT(RT_DEBUG_TRACE, ("==>Set_ResetStatCounter_Proc\n"));
 
 	// add the most up-to-date h/w raw counters into software counters
 	NICUpdateRawCounters(pAd);
-    
+
 	NdisZeroMemory(&pAd->WlanCounters, sizeof(COUNTER_802_11));
 	NdisZeroMemory(&pAd->Counters8023, sizeof(COUNTER_802_3));
 	NdisZeroMemory(&pAd->RalinkCounters, sizeof(COUNTER_RALINK));
@@ -880,24 +880,24 @@ INT	Set_ResetStatCounter_Proc(
 }
 
 BOOLEAN RTMPCheckStrPrintAble(
-    IN  CHAR *pInPutStr, 
+    IN  CHAR *pInPutStr,
     IN  UCHAR strLen)
 {
     UCHAR i=0;
-    
+
     for (i=0; i<strLen; i++)
     {
         if ((pInPutStr[i] < 0x21) ||
             (pInPutStr[i] > 0x7E))
             return FALSE;
     }
-    
+
     return TRUE;
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Remove WPA Key process
 
@@ -909,9 +909,9 @@ BOOLEAN RTMPCheckStrPrintAble(
 		NDIS_SUCCESS					Add key successfully
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-		
+
 	========================================================================
 */
 #ifdef CONFIG_STA_SUPPORT
@@ -1079,7 +1079,7 @@ NDIS_STATUS RTMPWPARemoveKeyProc(
 	INT 		i;
 
 	DBGPRINT(RT_DEBUG_TRACE,("---> RTMPWPARemoveKeyProc\n"));
-	
+
 	pKey = (PNDIS_802_11_REMOVE_KEY) pBuf;
 	KeyIdx = pKey->KeyIndex & 0xff;
 	// Bit 31 of Add-key, Tx Key
@@ -1133,7 +1133,7 @@ NDIS_STATUS RTMPWPARemoveKeyProc(
 #ifdef CONFIG_STA_SUPPORT
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Remove All WPA Keys
 
@@ -1144,9 +1144,9 @@ NDIS_STATUS RTMPWPARemoveKeyProc(
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	RTMPWPARemoveAllKeys(
@@ -1154,7 +1154,7 @@ VOID	RTMPWPARemoveAllKeys(
 {
 
 	UCHAR 	i;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE,("RTMPWPARemoveAllKeys(AuthMode=%d, WepStatus=%d)\n", pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus));
 
 	// For WEP/CKIP, there is no need to remove it, since WinXP won't set it again after
@@ -1170,31 +1170,31 @@ VOID	RTMPWPARemoveAllKeys(
 	// set BSSID wcid entry of the Pair-wise Key table as no-security mode
 	AsicRemovePairwiseKeyEntry(pAd, BSS0, BSSID_WCID);
 
-	// set all shared key mode as no-security. 
+	// set all shared key mode as no-security.
 	for (i = 0; i < SHARE_KEY_NUM; i++)
     {
 		DBGPRINT(RT_DEBUG_TRACE,("remove %s key #%d\n", CipherName[pAd->SharedKey[BSS0][i].CipherAlg], i));
-		NdisZeroMemory(&pAd->SharedKey[BSS0][i], sizeof(CIPHER_KEY));  						
+		NdisZeroMemory(&pAd->SharedKey[BSS0][i], sizeof(CIPHER_KEY));
 
 		AsicRemoveSharedKeyEntry(pAd, BSS0, i);
 	}
 
 }
-#endif // CONFIG_STA_SUPPORT //	
+#endif // CONFIG_STA_SUPPORT //
 
 /*
 	========================================================================
 	Routine Description:
 		Change NIC PHY mode. Re-association may be necessary. possible settings
-		include - PHY_11B, PHY_11BG_MIXED, PHY_11A, and PHY_11ABG_MIXED 
+		include - PHY_11B, PHY_11BG_MIXED, PHY_11A, and PHY_11ABG_MIXED
 
 	Arguments:
 		pAd - Pointer to our adapter
-		phymode  - 
+		phymode  -
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	========================================================================
 */
 VOID	RTMPSetPhyMode(
@@ -1233,7 +1233,7 @@ VOID	RTMPSetPhyMode(
 #endif // CONFIG_STA_SUPPORT //
 		DBGPRINT(RT_DEBUG_ERROR, ("RTMPSetPhyMode: channel is out of range, use first channel=%d \n", pAd->CommonCfg.Channel));
 	}
-	
+
 	NdisZeroMemory(pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
 	NdisZeroMemory(pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
 	NdisZeroMemory(pAd->CommonCfg.DesireRate, MAX_LEN_OF_SUPPORTED_RATES);
@@ -1321,7 +1321,7 @@ VOID	RTMPSetPhyMode(
 	}
 
 
-	pAd->CommonCfg.BandState = UNKNOWN_BAND;	
+	pAd->CommonCfg.BandState = UNKNOWN_BAND;
 }
 
 
@@ -1334,7 +1334,7 @@ VOID	RTMPSetPhyMode(
 
 	Arguments:
 		pAd - Pointer to our adapter
-		phymode  - 
+		phymode  -
 
 	========================================================================
 */
@@ -1349,10 +1349,10 @@ VOID	RTMPSetHT(
 	UCHAR	RxStream = pAd->CommonCfg.RxStream;
 
 	DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : HT_mode(%d), ExtOffset(%d), MCS(%d), BW(%d), STBC(%d), SHORTGI(%d)\n",
-										pHTPhyMode->HtMode, pHTPhyMode->ExtOffset, 
+										pHTPhyMode->HtMode, pHTPhyMode->ExtOffset,
 										pHTPhyMode->MCS, pHTPhyMode->BW,
 										pHTPhyMode->STBC, pHTPhyMode->SHORTGI));
-			
+
 	// Don't zero supportedHyPhy structure.
 	RTMPZeroMemory(&pAd->CommonCfg.HtCapability, sizeof(pAd->CommonCfg.HtCapability));
 	RTMPZeroMemory(&pAd->CommonCfg.AddHTInfo, sizeof(pAd->CommonCfg.AddHTInfo));
@@ -1375,7 +1375,7 @@ VOID	RTMPSetHT(
 
 	DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : RxBAWinLimit = %d\n", pAd->CommonCfg.BACapability.field.RxBAWinLimit));
 
-	// Mimo power save, A-MSDU size, 
+	// Mimo power save, A-MSDU size,
 	pAd->CommonCfg.DesiredHtPhy.AmsduEnable = (USHORT)pAd->CommonCfg.BACapability.field.AmsduEnable;
 	pAd->CommonCfg.DesiredHtPhy.AmsduSize = (UCHAR)pAd->CommonCfg.BACapability.field.AmsduSize;
 	pAd->CommonCfg.DesiredHtPhy.MimoPs = (UCHAR)pAd->CommonCfg.BACapability.field.MMPSmode;
@@ -1384,13 +1384,13 @@ VOID	RTMPSetHT(
 	pAd->CommonCfg.HtCapability.HtCapInfo.AMsduSize = (USHORT)pAd->CommonCfg.BACapability.field.AmsduSize;
 	pAd->CommonCfg.HtCapability.HtCapInfo.MimoPs = (USHORT)pAd->CommonCfg.BACapability.field.MMPSmode;
 	pAd->CommonCfg.HtCapability.HtCapParm.MpduDensity = (UCHAR)pAd->CommonCfg.BACapability.field.MpduDensity;
-	
-	DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : AMsduSize = %d, MimoPs = %d, MpduDensity = %d, MaxRAmpduFactor = %d\n", 
-													pAd->CommonCfg.DesiredHtPhy.AmsduSize, 
+
+	DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetHT : AMsduSize = %d, MimoPs = %d, MpduDensity = %d, MaxRAmpduFactor = %d\n",
+													pAd->CommonCfg.DesiredHtPhy.AmsduSize,
 													pAd->CommonCfg.DesiredHtPhy.MimoPs,
 													pAd->CommonCfg.DesiredHtPhy.MpduDensity,
 													pAd->CommonCfg.DesiredHtPhy.MaxRAmpduFactor));
-	
+
 	if(pHTPhyMode->HtMode == HTMODE_GF)
 	{
 		pAd->CommonCfg.HtCapability.HtCapInfo.GF = 1;
@@ -1398,11 +1398,11 @@ VOID	RTMPSetHT(
 	}
 	else
 		pAd->CommonCfg.DesiredHtPhy.GF = 0;
-	
+
 	// Decide Rx MCSSet
 	switch (RxStream)
 	{
-		case 1:			
+		case 1:
 			pAd->CommonCfg.HtCapability.MCSSet[0] =  0xff;
 			pAd->CommonCfg.HtCapability.MCSSet[1] =  0x00;
 			break;
@@ -1429,7 +1429,7 @@ VOID	RTMPSetHT(
 	{
 		pAd->CommonCfg.HtCapability.MCSSet[4] = 0x1; // MCS 32
 		pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth = 1;
-		if (pAd->CommonCfg.Channel <= 14) 		
+		if (pAd->CommonCfg.Channel <= 14)
 			pAd->CommonCfg.HtCapability.HtCapInfo.CCKmodein40 = 1;
 
 		pAd->CommonCfg.DesiredHtPhy.ChannelWidth = 1;
@@ -1451,7 +1451,7 @@ VOID	RTMPSetHT(
 			RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Value);
 		}
 
-		// Turn on BBP 40MHz mode now only as AP . 
+		// Turn on BBP 40MHz mode now only as AP .
 		// Sta can turn on BBP 40MHz after connection with 40MHz AP. Sta only broadcast 40MHz capability before connection.
 		if ((pAd->OpMode == OPMODE_AP) || INFRA_ON(pAd) || ADHOC_ON(pAd)
 			)
@@ -1480,7 +1480,7 @@ VOID	RTMPSetHT(
 			pAd->CommonCfg.BBPCurrentBW = BW_20;
 		}
 	}
-		
+
 	if(pHTPhyMode->STBC == STBC_USE)
 	{
 		pAd->CommonCfg.HtCapability.HtCapInfo.TxSTBC = 1;
@@ -1509,12 +1509,12 @@ VOID	RTMPSetHT(
 		pAd->CommonCfg.DesiredHtPhy.ShortGIfor20 = 0;
 		pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 = 0;
 	}
-	
+
 	// We support link adaptation for unsolicit MCS feedback, set to 2.
 	pAd->CommonCfg.HtCapability.ExtHtCapInfo.MCSFeedback = MCSFBK_NONE; //MCSFBK_UNSOLICIT;
 	pAd->CommonCfg.AddHTInfo.ControlChan = pAd->CommonCfg.Channel;
-	// 1, the extension channel above the control channel. 
-	
+	// 1, the extension channel above the control channel.
+
 	// EDCA parameters used for AP's own transmission
 	if (pAd->CommonCfg.APEdcaParm.bValid == FALSE)
 	{
@@ -1523,7 +1523,7 @@ VOID	RTMPSetHT(
 		pAd->CommonCfg.APEdcaParm.Aifsn[1] = 7;
 		pAd->CommonCfg.APEdcaParm.Aifsn[2] = 1;
 		pAd->CommonCfg.APEdcaParm.Aifsn[3] = 1;
-	
+
 		pAd->CommonCfg.APEdcaParm.Cwmin[0] = 4;
 		pAd->CommonCfg.APEdcaParm.Cwmin[1] = 4;
 		pAd->CommonCfg.APEdcaParm.Cwmin[2] = 3;
@@ -1536,11 +1536,11 @@ VOID	RTMPSetHT(
 
 		pAd->CommonCfg.APEdcaParm.Txop[0]  = 0;
 		pAd->CommonCfg.APEdcaParm.Txop[1]  = 0;
-		pAd->CommonCfg.APEdcaParm.Txop[2]  = 94;	
-		pAd->CommonCfg.APEdcaParm.Txop[3]  = 47;	
+		pAd->CommonCfg.APEdcaParm.Txop[2]  = 94;
+		pAd->CommonCfg.APEdcaParm.Txop[3]  = 47;
 	}
 	AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
-	
+
 
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
@@ -1559,29 +1559,29 @@ VOID	RTMPSetHT(
 
 	Arguments:
 		pAd - Pointer to our adapter
-		phymode  - 
+		phymode  -
 
 	========================================================================
 */
 VOID	RTMPSetIndividualHT(
 	IN	PRTMP_ADAPTER		pAd,
 	IN	UCHAR				apidx)
-{	
+{
 	PRT_HT_PHY_INFO		pDesired_ht_phy = NULL;
-	UCHAR	TxStream = pAd->CommonCfg.TxStream;		
+	UCHAR	TxStream = pAd->CommonCfg.TxStream;
 	UCHAR	DesiredMcs	= MCS_AUTO;
-						
+
 	do
 	{
 
 #ifdef CONFIG_STA_SUPPORT
 		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
-		{		
-			pDesired_ht_phy = &pAd->StaCfg.DesiredHtPhyInfo;					
+		{
+			pDesired_ht_phy = &pAd->StaCfg.DesiredHtPhyInfo;
 			DesiredMcs = pAd->StaCfg.DesiredTransmitSetting.field.MCS;
 			//pAd->StaCfg.bAutoTxRateSwitch = (DesiredMcs == MCS_AUTO) ? TRUE : FALSE;
 				break;
-		}	
+		}
 #endif // CONFIG_STA_SUPPORT //
 	} while (FALSE);
 
@@ -1593,21 +1593,21 @@ VOID	RTMPSetIndividualHT(
 	RTMPZeroMemory(pDesired_ht_phy, sizeof(RT_HT_PHY_INFO));
 
 	DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetIndividualHT : Desired MCS = %d\n", DesiredMcs));
-	// Check the validity of MCS 
+	// Check the validity of MCS
 	if ((TxStream == 1) && ((DesiredMcs >= MCS_8) && (DesiredMcs <= MCS_15)))
 	{
 		DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS(%d) is invalid in 1S, reset it as MCS_7\n", DesiredMcs));
-		DesiredMcs = MCS_7;		
+		DesiredMcs = MCS_7;
 	}
 
 	if ((pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_20) && (DesiredMcs == MCS_32))
 	{
 		DBGPRINT(RT_DEBUG_WARN, ("RTMPSetIndividualHT: MCS_32 is only supported in 40-MHz, reset it as MCS_0\n"));
-		DesiredMcs = MCS_0;		
+		DesiredMcs = MCS_0;
 	}
-	   		
+
 	pDesired_ht_phy->bHtEnable = TRUE;
-					 
+
 	// Decide desired Tx MCS
 	switch (TxStream)
 	{
@@ -1621,7 +1621,7 @@ VOID	RTMPSetIndividualHT(
 			{
 				pDesired_ht_phy->MCSSet[0]= 1<<DesiredMcs;
 				pDesired_ht_phy->MCSSet[1]= 0x00;
-			}			
+			}
 			break;
 
 		case 2:
@@ -1633,11 +1633,11 @@ VOID	RTMPSetIndividualHT(
 			else if (DesiredMcs <= MCS_15)
 			{
 				ULONG mode;
-				
+
 				mode = DesiredMcs / 8;
 				if (mode < 2)
 					pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
-			}			
+			}
 			break;
 
 		case 3: // 3*3
@@ -1657,7 +1657,7 @@ VOID	RTMPSetIndividualHT(
 					pDesired_ht_phy->MCSSet[mode] = (1 << (DesiredMcs - mode * 8));
 			}
 			break;
-	}							
+	}
 
 	if(pAd->CommonCfg.DesiredHtPhy.ChannelWidth == BW_40)
 	{
@@ -1665,7 +1665,7 @@ VOID	RTMPSetIndividualHT(
 			pDesired_ht_phy->MCSSet[4] = 0x1;
 	}
 
-	// update HT Rate setting				
+	// update HT Rate setting
     if (pAd->OpMode == OPMODE_STA)
         MlmeUpdateHtTxRates(pAd, BSS0);
     else
@@ -1677,11 +1677,11 @@ VOID	RTMPSetIndividualHT(
 	========================================================================
 	Routine Description:
 		Update HT IE from our capability.
-		
+
 	Arguments:
 		Send all HT IE in beacon/probe rsp/assoc rsp/action frame.
-		
-	
+
+
 	========================================================================
 */
 VOID	RTMPUpdateHTIE(
@@ -1692,7 +1692,7 @@ VOID	RTMPUpdateHTIE(
 {
 	RTMPZeroMemory(pHtCapability, sizeof(HT_CAPABILITY_IE));
 	RTMPZeroMemory(pAddHtInfo, sizeof(ADD_HT_INFO_IE));
-	
+
 		pHtCapability->HtCapInfo.ChannelWidth = pRtHt->ChannelWidth;
 		pHtCapability->HtCapInfo.MimoPs = pRtHt->MimoPs;
 		pHtCapability->HtCapInfo.GF = pRtHt->GF;
@@ -1709,7 +1709,7 @@ VOID	RTMPUpdateHTIE(
 		pAddHtInfo->AddHtInfo2.OperaionMode = pRtHt->OperaionMode;
 		pAddHtInfo->AddHtInfo2.NonGfPresent = pRtHt->NonGfPresent;
 		RTMPMoveMemory(pAddHtInfo->MCSSet, /*pRtHt->MCSSet*/pMcsSet, 4); // rt2860 only support MCS max=32, no need to copy all 16 uchar.
-	
+
         DBGPRINT(RT_DEBUG_TRACE,("RTMPUpdateHTIE <== \n"));
 }
 #endif // DOT11_N_SUPPORT //
@@ -1739,13 +1739,13 @@ VOID	RTMPAddWcidAttributeEntry(
 		{
 			if (BssIdx > BSS0)
 			{
-				DBGPRINT(RT_DEBUG_ERROR, ("RTMPAddWcidAttributeEntry: The BSS-index(%d) is out of range for Infra link. \n", BssIdx));	
+				DBGPRINT(RT_DEBUG_ERROR, ("RTMPAddWcidAttributeEntry: The BSS-index(%d) is out of range for Infra link. \n", BssIdx));
 				return;
 			}
 
 			// 1.	In ADHOC mode, the AID is wcid number. And NO mesh link exists.
-			// 2.	In Infra mode, the AID:1 MUST be wcid of infra STA. 
-			//					   the AID:2~ assign to mesh link entry. 	
+			// 2.	In Infra mode, the AID:1 MUST be wcid of infra STA.
+			//					   the AID:2~ assign to mesh link entry.
 			if (pEntry && ADHOC_ON(pAd))
 				Wcid = pEntry->Aid;
 			else if (pEntry && INFRA_ON(pAd))
@@ -1773,46 +1773,46 @@ VOID	RTMPAddWcidAttributeEntry(
 			WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
 #ifdef QOS_DLS_SUPPORT
 		else if ((pEntry) && (pEntry->ValidAsDls) &&
-					((CipherAlg == CIPHER_TKIP) || 
-				 	(CipherAlg == CIPHER_TKIP_NO_MIC) || 
-					(CipherAlg == CIPHER_AES) || 
-				 	(CipherAlg == CIPHER_NONE))) 
+					((CipherAlg == CIPHER_TKIP) ||
+				 	(CipherAlg == CIPHER_TKIP_NO_MIC) ||
+					(CipherAlg == CIPHER_AES) ||
+				 	(CipherAlg == CIPHER_NONE)))
 			WCIDAttri = (CipherAlg<<1) | PAIRWISEKEYTABLE;
 #endif // QOS_DLS_SUPPORT //
 		else
 			WCIDAttri = (CipherAlg<<1) | SHAREDKEYTABLE;
 	}
 #endif // CONFIG_STA_SUPPORT //
-		
+
 	RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
 
-		
+
 	// Update IV/EIV table
 	offset = MAC_IVEIV_TABLE_BASE + (Wcid * HW_IVEIV_ENTRY_SIZE);
 
 	// WPA mode
 	if ((CipherAlg == CIPHER_TKIP) || (CipherAlg == CIPHER_TKIP_NO_MIC) || (CipherAlg == CIPHER_AES))
-	{	
-		// Eiv bit on. keyid always is 0 for pairwise key 			
-		IVEIV = (KeyIdx <<6) | 0x20;	
-	}	 
+	{
+		// Eiv bit on. keyid always is 0 for pairwise key
+		IVEIV = (KeyIdx <<6) | 0x20;
+	}
 	else
 	{
-		// WEP KeyIdx is default tx key. 
-		IVEIV = (KeyIdx << 6);	
+		// WEP KeyIdx is default tx key.
+		IVEIV = (KeyIdx << 6);
 	}
 
 	// For key index and ext IV bit, so only need to update the position(offset+3).
-#ifdef RT2860	
+#ifdef RT2860
 	RTMP_IO_WRITE8(pAd, offset+3, IVEIV);
 #endif // RT2860 //
-	
+
 	DBGPRINT(RT_DEBUG_TRACE,("RTMPAddWcidAttributeEntry: WCID #%d, KeyIndex #%d, Alg=%s\n",Wcid, KeyIdx, CipherName[CipherAlg]));
-	DBGPRINT(RT_DEBUG_TRACE,("	WCIDAttri = 0x%x \n",  WCIDAttri));	
+	DBGPRINT(RT_DEBUG_TRACE,("	WCIDAttri = 0x%x \n",  WCIDAttri));
 
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Parse encryption type
@@ -1864,12 +1864,12 @@ CHAR *GetAuthMode(CHAR auth)
     	return "WPA1WPA2";
 	if(auth == Ndis802_11AuthModeWPA1PSKWPA2PSK)
     	return "WPA1PSKWPA2PSK";
-	
+
     	return "UNKNOW";
-}		
+}
 
 #if 1 //#ifndef UCOS
-/* 
+/*
     ==========================================================================
     Description:
         Get site survey results
@@ -1889,11 +1889,11 @@ CHAR *GetAuthMode(CHAR auth)
 */
 #define	LINE_LEN	(4+33+20+8+10+9+7+3)	// Channel+SSID+Bssid+WepStatus+AuthMode+Signal+WiressMode+NetworkType
 VOID RTMPIoctlGetSiteSurvey(
-	IN	PRTMP_ADAPTER	pAdapter, 
+	IN	PRTMP_ADAPTER	pAdapter,
 	IN	struct iwreq	*wrq)
 {
 	CHAR		*msg;
-	INT 		i=0;	 
+	INT 		i=0;
 	INT			WaitCnt;
 	INT 		Status=0;
 	CHAR		Ssid[MAX_LEN_OF_SSID +1];
@@ -1904,7 +1904,7 @@ VOID RTMPIoctlGetSiteSurvey(
 	os_alloc_mem(NULL, (PUCHAR *)&msg, sizeof(CHAR)*((MAX_LEN_OF_BSS_TABLE)*max_len));
 
 	if (msg == NULL)
-	{   
+	{
 		DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - msg memory alloc fail.\n"));
 		return;
 	}
@@ -1914,12 +1914,12 @@ VOID RTMPIoctlGetSiteSurvey(
 	sprintf(msg,"%s","\n");
 	sprintf(msg+strlen(msg),"%-4s%-33s%-20s%-8s%-10s%-9s%-7s%-3s\n",
 	    "Ch", "SSID", "BSSID", "Enc", "Auth", "Siganl(%)", "W-Mode", " NT");
-	
+
 	WaitCnt = 0;
 #ifdef CONFIG_STA_SUPPORT
 	pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
 	while ((ScanRunning(pAdapter) == TRUE) && (WaitCnt++ < 200))
-		OS_WAIT(500);	
+		OS_WAIT(500);
 #endif // CONFIG_STA_SUPPORT //
 
 	for(i=0; i<pAdapter->ScanTab.BssNr ;i++)
@@ -1935,14 +1935,14 @@ VOID RTMPIoctlGetSiteSurvey(
 		//SSID
 		memcpy(Ssid, pAdapter->ScanTab.BssEntry[i].Ssid, pAdapter->ScanTab.BssEntry[i].SsidLen);
 		Ssid[pAdapter->ScanTab.BssEntry[i].SsidLen] = '\0';
-		sprintf(msg+strlen(msg),"%-33s", Ssid);      
+		sprintf(msg+strlen(msg),"%-33s", Ssid);
 		//BSSID
-		sprintf(msg+strlen(msg),"%02x:%02x:%02x:%02x:%02x:%02x   ", 
-			pAdapter->ScanTab.BssEntry[i].Bssid[0], 
+		sprintf(msg+strlen(msg),"%02x:%02x:%02x:%02x:%02x:%02x   ",
+			pAdapter->ScanTab.BssEntry[i].Bssid[0],
 			pAdapter->ScanTab.BssEntry[i].Bssid[1],
-			pAdapter->ScanTab.BssEntry[i].Bssid[2], 
-			pAdapter->ScanTab.BssEntry[i].Bssid[3], 
-			pAdapter->ScanTab.BssEntry[i].Bssid[4], 
+			pAdapter->ScanTab.BssEntry[i].Bssid[2],
+			pAdapter->ScanTab.BssEntry[i].Bssid[3],
+			pAdapter->ScanTab.BssEntry[i].Bssid[4],
 			pAdapter->ScanTab.BssEntry[i].Bssid[5]);
 		//Encryption Type
 		sprintf(msg+strlen(msg),"%-8s",GetEncryptType(pAdapter->ScanTab.BssEntry[i].WepStatus));
@@ -1977,7 +1977,7 @@ VOID RTMPIoctlGetSiteSurvey(
 			sprintf(msg+strlen(msg),"%-7s", "11b/g/n");
 		else
 			sprintf(msg+strlen(msg),"%-7s", "unknow");
-		//Network Type		
+		//Network Type
 		if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_ADHOC)
 			sprintf(msg+strlen(msg),"%-3s", " Ad");
 		else
@@ -1993,13 +1993,13 @@ VOID RTMPIoctlGetSiteSurvey(
 	Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
 
 	DBGPRINT(RT_DEBUG_TRACE, ("RTMPIoctlGetSiteSurvey - wrq->u.data.length = %d\n", wrq->u.data.length));
-	os_free_mem(NULL, (PUCHAR)msg);	
+	os_free_mem(NULL, (PUCHAR)msg);
 }
 
 
 #define	MAC_LINE_LEN	(14+4+4+10+10+10+6+6)	// Addr+aid+psm+datatime+rxbyte+txbyte+current tx rate+last tx rate
 VOID RTMPIoctlGetMacTable(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN struct iwreq *wrq)
 {
 	INT i;
@@ -2032,7 +2032,7 @@ VOID RTMPIoctlGetMacTable(
 			MacTab.Entry[MacTab.Num].TxRate.field.rsv = pAd->MacTab.Content[i].HTPhyMode.field.rsv;
 			MacTab.Entry[MacTab.Num].TxRate.field.MODE = pAd->MacTab.Content[i].HTPhyMode.field.MODE;
 			MacTab.Entry[MacTab.Num].TxRate.word = pAd->MacTab.Content[i].HTPhyMode.word;
-									
+
 			MacTab.Num += 1;
 		}
 	}
@@ -2047,14 +2047,14 @@ VOID RTMPIoctlGetMacTable(
 	sprintf(msg,"%s","\n");
 	sprintf(msg+strlen(msg),"%-14s%-4s%-4s%-10s%-10s%-10s%-6s%-6s\n",
 		"MAC", "AID", "PSM", "LDT", "RxB", "TxB","CTxR", "LTxR");
-	
+
 	for (i=0; i<MAX_LEN_OF_MAC_TABLE; i++)
 	{
 		PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
 		if (pEntry->ValidAsCLI && (pEntry->Sst == SST_ASSOC))
 		{
 			if((strlen(msg)+MAC_LINE_LEN ) >= (MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN) )
-				break;	
+				break;
 			sprintf(msg+strlen(msg),"%02x%02x%02x%02x%02x%02x  ",
 				pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
 				pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5]);
@@ -2066,7 +2066,7 @@ VOID RTMPIoctlGetMacTable(
 			sprintf(msg+strlen(msg),"%-6d",RateIdToMbps[pAd->MacTab.Content[i].CurrTxRate]);
 			sprintf(msg+strlen(msg),"%-6d\n",0/*RateIdToMbps[pAd->MacTab.Content[i].LastTxRate]*/); // ToDo
 		}
-	} 
+	}
 	// for compatible with old API just do the printk to console
 	//wrq->u.data.length = strlen(msg);
 	//if (copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length))
@@ -2080,7 +2080,7 @@ VOID RTMPIoctlGetMacTable(
 
 #ifdef DOT11_N_SUPPORT
 INT	Set_BASetup_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
     UCHAR mac[6], tid;
@@ -2089,12 +2089,12 @@ INT	Set_BASetup_Proc(
     MAC_TABLE_ENTRY *pEntry;
 
 /*
-	The BASetup inupt string format should be xx:xx:xx:xx:xx:xx-d, 
-		=>The six 2 digit hex-decimal number previous are the Mac address, 
+	The BASetup inupt string format should be xx:xx:xx:xx:xx:xx-d,
+		=>The six 2 digit hex-decimal number previous are the Mac address,
 		=>The seventh decimal number is the tid value.
 */
 	//printk("\n%s\n", arg);
-	
+
 	if(strlen(arg) < 19)  //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
 		return FALSE;
 
@@ -2104,7 +2104,7 @@ INT	Set_BASetup_Proc(
 		tid = simple_strtol((token+1), 0, 10);
 		if (tid > 15)
 			return FALSE;
-		
+
 		*token = '\0';
 		for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
 		{
@@ -2133,7 +2133,7 @@ INT	Set_BASetup_Proc(
 }
 
 INT	Set_BADecline_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG bBADecline;
@@ -2148,7 +2148,7 @@ INT	Set_BADecline_Proc(
 	{
 		pAd->CommonCfg.bBADecline = TRUE;
 	}
-	else 
+	else
 	{
 		return FALSE; //Invalid argument
 	}
@@ -2159,7 +2159,7 @@ INT	Set_BADecline_Proc(
 }
 
 INT	Set_BAOriTearDown_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
     UCHAR mac[6], tid;
@@ -2168,8 +2168,8 @@ INT	Set_BAOriTearDown_Proc(
     MAC_TABLE_ENTRY *pEntry;
 
 /*
-	The BAOriTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d, 
-		=>The six 2 digit hex-decimal number previous are the Mac address, 
+	The BAOriTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
+		=>The six 2 digit hex-decimal number previous are the Mac address,
 		=>The seventh decimal number is the tid value.
 */
     if(strlen(arg) < 19)  //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
@@ -2181,7 +2181,7 @@ INT	Set_BAOriTearDown_Proc(
 		tid = simple_strtol((token+1), 0, 10);
 		if (tid > NUM_OF_TID)
 			return FALSE;
-		
+
 		*token = '\0';
 		for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
 		{
@@ -2210,7 +2210,7 @@ INT	Set_BAOriTearDown_Proc(
 }
 
 INT	Set_BARecTearDown_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
     UCHAR mac[6], tid;
@@ -2220,8 +2220,8 @@ INT	Set_BARecTearDown_Proc(
 
     //printk("\n%s\n", arg);
 /*
-	The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d, 
-		=>The six 2 digit hex-decimal number previous are the Mac address, 
+	The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
+		=>The six 2 digit hex-decimal number previous are the Mac address,
 		=>The seventh decimal number is the tid value.
 */
     if(strlen(arg) < 19)  //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and tid value in decimal format.
@@ -2233,7 +2233,7 @@ INT	Set_BARecTearDown_Proc(
 		tid = simple_strtol((token+1), 0, 10);
 		if (tid > NUM_OF_TID)
 			return FALSE;
-		
+
 		*token = '\0';
 		for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
 		{
@@ -2262,7 +2262,7 @@ INT	Set_BARecTearDown_Proc(
 }
 
 INT	Set_HtBw_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG HtBw;
@@ -2273,37 +2273,37 @@ INT	Set_HtBw_Proc(
 	else if (HtBw == BW_20)
 		pAd->CommonCfg.RegTransmitSetting.field.BW  = BW_20;
 	else
-		return FALSE;  //Invalid argument 
+		return FALSE;  //Invalid argument
 
 	SetCommonHT(pAd);
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBw_Proc::(HtBw=%d)\n", pAd->CommonCfg.RegTransmitSetting.field.BW));
 
 	return TRUE;
 }
 
 INT	Set_HtMcs_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG HtMcs, Mcs_tmp;
-#ifdef CONFIG_STA_SUPPORT    
+#ifdef CONFIG_STA_SUPPORT
     BOOLEAN bAutoRate = FALSE;
 #endif // CONFIG_STA_SUPPORT //
 
 	Mcs_tmp = simple_strtol(arg, 0, 10);
-		
-	if (Mcs_tmp <= 15 || Mcs_tmp == 32)			
-		HtMcs = Mcs_tmp;	
+
+	if (Mcs_tmp <= 15 || Mcs_tmp == 32)
+		HtMcs = Mcs_tmp;
 	else
-		HtMcs = MCS_AUTO;	
+		HtMcs = MCS_AUTO;
 
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 	{
 		pAd->StaCfg.DesiredTransmitSetting.field.MCS = HtMcs;
 		pAd->StaCfg.bAutoTxRateSwitch = (HtMcs == MCS_AUTO) ? TRUE:FALSE;
-		DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(HtMcs=%d, bAutoTxRateSwitch = %d)\n", 
+		DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMcs_Proc::(HtMcs=%d, bAutoTxRateSwitch = %d)\n",
 						pAd->StaCfg.DesiredTransmitSetting.field.MCS, pAd->StaCfg.bAutoTxRateSwitch));
 
 		if ((pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED) ||
@@ -2337,27 +2337,27 @@ INT	Set_HtMcs_Proc(
 #endif // CONFIG_STA_SUPPORT //
 
 	SetCommonHT(pAd);
-	
+
 	return TRUE;
 }
 
 INT	Set_HtGi_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG HtGi;
 
 	HtGi = simple_strtol(arg, 0, 10);
-		
-	if ( HtGi == GI_400)			
+
+	if ( HtGi == GI_400)
 		pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_400;
 	else if ( HtGi == GI_800 )
 		pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
-	else 
-		return FALSE; //Invalid argument 	
+	else
+		return FALSE; //Invalid argument
 
 	SetCommonHT(pAd);
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_HtGi_Proc::(ShortGI=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.ShortGI));
 
 	return TRUE;
@@ -2365,13 +2365,13 @@ INT	Set_HtGi_Proc(
 
 
 INT	Set_HtTxBASize_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UCHAR Size;
 
 	Size = simple_strtol(arg, 0, 10);
-		
+
 	if (Size <=0 || Size >=64)
 	{
 		Size = 8;
@@ -2384,103 +2384,103 @@ INT	Set_HtTxBASize_Proc(
 
 
 INT	Set_HtOpMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 
 	ULONG Value;
-	
+
 	Value = simple_strtol(arg, 0, 10);
 
 	if (Value == HTMODE_GF)
 		pAd->CommonCfg.RegTransmitSetting.field.HTMODE  = HTMODE_GF;
 	else if ( Value == HTMODE_MM )
 		pAd->CommonCfg.RegTransmitSetting.field.HTMODE  = HTMODE_MM;
-	else 
-		return FALSE; //Invalid argument 	
+	else
+		return FALSE; //Invalid argument
 
 	SetCommonHT(pAd);
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_HtOpMode_Proc::(HtOpMode=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.HTMODE));
 
 	return TRUE;
 
-}	
+}
 
 INT	Set_HtStbc_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 
 	ULONG Value;
-	
+
 	Value = simple_strtol(arg, 0, 10);
-	
+
 	if (Value == STBC_USE)
 		pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
 	else if ( Value == STBC_NONE )
 		pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_NONE;
-	else 
-		return FALSE; //Invalid argument 	
+	else
+		return FALSE; //Invalid argument
 
 	SetCommonHT(pAd);
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_Stbc_Proc::(HtStbc=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.STBC));
 
-	return TRUE;											
+	return TRUE;
 }
 
 INT	Set_HtHtc_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 
 	ULONG Value;
-	
+
 	Value = simple_strtol(arg, 0, 10);
 	if (Value == 0)
 		pAd->HTCEnable = FALSE;
 	else if ( Value ==1 )
         	pAd->HTCEnable = TRUE;
-	else 
-		return FALSE; //Invalid argument 	
-	
+	else
+		return FALSE; //Invalid argument
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_HtHtc_Proc::(HtHtc=%d)\n",pAd->HTCEnable));
 
-	return TRUE;		
+	return TRUE;
 }
-			
+
 INT	Set_HtExtcha_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 
 	ULONG Value;
-	
+
 	Value = simple_strtol(arg, 0, 10);
-	
-	if (Value == 0)			
+
+	if (Value == 0)
 		pAd->CommonCfg.RegTransmitSetting.field.EXTCHA  = EXTCHA_BELOW;
 	else if ( Value ==1 )
         pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
-	else 
-		return FALSE; //Invalid argument 	
-	
+	else
+		return FALSE; //Invalid argument
+
 	SetCommonHT(pAd);
 
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_HtExtcha_Proc::(HtExtcha=%d)\n",pAd->CommonCfg.RegTransmitSetting.field.EXTCHA));
 
-	return TRUE;			
+	return TRUE;
 }
 
 INT	Set_HtMpduDensity_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG Value;
-	
+
 	Value = simple_strtol(arg, 0, 10);
-	
+
 	if (Value <=7 && Value >= 0)
 		pAd->CommonCfg.BACapability.field.MpduDensity = Value;
 	else
@@ -2490,15 +2490,15 @@ INT	Set_HtMpduDensity_Proc(
 
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMpduDensity_Proc::(HtMpduDensity=%d)\n",pAd->CommonCfg.BACapability.field.MpduDensity));
 
-	return TRUE;																																	
+	return TRUE;
 }
 
 INT	Set_HtBaWinSize_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG Value;
-	
+
 	Value = simple_strtol(arg, 0, 10);
 
 
@@ -2512,45 +2512,45 @@ INT	Set_HtBaWinSize_Proc(
         pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = 64;
 		pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64;
 	}
-	
+
 	SetCommonHT(pAd);
 
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_HtBaWinSize_Proc::(HtBaWinSize=%d)\n",pAd->CommonCfg.BACapability.field.RxBAWinLimit));
 
-	return TRUE;																																	
-}		
+	return TRUE;
+}
 
 INT	Set_HtRdg_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG Value;
-	
+
 	Value = simple_strtol(arg, 0, 10);
-	
-	if (Value == 0)			
+
+	if (Value == 0)
 		pAd->CommonCfg.bRdg = FALSE;
 	else if ( Value ==1 )
 	{
 		pAd->HTCEnable = TRUE;
         	pAd->CommonCfg.bRdg = TRUE;
 	}
-	else 
+	else
 		return FALSE; //Invalid argument
-	
-	SetCommonHT(pAd);	
-		
+
+	SetCommonHT(pAd);
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_HtRdg_Proc::(HtRdg=%d)\n",pAd->CommonCfg.bRdg));
 
-	return TRUE;																																	
-}		
+	return TRUE;
+}
 
-INT	Set_HtLinkAdapt_Proc(																																																																																																																																																																																																																																																																																																																			
-	IN	PRTMP_ADAPTER	pAd, 
+INT	Set_HtLinkAdapt_Proc(
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG Value;
-	
+
 	Value = simple_strtol(arg, 0, 10);
 	if (Value == 0)
 		pAd->bLinkAdapt = FALSE;
@@ -2561,18 +2561,18 @@ INT	Set_HtLinkAdapt_Proc(
 	}
 	else
 		return FALSE; //Invalid argument
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_HtLinkAdapt_Proc::(HtLinkAdapt=%d)\n",pAd->bLinkAdapt));
 
-	return TRUE;																																	
-}		
+	return TRUE;
+}
 
-INT	Set_HtAmsdu_Proc(																																																																																																																																																																																																																																																																																																																			
-	IN	PRTMP_ADAPTER	pAd, 
+INT	Set_HtAmsdu_Proc(
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG Value;
-	
+
 	Value = simple_strtol(arg, 0, 10);
 	if (Value == 0)
 		pAd->CommonCfg.BACapability.field.AmsduEnable = FALSE;
@@ -2580,39 +2580,39 @@ INT	Set_HtAmsdu_Proc(
         pAd->CommonCfg.BACapability.field.AmsduEnable = TRUE;
 	else
 		return FALSE; //Invalid argument
-	
-	SetCommonHT(pAd);	
-		
+
+	SetCommonHT(pAd);
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAmsdu_Proc::(HtAmsdu=%d)\n",pAd->CommonCfg.BACapability.field.AmsduEnable));
 
-	return TRUE;																																	
-}			
+	return TRUE;
+}
 
 INT	Set_HtAutoBa_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG Value;
-	
+
 	Value = simple_strtol(arg, 0, 10);
 	if (Value == 0)
 		pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
-    else if (Value == 1)	
+    else if (Value == 1)
 		pAd->CommonCfg.BACapability.field.AutoBA = TRUE;
 	else
 		return FALSE; //Invalid argument
-	
+
     pAd->CommonCfg.REGBACapability.field.AutoBA = pAd->CommonCfg.BACapability.field.AutoBA;
-	SetCommonHT(pAd);	
-		
+	SetCommonHT(pAd);
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_HtAutoBa_Proc::(HtAutoBa=%d)\n",pAd->CommonCfg.BACapability.field.AutoBA));
 
-	return TRUE;				
-		
-}		
-																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																																						
+	return TRUE;
+
+}
+
 INT	Set_HtProtect_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG Value;
@@ -2620,7 +2620,7 @@ INT	Set_HtProtect_Proc(
 	Value = simple_strtol(arg, 0, 10);
 	if (Value == 0)
 		pAd->CommonCfg.bHTProtect = FALSE;
-    else if (Value == 1)	
+    else if (Value == 1)
 		pAd->CommonCfg.bHTProtect = TRUE;
 	else
 		return FALSE; //Invalid argument
@@ -2631,7 +2631,7 @@ INT	Set_HtProtect_Proc(
 }
 
 INT	Set_SendPSMPAction_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
     UCHAR mac[6], mode;
@@ -2641,8 +2641,8 @@ INT	Set_SendPSMPAction_Proc(
 
     //printk("\n%s\n", arg);
 /*
-	The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d, 
-		=>The six 2 digit hex-decimal number previous are the Mac address, 
+	The BARecTearDown inupt string format should be xx:xx:xx:xx:xx:xx-d,
+		=>The six 2 digit hex-decimal number previous are the Mac address,
 		=>The seventh decimal number is the mode value.
 */
     if(strlen(arg) < 19)  //Mac address acceptable format 01:02:03:04:05:06 length 17 plus the "-" and mode value in decimal format.
@@ -2654,7 +2654,7 @@ INT	Set_SendPSMPAction_Proc(
 		mode = simple_strtol((token+1), 0, 10);
 		if (mode > MMPS_ENABLE)
 			return FALSE;
-		
+
 		*token = '\0';
 		for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
 		{
@@ -2684,13 +2684,13 @@ INT	Set_SendPSMPAction_Proc(
 }
 
 INT	Set_HtMIMOPSmode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG Value;
-	
+
 	Value = simple_strtol(arg, 0, 10);
-	
+
 	if (Value <=3 && Value >= 0)
 		pAd->CommonCfg.BACapability.field.MMPSmode = Value;
 	else
@@ -2700,12 +2700,12 @@ INT	Set_HtMIMOPSmode_Proc(
 
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_HtMIMOPSmode_Proc::(MIMOPS mode=%d)\n",pAd->CommonCfg.BACapability.field.MMPSmode));
 
-	return TRUE;																																	
+	return TRUE;
 }
 
 
 INT	Set_ForceShortGI_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG Value;
@@ -2713,7 +2713,7 @@ INT	Set_ForceShortGI_Proc(
 	Value = simple_strtol(arg, 0, 10);
 	if (Value == 0)
 		pAd->WIFItestbed.bShortGI = FALSE;
-	else if (Value == 1)	
+	else if (Value == 1)
 		pAd->WIFItestbed.bShortGI = TRUE;
 	else
 		return FALSE; //Invalid argument
@@ -2728,7 +2728,7 @@ INT	Set_ForceShortGI_Proc(
 
 
 INT	Set_ForceGF_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG Value;
@@ -2736,7 +2736,7 @@ INT	Set_ForceGF_Proc(
 	Value = simple_strtol(arg, 0, 10);
 	if (Value == 0)
 		pAd->WIFItestbed.bGreenField = FALSE;
-	else if (Value == 1)	
+	else if (Value == 1)
 		pAd->WIFItestbed.bGreenField = TRUE;
 	else
 		return FALSE; //Invalid argument
@@ -2749,7 +2749,7 @@ INT	Set_ForceGF_Proc(
 }
 
 INT	Set_HtMimoPs_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG Value;
@@ -2757,7 +2757,7 @@ INT	Set_HtMimoPs_Proc(
 	Value = simple_strtol(arg, 0, 10);
 	if (Value == 0)
 		pAd->CommonCfg.bMIMOPSEnable = FALSE;
-	else if (Value == 1)	
+	else if (Value == 1)
 		pAd->CommonCfg.bMIMOPSEnable = TRUE;
 	else
 		return FALSE; //Invalid argument
@@ -2774,10 +2774,10 @@ INT	SetCommonHT(
 	IN	PRTMP_ADAPTER	pAd)
 {
 	OID_SET_HT_PHYMODE		SetHT;
-	
+
 	if (pAd->CommonCfg.PhyMode < PHY_11ABGN_MIXED)
 		return FALSE;
-				
+
 	SetHT.PhyMode = pAd->CommonCfg.PhyMode;
 	SetHT.TransmitNo = ((UCHAR)pAd->Antenna.field.TxPath);
 	SetHT.HtMode = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.HTMODE;
@@ -2785,7 +2785,7 @@ INT	SetCommonHT(
 	SetHT.MCS = MCS_AUTO;
 	SetHT.BW = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.BW;
 	SetHT.STBC = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.STBC;
-	SetHT.SHORTGI = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;		
+	SetHT.SHORTGI = (UCHAR)pAd->CommonCfg.RegTransmitSetting.field.ShortGI;
 
 	RTMPSetHT(pAd, &SetHT);
 
@@ -2794,7 +2794,7 @@ INT	SetCommonHT(
 #endif // DOT11_N_SUPPORT //
 
 INT	Set_FixedTxMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UCHAR	fix_tx_mode = FIXED_TXMODE_HT;
@@ -2802,17 +2802,17 @@ INT	Set_FixedTxMode_Proc(
 	if (strcmp(arg, "OFDM") == 0 || strcmp(arg, "ofdm") == 0)
 	{
 		fix_tx_mode = FIXED_TXMODE_OFDM;
-	}	
+	}
 	else if (strcmp(arg, "CCK") == 0 || strcmp(arg, "cck") == 0)
 	{
         fix_tx_mode = FIXED_TXMODE_CCK;
 	}
-	
+
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 		pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
 #endif // CONFIG_STA_SUPPORT //
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Set_FixedTxMode_Proc::(FixedTxMode=%d)\n", fix_tx_mode));
 
 	return TRUE;
@@ -2820,7 +2820,7 @@ INT	Set_FixedTxMode_Proc(
 
 #ifdef CONFIG_APSTA_MIXED_SUPPORT
 INT	Set_OpMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG Value;
@@ -2837,7 +2837,7 @@ INT	Set_OpMode_Proc(
 
 	if (Value == 0)
 		pAd->OpMode = OPMODE_STA;
-	else if (Value == 1)	
+	else if (Value == 1)
 		pAd->OpMode = OPMODE_AP;
 	else
 		return FALSE; //Invalid argument
@@ -2886,7 +2886,7 @@ PCHAR   RTMPGetRalinkEncryModeStr(
 		case Ndis802_11WEPDisabled:
 			return "NONE";
 		case Ndis802_11WEPEnabled:
-			return "WEP";        
+			return "WEP";
 		case Ndis802_11Encryption2Enabled:
 			return "TKIP";
 		case Ndis802_11Encryption3Enabled:
@@ -2897,16 +2897,16 @@ PCHAR   RTMPGetRalinkEncryModeStr(
 }
 
 INT RTMPShowCfgValue(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			pName,
 	IN	PUCHAR			pBuf)
 {
-	INT	Status = 0;	
-	
+	INT	Status = 0;
+
 	for (PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC = RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC++)
 	{
-		if (!strcmp(pName, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name)) 
-		{						
+		if (!strcmp(pName, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name))
+		{
 			if(PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->show_proc(pAd, pBuf))
 				Status = -EINVAL;
 			break;  //Exit for loop.
@@ -2919,12 +2919,12 @@ INT RTMPShowCfgValue(
 		for (PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC = RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC++)
 			sprintf(pBuf, "%s%s\n", pBuf, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name);
 	}
-	
+
 	return Status;
 }
 
 INT	Show_SSID_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 
@@ -2936,7 +2936,7 @@ INT	Show_SSID_Proc(
 }
 
 INT	Show_WirelessMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	switch(pAd->CommonCfg.PhyMode)
@@ -2988,7 +2988,7 @@ INT	Show_WirelessMode_Proc(
 
 
 INT	Show_TxBurst_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%s", pAd->CommonCfg.bEnableTxBurst ? "TRUE":"FALSE");
@@ -2996,7 +2996,7 @@ INT	Show_TxBurst_Proc(
 }
 
 INT	Show_TxPreamble_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	switch(pAd->CommonCfg.TxPreamble)
@@ -3014,12 +3014,12 @@ INT	Show_TxPreamble_Proc(
 			sprintf(pBuf, "\tUnknow Value(%lu)", pAd->CommonCfg.TxPreamble);
 			break;
 	}
-	
+
 	return 0;
 }
 
 INT	Show_TxPower_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%lu", pAd->CommonCfg.TxPowerPercentage);
@@ -3027,7 +3027,7 @@ INT	Show_TxPower_Proc(
 }
 
 INT	Show_Channel_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%d", pAd->CommonCfg.Channel);
@@ -3035,7 +3035,7 @@ INT	Show_Channel_Proc(
 }
 
 INT	Show_BGProtection_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	switch(pAd->CommonCfg.UseBGProtection)
@@ -3057,7 +3057,7 @@ INT	Show_BGProtection_Proc(
 }
 
 INT	Show_RTSThreshold_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%u", pAd->CommonCfg.RtsThreshold);
@@ -3065,7 +3065,7 @@ INT	Show_RTSThreshold_Proc(
 }
 
 INT	Show_FragThreshold_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%u", pAd->CommonCfg.FragmentThreshold);
@@ -3074,7 +3074,7 @@ INT	Show_FragThreshold_Proc(
 
 #ifdef DOT11_N_SUPPORT
 INT	Show_HtBw_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	if (pAd->CommonCfg.RegTransmitSetting.field.BW == BW_40)
@@ -3089,7 +3089,7 @@ INT	Show_HtBw_Proc(
 }
 
 INT	Show_HtMcs_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 
@@ -3101,7 +3101,7 @@ INT	Show_HtMcs_Proc(
 }
 
 INT	Show_HtGi_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	switch(pAd->CommonCfg.RegTransmitSetting.field.ShortGI)
@@ -3120,7 +3120,7 @@ INT	Show_HtGi_Proc(
 }
 
 INT	Show_HtOpMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	switch(pAd->CommonCfg.RegTransmitSetting.field.HTMODE)
@@ -3139,7 +3139,7 @@ INT	Show_HtOpMode_Proc(
 }
 
 INT	Show_HtExtcha_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	switch(pAd->CommonCfg.RegTransmitSetting.field.EXTCHA)
@@ -3159,7 +3159,7 @@ INT	Show_HtExtcha_Proc(
 
 
 INT	Show_HtMpduDensity_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.MpduDensity);
@@ -3167,7 +3167,7 @@ INT	Show_HtMpduDensity_Proc(
 }
 
 INT	Show_HtBaWinSize_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%u", pAd->CommonCfg.BACapability.field.RxBAWinLimit);
@@ -3175,7 +3175,7 @@ INT	Show_HtBaWinSize_Proc(
 }
 
 INT	Show_HtRdg_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%s", pAd->CommonCfg.bRdg ? "TRUE":"FALSE");
@@ -3183,7 +3183,7 @@ INT	Show_HtRdg_Proc(
 }
 
 INT	Show_HtAmsdu_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AmsduEnable ? "TRUE":"FALSE");
@@ -3191,7 +3191,7 @@ INT	Show_HtAmsdu_Proc(
 }
 
 INT	Show_HtAutoBa_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%s", pAd->CommonCfg.BACapability.field.AutoBA ? "TRUE":"FALSE");
@@ -3200,7 +3200,7 @@ INT	Show_HtAutoBa_Proc(
 #endif // DOT11_N_SUPPORT //
 
 INT	Show_CountryRegion_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegion);
@@ -3208,7 +3208,7 @@ INT	Show_CountryRegion_Proc(
 }
 
 INT	Show_CountryRegionABand_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%d", pAd->CommonCfg.CountryRegionForABand);
@@ -3216,7 +3216,7 @@ INT	Show_CountryRegionABand_Proc(
 }
 
 INT	Show_CountryCode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%s", pAd->CommonCfg.CountryCode);
@@ -3225,7 +3225,7 @@ INT	Show_CountryCode_Proc(
 
 #ifdef AGGREGATION_SUPPORT
 INT	Show_PktAggregate_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%s", pAd->CommonCfg.bAggregationCapable ? "TRUE":"FALSE");
@@ -3235,7 +3235,7 @@ INT	Show_PktAggregate_Proc(
 
 #ifdef WMM_SUPPORT
 INT	Show_WmmCapable_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 
@@ -3243,13 +3243,13 @@ INT	Show_WmmCapable_Proc(
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 		sprintf(pBuf, "\t%s", pAd->CommonCfg.bWmmCapable ? "TRUE":"FALSE");
 #endif // CONFIG_STA_SUPPORT //
-	
+
 	return 0;
 }
 #endif // WMM_SUPPORT //
 
 INT	Show_IEEE80211H_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	sprintf(pBuf, "\t%s", pAd->CommonCfg.bIEEE80211H ? "TRUE":"FALSE");
@@ -3258,7 +3258,7 @@ INT	Show_IEEE80211H_Proc(
 
 #ifdef CONFIG_STA_SUPPORT
 INT	Show_NetworkType_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	switch(pAd->StaCfg.BssType)
@@ -3284,27 +3284,27 @@ INT	Show_NetworkType_Proc(
 #endif // CONFIG_STA_SUPPORT //
 
 INT	Show_AuthMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
-	NDIS_802_11_AUTHENTICATION_MODE	AuthMode = Ndis802_11AuthModeOpen; 
+	NDIS_802_11_AUTHENTICATION_MODE	AuthMode = Ndis802_11AuthModeOpen;
 
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 		AuthMode = pAd->StaCfg.AuthMode;
 #endif // CONFIG_STA_SUPPORT //
 
-	if ((AuthMode >= Ndis802_11AuthModeOpen) && 
+	if ((AuthMode >= Ndis802_11AuthModeOpen) &&
 		(AuthMode <= Ndis802_11AuthModeWPA1PSKWPA2PSK))
 		sprintf(pBuf, "\t%s", RTMPGetRalinkAuthModeStr(AuthMode));
 	else
 		sprintf(pBuf, "\tUnknow Value(%d)", AuthMode);
-	
+
 	return 0;
 }
 
 INT	Show_EncrypType_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	NDIS_802_11_WEP_STATUS	WepStatus = Ndis802_11WEPDisabled;
@@ -3314,17 +3314,17 @@ INT	Show_EncrypType_Proc(
 		WepStatus = pAd->StaCfg.WepStatus;
 #endif // CONFIG_STA_SUPPORT //
 
-	if ((WepStatus >= Ndis802_11WEPEnabled) && 
+	if ((WepStatus >= Ndis802_11WEPEnabled) &&
 		(WepStatus <= Ndis802_11Encryption4KeyAbsent))
 		sprintf(pBuf, "\t%s", RTMPGetRalinkEncryModeStr(WepStatus));
 	else
 		sprintf(pBuf, "\tUnknow Value(%d)", WepStatus);
-	
+
 	return 0;
 }
 
 INT	Show_DefaultKeyID_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	UCHAR DefaultKeyId = 0;
@@ -3340,7 +3340,7 @@ INT	Show_DefaultKeyID_Proc(
 }
 
 INT	Show_WepKey_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN  INT				KeyIdx,
 	OUT	PUCHAR			pBuf)
 {
@@ -3348,8 +3348,8 @@ INT	Show_WepKey_Proc(
 	INT		index = BSS0;
 
 	KeyLength = pAd->SharedKey[index][KeyIdx].KeyLen;
-	NdisMoveMemory(Key, pAd->SharedKey[index][KeyIdx].Key, KeyLength);		
-		
+	NdisMoveMemory(Key, pAd->SharedKey[index][KeyIdx].Key, KeyLength);
+
 	//check key string is ASCII or not
     if (RTMPCheckStrPrintAble(Key, KeyLength))
         sprintf(pBuf, "\t%s", Key);
@@ -3364,7 +3364,7 @@ INT	Show_WepKey_Proc(
 }
 
 INT	Show_Key1_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	Show_WepKey_Proc(pAd, 0, pBuf);
@@ -3372,7 +3372,7 @@ INT	Show_Key1_Proc(
 }
 
 INT	Show_Key2_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	Show_WepKey_Proc(pAd, 1, pBuf);
@@ -3380,7 +3380,7 @@ INT	Show_Key2_Proc(
 }
 
 INT	Show_Key3_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	Show_WepKey_Proc(pAd, 2, pBuf);
@@ -3388,7 +3388,7 @@ INT	Show_Key3_Proc(
 }
 
 INT	Show_Key4_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	Show_WepKey_Proc(pAd, 3, pBuf);
@@ -3396,7 +3396,7 @@ INT	Show_Key4_Proc(
 }
 
 INT	Show_WPAPSK_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	OUT	PUCHAR			pBuf)
 {
 	INT 	idx;
@@ -3407,7 +3407,7 @@ INT	Show_WPAPSK_Proc(
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 		NdisMoveMemory(PMK, pAd->StaCfg.PMK, 32);
 #endif // CONFIG_STA_SUPPORT //
-	
+
     sprintf(pBuf, "\tPMK = ");
     for (idx = 0; idx < 32; idx++)
         sprintf(pBuf+strlen(pBuf), "%02X", PMK[idx]);
diff --git a/common/cmm_sanity.c b/common/cmm_sanity.c
index 1c52263..b0f070d 100644
--- a/common/cmm_sanity.c
+++ b/common/cmm_sanity.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -34,7 +34,7 @@
 	--------	----------		----------------------------------------------
 	John Chang  2004-09-01      add WMM support
 */
-#include "rt_config.h"
+#include "../rt_config.h"
 
 
 extern UCHAR	CISCO_OUI[];
@@ -48,22 +48,22 @@ extern UCHAR	RALINK_OUI[];
 extern UCHAR	BROADCOM_OUI[];
 extern UCHAR    WPS_OUI[];
 
-/* 
+/*
     ==========================================================================
     Description:
         MLME message sanity check
     Return:
         TRUE if all parameters are OK, FALSE otherwise
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 BOOLEAN MlmeAddBAReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
-    OUT PUCHAR pAddr2) 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
+    OUT PUCHAR pAddr2)
 {
     PMLME_ADDBA_REQ_STRUCT   pInfo;
 
@@ -73,38 +73,38 @@ BOOLEAN MlmeAddBAReqSanity(
     {
         DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - message lenght not correct.\n"));
         return FALSE;
-    }	
-	
+    }
+
     if ((pInfo->Wcid >= MAX_LEN_OF_MAC_TABLE))
     {
         DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - The peer Mac is not associated yet.\n"));
         return FALSE;
-    }	
+    }
 
     if ((pInfo->pAddr[0]&0x01) == 0x01)
     {
         DBGPRINT(RT_DEBUG_TRACE, ("MlmeAddBAReqSanity fail - broadcast address not support BA\n"));
         return FALSE;
-    }	
-    
+    }
+
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         MLME message sanity check
     Return:
         TRUE if all parameters are OK, FALSE otherwise
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 BOOLEAN MlmeDelBAReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen) 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen)
 {
 	MLME_DELBA_REQ_STRUCT *pInfo;
 	pInfo = (MLME_DELBA_REQ_STRUCT *)Msg;
@@ -113,32 +113,32 @@ BOOLEAN MlmeDelBAReqSanity(
     {
         DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - message lenght not correct.\n"));
         return FALSE;
-    }	
-	
+    }
+
     if ((pInfo->Wcid >= MAX_LEN_OF_MAC_TABLE))
     {
         DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - The peer Mac is not associated yet.\n"));
         return FALSE;
-    }	
+    }
 
     if ((pInfo->TID & 0xf0))
     {
         DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - The peer TID is incorrect.\n"));
         return FALSE;
-    }	
+    }
 
 	if (NdisEqualMemory(pAd->MacTab.Content[pInfo->Wcid].Addr, pInfo->Addr, MAC_ADDR_LEN) == 0)
-    {    	
-        DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - the peer addr dosen't exist.\n"));		
+    {
+        DBGPRINT(RT_DEBUG_ERROR, ("MlmeDelBAReqSanity fail - the peer addr dosen't exist.\n"));
         return FALSE;
-    }	
-    
+    }
+
     return TRUE;
 }
 
 BOOLEAN PeerAddBAReqActionSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *pMsg, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *pMsg,
     IN ULONG MsgLen,
 	OUT PUCHAR pAddr2)
 {
@@ -153,7 +153,7 @@ BOOLEAN PeerAddBAReqActionSanity(
 	// we support immediate BA.
 	*(USHORT *)(&pAddFrame->BaParm) = cpu2le16(*(USHORT *)(&pAddFrame->BaParm));
 	pAddFrame->TimeOutValue = cpu2le16(pAddFrame->TimeOutValue);
-	pAddFrame->BaStartSeq.word = cpu2le16(pAddFrame->BaStartSeq.word); 
+	pAddFrame->BaStartSeq.word = cpu2le16(pAddFrame->BaStartSeq.word);
 
 	if (pAddFrame->BaParm.BAPolicy != IMMED_BA)
 	{
@@ -173,12 +173,12 @@ BOOLEAN PeerAddBAReqActionSanity(
 }
 
 BOOLEAN PeerAddBARspActionSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *pMsg, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *pMsg,
     IN ULONG MsgLen)
 {
 	PFRAME_ADDBA_RSP pAddFrame;
-	
+
 	pAddFrame = (PFRAME_ADDBA_RSP)(pMsg);
 	if (MsgLen < (sizeof(FRAME_ADDBA_RSP)))
 	{
@@ -207,19 +207,19 @@ BOOLEAN PeerAddBARspActionSanity(
 }
 
 BOOLEAN PeerDelBAActionSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN UCHAR Wcid, 
-    IN VOID *pMsg, 
+    IN PRTMP_ADAPTER pAd,
+    IN UCHAR Wcid,
+    IN VOID *pMsg,
     IN ULONG MsgLen )
 {
 	//PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
 	PFRAME_DELBA_REQ  pDelFrame;
 	if (MsgLen != (sizeof(FRAME_DELBA_REQ)))
 		return FALSE;
-	
+
 	if (Wcid >= MAX_LEN_OF_MAC_TABLE)
 		return FALSE;
-	
+
 	pDelFrame = (PFRAME_DELBA_REQ)(pMsg);
 
 	*(USHORT *)(&pDelFrame->DelbaParm) = cpu2le16(*(USHORT *)(&pDelFrame->DelbaParm));
@@ -227,43 +227,43 @@ BOOLEAN PeerDelBAActionSanity(
 
 	if (pDelFrame->DelbaParm.TID &0xfff0)
 		return FALSE;
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         MLME message sanity check
     Return:
         TRUE if all parameters are OK, FALSE otherwise
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 BOOLEAN PeerBeaconAndProbeRspSanity(
     IN PRTMP_ADAPTER pAd,
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
+    IN VOID *Msg,
+    IN ULONG MsgLen,
     IN UCHAR  MsgChannel,
-    OUT PUCHAR pAddr2, 
-    OUT PUCHAR pBssid, 
-    OUT CHAR Ssid[], 
-    OUT UCHAR *pSsidLen, 
-    OUT UCHAR *pBssType, 
-    OUT USHORT *pBeaconPeriod, 
-    OUT UCHAR *pChannel, 
-    OUT UCHAR *pNewChannel, 
-    OUT LARGE_INTEGER *pTimestamp, 
-    OUT CF_PARM *pCfParm, 
-    OUT USHORT *pAtimWin, 
-    OUT USHORT *pCapabilityInfo, 
+    OUT PUCHAR pAddr2,
+    OUT PUCHAR pBssid,
+    OUT CHAR Ssid[],
+    OUT UCHAR *pSsidLen,
+    OUT UCHAR *pBssType,
+    OUT USHORT *pBeaconPeriod,
+    OUT UCHAR *pChannel,
+    OUT UCHAR *pNewChannel,
+    OUT LARGE_INTEGER *pTimestamp,
+    OUT CF_PARM *pCfParm,
+    OUT USHORT *pAtimWin,
+    OUT USHORT *pCapabilityInfo,
     OUT UCHAR *pErp,
-    OUT UCHAR *pDtimCount, 
-    OUT UCHAR *pDtimPeriod, 
-    OUT UCHAR *pBcastFlag, 
-    OUT UCHAR *pMessageToMe, 
+    OUT UCHAR *pDtimCount,
+    OUT UCHAR *pDtimPeriod,
+    OUT UCHAR *pBcastFlag,
+    OUT UCHAR *pMessageToMe,
     OUT UCHAR SupRate[],
     OUT UCHAR *pSupRateLen,
     OUT UCHAR ExtRate[],
@@ -282,8 +282,8 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
 	OUT UCHAR		 *AddHtInfoLen,
 	OUT ADD_HT_INFO_IE *AddHtInfo,
 	OUT UCHAR *NewExtChannelOffset,		// Ht extension channel offset(above or below)
-    OUT USHORT *LengthVIE,	
-    OUT	PNDIS_802_11_VARIABLE_IEs pVIE) 
+    OUT USHORT *LengthVIE,
+    OUT	PNDIS_802_11_VARIABLE_IEs pVIE)
 {
     CHAR				*Ptr;
 #ifdef CONFIG_STA_SUPPORT
@@ -301,12 +301,12 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
 	//	1. If the AP is 11n enabled, then check the control channel.
 	//	2. If the AP didn't have any info about channel, use the channel we received this frame as the channel. (May inaccuracy!!)
 	UCHAR			CtrlChannel = 0;
-	
+
     // Add for 3 necessary EID field check
     Sanity = 0;
 
     *pAtimWin = 0;
-    *pErp = 0;	
+    *pErp = 0;
     *pDtimCount = 0;
     *pDtimPeriod = 0;
     *pBcastFlag = 0;
@@ -328,19 +328,19 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
     pQbssLoad->bValid = FALSE;      // default: no IE_QBSS_LOAD found
     pEdcaParm->bValid = FALSE;      // default: no IE_EDCA_PARAMETER found
     pQosCapability->bValid = FALSE; // default: no IE_QOS_CAPABILITY found
-    
+
     pFrame = (PFRAME_802_11)Msg;
-    
+
     // get subtype from header
     SubType = (UCHAR)pFrame->Hdr.FC.SubType;
 
     // get Addr2 and BSSID from header
     COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
     COPY_MAC_ADDR(pBssid, pFrame->Hdr.Addr3);
-    
+
     Ptr = pFrame->Octet;
     Length += LENGTH_802_11;
-    
+
     // get timestamp from payload and advance the pointer
     NdisMoveMemory(pTimestamp, Ptr, TIMESTAMP_LEN);
 
@@ -360,15 +360,15 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
     Ptr += 2;
     Length += 2;
 
-    if (CAP_IS_ESS_ON(*pCapabilityInfo)) 
+    if (CAP_IS_ESS_ON(*pCapabilityInfo))
         *pBssType = BSS_INFRA;
-    else 
+    else
         *pBssType = BSS_ADHOC;
 
     pEid = (PEID_STRUCT) Ptr;
 
     // get variable fields from payload and advance the pointer
-    while ((Length + 2 + pEid->Len) <= MsgLen)    
+    while ((Length + 2 + pEid->Len) <= MsgLen)
     {
         //
         // Secure copy VIE to VarIE[MAX_VIE_LEN] didn't overflow.
@@ -406,7 +406,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
                     NdisMoveMemory(SupRate, pEid->Octet, pEid->Len);
                     *pSupRateLen = pEid->Len;
 
-                    // TODO: 2004-09-14 not a good design here, cause it exclude extra rates 
+                    // TODO: 2004-09-14 not a good design here, cause it exclude extra rates
                     // from ScanTab. We should report as is. And filter out unsupported
                     // rates in MlmeAux.
                     // Check against the supported rates
@@ -443,10 +443,10 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
 			{
 				DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - wrong IE_HT_CAP. pEid->Len = %d\n", pEid->Len));
 			}
-				
+
 		break;
             case IE_ADD_HT:
-			if (pEid->Len >= sizeof(ADD_HT_INFO_IE))				
+			if (pEid->Len >= sizeof(ADD_HT_INFO_IE))
 			{
 				// This IE allows extension, but we can ignore extra bytes beyond our knowledge , so only
 				// copy first sizeof(ADD_HT_INFO_IE)
@@ -454,10 +454,10 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
 				*AddHtInfoLen = SIZE_ADD_HT_INFO_IE;
 
 				CtrlChannel = AddHtInfo->ControlChan;
-				
+
 				*(USHORT *)(&AddHtInfo->AddHtInfo2) = cpu2le16(*(USHORT *)(&AddHtInfo->AddHtInfo2));
 				*(USHORT *)(&AddHtInfo->AddHtInfo3) = cpu2le16(*(USHORT *)(&AddHtInfo->AddHtInfo3));
-           
+
 #ifdef CONFIG_STA_SUPPORT
 				IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 				{
@@ -471,7 +471,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
 			{
 				DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - wrong IE_ADD_HT. \n"));
 			}
-				
+
 		break;
             case IE_SECONDARY_CH_OFFSET:
 			if (pEid->Len == 1)
@@ -482,7 +482,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
 			{
 				DBGPRINT(RT_DEBUG_WARN, ("PeerBeaconAndProbeRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
 			}
-				
+
 		break;
             case IE_FH_PARM:
                 DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAndProbeRspSanity(IE_FH_PARM) \n"));
@@ -497,7 +497,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
 					{
 						if (ChannelSanity(pAd, *pChannel) == 0)
 						{
-							
+
 							return FALSE;
 						}
 					}
@@ -571,7 +571,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
 #ifdef CONFIG_STA_SUPPORT
 #ifdef DOT11_N_SUPPORT
 		// This HT IE is before IEEE draft set HT IE value.2006-09-28 by Jan.
-                
+
                 // Other vendors had production before IE_HT_CAP value is assigned. To backward support those old-firmware AP,
                 // Check broadcom-defiend pre-802.11nD1.0 OUI for HT related IE, including HT Capatilities IE and HT Information IE
                 else if ((*pHtCapabilityLen == 0) && NdisEqualMemory(pEid->Octet, PRE_N_HT_OUI, 3) && (pEid->Len >= 4) && (pAd->OpMode == OPMODE_STA))
@@ -664,7 +664,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
                     NdisMoveMemory(ExtRate, pEid->Octet, pEid->Len);
                     *pExtRateLen = pEid->Len;
 
-                    // TODO: 2004-09-14 not a good design here, cause it exclude extra rates 
+                    // TODO: 2004-09-14 not a good design here, cause it exclude extra rates
                     // from ScanTab. We should report as is. And filter out unsupported
                     // rates in MlmeAux.
                     // Check against the supported rates
@@ -687,7 +687,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
                     break;
 
                 // 1. Copy CKIP flag byte to buffer for process
-                *pCkipFlag = *(pEid->Octet + 8);				
+                *pCkipFlag = *(pEid->Octet + 8);
                 break;
 
             case IE_AP_TX_POWER:
@@ -698,7 +698,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
 
                 // Get cell power limit in dBm
                 if (NdisEqualMemory(pEid->Octet, CISCO_OUI, 3) == 1)
-                    *pAironetCellPowerLimit = *(pEid->Octet + 4);	
+                    *pAironetCellPowerLimit = *(pEid->Octet + 4);
                 break;
 
             // WPA2 & 802.11i RSN
@@ -714,20 +714,20 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
                 break;
 #ifdef CONFIG_STA_SUPPORT
 #ifdef EXT_BUILD_CHANNEL_LIST
-			case IE_COUNTRY:				
+			case IE_COUNTRY:
 				Ptr = (PUCHAR) pVIE;
                 NdisMoveMemory(Ptr + *LengthVIE, &pEid->Eid, pEid->Len + 2);
                 *LengthVIE += (pEid->Len + 2);
 				break;
 #endif // EXT_BUILD_CHANNEL_LIST //
 #endif // CONFIG_STA_SUPPORT //
-                
+
             default:
                 break;
         }
-        
+
         Length = Length + 2 + pEid->Len;  // Eid[1] + Len[1]+ content[Len]
-        pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);        
+        pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
     }
 
     // For some 11a AP. it did not have the channel EID, patch here
@@ -759,7 +759,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
 }
 
 #ifdef DOT11N_DRAFT3
-/* 
+/*
 	==========================================================================
 	Description:
 		MLME message sanity check for some IE addressed  in 802.11n d3.03.
@@ -771,15 +771,15 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
 	==========================================================================
  */
 BOOLEAN PeerBeaconAndProbeRspSanity2(
-	IN PRTMP_ADAPTER pAd, 
-	IN VOID *Msg, 
-	IN ULONG MsgLen, 
-	OUT UCHAR 	*RegClass) 
+	IN PRTMP_ADAPTER pAd,
+	IN VOID *Msg,
+	IN ULONG MsgLen,
+	OUT UCHAR 	*RegClass)
 {
 	CHAR				*Ptr;
 	PFRAME_802_11		pFrame;
 	PEID_STRUCT			pEid;
-	ULONG				Length = 0;	
+	ULONG				Length = 0;
 
 	pFrame = (PFRAME_802_11)Msg;
 
@@ -802,8 +802,8 @@ BOOLEAN PeerBeaconAndProbeRspSanity2(
 	pEid = (PEID_STRUCT) Ptr;
 
 	// get variable fields from payload and advance the pointer
-	while ((Length + 2 + pEid->Len) <= MsgLen)	  
-	{	
+	while ((Length + 2 + pEid->Len) <= MsgLen)
+	{
 		switch(pEid->Eid)
 		{
 			case IE_SUPP_REG_CLASS:
@@ -819,8 +819,8 @@ BOOLEAN PeerBeaconAndProbeRspSanity2(
 				break;
 		}
 
-		Length = Length + 2 + pEid->Len;  // Eid[1] + Len[1]+ content[Len]	
-		pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len); 	   
+		Length = Length + 2 + pEid->Len;  // Eid[1] + Len[1]+ content[Len]
+		pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
 	}
 
 	return TRUE;
@@ -828,7 +828,7 @@ BOOLEAN PeerBeaconAndProbeRspSanity2(
 }
 #endif // DOT11N_DRAFT3 //
 
-/* 
+/*
     ==========================================================================
     Description:
         MLME message sanity check
@@ -837,19 +837,19 @@ BOOLEAN PeerBeaconAndProbeRspSanity2(
     ==========================================================================
  */
 BOOLEAN MlmeScanReqSanity(
-	IN PRTMP_ADAPTER pAd, 
-	IN VOID *Msg, 
-	IN ULONG MsgLen, 
-	OUT UCHAR *pBssType, 
-	OUT CHAR Ssid[], 
-	OUT UCHAR *pSsidLen, 
-	OUT UCHAR *pScanType) 
+	IN PRTMP_ADAPTER pAd,
+	IN VOID *Msg,
+	IN ULONG MsgLen,
+	OUT UCHAR *pBssType,
+	OUT CHAR Ssid[],
+	OUT UCHAR *pSsidLen,
+	OUT UCHAR *pScanType)
 {
 	MLME_SCAN_REQ_STRUCT *Info;
 
 	Info = (MLME_SCAN_REQ_STRUCT *)(Msg);
 	*pBssType = Info->BssType;
-	*pSsidLen = Info->SsidLen;	
+	*pSsidLen = Info->SsidLen;
 	NdisMoveMemory(Ssid, Info->Ssid, *pSsidLen);
 	*pScanType = Info->ScanType;
 
@@ -872,7 +872,7 @@ BOOLEAN MlmeScanReqSanity(
 
 // IRQL = DISPATCH_LEVEL
 UCHAR ChannelSanity(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN UCHAR channel)
 {
     int i;
@@ -885,23 +885,23 @@ UCHAR ChannelSanity(
     return 0;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         MLME message sanity check
     Return:
         TRUE if all parameters are OK, FALSE otherwise
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 BOOLEAN PeerDeauthSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
-    OUT PUCHAR pAddr2, 
-    OUT USHORT *pReason) 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
+    OUT PUCHAR pAddr2,
+    OUT USHORT *pReason)
 {
     PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
 
@@ -911,26 +911,26 @@ BOOLEAN PeerDeauthSanity(
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         MLME message sanity check
     Return:
         TRUE if all parameters are OK, FALSE otherwise
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 BOOLEAN PeerAuthSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
-    OUT PUCHAR pAddr, 
-    OUT USHORT *pAlg, 
-    OUT USHORT *pSeq, 
-    OUT USHORT *pStatus, 
-    CHAR *pChlgText) 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
+    OUT PUCHAR pAddr,
+    OUT USHORT *pAlg,
+    OUT USHORT *pSeq,
+    OUT USHORT *pStatus,
+    CHAR *pChlgText)
 {
     PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
 
@@ -940,46 +940,46 @@ BOOLEAN PeerAuthSanity(
     NdisMoveMemory(pStatus, &pFrame->Octet[4], 2);
 
     if ((*pAlg == Ndis802_11AuthModeOpen)
-#ifdef LEAP_SUPPORT	
+#ifdef LEAP_SUPPORT
       || (*pAlg == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //      
+#endif // LEAP_SUPPORT //
       )
     {
-        if (*pSeq == 1 || *pSeq == 2) 
+        if (*pSeq == 1 || *pSeq == 2)
         {
             return TRUE;
-        } 
-        else 
+        }
+        else
         {
             DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong Seg#\n"));
             return FALSE;
         }
-    } 
-    else if (*pAlg == Ndis802_11AuthModeShared) 
+    }
+    else if (*pAlg == Ndis802_11AuthModeShared)
     {
-        if (*pSeq == 1 || *pSeq == 4) 
+        if (*pSeq == 1 || *pSeq == 4)
         {
             return TRUE;
-        } 
-        else if (*pSeq == 2 || *pSeq == 3) 
+        }
+        else if (*pSeq == 2 || *pSeq == 3)
         {
             NdisMoveMemory(pChlgText, &pFrame->Octet[8], CIPHER_TEXT_LEN);
             return TRUE;
-        } 
-        else 
+        }
+        else
         {
             DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong Seg#\n"));
             return FALSE;
         }
-    } 
-    else 
+    }
+    else
     {
         DBGPRINT(RT_DEBUG_TRACE, ("PeerAuthSanity fail - wrong algorithm\n"));
         return FALSE;
     }
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         MLME message sanity check
@@ -988,12 +988,12 @@ BOOLEAN PeerAuthSanity(
     ==========================================================================
  */
 BOOLEAN MlmeAuthReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
-    OUT PUCHAR pAddr, 
-    OUT ULONG *pTimeout, 
-    OUT USHORT *pAlg) 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
+    OUT PUCHAR pAddr,
+    OUT ULONG *pTimeout,
+    OUT USHORT *pAlg)
 {
     MLME_AUTH_REQ_STRUCT *pInfo;
 
@@ -1001,42 +1001,42 @@ BOOLEAN MlmeAuthReqSanity(
     COPY_MAC_ADDR(pAddr, pInfo->Addr);
     *pTimeout = pInfo->Timeout;
     *pAlg = pInfo->Alg;
-    
+
     if (((*pAlg == Ndis802_11AuthModeShared) ||(*pAlg == Ndis802_11AuthModeOpen)
-#ifdef LEAP_SUPPORT	
+#ifdef LEAP_SUPPORT
      || (*pAlg == CISCO_AuthModeLEAP)
-#endif // LEAP_SUPPORT //     
-     	) && 
-        ((*pAddr & 0x01) == 0)) 
+#endif // LEAP_SUPPORT //
+     	) &&
+        ((*pAddr & 0x01) == 0))
     {
         return TRUE;
-    } 
-    else 
+    }
+    else
     {
         DBGPRINT(RT_DEBUG_TRACE, ("MlmeAuthReqSanity fail - wrong algorithm\n"));
         return FALSE;
     }
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         MLME message sanity check
     Return:
         TRUE if all parameters are OK, FALSE otherwise
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 BOOLEAN MlmeAssocReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
-    OUT PUCHAR pApAddr, 
-    OUT USHORT *pCapabilityInfo, 
-    OUT ULONG *pTimeout, 
-    OUT USHORT *pListenIntv) 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
+    OUT PUCHAR pApAddr,
+    OUT USHORT *pCapabilityInfo,
+    OUT ULONG *pTimeout,
+    OUT USHORT *pListenIntv)
 {
     MLME_ASSOC_REQ_STRUCT *pInfo;
 
@@ -1045,27 +1045,27 @@ BOOLEAN MlmeAssocReqSanity(
     COPY_MAC_ADDR(pApAddr, pInfo->Addr);                   // AP address
     *pCapabilityInfo = pInfo->CapabilityInfo;               // capability info
     *pListenIntv = pInfo->ListenIntv;
-    
+
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         MLME message sanity check
     Return:
         TRUE if all parameters are OK, FALSE otherwise
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 BOOLEAN PeerDisassocSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
-    OUT PUCHAR pAddr2, 
-    OUT USHORT *pReason) 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
+    OUT PUCHAR pAddr2,
+    OUT USHORT *pReason)
 {
     PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
 
@@ -1079,7 +1079,7 @@ BOOLEAN PeerDisassocSanity(
 	========================================================================
 	Routine Description:
 		Sanity check NetworkType (11b, 11g or 11a)
-		
+
 	Arguments:
 		pBss - Pointer to BSS table.
 
@@ -1087,9 +1087,9 @@ BOOLEAN PeerDisassocSanity(
         Ndis802_11DS .......(11b)
         Ndis802_11OFDM24....(11g)
         Ndis802_11OFDM5.....(11a)
-        
+
 	IRQL = DISPATCH_LEVEL
-	
+
 	========================================================================
 */
 NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
@@ -1099,7 +1099,7 @@ NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
 	UCHAR						rate, i;
 
 	NetWorkType = Ndis802_11DS;
-	
+
 	if (pBss->Channel <= 14)
 	{
 		//
@@ -1119,7 +1119,7 @@ NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
 				//
 				NetWorkType = Ndis802_11OFDM24;
 				break;
-			}	
+			}
 		}
 
 		//
@@ -1159,9 +1159,9 @@ NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
     }
 
 	return NetWorkType;
-}	
+}
 
-/* 
+/*
     ==========================================================================
     Description:
         WPA message sanity check
@@ -1170,24 +1170,24 @@ NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
     ==========================================================================
  */
 BOOLEAN PeerWpaMessageSanity(
-    IN 	PRTMP_ADAPTER 		pAd, 
-    IN 	PEAPOL_PACKET 		pMsg, 
-    IN 	ULONG 				MsgLen, 
+    IN 	PRTMP_ADAPTER 		pAd,
+    IN 	PEAPOL_PACKET 		pMsg,
+    IN 	ULONG 				MsgLen,
     IN 	UCHAR				MsgType,
     IN 	MAC_TABLE_ENTRY  	*pEntry)
 {
 	UCHAR			mic[LEN_KEY_DESC_MIC], digest[80], KEYDATA[MAX_LEN_OF_RSNIE];
 	BOOLEAN			bReplayDiff = FALSE;
 	BOOLEAN			bWPA2 = FALSE;
-	KEY_INFO		EapolKeyInfo;	
+	KEY_INFO		EapolKeyInfo;
 	UCHAR			GroupKeyIndex = 0;
-	
-	
+
+
 	NdisZeroMemory(mic, sizeof(mic));
 	NdisZeroMemory(digest, sizeof(digest));
 	NdisZeroMemory(KEYDATA, sizeof(KEYDATA));
 	NdisZeroMemory((PUCHAR)&EapolKeyInfo, sizeof(EapolKeyInfo));
-	
+
 	NdisMoveMemory((PUCHAR)&EapolKeyInfo, (PUCHAR)&pMsg->KeyDesc.KeyInfo, sizeof(KEY_INFO));
 
 	*((USHORT *)&EapolKeyInfo) = cpu2le16(*((USHORT *)&EapolKeyInfo));
@@ -1202,27 +1202,27 @@ BOOLEAN PeerWpaMessageSanity(
 		DBGPRINT(RT_DEBUG_ERROR, ("The message type is invalid(%d)! \n", MsgType));
 		return FALSE;
 	}
-				
-	// 1. Replay counter check	
+
+	// 1. Replay counter check
  	if (MsgType == EAPOL_PAIR_MSG_1 || MsgType == EAPOL_PAIR_MSG_3 || MsgType == EAPOL_GROUP_MSG_1)	// For supplicant
     {
     	// First validate replay counter, only accept message with larger replay counter.
 		// Let equal pass, some AP start with all zero replay counter
 		UCHAR	ZeroReplay[LEN_KEY_DESC_REPLAY];
-		
+
         NdisZeroMemory(ZeroReplay, LEN_KEY_DESC_REPLAY);
 		if ((RTMPCompareMemory(pMsg->KeyDesc.ReplayCounter, pEntry->R_Counter, LEN_KEY_DESC_REPLAY) != 1) &&
 			(RTMPCompareMemory(pMsg->KeyDesc.ReplayCounter, ZeroReplay, LEN_KEY_DESC_REPLAY) != 0))
     	{
 			bReplayDiff = TRUE;
-    	}						
+    	}
  	}
 	else if (MsgType == EAPOL_PAIR_MSG_2 || MsgType == EAPOL_PAIR_MSG_4 || MsgType == EAPOL_GROUP_MSG_2)	// For authenticator
 	{
 		// check Replay Counter coresponds to MSG from authenticator, otherwise discard
     	if (!NdisEqualMemory(pMsg->KeyDesc.ReplayCounter, pEntry->R_Counter, LEN_KEY_DESC_REPLAY))
-    	{	
-			bReplayDiff = TRUE;	        
+    	{
+			bReplayDiff = TRUE;
     	}
 	}
 
@@ -1231,7 +1231,7 @@ BOOLEAN PeerWpaMessageSanity(
 	{
 		// send wireless event - for replay counter different
 		if (pAd->CommonCfg.bWirelessEvent)
-			RTMPSendWirelessEvent(pAd, IW_REPLAY_COUNTER_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0); 
+			RTMPSendWirelessEvent(pAd, IW_REPLAY_COUNTER_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
 
 		if (MsgType < EAPOL_GROUP_MSG_1)
 		{
@@ -1241,9 +1241,9 @@ BOOLEAN PeerWpaMessageSanity(
 		{
 			DBGPRINT(RT_DEBUG_ERROR, ("Replay Counter Different in group msg %d of 2-way handshake!\n", (MsgType - EAPOL_PAIR_MSG_4)));
 		}
-		
+
 		hex_dump("Receive replay counter ", pMsg->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
-		hex_dump("Current replay counter ", pEntry->R_Counter, LEN_KEY_DESC_REPLAY);	
+		hex_dump("Current replay counter ", pEntry->R_Counter, LEN_KEY_DESC_REPLAY);
         return FALSE;
 	}
 
@@ -1255,22 +1255,22 @@ BOOLEAN PeerWpaMessageSanity(
 		// Record the received MIC for check later
 		NdisMoveMemory(rcvd_mic, pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
 		NdisZeroMemory(pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
-							
+
         if (pEntry->WepStatus == Ndis802_11Encryption2Enabled)	// TKIP
-        {	
+        {
             hmac_md5(pEntry->PTK, LEN_EAP_MICK, (PUCHAR)pMsg, MsgLen, mic);
         }
-        else if (pEntry->WepStatus == Ndis802_11Encryption3Enabled)	// AES        
-        {                        
+        else if (pEntry->WepStatus == Ndis802_11Encryption3Enabled)	// AES
+        {
             HMAC_SHA1((PUCHAR)pMsg, MsgLen, pEntry->PTK, LEN_EAP_MICK, digest);
             NdisMoveMemory(mic, digest, LEN_KEY_DESC_MIC);
         }
-	
+
         if (!NdisEqualMemory(rcvd_mic, mic, LEN_KEY_DESC_MIC))
         {
 			// send wireless event - for MIC different
 			if (pAd->CommonCfg.bWirelessEvent)
-				RTMPSendWirelessEvent(pAd, IW_MIC_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0); 
+				RTMPSendWirelessEvent(pAd, IW_MIC_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
 
 			if (MsgType < EAPOL_GROUP_MSG_1)
 			{
@@ -1280,28 +1280,28 @@ BOOLEAN PeerWpaMessageSanity(
 			{
 				DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in group msg %d of 2-way handshake!\n", (MsgType - EAPOL_PAIR_MSG_4)));
 			}
-	
+
 			hex_dump("Received MIC", rcvd_mic, LEN_KEY_DESC_MIC);
 			hex_dump("Desired  MIC", mic, LEN_KEY_DESC_MIC);
 
 			return FALSE;
-        }        
+        }
 	}
 
 	// Extract the context of the Key Data field if it exist
 	// The field in pairwise_msg_2_WPA1(WPA2) & pairwise_msg_3_WPA1 is un-encrypted.
 	// The field in group_msg_1_WPA1(WPA2) & pairwise_msg_3_WPA2 is encrypted.
 	if (pMsg->KeyDesc.KeyDataLen[1] > 0)
-	{		
-		// Decrypt this field		
+	{
+		// Decrypt this field
 		if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2) || (MsgType == EAPOL_GROUP_MSG_1))
-		{					
+		{
 			if(pEntry->WepStatus == Ndis802_11Encryption3Enabled)
 			{
-				// AES 
-				AES_GTK_KEY_UNWRAP(&pEntry->PTK[16], KEYDATA, pMsg->KeyDesc.KeyDataLen[1],pMsg->KeyDesc.KeyData);       
-			} 
-			else	  
+				// AES
+				AES_GTK_KEY_UNWRAP(&pEntry->PTK[16], KEYDATA, pMsg->KeyDesc.KeyDataLen[1],pMsg->KeyDesc.KeyData);
+			}
+			else
 			{
 				INT 	i;
 				UCHAR   Key[32];
@@ -1314,24 +1314,24 @@ BOOLEAN PeerWpaMessageSanity(
 				for(i = 0; i < 256; i++)
 					ARCFOUR_BYTE(&pAd->PrivateInfo.WEPCONTEXT);
 				// Decrypt GTK. Becareful, there is no ICV to check the result is correct or not
-				ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pMsg->KeyDesc.KeyData, pMsg->KeyDesc.KeyDataLen[1]);       
-			}	
+				ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pMsg->KeyDesc.KeyData, pMsg->KeyDesc.KeyDataLen[1]);
+			}
 
 			if (!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))
 				GroupKeyIndex = EapolKeyInfo.KeyIndex;
-			
+
 		}
 		else if ((MsgType == EAPOL_PAIR_MSG_2) || (MsgType == EAPOL_PAIR_MSG_3 && !bWPA2))
-		{					
-			NdisMoveMemory(KEYDATA, pMsg->KeyDesc.KeyData, pMsg->KeyDesc.KeyDataLen[1]);			     
+		{
+			NdisMoveMemory(KEYDATA, pMsg->KeyDesc.KeyData, pMsg->KeyDesc.KeyDataLen[1]);
 		}
 		else
 		{
-			
+
 			return TRUE;
 		}
 
-		// Parse Key Data field to 
+		// Parse Key Data field to
 		// 1. verify RSN IE for pairwise_msg_2_WPA1(WPA2) ,pairwise_msg_3_WPA1(WPA2)
 		// 2. verify KDE format for pairwise_msg_3_WPA2, group_msg_1_WPA2
 		// 3. update shared key for pairwise_msg_3_WPA2, group_msg_1_WPA1(WPA2)
@@ -1342,14 +1342,14 @@ BOOLEAN PeerWpaMessageSanity(
 	}
 
 	return TRUE;
-	
+
 }
 
 #ifdef CONFIG_STA_SUPPORT
 #ifdef QOS_DLS_SUPPORT
 BOOLEAN MlmeDlsReqSanity(
-	IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
+	IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
     IN ULONG MsgLen,
     OUT PRT_802_11_DLS *pDLS,
     OUT PUSHORT pReason)
@@ -1357,7 +1357,7 @@ BOOLEAN MlmeDlsReqSanity(
 	MLME_DLS_REQ_STRUCT *pInfo;
 
     pInfo = (MLME_DLS_REQ_STRUCT *)Msg;
-    
+
 	*pDLS = pInfo->pDLS;
 	*pReason = pInfo->Reason;
 
@@ -1368,12 +1368,12 @@ BOOLEAN MlmeDlsReqSanity(
 
 #ifdef QOS_DLS_SUPPORT
 BOOLEAN PeerDlsReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
     IN ULONG MsgLen,
     OUT PUCHAR pDA,
     OUT PUCHAR pSA,
-    OUT USHORT *pCapabilityInfo, 
+    OUT USHORT *pCapabilityInfo,
     OUT USHORT *pDlsTimeout,
     OUT UCHAR *pRatesLen,
     OUT UCHAR Rates[],
@@ -1411,7 +1411,7 @@ BOOLEAN PeerDlsReqSanity(
     Ptr += 2;
 
 	// Category and Action field + DA + SA + capability + Timeout
-	eid_ptr = (PEID_STRUCT) &Fr->Octet[18];	
+	eid_ptr = (PEID_STRUCT) &Fr->Octet[18];
 
 	while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
 	{
@@ -1481,17 +1481,17 @@ BOOLEAN PeerDlsReqSanity(
 }
 
 BOOLEAN PeerDlsRspSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
     IN ULONG MsgLen,
     OUT PUCHAR pDA,
     OUT PUCHAR pSA,
-    OUT USHORT *pCapabilityInfo, 
+    OUT USHORT *pCapabilityInfo,
     OUT USHORT *pStatus,
     OUT UCHAR *pRatesLen,
     OUT UCHAR Rates[],
     OUT UCHAR *pHtCapabilityLen,
-    OUT HT_CAPABILITY_IE *pHtCapability) 
+    OUT HT_CAPABILITY_IE *pHtCapability)
 {
     CHAR            *Ptr;
     PFRAME_802_11	Fr = (PFRAME_802_11)Msg;
@@ -1527,7 +1527,7 @@ BOOLEAN PeerDlsRspSanity(
 	}
 
 	// Category and Action field + status code + DA + SA + capability
-	eid_ptr = (PEID_STRUCT) &Fr->Octet[18];	
+	eid_ptr = (PEID_STRUCT) &Fr->Octet[18];
 
 	while (((UCHAR*)eid_ptr + eid_ptr->Len + 1) < ((UCHAR*)Fr + MsgLen))
 	{
@@ -1597,12 +1597,12 @@ BOOLEAN PeerDlsRspSanity(
 }
 
 BOOLEAN PeerDlsTearDownSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
     IN ULONG MsgLen,
     OUT PUCHAR pDA,
     OUT PUCHAR pSA,
-    OUT USHORT *pReason) 
+    OUT USHORT *pReason)
 {
     CHAR            *Ptr;
     PFRAME_802_11	Fr = (PFRAME_802_11)Msg;
diff --git a/common/cmm_sync.c b/common/cmm_sync.c
index 8581439..40e4109 100644
--- a/common/cmm_sync.c
+++ b/common/cmm_sync.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -34,10 +34,10 @@
 	--------	----------		----------------------------------------------
 	John Chang	2004-09-01      modified for rt2561/2661
 */
-#include "rt_config.h"
+#include "../rt_config.h"
 
 // 2.4 Ghz channel plan index in the TxPower arrays.
-#define	BG_BAND_REGION_0_START	0			// 1,2,3,4,5,6,7,8,9,10,11	
+#define	BG_BAND_REGION_0_START	0			// 1,2,3,4,5,6,7,8,9,10,11
 #define	BG_BAND_REGION_0_SIZE	11
 #define	BG_BAND_REGION_1_START	0			// 1,2,3,4,5,6,7,8,9,10,11,12,13
 #define	BG_BAND_REGION_1_SIZE	13
@@ -47,13 +47,13 @@
 #define	BG_BAND_REGION_3_SIZE	4
 #define	BG_BAND_REGION_4_START	13			// 14
 #define	BG_BAND_REGION_4_SIZE	1
-#define	BG_BAND_REGION_5_START	0			// 1,2,3,4,5,6,7,8,9,10,11,12,13,14 
+#define	BG_BAND_REGION_5_START	0			// 1,2,3,4,5,6,7,8,9,10,11,12,13,14
 #define	BG_BAND_REGION_5_SIZE	14
 #define	BG_BAND_REGION_6_START	2			// 3,4,5,6,7,8,9
 #define	BG_BAND_REGION_6_SIZE	7
 #define	BG_BAND_REGION_7_START	4			// 5,6,7,8,9,10,11,12,13
 #define	BG_BAND_REGION_7_SIZE	9
-#define	BG_BAND_REGION_31_START	0			// 1,2,3,4,5,6,7,8,9,10,11,12,13,14 
+#define	BG_BAND_REGION_31_START	0			// 1,2,3,4,5,6,7,8,9,10,11,12,13,14
 #define	BG_BAND_REGION_31_SIZE	14
 
 // 5 Ghz channel plan index in the TxPower arrays.
@@ -73,7 +73,7 @@ UCHAR A_BAND_REGION_11_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104,
 //BaSizeArray follows the 802.11n definition as MaxRxFactor.  2^(13+factor) bytes. When factor =0, it's about Ba buffer size =8.
 UCHAR BaSizeArray[4] = {8,16,32,64};
 
-/* 
+/*
 	==========================================================================
 	Description:
 		Update StaCfg->ChannelList[] according to 1) Country Region 2) RF IC type,
@@ -82,7 +82,7 @@ UCHAR BaSizeArray[4] = {8,16,32,64};
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID BuildChannelList(
@@ -94,7 +94,7 @@ VOID BuildChannelList(
 	NdisZeroMemory(pAd->ChannelList, MAX_NUM_OF_CHANNELS * sizeof(CHANNEL_TX_POWER));
 
 	// if not 11a-only mode, channel list starts from 2.4Ghz band
-	if ((pAd->CommonCfg.PhyMode != PHY_11A) 
+	if ((pAd->CommonCfg.PhyMode != PHY_11A)
 #ifdef DOT11_N_SUPPORT
 		&& (pAd->CommonCfg.PhyMode != PHY_11AN_MIXED) && (pAd->CommonCfg.PhyMode != PHY_11N_5G)
 #endif // DOT11_N_SUPPORT //
@@ -140,14 +140,14 @@ VOID BuildChannelList(
 				break;
 			default:            // Error. should never happen
 				break;
-		}   
+		}
 		for (i=0; i<index; i++)
 			pAd->ChannelList[i].MaxTxPwr = 20;
 	}
 
-	if ((pAd->CommonCfg.PhyMode == PHY_11A) || (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED) 
+	if ((pAd->CommonCfg.PhyMode == PHY_11A) || (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
 #ifdef DOT11_N_SUPPORT
-		|| (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED) 
+		|| (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED)
 		|| (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11N_5G)
 #endif // DOT11_N_SUPPORT //
 	)
@@ -203,7 +203,7 @@ VOID BuildChannelList(
 			case REGION_11_A_BAND:
 				num = sizeof(A_BAND_REGION_11_CHANNEL_LIST)/sizeof(UCHAR);
 				pChannelList = A_BAND_REGION_11_CHANNEL_LIST;
-				break;	
+				break;
 
 			default:            // Error. should never happen
 				DBGPRINT(RT_DEBUG_WARN,("countryregion=%d not support", pAd->CommonCfg.CountryRegionForABand));
@@ -231,10 +231,10 @@ VOID BuildChannelList(
 		}
 	}
 
-	pAd->ChannelListNum = index;	
-	DBGPRINT(RT_DEBUG_TRACE,("country code=%d/%d, RFIC=%d, PHY mode=%d, support %d channels\n", 
+	pAd->ChannelListNum = index;
+	DBGPRINT(RT_DEBUG_TRACE,("country code=%d/%d, RFIC=%d, PHY mode=%d, support %d channels\n",
 		pAd->CommonCfg.CountryRegion, pAd->CommonCfg.CountryRegionForABand, pAd->RfIcType, pAd->CommonCfg.PhyMode, pAd->ChannelListNum));
-#ifdef DBG	
+#ifdef DBG
 	for (i=0;i<pAd->ChannelListNum;i++)
 	{
 		DBGPRINT_RAW(RT_DEBUG_TRACE,("BuildChannel # %d :: Pwr0 = %d, Pwr1 =%d, \n ", pAd->ChannelList[i].Channel, pAd->ChannelList[i].Power, pAd->ChannelList[i].Power2));
@@ -242,10 +242,10 @@ VOID BuildChannelList(
 #endif
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
-		This routine return the first channel number according to the country 
+		This routine return the first channel number according to the country
 		code selection and RF IC selection (signal band or dual band). It is called
 		whenever driver need to start a site survey of all supported channels.
 	Return:
@@ -261,7 +261,7 @@ UCHAR FirstChannel(
 	return pAd->ChannelList[0].Channel;
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 		This routine returns the next channel number. This routine is called
@@ -273,12 +273,12 @@ UCHAR FirstChannel(
 	==========================================================================
  */
 UCHAR NextChannel(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN UCHAR channel)
 {
 	int i;
 	UCHAR next_channel = 0;
-			
+
 	for (i = 0; i < (pAd->ChannelListNum - 1); i++)
 		if (channel == pAd->ChannelList[i].Channel)
 		{
@@ -288,10 +288,10 @@ UCHAR NextChannel(
 	return next_channel;
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
-		This routine is for Cisco Compatible Extensions 2.X 
+		This routine is for Cisco Compatible Extensions 2.X
 		Spec31. AP Control of Client Transmit Power
 	Return:
 		None
@@ -300,7 +300,7 @@ UCHAR NextChannel(
 		   0dBm(1mW),   1dBm(5mW), 13dBm(20mW), 15dBm(30mW),
 		  17dBm(50mw), 20dBm(100mW)
 
-	   We supported 
+	   We supported
 		   3dBm(Lowest), 6dBm(10%), 9dBm(25%), 12dBm(50%),
 		  14dBm(75%),   15dBm(100%)
 
@@ -312,13 +312,13 @@ VOID ChangeToCellPowerLimit(
 	IN PRTMP_ADAPTER pAd,
 	IN UCHAR         AironetCellPowerLimit)
 {
-	//valud 0xFF means that hasn't found power limit information 
+	//valud 0xFF means that hasn't found power limit information
 	//from the AP's Beacon/Probe response.
 	if (AironetCellPowerLimit == 0xFF)
-		return;  
-	
+		return;
+
 	if (AironetCellPowerLimit < 6) //Used Lowest Power Percentage.
-		pAd->CommonCfg.TxPowerPercentage = 6; 
+		pAd->CommonCfg.TxPowerPercentage = 6;
 	else if (AironetCellPowerLimit < 9)
 		pAd->CommonCfg.TxPowerPercentage = 10;
 	else if (AironetCellPowerLimit < 12)
@@ -332,7 +332,7 @@ VOID ChangeToCellPowerLimit(
 
 	if (pAd->CommonCfg.TxPowerPercentage > pAd->CommonCfg.TxPowerDefault)
 		pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
-	
+
 }
 
 CHAR	ConvertToRssi(
@@ -365,7 +365,7 @@ CHAR	ConvertToRssi(
 		else
 			RssiOffset = pAd->BGRssiOffset2;
     }
-	
+
     return (-12 - RssiOffset - LNAGain - Rssi);
 }
 
@@ -376,7 +376,7 @@ CHAR	ConvertToRssi(
 	==========================================================================
  */
 VOID ScanNextChannel(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	HEADER_802_11   Hdr80211;
 	PUCHAR          pOutBuffer = NULL;
@@ -398,12 +398,12 @@ VOID ScanNextChannel(
 #endif // CONFIG_STA_SUPPORT //
 
 #ifdef RALINK_ATE
-	// Nothing to do in ATE mode. 
+	// Nothing to do in ATE mode.
 	if (ATE_ON(pAd))
 		return;
 #endif // RALINK_ATE //
 
-	if (pAd->MlmeAux.Channel == 0) 
+	if (pAd->MlmeAux.Channel == 0)
 	{
 		if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
 #ifdef CONFIG_STA_SUPPORT
@@ -426,14 +426,14 @@ VOID ScanNextChannel(
 			AsicLockChannel(pAd, pAd->CommonCfg.Channel);
 			DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to channel %d, Total BSS[%02d]\n",pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
 		}
-		
+
 #ifdef CONFIG_STA_SUPPORT
 		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 		{
 			//
 			// To prevent data lost.
 			// Send an NULL data with turned PSM bit on to current associated AP before SCAN progress.
-			// Now, we need to send an NULL data with turned PSM bit off to AP, when scan progress done 
+			// Now, we need to send an NULL data with turned PSM bit off to AP, when scan progress done
 			//
 			if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && (INFRA_ON(pAd)))
 			{
@@ -462,8 +462,8 @@ VOID ScanNextChannel(
 
 
 		RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-	} 
-	else 
+	}
+	else
 	{
 #ifdef CONFIG_STA_SUPPORT
 		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
@@ -500,7 +500,7 @@ VOID ScanNextChannel(
 				ScanType = SCAN_PASSIVE;
 				ScanTimeIn5gChannel = MIN_CHANNEL_TIME;
 			}
-#endif // CARRIER_DETECTION_SUPPORT // 
+#endif // CARRIER_DETECTION_SUPPORT //
 		}
 
 #endif // CONFIG_STA_SUPPORT //
@@ -529,7 +529,7 @@ VOID ScanNextChannel(
 #endif // CONFIG_STA_SUPPORT //
 		else // must be SCAN_PASSIVE or SCAN_ACTIVE
 		{
-			if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED) 
+			if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
 #ifdef DOT11_N_SUPPORT
 				|| (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED)
 #endif // DOT11_N_SUPPORT //
@@ -537,7 +537,7 @@ VOID ScanNextChannel(
 			{
 				if (pAd->MlmeAux.Channel > 14)
 					RTMPSetTimer(&pAd->MlmeAux.ScanTimer, ScanTimeIn5gChannel);
-				else	
+				else
 				RTMPSetTimer(&pAd->MlmeAux.ScanTimer, MIN_CHANNEL_TIME);
 			}
 			else
@@ -578,7 +578,7 @@ VOID ScanNextChannel(
 							  SsidLen,			        pAd->MlmeAux.Ssid,
 							  1,                        &SupRateIe,
 							  1,                        &pAd->CommonCfg.SupRateLen,
-							  pAd->CommonCfg.SupRateLen,  pAd->CommonCfg.SupRate, 
+							  pAd->CommonCfg.SupRateLen,  pAd->CommonCfg.SupRate,
 							  END_OF_ARGS);
 
 			if (pAd->CommonCfg.ExtRateLen)
@@ -587,7 +587,7 @@ VOID ScanNextChannel(
 				MakeOutgoingFrame(pOutBuffer + FrameLen,            &Tmp,
 								  1,                                &ExtRateIe,
 								  1,                                &pAd->CommonCfg.ExtRateLen,
-								  pAd->CommonCfg.ExtRateLen,          pAd->CommonCfg.ExtRate, 
+								  pAd->CommonCfg.ExtRateLen,          pAd->CommonCfg.ExtRate,
 								  END_OF_ARGS);
 				FrameLen += Tmp;
 			}
@@ -613,18 +613,18 @@ VOID ScanNextChannel(
 									1,                                &WpaIe,
 									1,                                &HtLen,
 									4,                                &BROADCOM[0],
-									pAd->MlmeAux.HtCapabilityLen,     &HtCapabilityTmp, 
+									pAd->MlmeAux.HtCapabilityLen,     &HtCapabilityTmp,
 									END_OF_ARGS);
 #else
 					MakeOutgoingFrame(pOutBuffer + FrameLen,          &Tmp,
 									1,                                &WpaIe,
 									1,                                &HtLen,
 									4,                                &BROADCOM[0],
-									pAd->MlmeAux.HtCapabilityLen,     &pAd->MlmeAux.HtCapability, 
+									pAd->MlmeAux.HtCapabilityLen,     &pAd->MlmeAux.HtCapability,
 									END_OF_ARGS);
 #endif // RT_BIG_ENDIAN //
 				}
-				else				
+				else
 				{
 					HtLen = pAd->MlmeAux.HtCapabilityLen;
 #ifdef RT_BIG_ENDIAN
@@ -635,13 +635,13 @@ VOID ScanNextChannel(
 					MakeOutgoingFrame(pOutBuffer + FrameLen,          &Tmp,
 									1,                                &HtCapIe,
 									1,                                &HtLen,
-									HtLen,                            &HtCapabilityTmp, 
+									HtLen,                            &HtCapabilityTmp,
 									END_OF_ARGS);
 #else
 					MakeOutgoingFrame(pOutBuffer + FrameLen,          &Tmp,
 									1,                                &HtCapIe,
 									1,                                &HtLen,
-									HtLen,                            &pAd->CommonCfg.HtCapability, 
+									HtLen,                            &pAd->CommonCfg.HtCapability,
 									END_OF_ARGS);
 #endif // RT_BIG_ENDIAN //
 				}
@@ -655,7 +655,7 @@ VOID ScanNextChannel(
 					MakeOutgoingFrame(pOutBuffer + FrameLen,            &Tmp,
 									  1,					&ExtHtCapIe,
 									  1,					&HtLen,
-									  1,          			&pAd->CommonCfg.BSSCoexist2040.word, 
+									  1,          			&pAd->CommonCfg.BSSCoexist2040.word,
 									  END_OF_ARGS);
 
 					FrameLen += Tmp;
@@ -670,7 +670,7 @@ VOID ScanNextChannel(
 		}
 
 		// For SCAN_CISCO_PASSIVE, do nothing and silently wait for beacon or other probe reponse
-		
+
 #ifdef CONFIG_STA_SUPPORT
 		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 			pAd->Mlme.SyncMachine.CurrState = SCAN_LISTEN;
@@ -680,15 +680,15 @@ VOID ScanNextChannel(
 }
 
 VOID MgtProbReqMacHeaderInit(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN OUT PHEADER_802_11 pHdr80211, 
-	IN UCHAR SubType, 
-	IN UCHAR ToDs, 
-	IN PUCHAR pDA, 
-	IN PUCHAR pBssid) 
+	IN	PRTMP_ADAPTER	pAd,
+	IN OUT PHEADER_802_11 pHdr80211,
+	IN UCHAR SubType,
+	IN UCHAR ToDs,
+	IN PUCHAR pDA,
+	IN PUCHAR pBssid)
 {
 	NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
-	
+
 	pHdr80211->FC.Type = BTYPE_MGMT;
 	pHdr80211->FC.SubType = SubType;
 	if (SubType == SUBTYPE_ACK)
diff --git a/common/cmm_wpa.c b/common/cmm_wpa.c
index 35bee09..81c332a 100644
--- a/common/cmm_wpa.c
+++ b/common/cmm_wpa.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -35,7 +35,7 @@
 	Jan	Lee		03-07-22		Initial
 	Paul Lin	03-11-28		Modify for supplicant
 */
-#include "rt_config.h"
+#include "../rt_config.h"
 // WPA OUI
 UCHAR		OUI_WPA_NONE_AKM[4]		= {0x00, 0x50, 0xF2, 0x00};
 UCHAR       OUI_WPA_VERSION[4]      = {0x00, 0x50, 0xF2, 0x01};
@@ -57,23 +57,23 @@ UCHAR   	OUI_MSA_PSK_AKM[4]   	= {0x00, 0x0F, 0xAC, 0x06};		// Not yet final - I
 	========================================================================
 
 	Routine Description:
-		The pseudo-random function(PRF) that hashes various inputs to 
-		derive a pseudo-random value. To add liveness to the pseudo-random 
+		The pseudo-random function(PRF) that hashes various inputs to
+		derive a pseudo-random value. To add liveness to the pseudo-random
 		value, a nonce should be one of the inputs.
 
-		It is used to generate PTK, GTK or some specific random value.  
+		It is used to generate PTK, GTK or some specific random value.
 
 	Arguments:
 		UCHAR	*key,		-	the key material for HMAC_SHA1 use
 		INT		key_len		-	the length of key
 		UCHAR	*prefix		-	a prefix label
 		INT		prefix_len	-	the length of the label
-		UCHAR	*data		-	a specific data with variable length		
-		INT		data_len	-	the length of a specific data	
+		UCHAR	*data		-	a specific data with variable length
+		INT		data_len	-	the length of a specific data
 		INT		len			-	the output lenght
 
 	Return Value:
-		UCHAR	*output		-	the calculated result 
+		UCHAR	*output		-	the calculated result
 
 	Note:
 		802.11i-2004	Annex H.3
@@ -97,13 +97,13 @@ VOID	PRF(
 
 	// Allocate memory for input
 	os_alloc_mem(NULL, (PUCHAR *)&input, 1024);
-	
+
     if (input == NULL)
     {
         DBGPRINT(RT_DEBUG_ERROR, ("!!!PRF: no memory!!!\n"));
         return;
     }
-	
+
 	// Generate concatenation input
 	NdisMoveMemory(input, prefix, prefix_len);
 
@@ -126,15 +126,15 @@ VOID	PRF(
 		HMAC_SHA1(input, total_len,	key, key_len, &output[currentindex]);
 		currentindex +=	20;
 
-		// update the last octet 
+		// update the last octet
 		input[total_len - 1]++;
-	}	
+	}
     os_free_mem(NULL, input);
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		It utilizes PRF-384 or PRF-512 to derive session-specific keys from a PMK.
 		It shall be called by 4-way handshake processing.
@@ -145,19 +145,19 @@ VOID	PRF(
 		ANonce	-	pointer to ANonce
 		AA		-	pointer to Authenticator Address
 		SNonce	-	pointer to SNonce
-		SA		-	pointer to Supplicant Address		
-		len		-	indicate the length of PTK (octet)		
-		
+		SA		-	pointer to Supplicant Address
+		len		-	indicate the length of PTK (octet)
+
 	Return Value:
 		Output		pointer to the PTK
 
 	Note:
 		Refer to IEEE 802.11i-2004 8.5.1.2
-		
+
 	========================================================================
 */
 VOID WpaCountPTK(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	UCHAR	*PMK,
 	IN	UCHAR	*ANonce,
 	IN	UCHAR	*AA,
@@ -165,11 +165,11 @@ VOID WpaCountPTK(
 	IN	UCHAR	*SA,
 	OUT	UCHAR	*output,
 	IN	UINT	len)
-{	
+{
 	UCHAR	concatenation[76];
 	UINT	CurrPos = 0;
 	UCHAR	temp[32];
-	UCHAR	Prefix[] = {'P', 'a', 'i', 'r', 'w', 'i', 's', 'e', ' ', 'k', 'e', 'y', ' ', 
+	UCHAR	Prefix[] = {'P', 'a', 'i', 'r', 'w', 'i', 's', 'e', ' ', 'k', 'e', 'y', ' ',
 						'e', 'x', 'p', 'a', 'n', 's', 'i', 'o', 'n'};
 
 	// initiate the concatenation input
@@ -188,10 +188,10 @@ VOID WpaCountPTK(
 		NdisMoveMemory(&concatenation[CurrPos], SA, 6);
 	else
 		NdisMoveMemory(&concatenation[CurrPos], AA, 6);
-		
-	// store the larger mac address for backward compatible of 
-	// ralink proprietary STA-key issue		
-	NdisMoveMemory(temp, &concatenation[CurrPos], MAC_ADDR_LEN);		
+
+	// store the larger mac address for backward compatible of
+	// ralink proprietary STA-key issue
+	NdisMoveMemory(temp, &concatenation[CurrPos], MAC_ADDR_LEN);
 	CurrPos += 6;
 
 	// Get smaller Nonce
@@ -221,26 +221,26 @@ VOID WpaCountPTK(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Generate random number by software.
 
 	Arguments:
-		pAd		-	pointer to our pAdapter context 
+		pAd		-	pointer to our pAdapter context
 		macAddr	-	pointer to local MAC address
-		
+
 	Return Value:
 
 	Note:
 		802.1ii-2004  Annex H.5
-		
+
 	========================================================================
 */
 VOID	GenRandom(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	UCHAR			*macAddr,
 	OUT	UCHAR			*random)
-{	
+{
 	INT		i, curr;
 	UCHAR	local[80], KeyCounter[32];
 	UCHAR	result[80];
@@ -250,10 +250,10 @@ VOID	GenRandom(
 	// Zero the related information
 	NdisZeroMemory(result, 80);
 	NdisZeroMemory(local, 80);
-	NdisZeroMemory(KeyCounter, 32);	
+	NdisZeroMemory(KeyCounter, 32);
 
 	for	(i = 0;	i <	32;	i++)
-	{		
+	{
 		// copy the local MAC address
 		COPY_MAC_ADDR(local, macAddr);
 		curr =	MAC_ADDR_LEN;
@@ -266,52 +266,52 @@ VOID	GenRandom(
 		// concatenate the last result
 		NdisMoveMemory(&local[curr],  result, 32);
 		curr +=	32;
-		
-		// concatenate a variable 
-		NdisMoveMemory(&local[curr],  &i,  2);		
+
+		// concatenate a variable
+		NdisMoveMemory(&local[curr],  &i,  2);
 		curr +=	2;
 
 		// calculate the result
-		PRF(KeyCounter, 32, prefix,12, local, curr, result, 32); 
+		PRF(KeyCounter, 32, prefix,12, local, curr, result, 32);
 	}
-	
-	NdisMoveMemory(random, result,	32);	
+
+	NdisMoveMemory(random, result,	32);
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
-		Build cipher suite in RSN-IE. 
-		It only shall be called by RTMPMakeRSNIE. 
+		Build cipher suite in RSN-IE.
+		It only shall be called by RTMPMakeRSNIE.
 
 	Arguments:
-		pAd			-	pointer to our pAdapter context	
+		pAd			-	pointer to our pAdapter context
     	ElementID	-	indicate the WPA1 or WPA2
     	WepStatus	-	indicate the encryption type
-		bMixCipher	-	a boolean to indicate the pairwise cipher and group 
+		bMixCipher	-	a boolean to indicate the pairwise cipher and group
 						cipher are the same or not
-		
+
 	Return Value:
-		
+
 	Note:
-		
+
 	========================================================================
 */
 static VOID RTMPInsertRsnIeCipher(
 	IN  PRTMP_ADAPTER   pAd,
-	IN	UCHAR			ElementID,	
+	IN	UCHAR			ElementID,
 	IN	UINT			WepStatus,
 	IN	BOOLEAN			bMixCipher,
 	IN	UCHAR			FlexibleCipher,
 	OUT	PUCHAR			pRsnIe,
 	OUT	UCHAR			*rsn_len)
-{		
+{
 	UCHAR	PairwiseCnt;
 
 	*rsn_len = 0;
 
-	// decide WPA2 or WPA1	
+	// decide WPA2 or WPA1
 	if (ElementID == Wpa2Ie)
 	{
 		RSNIE2	*pRsnie_cipher = (RSNIE2*)pRsnIe;
@@ -334,7 +334,7 @@ static VOID RTMPInsertRsnIeCipher(
 				if (bMixCipher)
 					NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
 				else
-					NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_CCMP, 4);								
+					NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_CCMP, 4);
                 pRsnie_cipher->ucount = 1;
                 NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_CCMP, 4);
                 *rsn_len = sizeof(RSNIE2);
@@ -345,7 +345,7 @@ static VOID RTMPInsertRsnIeCipher(
                 NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA2_TKIP, 4);
 
 				PairwiseCnt = 1;
-				// Insert WPA2 TKIP as the first pairwise cipher 
+				// Insert WPA2 TKIP as the first pairwise cipher
 				if (MIX_CIPHER_WPA2_TKIP_ON(FlexibleCipher))
 				{
                 	NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_TKIP, 4);
@@ -354,18 +354,18 @@ static VOID RTMPInsertRsnIeCipher(
 					{
                 		NdisMoveMemory(pRsnie_cipher->ucast[0].oui + 4, OUI_WPA2_CCMP, 4);
 						PairwiseCnt = 2;
-					}	
+					}
 				}
 				else
 				{
-					// Insert WPA2 AES as the first pairwise cipher 
-					NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_CCMP, 4);	
+					// Insert WPA2 AES as the first pairwise cipher
+					NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA2_CCMP, 4);
 				}
-							
-                pRsnie_cipher->ucount = PairwiseCnt;				
+
+                pRsnie_cipher->ucount = PairwiseCnt;
                 *rsn_len = sizeof(RSNIE2) + (4 * (PairwiseCnt - 1));
-                break;			
-        }   
+                break;
+        }
 
 		// swap for big-endian platform
 		pRsnie_cipher->version = cpu2le16(pRsnie_cipher->version);
@@ -390,11 +390,11 @@ static VOID RTMPInsertRsnIeCipher(
                 break;
 
 			// AES mode
-            case Ndis802_11Encryption3Enabled:				
+            case Ndis802_11Encryption3Enabled:
 				if (bMixCipher)
 					NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
 				else
-					NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_CCMP, 4);			
+					NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_CCMP, 4);
                 pRsnie_cipher->ucount = 1;
                 NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_CCMP, 4);
                 *rsn_len = sizeof(RSNIE);
@@ -405,7 +405,7 @@ static VOID RTMPInsertRsnIeCipher(
                 NdisMoveMemory(pRsnie_cipher->mcast, OUI_WPA_TKIP, 4);
 
 				PairwiseCnt = 1;
-				// Insert WPA TKIP as the first pairwise cipher 
+				// Insert WPA TKIP as the first pairwise cipher
 				if (MIX_CIPHER_WPA_TKIP_ON(FlexibleCipher))
 				{
                 	NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_TKIP, 4);
@@ -414,17 +414,17 @@ static VOID RTMPInsertRsnIeCipher(
 					{
                 		NdisMoveMemory(pRsnie_cipher->ucast[0].oui + 4, OUI_WPA_CCMP, 4);
 						PairwiseCnt = 2;
-					}	
+					}
 				}
 				else
 				{
-					// Insert WPA AES as the first pairwise cipher 
-					NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_CCMP, 4);	
+					// Insert WPA AES as the first pairwise cipher
+					NdisMoveMemory(pRsnie_cipher->ucast[0].oui, OUI_WPA_CCMP, 4);
 				}
-						
-                pRsnie_cipher->ucount = PairwiseCnt;				
-                *rsn_len = sizeof(RSNIE) + (4 * (PairwiseCnt - 1));				
-                break;					
+
+                pRsnie_cipher->ucount = PairwiseCnt;
+                *rsn_len = sizeof(RSNIE) + (4 * (PairwiseCnt - 1));
+                break;
         }
 
 		// swap for big-endian platform
@@ -436,36 +436,36 @@ static VOID RTMPInsertRsnIeCipher(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
-		Build AKM suite in RSN-IE. 
-		It only shall be called by RTMPMakeRSNIE. 
+		Build AKM suite in RSN-IE.
+		It only shall be called by RTMPMakeRSNIE.
 
 	Arguments:
-		pAd			-	pointer to our pAdapter context	
+		pAd			-	pointer to our pAdapter context
     	ElementID	-	indicate the WPA1 or WPA2
     	AuthMode	-	indicate the authentication mode
 		apidx		-	indicate the interface index
-		
+
 	Return Value:
-		
+
 	Note:
-		
+
 	========================================================================
 */
-static VOID RTMPInsertRsnIeAKM(	
-	IN  PRTMP_ADAPTER   pAd,	
-	IN	UCHAR			ElementID,	
+static VOID RTMPInsertRsnIeAKM(
+	IN  PRTMP_ADAPTER   pAd,
+	IN	UCHAR			ElementID,
 	IN	UINT			AuthMode,
 	IN	UCHAR			apidx,
 	OUT	PUCHAR			pRsnIe,
 	OUT	UCHAR			*rsn_len)
 {
-	RSNIE_AUTH		*pRsnie_auth;	
+	RSNIE_AUTH		*pRsnie_auth;
 
 	pRsnie_auth = (RSNIE_AUTH*)(pRsnIe + (*rsn_len));
 
-	// decide WPA2 or WPA1	 
+	// decide WPA2 or WPA1
 	if (ElementID == Wpa2Ie)
 	{
 		switch (AuthMode)
@@ -503,35 +503,35 @@ static VOID RTMPInsertRsnIeAKM(
                 pRsnie_auth->acount = 1;
                 NdisMoveMemory(pRsnie_auth->auth[0].oui, OUI_WPA_NONE_AKM, 4);
                 break;
-        }			
+        }
 	}
-		 
+
 	pRsnie_auth->acount = cpu2le16(pRsnie_auth->acount);
-	
+
 	(*rsn_len) += sizeof(RSNIE_AUTH);	// update current RSNIE length
 
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
-		Build capability in RSN-IE. 
-		It only shall be called by RTMPMakeRSNIE. 
+		Build capability in RSN-IE.
+		It only shall be called by RTMPMakeRSNIE.
 
 	Arguments:
-		pAd			-	pointer to our pAdapter context	
-    	ElementID	-	indicate the WPA1 or WPA2    	
+		pAd			-	pointer to our pAdapter context
+    	ElementID	-	indicate the WPA1 or WPA2
 		apidx		-	indicate the interface index
-		
+
 	Return Value:
-		
+
 	Note:
-		
+
 	========================================================================
 */
-static VOID RTMPInsertRsnIeCap(	
-	IN  PRTMP_ADAPTER   pAd,	
+static VOID RTMPInsertRsnIeCap(
+	IN  PRTMP_ADAPTER   pAd,
 	IN	UCHAR			ElementID,
 	IN	UCHAR			apidx,
 	OUT	PUCHAR			pRsnIe,
@@ -542,12 +542,12 @@ static VOID RTMPInsertRsnIeCap(
 	// it could be ignored in WPA1 mode
 	if (ElementID == WpaIe)
 		return;
-	
+
 	pRSN_Cap = (RSN_CAPABILITIES*)(pRsnIe + (*rsn_len));
-	
-					 
+
+
 	pRSN_Cap->word = cpu2le16(pRSN_Cap->word);
-	
+
 	(*rsn_len) += sizeof(RSN_CAPABILITIES);	// update current RSNIE length
 
 }
@@ -560,15 +560,15 @@ static VOID RTMPInsertRsnIeCap(
 		Build RSN IE context. It is not included element-ID and length.
 
 	Arguments:
-		pAd			-	pointer to our pAdapter context	
+		pAd			-	pointer to our pAdapter context
     	AuthMode	-	indicate the authentication mode
     	WepStatus	-	indicate the encryption type
 		apidx		-	indicate the interface index
-		
+
 	Return Value:
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID RTMPMakeRSNIE(
@@ -578,13 +578,13 @@ VOID RTMPMakeRSNIE(
 	IN	UCHAR			apidx)
 {
 	PUCHAR		pRsnIe = NULL;			// primary RSNIE
-	UCHAR 		*rsnielen_cur_p = 0;	// the length of the primary RSNIE 		
-	UCHAR		*rsnielen_ex_cur_p = 0;	// the length of the secondary RSNIE	  	
-	UCHAR		PrimaryRsnie;			
+	UCHAR 		*rsnielen_cur_p = 0;	// the length of the primary RSNIE
+	UCHAR		*rsnielen_ex_cur_p = 0;	// the length of the secondary RSNIE
+	UCHAR		PrimaryRsnie;
 	BOOLEAN		bMixCipher = FALSE;	// indicate the pairwise and group cipher are different
-	UCHAR		p_offset;		
+	UCHAR		p_offset;
 	WPA_MIX_PAIR_CIPHER		FlexibleCipher = MIX_CIPHER_NOTUSE;	// it provide the more flexible cipher combination in WPA-WPA2 and TKIPAES mode
-		
+
 	rsnielen_cur_p = NULL;
 	rsnielen_ex_cur_p = NULL;
 
@@ -603,33 +603,33 @@ VOID RTMPMakeRSNIE(
 			{
 				// Support WPAPSK or WPA2PSK in STA-Infra mode
 				// Support WPANone in STA-Adhoc mode
-				if ((AuthMode != Ndis802_11AuthModeWPAPSK) && 
-					(AuthMode != Ndis802_11AuthModeWPA2PSK) && 
+				if ((AuthMode != Ndis802_11AuthModeWPAPSK) &&
+					(AuthMode != Ndis802_11AuthModeWPA2PSK) &&
 					(AuthMode != Ndis802_11AuthModeWPANone)
 					)
 					return;
-			}	
-	
+			}
+
 			DBGPRINT(RT_DEBUG_TRACE,("==> RTMPMakeRSNIE(STA)\n"));
 
-			// Zero RSNIE context 
+			// Zero RSNIE context
 			pAd->StaCfg.RSNIE_Len = 0;
 			NdisZeroMemory(pAd->StaCfg.RSN_IE, MAX_LEN_OF_RSNIE);
 
-			// Pointer to RSNIE 
+			// Pointer to RSNIE
 			rsnielen_cur_p = &pAd->StaCfg.RSNIE_Len;
 			pRsnIe = pAd->StaCfg.RSN_IE;
 
-			bMixCipher = pAd->StaCfg.bMixCipher;						
+			bMixCipher = pAd->StaCfg.bMixCipher;
 		}
 #endif // CONFIG_STA_SUPPORT //
 	}
 
 	// indicate primary RSNIE as WPA or WPA2
-	if ((AuthMode == Ndis802_11AuthModeWPA) || 
-		(AuthMode == Ndis802_11AuthModeWPAPSK) || 
-		(AuthMode == Ndis802_11AuthModeWPANone) || 
-		(AuthMode == Ndis802_11AuthModeWPA1WPA2) || 
+	if ((AuthMode == Ndis802_11AuthModeWPA) ||
+		(AuthMode == Ndis802_11AuthModeWPAPSK) ||
+		(AuthMode == Ndis802_11AuthModeWPANone) ||
+		(AuthMode == Ndis802_11AuthModeWPA1WPA2) ||
 		(AuthMode == Ndis802_11AuthModeWPA1PSKWPA2PSK))
 		PrimaryRsnie = WpaIe;
 	else
@@ -639,7 +639,7 @@ VOID RTMPMakeRSNIE(
 		// Build the primary RSNIE
 		// 1. insert cipher suite
 		RTMPInsertRsnIeCipher(pAd, PrimaryRsnie, WepStatus, bMixCipher, FlexibleCipher, pRsnIe, &p_offset);
-	
+
 		// 2. insert AKM
 		RTMPInsertRsnIeAKM(pAd, PrimaryRsnie, AuthMode, apidx, pRsnIe, &p_offset);
 
@@ -648,7 +648,7 @@ VOID RTMPMakeRSNIE(
 	}
 
 	// 4. update the RSNIE length
-	*rsnielen_cur_p = p_offset; 
+	*rsnielen_cur_p = p_offset;
 
 	hex_dump("The primary RSNIE", pRsnIe, (*rsnielen_cur_p));
 
@@ -661,12 +661,12 @@ VOID RTMPMakeRSNIE(
 		Check whether the received frame is EAP frame.
 
 	Arguments:
-		pAd				-	pointer to our pAdapter context	
+		pAd				-	pointer to our pAdapter context
 		pEntry			-	pointer to active entry
 		pData			-	the received frame
-		DataByteCount 	-	the received frame's length		
+		DataByteCount 	-	the received frame's length
 		FromWhichBSSID	-	indicate the interface index
-       
+
     Return:
          TRUE 			-	This frame is EAP frame
          FALSE 			-	otherwise
@@ -686,24 +686,24 @@ BOOLEAN RTMPCheckWPAframe(
     if(DataByteCount < (LENGTH_802_1_H + LENGTH_EAPOL_H))
         return FALSE;
 
-    
-	// Skip LLC header	
+
+	// Skip LLC header
     if (NdisEqualMemory(SNAP_802_1H, pData, 6) ||
         // Cisco 1200 AP may send packet with SNAP_BRIDGE_TUNNEL
-        NdisEqualMemory(SNAP_BRIDGE_TUNNEL, pData, 6)) 
+        NdisEqualMemory(SNAP_BRIDGE_TUNNEL, pData, 6))
     {
         pData += 6;
     }
-	// Skip 2-bytes EAPoL type 
-    if (NdisEqualMemory(EAPOL, pData, 2)) 
+	// Skip 2-bytes EAPoL type
+    if (NdisEqualMemory(EAPOL, pData, 2))
     {
-        pData += 2;         
+        pData += 2;
     }
-    else    
+    else
         return FALSE;
 
-    switch (*(pData+1))     
-    {   
+    switch (*(pData+1))
+    {
         case EAPPacket:
 			Body_len = (*(pData+2)<<8) | (*(pData+3));
             DBGPRINT(RT_DEBUG_TRACE, ("Receive EAP-Packet frame, TYPE = 0, Length = %ld\n", Body_len));
@@ -711,11 +711,11 @@ BOOLEAN RTMPCheckWPAframe(
         case EAPOLStart:
             DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL-Start frame, TYPE = 1 \n"));
 			if (pEntry->EnqueueEapolStartTimerRunning != EAPOL_START_DISABLE)
-            {    
+            {
             	DBGPRINT(RT_DEBUG_TRACE, ("Cancel the EnqueueEapolStartTimerRunning \n"));
                 RTMPCancelTimer(&pEntry->EnqueueStartForPSKTimer, &Cancelled);
-                pEntry->EnqueueEapolStartTimerRunning = EAPOL_START_DISABLE;             
-            }				
+                pEntry->EnqueueEapolStartTimerRunning = EAPOL_START_DISABLE;
+            }
             break;
         case EAPOLLogoff:
             DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOLLogoff frame, TYPE = 2 \n"));
@@ -729,8 +729,8 @@ BOOLEAN RTMPCheckWPAframe(
             break;
         default:
             return FALSE;
-    
-    }   
+
+    }
     return TRUE;
 }
 
@@ -743,8 +743,8 @@ BOOLEAN RTMPCheckWPAframe(
         This function references to RFC 3394 for aes key wrap algorithm.
     Return:
     ==========================================================================
-*/  
-VOID AES_GTK_KEY_WRAP( 
+*/
+VOID AES_GTK_KEY_WRAP(
     IN UCHAR    *key,
     IN UCHAR    *plaintext,
     IN UCHAR    p_len,
@@ -800,25 +800,25 @@ VOID AES_GTK_KEY_WRAP(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Misc function to decrypt AES body
-	
+
 	Arguments:
-			
+
 	Return Value:
-	
+
 	Note:
 		This function references to	RFC	3394 for aes key unwrap algorithm.
-			
+
 	========================================================================
 */
-VOID	AES_GTK_KEY_UNWRAP( 
+VOID	AES_GTK_KEY_UNWRAP(
 	IN	UCHAR	*key,
 	OUT	UCHAR	*plaintext,
 	IN	UCHAR    c_len,
 	IN	UCHAR	*ciphertext)
-	
+
 {
 	UCHAR       A[8], BIN[16], BOUT[16];
 	UCHAR       xor;
@@ -827,7 +827,7 @@ VOID	AES_GTK_KEY_UNWRAP(
 	UCHAR       *R;
 	INT         num_blocks = c_len/8;	// unit:64bits
 
-	
+
 	os_alloc_mem(NULL, (PUCHAR *)&R, 512);
 
 	if (R == NULL)
@@ -865,7 +865,7 @@ VOID	AES_GTK_KEY_UNWRAP(
 	{
 		plaintext[i] = R[i];
 	}
-	
+
 
 	os_free_mem(NULL, R);
 }
@@ -882,7 +882,7 @@ VOID	AES_GTK_KEY_UNWRAP(
 					EAPOL_PAIR_MSG_4
 					EAPOL_GROUP_MSG_1
 					EAPOL_GROUP_MSG_2
-											       
+
     Return:
          message type string
 
@@ -909,15 +909,15 @@ CHAR *GetEapolMsgType(CHAR msg)
 
 /*
     ========================================================================
-    
+
     Routine Description:
     Check Sanity RSN IE of EAPoL message
 
     Arguments:
-        
+
     Return Value:
 
-		
+
     ========================================================================
 */
 BOOLEAN RTMPCheckRSNIE(
@@ -931,25 +931,25 @@ BOOLEAN RTMPCheckRSNIE(
 	UCHAR               len;
 	PEID_STRUCT         pEid;
 	BOOLEAN				result = FALSE;
-		
+
 	pVIE = pData;
 	len	 = DataLen;
 	*Offset = 0;
 
 	while (len > sizeof(RSNIE2))
 	{
-		pEid = (PEID_STRUCT) pVIE;	
+		pEid = (PEID_STRUCT) pVIE;
 		// WPA RSN IE
 		if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4)))
-		{			
+		{
 			if ((pEntry->AuthMode == Ndis802_11AuthModeWPA || pEntry->AuthMode == Ndis802_11AuthModeWPAPSK) &&
 				(NdisEqualMemory(pVIE, pEntry->RSN_IE, pEntry->RSNIE_Len)) &&
 				(pEntry->RSNIE_Len == (pEid->Len + 2)))
 			{
-					result = TRUE;				
-			}		
-			
-			*Offset += (pEid->Len + 2);			
+					result = TRUE;
+			}
+
+			*Offset += (pEid->Len + 2);
 		}
 		// WPA2 RSN IE
 		else if ((pEid->Eid == IE_RSN) && (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3)))
@@ -958,40 +958,40 @@ BOOLEAN RTMPCheckRSNIE(
 				(NdisEqualMemory(pVIE, pEntry->RSN_IE, pEntry->RSNIE_Len)) &&
 				(pEntry->RSNIE_Len == (pEid->Len + 2))/* ToDo-AlbertY for mesh*/)
 			{
-					result = TRUE;				
-			}			
+					result = TRUE;
+			}
 
 			*Offset += (pEid->Len + 2);
-		}		
+		}
 		else
-		{			
+		{
 			break;
 		}
 
 		pVIE += (pEid->Len + 2);
 		len  -= (pEid->Len + 2);
 	}
-	
-		
+
+
 	return result;
-	
+
 }
 
 
 /*
     ========================================================================
-    
+
     Routine Description:
-    Parse KEYDATA field.  KEYDATA[] May contain 2 RSN IE and optionally GTK.  
+    Parse KEYDATA field.  KEYDATA[] May contain 2 RSN IE and optionally GTK.
     GTK  is encaptulated in KDE format at  p.83 802.11i D10
 
     Arguments:
-        
+
     Return Value:
 
     Note:
-        802.11i D10  
-        
+        802.11i D10
+
     ========================================================================
 */
 BOOLEAN RTMPParseEapolKeyData(
@@ -1008,23 +1008,23 @@ BOOLEAN RTMPParseEapolKeyData(
     UCHAR               KeyDataLength = KeyDataLen;
     UCHAR               GTKLEN = 0;
 	UCHAR				DefaultIdx = 0;
-	UCHAR				skip_offset;		
-	    
+	UCHAR				skip_offset;
+
 	// Verify The RSN IE contained in pairewise_msg_2 && pairewise_msg_3 and skip it
 	if (MsgType == EAPOL_PAIR_MSG_2 || MsgType == EAPOL_PAIR_MSG_3)
     {
-		// Check RSN IE whether it is WPA2/WPA2PSK   		
+		// Check RSN IE whether it is WPA2/WPA2PSK
 		if (!RTMPCheckRSNIE(pAd, pKeyData, KeyDataLen, pEntry, &skip_offset))
 		{
 			// send wireless event - for RSN IE different
 			if (pAd->CommonCfg.bWirelessEvent)
-				RTMPSendWirelessEvent(pAd, IW_RSNIE_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0); 
+				RTMPSendWirelessEvent(pAd, IW_RSNIE_DIFF_EVENT_FLAG, pEntry->Addr, pEntry->apidx, 0);
 
-        	DBGPRINT(RT_DEBUG_ERROR, ("RSN_IE Different in msg %d of 4-way handshake!\n", MsgType));			
+        	DBGPRINT(RT_DEBUG_ERROR, ("RSN_IE Different in msg %d of 4-way handshake!\n", MsgType));
 			hex_dump("Receive RSN_IE ", pKeyData, KeyDataLen);
-			hex_dump("Desired RSN_IE ", pEntry->RSN_IE, pEntry->RSNIE_Len);	
-					
-			return FALSE;			
+			hex_dump("Desired RSN_IE ", pEntry->RSN_IE, pEntry->RSNIE_Len);
+
+			return FALSE;
     	}
     	else
 		{
@@ -1036,7 +1036,7 @@ BOOLEAN RTMPParseEapolKeyData(
 				DBGPRINT(RT_DEBUG_TRACE, ("RTMPParseEapolKeyData ==> WPA2/WPA2PSK RSN IE matched in Msg 3, Length(%d) \n", skip_offset));
 			}
 			else
-				return TRUE;			
+				return TRUE;
 		}
 	}
 
@@ -1044,19 +1044,19 @@ BOOLEAN RTMPParseEapolKeyData(
 
 	// Parse EKD format in pairwise_msg_3_WPA2 && group_msg_1_WPA2
 	if (bWPA2 && (MsgType == EAPOL_PAIR_MSG_3 || MsgType == EAPOL_GROUP_MSG_1))
-	{				
+	{
 		if (KeyDataLength >= 8)	// KDE format exclude GTK length
     	{
         	pKDE = (PKDE_ENCAP) pMyKeyData;
-	        
-			
+
+
 			DefaultIdx = pKDE->GTKEncap.Kid;
 
 			// Sanity check - KED length
 			if (KeyDataLength < (pKDE->Len + 2))
     		{
         		DBGPRINT(RT_DEBUG_ERROR, ("ERROR: The len from KDE is too short \n"));
-        		return FALSE;			
+        		return FALSE;
     		}
 
 			// Get GTK length - refer to IEEE 802.11i-2004 p.82
@@ -1066,7 +1066,7 @@ BOOLEAN RTMPParseEapolKeyData(
 				DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key length is too short (%d) \n", GTKLEN));
         		return FALSE;
 			}
-			
+
     	}
 		else
     	{
@@ -1078,20 +1078,20 @@ BOOLEAN RTMPParseEapolKeyData(
 		// skip it
 		pMyKeyData += 8;
 		KeyDataLength -= 8;
-		
+
 	}
 	else if (!bWPA2 && MsgType == EAPOL_GROUP_MSG_1)
 	{
 		DefaultIdx = GroupKeyIndex;
 		DBGPRINT(RT_DEBUG_TRACE, ("GTK DefaultKeyID=%d \n", DefaultIdx));
 	}
-		
+
 	// Sanity check - shared key index must be 1 ~ 3
 	if (DefaultIdx < 1 || DefaultIdx > 3)
     {
      	DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key index(%d) is invalid in %s %s \n", DefaultIdx, ((bWPA2) ? "WPA2" : "WPA"), GetEapolMsgType(MsgType)));
         return FALSE;
-    } 
+    }
 
 
 #ifdef CONFIG_STA_SUPPORT
@@ -1099,21 +1099,21 @@ BOOLEAN RTMPParseEapolKeyData(
 #endif // CONFIG_STA_SUPPORT //
 
 	return TRUE;
- 
+
 }
 
 
 /*
 	========================================================================
-	
+
 	Routine Description:
-		Construct EAPoL message for WPA handshaking 
+		Construct EAPoL message for WPA handshaking
 		Its format is below,
-		
+
 		+--------------------+
 		| Protocol Version	 |  1 octet
 		+--------------------+
-		| Protocol Type		 |	1 octet	
+		| Protocol Type		 |	1 octet
 		+--------------------+
 		| Body Length		 |  2 octets
 		+--------------------+
@@ -1139,16 +1139,16 @@ BOOLEAN RTMPParseEapolKeyData(
 		+--------------------+
 		| Key Data			 |	n octets
 		+--------------------+
-		
+
 
 	Arguments:
 		pAd			Pointer	to our adapter
-				
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	ConstructEapolMsg(
@@ -1156,7 +1156,7 @@ VOID	ConstructEapolMsg(
     IN 	UCHAR				AuthMode,
     IN 	UCHAR				WepStatus,
     IN 	UCHAR				GroupKeyWepStatus,
-    IN 	UCHAR				MsgType,  
+    IN 	UCHAR				MsgType,
     IN	UCHAR				DefaultKeyIdx,
     IN 	UCHAR				*ReplayCounter,
 	IN 	UCHAR				*KeyNonce,
@@ -1172,23 +1172,23 @@ VOID	ConstructEapolMsg(
 	// Choose WPA2 or not
 	if ((AuthMode == Ndis802_11AuthModeWPA2) || (AuthMode == Ndis802_11AuthModeWPA2PSK))
 		bWPA2 = TRUE;
-		
-    // Init Packet and Fill header    
+
+    // Init Packet and Fill header
     pMsg->ProVer = EAPOL_VER;
     pMsg->ProType = EAPOLKey;
 
 	// Default 95 bytes, the EAPoL-Key descriptor exclude Key-data field
-	pMsg->Body_Len[1] = LEN_EAPOL_KEY_MSG;  
+	pMsg->Body_Len[1] = LEN_EAPOL_KEY_MSG;
 
 	// Fill in EAPoL descriptor
 	if (bWPA2)
 		pMsg->KeyDesc.Type = WPA2_KEY_DESC;
 	else
 		pMsg->KeyDesc.Type = WPA1_KEY_DESC;
-			
-	// Fill in Key information, refer to IEEE Std 802.11i-2004 page 78 
+
+	// Fill in Key information, refer to IEEE Std 802.11i-2004 page 78
 	// When either the pairwise or the group cipher is AES, the DESC_TYPE_AES(2) shall be used.
-	pMsg->KeyDesc.KeyInfo.KeyDescVer = 
+	pMsg->KeyDesc.KeyInfo.KeyDescVer =
         	(((WepStatus == Ndis802_11Encryption3Enabled) || (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
 
 	// Specify Key Type as Group(0) or Pairwise(1)
@@ -1200,27 +1200,27 @@ VOID	ConstructEapolMsg(
 	// Specify Key Index, only group_msg1_WPA1
 	if (!bWPA2 && (MsgType >= EAPOL_GROUP_MSG_1))
 		pMsg->KeyDesc.KeyInfo.KeyIndex = DefaultKeyIdx;
-	
+
 	if (MsgType == EAPOL_PAIR_MSG_3)
 		pMsg->KeyDesc.KeyInfo.Install = 1;
-	
+
 	if ((MsgType == EAPOL_PAIR_MSG_1) || (MsgType == EAPOL_PAIR_MSG_3) || (MsgType == EAPOL_GROUP_MSG_1))
 		pMsg->KeyDesc.KeyInfo.KeyAck = 1;
 
-	if (MsgType != EAPOL_PAIR_MSG_1)	
+	if (MsgType != EAPOL_PAIR_MSG_1)
 		pMsg->KeyDesc.KeyInfo.KeyMic = 1;
- 
+
 	if ((bWPA2 && (MsgType >= EAPOL_PAIR_MSG_3)) || (!bWPA2 && (MsgType >= EAPOL_GROUP_MSG_1)))
-    {                        
-       	pMsg->KeyDesc.KeyInfo.Secure = 1;                   
+    {
+       	pMsg->KeyDesc.KeyInfo.Secure = 1;
     }
 
 	if (bWPA2 && ((MsgType == EAPOL_PAIR_MSG_3) || (MsgType == EAPOL_GROUP_MSG_1)))
-    {                               	
-        pMsg->KeyDesc.KeyInfo.EKD_DL = 1;            
+    {
+        pMsg->KeyDesc.KeyInfo.EKD_DL = 1;
     }
 
-	// key Information element has done. 
+	// key Information element has done.
 	*(USHORT *)(&pMsg->KeyDesc.KeyInfo) = cpu2le16(*(USHORT *)(&pMsg->KeyDesc.KeyInfo));
 
 	// Fill in Key Length
@@ -1233,51 +1233,51 @@ VOID	ConstructEapolMsg(
 		else
 		{
 			// the length of pairwise key cipher
-			pMsg->KeyDesc.KeyLength[1] = ((WepStatus == Ndis802_11Encryption2Enabled) ? LEN_TKIP_KEY : LEN_AES_KEY);			
-		}				
-	}			
-	
- 	// Fill in replay counter        		
+			pMsg->KeyDesc.KeyLength[1] = ((WepStatus == Ndis802_11Encryption2Enabled) ? LEN_TKIP_KEY : LEN_AES_KEY);
+		}
+	}
+
+ 	// Fill in replay counter
     NdisMoveMemory(pMsg->KeyDesc.ReplayCounter, ReplayCounter, LEN_KEY_DESC_REPLAY);
 
-	// Fill Key Nonce field		  
+	// Fill Key Nonce field
 	// ANonce : pairwise_msg1 & pairwise_msg3
 	// SNonce : pairwise_msg2
-	// GNonce : group_msg1_wpa1	
+	// GNonce : group_msg1_wpa1
 	if ((MsgType <= EAPOL_PAIR_MSG_3) || ((!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))))
     	NdisMoveMemory(pMsg->KeyDesc.KeyNonce, KeyNonce, LEN_KEY_DESC_NONCE);
 
 	// Fill key IV - WPA2 as 0, WPA1 as random
 	if (!bWPA2 && (MsgType == EAPOL_GROUP_MSG_1))
-	{		
+	{
 		// Suggest IV be random number plus some number,
-		NdisMoveMemory(pMsg->KeyDesc.KeyIv, &KeyNonce[16], LEN_KEY_DESC_IV);		
-        pMsg->KeyDesc.KeyIv[15] += 2;		
+		NdisMoveMemory(pMsg->KeyDesc.KeyIv, &KeyNonce[16], LEN_KEY_DESC_IV);
+        pMsg->KeyDesc.KeyIv[15] += 2;
 	}
-	
-    // Fill Key RSC field        
+
+    // Fill Key RSC field
     // It contains the RSC for the GTK being installed.
 	if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2) || (MsgType == EAPOL_GROUP_MSG_1))
-	{		
+	{
         NdisMoveMemory(pMsg->KeyDesc.KeyRsc, TxRSC, 6);
 	}
 
-	// Clear Key MIC field for MIC calculation later   
+	// Clear Key MIC field for MIC calculation later
     NdisZeroMemory(pMsg->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
-	
-	ConstructEapolKeyData(pAd, 
+
+	ConstructEapolKeyData(pAd,
 						  AuthMode,
 						  WepStatus,
-						  GroupKeyWepStatus, 
-						  MsgType, 
-						  DefaultKeyIdx, 
-						  bWPA2, 
+						  GroupKeyWepStatus,
+						  MsgType,
+						  DefaultKeyIdx,
+						  bWPA2,
 						  PTK,
 						  GTK,
 						  RSNIE,
 						  RSNIE_Len,
 						  pMsg);
- 
+
 	// Calculate MIC and fill in KeyMic Field except Pairwise Msg 1.
 	if (MsgType != EAPOL_PAIR_MSG_1)
 	{
@@ -1293,19 +1293,19 @@ VOID	ConstructEapolMsg(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
-		Construct the Key Data field of EAPoL message 
+		Construct the Key Data field of EAPoL message
 
 	Arguments:
 		pAd			Pointer	to our adapter
 		Elem		Message body
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	ConstructEapolKeyData(
@@ -1322,20 +1322,20 @@ VOID	ConstructEapolKeyData(
 	IN	UCHAR			RSNIE_LEN,
 	OUT PEAPOL_PACKET   pMsg)
 {
-	UCHAR		*mpool, *Key_Data, *Rc4GTK;  
-	UCHAR       ekey[(LEN_KEY_DESC_IV+LEN_EAP_EK)];   
+	UCHAR		*mpool, *Key_Data, *Rc4GTK;
+	UCHAR       ekey[(LEN_KEY_DESC_IV+LEN_EAP_EK)];
 	UCHAR		data_offset;
 
 
 	if (MsgType == EAPOL_PAIR_MSG_1 || MsgType == EAPOL_PAIR_MSG_4 || MsgType == EAPOL_GROUP_MSG_2)
 		return;
- 
+
 	// allocate memory pool
 	os_alloc_mem(pAd, (PUCHAR *)&mpool, 1500);
 
     if (mpool == NULL)
 		return;
-        
+
 	/* Rc4GTK Len = 512 */
 	Rc4GTK = (UCHAR *) ROUND_UP(mpool, 4);
 	/* Key_Data Len = 512 */
@@ -1344,15 +1344,15 @@ VOID	ConstructEapolKeyData(
 	NdisZeroMemory(Key_Data, 512);
 	pMsg->KeyDesc.KeyDataLen[1] = 0;
 	data_offset = 0;
-	
-	// Encapsulate RSNIE in pairwise_msg2 & pairwise_msg3		
+
+	// Encapsulate RSNIE in pairwise_msg2 & pairwise_msg3
 	if (RSNIE_LEN && ((MsgType == EAPOL_PAIR_MSG_2) || (MsgType == EAPOL_PAIR_MSG_3)))
 	{
-		if (bWPA2Capable)			
-			Key_Data[data_offset + 0] = IE_WPA2;		
-		else						 				
-			Key_Data[data_offset + 0] = IE_WPA;            			
-		
+		if (bWPA2Capable)
+			Key_Data[data_offset + 0] = IE_WPA2;
+		else
+			Key_Data[data_offset + 0] = IE_WPA;
+
         Key_Data[data_offset + 1] = RSNIE_LEN;
 		NdisMoveMemory(&Key_Data[data_offset + 2], RSNIE, RSNIE_LEN);
 		data_offset += (2 + RSNIE_LEN);
@@ -1366,13 +1366,13 @@ VOID	ConstructEapolKeyData(
 
 		if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)
 		{
-			Key_Data[data_offset + 1] = 0x16;// 4+2+16(OUI+DataType+DataField)			
+			Key_Data[data_offset + 1] = 0x16;// 4+2+16(OUI+DataType+DataField)
 		}
 		else
 		{
-			Key_Data[data_offset + 1] = 0x26;// 4+2+32(OUI+DataType+DataField)			
+			Key_Data[data_offset + 1] = 0x26;// 4+2+32(OUI+DataType+DataField)
 		}
-		
+
         Key_Data[data_offset + 2] = 0x00;
         Key_Data[data_offset + 3] = 0x0F;
         Key_Data[data_offset + 4] = 0xAC;
@@ -1381,7 +1381,7 @@ VOID	ConstructEapolKeyData(
 		// GTK KDE format - 802.11i-2004  Figure-43x
         Key_Data[data_offset + 6] = (DefaultKeyIdx & 0x03);
         Key_Data[data_offset + 7] = 0x00;	// Reserved Byte
-				
+
 		data_offset += 8;
 	}
 
@@ -1389,15 +1389,15 @@ VOID	ConstructEapolKeyData(
 	// Encapsulate GTK and encrypt the key-data field with KEK.
 	// Only for pairwise_msg3_WPA2 and group_msg1
 	if ((MsgType == EAPOL_PAIR_MSG_3 && bWPA2Capable) || (MsgType == EAPOL_GROUP_MSG_1))
-	{		
-		// Fill in GTK 
+	{
+		// Fill in GTK
 		if (GroupKeyWepStatus == Ndis802_11Encryption3Enabled)
-		{			
+		{
 			NdisMoveMemory(&Key_Data[data_offset], GTK, LEN_AES_KEY);
 			data_offset += LEN_AES_KEY;
 		}
 		else
-		{			
+		{
 			NdisMoveMemory(&Key_Data[data_offset], GTK, TKIP_GTK_LENGTH);
 			data_offset += TKIP_GTK_LENGTH;
 		}
@@ -1429,7 +1429,7 @@ VOID	ConstructEapolKeyData(
 		{
 			AES_GTK_KEY_WRAP(&PTK[16], Key_Data, data_offset, Rc4GTK);
             // AES wrap function will grow 8 bytes in length
-            data_offset += 8;            				
+            data_offset += 8;
 		}
 		else
 		{
@@ -1442,7 +1442,7 @@ VOID	ConstructEapolKeyData(
 			NdisMoveMemory(&ekey[LEN_KEY_DESC_IV], &PTK[16], LEN_EAP_EK);
 			ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, ekey, sizeof(ekey));  //INIT SBOX, KEYLEN+3(IV)
 			pAd->PrivateInfo.FCSCRC32 = RTMP_CALC_FCS32(pAd->PrivateInfo.FCSCRC32, Key_Data, data_offset);
-			WPAARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, Rc4GTK, Key_Data, data_offset);  
+			WPAARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, Rc4GTK, Key_Data, data_offset);
 		}
 
 		NdisMoveMemory(pMsg->KeyDesc.KeyData, Rc4GTK, data_offset);
@@ -1453,7 +1453,7 @@ VOID	ConstructEapolKeyData(
 	}
 
 	// set key data length field and total length
-	pMsg->KeyDesc.KeyDataLen[1] = data_offset;		
+	pMsg->KeyDesc.KeyDataLen[1] = data_offset;
     pMsg->Body_Len[1] += data_offset;
 
 	os_free_mem(pAd, mpool);
@@ -1462,18 +1462,18 @@ VOID	ConstructEapolKeyData(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Calcaulate MIC. It is used during 4-ways handsharking.
 
 	Arguments:
-		pAd				-	pointer to our pAdapter context	
-    	PeerWepStatus	-	indicate the encryption type    			 
-		
+		pAd				-	pointer to our pAdapter context
+    	PeerWepStatus	-	indicate the encryption type
+
 	Return Value:
 
 	Note:
-		
+
 	========================================================================
 */
 VOID	CalculateMIC(
@@ -1495,14 +1495,14 @@ VOID	CalculateMIC(
 		DBGPRINT(RT_DEBUG_ERROR, ("!!!CalculateMIC: no memory!!!\n"));
 		return;
     }
-		
+
 	// make a frame for calculating MIC.
     MakeOutgoingFrame(OutBuffer,            	&FrameLen,
                       pMsg->Body_Len[1] + 4,  	pMsg,
                       END_OF_ARGS);
 
 	NdisZeroMemory(mic, sizeof(mic));
-			
+
 	// Calculate MIC
     if (PeerWepStatus == Ndis802_11Encryption3Enabled)
  	{
@@ -1524,16 +1524,16 @@ VOID	CalculateMIC(
 	========================================================================
 
 	Routine Description:
-		Some received frames can't decrypt by Asic, so decrypt them by software.  
+		Some received frames can't decrypt by Asic, so decrypt them by software.
 
 	Arguments:
-		pAd				-	pointer to our pAdapter context	
-    	PeerWepStatus	-	indicate the encryption type    			 
+		pAd				-	pointer to our pAdapter context
+    	PeerWepStatus	-	indicate the encryption type
 
 	Return Value:
-		NDIS_STATUS_SUCCESS		-	decryption successful	
+		NDIS_STATUS_SUCCESS		-	decryption successful
 		NDIS_STATUS_FAILURE		-	decryption failure
-		
+
 	========================================================================
 */
 NDIS_STATUS	RTMPSoftDecryptBroadCastData(
@@ -1541,66 +1541,66 @@ NDIS_STATUS	RTMPSoftDecryptBroadCastData(
 	IN	RX_BLK							*pRxBlk,
 	IN  NDIS_802_11_ENCRYPTION_STATUS 	GroupCipher,
 	IN  PCIPHER_KEY						pShard_key)
-{		
-	PRXWI_STRUC			pRxWI = pRxBlk->pRxWI;	
+{
+	PRXWI_STRUC			pRxWI = pRxBlk->pRxWI;
+
 
-	
 
 	// handle WEP decryption
 	if (GroupCipher == Ndis802_11Encryption1Enabled)
-    {    	        	        
+    {
 		if (RTMPSoftDecryptWEP(pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount, pShard_key))
 		{
-			
+
 			//Minus IV[4] & ICV[4]
-			pRxWI->MPDUtotalByteCount -= 8;  
+			pRxWI->MPDUtotalByteCount -= 8;
 		}
 		else
 		{
-			DBGPRINT(RT_DEBUG_ERROR, ("ERROR : Software decrypt WEP data fails.\n"));	
+			DBGPRINT(RT_DEBUG_ERROR, ("ERROR : Software decrypt WEP data fails.\n"));
 			// give up this frame
-			return NDIS_STATUS_FAILURE; 
-		}        											
+			return NDIS_STATUS_FAILURE;
+		}
 	}
 	// handle TKIP decryption
 	else if (GroupCipher == Ndis802_11Encryption2Enabled)
-	{	
+	{
 		if (RTMPSoftDecryptTKIP(pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount, 0, pShard_key))
 		{
-			
+
 			//Minus 8 bytes MIC, 8 bytes IV/EIV, 4 bytes ICV
-			pRxWI->MPDUtotalByteCount -= 20;  
+			pRxWI->MPDUtotalByteCount -= 20;
 		}
         else
 		{
 			DBGPRINT(RT_DEBUG_ERROR, ("ERROR : RTMPSoftDecryptTKIP Failed\n"));
 			// give up this frame
-			return NDIS_STATUS_FAILURE; 
+			return NDIS_STATUS_FAILURE;
         }
 	}
 	// handle AES decryption
 	else if (GroupCipher == Ndis802_11Encryption3Enabled)
 	{
 		if (RTMPSoftDecryptAES(pAd, pRxBlk->pData, pRxWI->MPDUtotalByteCount , pShard_key))
-		{							
-			
+		{
+
 			//8 bytes MIC, 8 bytes IV/EIV (CCMP Header)
-			pRxWI->MPDUtotalByteCount -= 16;  
+			pRxWI->MPDUtotalByteCount -= 16;
 		}
 		else
 		{
 			DBGPRINT(RT_DEBUG_ERROR, ("ERROR : RTMPSoftDecryptAES Failed\n"));
 			// give up this frame
-			return NDIS_STATUS_FAILURE;  
+			return NDIS_STATUS_FAILURE;
 		}
 	}
 	else
 	{
 		// give up this frame
-		return NDIS_STATUS_FAILURE;  
-	}	
+		return NDIS_STATUS_FAILURE;
+	}
 
 	return NDIS_STATUS_SUCCESS;
-		
+
 }
 
diff --git a/common/dfs.c b/common/dfs.c
index f557ee7..23cf151 100644
--- a/common/dfs.c
+++ b/common/dfs.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
     Module Name:
@@ -36,7 +36,7 @@
     Fonchi    03-12-2007      created
 */
 
-#include "rt_config.h"
+#include "../rt_config.h"
 
 typedef struct _RADAR_DURATION_TABLE
 {
@@ -91,7 +91,7 @@ VOID BbpRadarDetectionStart(
 	Value &= ~(0x1 << 3);
 	RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
 	}
-#endif 
+#endif
 	RadarPeriod = ((UINT)RdIdleTimeTable[pAd->CommonCfg.RadarDetect.RDDurRegion][0] + (UINT)pAd->CommonCfg.RadarDetect.DfsSessionTime) < 250 ?
 			(RdIdleTimeTable[pAd->CommonCfg.RadarDetect.RDDurRegion][0] + pAd->CommonCfg.RadarDetect.DfsSessionTime) : 250;
 
@@ -164,7 +164,7 @@ VOID RadarDetectionStart(
 	}
 	else
 		CtsProtect = 0x01;
-	
+
 
 	// send start-RD with CTS protection command to MCU
 	// highbyte [7]		reserve
@@ -337,13 +337,13 @@ VOID RTMPCleanRadarDuration(
     ========================================================================
     Routine Description:
         Radar wave detection. The API should be invoke each second.
-        
+
     Arguments:
         pAd         - Adapter pointer
-        
+
     Return Value:
         None
-        
+
     ========================================================================
 */
 VOID ApRadarDetectPeriodic(
@@ -401,7 +401,7 @@ VOID RadarDetectPeriodic(
 }
 
 
-/* 
+/*
     ==========================================================================
     Description:
 		change channel moving time for DFS testing.
@@ -414,12 +414,12 @@ VOID RadarDetectPeriodic(
         None
 
     Note:
-        Usage: 
+        Usage:
                1.) iwpriv ra0 set ChMovTime=[value]
     ==========================================================================
 */
 INT Set_ChMovingTime_Proc(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR arg)
 {
 	UINT8 Value;
@@ -435,13 +435,13 @@ INT Set_ChMovingTime_Proc(
 }
 
 INT Set_LongPulseRadarTh_Proc(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR arg)
 {
 	UINT8 Value;
 
 	Value = simple_strtol(arg, 0, 10) > 10 ? 10 : simple_strtol(arg, 0, 10);
-	
+
 	pAd->CommonCfg.RadarDetect.LongPulseRadarTh = Value;
 
 	DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __FUNCTION__,
diff --git a/common/eeprom.c b/common/eeprom.c
index 2693750..bed2d66 100644
--- a/common/eeprom.c
+++ b/common/eeprom.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -34,7 +34,7 @@
 	--------	----------		----------------------------------------------
 	Name		Date			Modification logs
 */
-#include	"rt_config.h"
+#include "../rt_config.h"
 
 // IRQL = PASSIVE_LEVEL
 VOID RaiseClock(
@@ -43,7 +43,7 @@ VOID RaiseClock(
 {
     *x = *x | EESK;
     RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
-    RTMPusecDelay(1);				// Max frequency = 1MHz in Spec. definition 
+    RTMPusecDelay(1);				// Max frequency = 1MHz in Spec. definition
 }
 
 // IRQL = PASSIVE_LEVEL
@@ -66,7 +66,7 @@ USHORT ShiftInBits(
     RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
 
     x &= ~( EEDO | EEDI);
-    
+
     for(i=0; i<16; i++)
     {
         data = data << 1;
@@ -121,12 +121,12 @@ VOID EEpromCleanup(
     UINT32 x;
 
     RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
-	
+
     x &= ~(EECS | EEDI);
     RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
 
     RaiseClock(pAd, &x);
-    LowerClock(pAd, &x);	
+    LowerClock(pAd, &x);
 }
 
 VOID EWEN(
@@ -144,11 +144,11 @@ VOID EWEN(
 	RaiseClock(pAd, &x);
 	LowerClock(pAd, &x);
 
-    // output the read_opcode and six pulse in that order    
+    // output the read_opcode and six pulse in that order
     ShiftOutBits(pAd, EEPROM_EWEN_OPCODE, 5);
     ShiftOutBits(pAd, 0, 6);
 
-    EEpromCleanup(pAd);    
+    EEpromCleanup(pAd);
 }
 
 VOID EWDS(
@@ -166,11 +166,11 @@ VOID EWDS(
 	RaiseClock(pAd, &x);
 	LowerClock(pAd, &x);
 
-    // output the read_opcode and six pulse in that order    
+    // output the read_opcode and six pulse in that order
     ShiftOutBits(pAd, EEPROM_EWDS_OPCODE, 5);
     ShiftOutBits(pAd, 0, 6);
 
-    EEpromCleanup(pAd);    
+    EEpromCleanup(pAd);
 }
 
 // IRQL = PASSIVE_LEVEL
@@ -192,7 +192,7 @@ USHORT RTMP_EEPROM_READ16(
 	RaiseClock(pAd, &x);
 	LowerClock(pAd, &x);
 
-    // output the read_opcode and register number in that order    
+    // output the read_opcode and register number in that order
     ShiftOutBits(pAd, EEPROM_READ_OPCODE, 3);
     ShiftOutBits(pAd, Offset, pAd->EEPROMAddressNum);
 
@@ -210,7 +210,7 @@ VOID RTMP_EEPROM_WRITE16(
     IN  USHORT Data)
 {
     UINT32 x;
-	
+
 	Offset /= 2;
 
 	EWEN(pAd);
@@ -225,7 +225,7 @@ VOID RTMP_EEPROM_WRITE16(
 	RaiseClock(pAd, &x);
 	LowerClock(pAd, &x);
 
-    // output the read_opcode ,register number and data in that order    
+    // output the read_opcode ,register number and data in that order
     ShiftOutBits(pAd, EEPROM_WRITE_OPCODE, 3);
     ShiftOutBits(pAd, Offset, pAd->EEPROMAddressNum);
 	ShiftOutBits(pAd, Data, 16);		// 16-bit access
@@ -236,7 +236,7 @@ VOID RTMP_EEPROM_WRITE16(
 	EEpromCleanup(pAd);
 
 	RTMPusecDelay(10000);	//delay for twp(MAX)=10ms
-		
+
 	EWDS(pAd);
 
     EEpromCleanup(pAd);
diff --git a/include/firmware.h b/common/firmware.h
similarity index 66%
rename from include/firmware.h
rename to common/firmware.h
index f6153c0..e72996f 100644
--- a/include/firmware.h
+++ b/common/firmware.h
@@ -1,558 +1,558 @@
 /*
- Copyright (c) 2007, Ralink Technology Corporation 
- All rights reserved. 
+ Copyright (c) 2007, Ralink Technology Corporation
+ All rights reserved.
 
- Redistribution.  Redistribution and use in binary form, without 
- modification, are permitted provided that the following conditions are 
- met: 
+ Redistribution.  Redistribution and use in binary form, without
+ modification, are permitted provided that the following conditions are
+ met:
 
- 	* Redistributions must reproduce the above copyright notice and the 
- 	following disclaimer in the documentation and/or other materials 
- 	provided with the distribution. 
- 	* Neither the name of Ralink Technology Corporation nor the names of its 
- 	suppliers may be used to endorse or promote products derived from this 
- 	software without specific prior written permission. 
- 	* No reverse engineering, decompilation, or disassembly of this software 
- 	is permitted. 
+ 	* Redistributions must reproduce the above copyright notice and the
+ 	following disclaimer in the documentation and/or other materials
+ 	provided with the distribution.
+ 	* Neither the name of Ralink Technology Corporation nor the names of its
+ 	suppliers may be used to endorse or promote products derived from this
+ 	software without specific prior written permission.
+ 	* No reverse engineering, decompilation, or disassembly of this software
+ 	is permitted.
 
- Limited patent license. Ralink Technology Corporation grants a world-wide, 
- royalty-free, non-exclusive license under patents it now or hereafter 
- owns or controls to make, have made, use, import, offer to sell and 
- sell ("Utilize") this software, but solely to the extent that any 
- such patent is necessary to Utilize the software alone, or in 
- combination with an operating system licensed under an approved Open 
- Source license as listed by the Open Source Initiative at 
- http://opensource.org/licenses.  The patent license shall not apply to 
- any other combinations which include this software.  No hardware per 
- se is licensed hereunder. 
+ Limited patent license. Ralink Technology Corporation grants a world-wide,
+ royalty-free, non-exclusive license under patents it now or hereafter
+ owns or controls to make, have made, use, import, offer to sell and
+ sell ("Utilize") this software, but solely to the extent that any
+ such patent is necessary to Utilize the software alone, or in
+ combination with an operating system licensed under an approved Open
+ Source license as listed by the Open Source Initiative at
+ http://opensource.org/licenses.  The patent license shall not apply to
+ any other combinations which include this software.  No hardware per
+ se is licensed hereunder.
 
- DISCLAIMER.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
- BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
- DAMAGE. 
-*/ 
-/* AUTO GEN PLEASE DO NOT MODIFY IT */ 
-/* AUTO GEN PLEASE DO NOT MODIFY IT */ 
+ DISCLAIMER.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+ BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
+*/
+/* AUTO GEN PLEASE DO NOT MODIFY IT */
+/* AUTO GEN PLEASE DO NOT MODIFY IT */
 
 
-UCHAR FirmwareImage [] = { 
-0x02, 0x03, 0x5e, 0x02, 0x02, 0xb1, 0x22, 0x22, 0xff, 0xff, 0xff, 0x02, 0x01, 0x82, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0x02, 0x00, 0x1e, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x01, 0x33, 0xc0, 0xe0, 
-0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0x75, 0xd0, 0x18, 0xc2, 0xaf, 0x30, 0x45, 0x03, 
-0x12, 0x10, 0x09, 0x90, 0x04, 0x16, 0xe0, 0x30, 0xe3, 0x03, 0x74, 0x08, 0xf0, 0x90, 0x04, 0x14, 
-0xe0, 0x20, 0xe7, 0x03, 0x02, 0x00, 0xcb, 0x74, 0x80, 0xf0, 0x90, 0x70, 0x12, 0xe0, 0xf5, 0x2f, 
-0x90, 0x04, 0x04, 0xe0, 0x24, 0xcf, 0x60, 0x30, 0x14, 0x60, 0x42, 0x24, 0xe2, 0x60, 0x47, 0x14, 
-0x60, 0x55, 0x24, 0x21, 0x70, 0x60, 0xe5, 0x55, 0x24, 0xfe, 0x60, 0x07, 0x14, 0x60, 0x08, 0x24, 
-0x02, 0x70, 0x08, 0x7d, 0x01, 0x80, 0x28, 0x7d, 0x02, 0x80, 0x24, 0x90, 0x70, 0x10, 0xe0, 0xf5, 
-0x50, 0x85, 0x2f, 0x40, 0xd2, 0x01, 0x80, 0x3e, 0xe5, 0x55, 0x64, 0x03, 0x60, 0x04, 0xe5, 0x55, 
-0x70, 0x04, 0x7d, 0x02, 0x80, 0x09, 0x85, 0x2f, 0x41, 0xd2, 0x02, 0x80, 0x29, 0xad, 0x55, 0xaf, 
-0x2f, 0x12, 0x02, 0x8d, 0x80, 0x20, 0x90, 0x70, 0x10, 0xe0, 0xf5, 0x47, 0x90, 0x70, 0x11, 0xe0, 
-0xf5, 0x44, 0x12, 0x10, 0x25, 0x80, 0x06, 0x90, 0x70, 0x10, 0xe0, 0xf5, 0x45, 0xe4, 0xfd, 0xaf, 
-0x2f, 0x12, 0x02, 0x8d, 0xd2, 0x04, 0x90, 0x70, 0x13, 0xe4, 0xf0, 0xd2, 0xaf, 0xd0, 0xd0, 0xd0, 
-0x82, 0xd0, 0x83, 0xd0, 0xf0, 0xd0, 0xe0, 0x32, 0x90, 0x70, 0x2a, 0xe0, 0x30, 0xe1, 0x53, 0xc2, 
-0xaf, 0x90, 0x70, 0x28, 0xe0, 0x90, 0x10, 0x1c, 0xf0, 0x90, 0x70, 0x29, 0xe0, 0x90, 0x10, 0x1d, 
-0xf0, 0x90, 0x70, 0x2a, 0xe0, 0x90, 0x10, 0x1e, 0xf0, 0x90, 0x10, 0x1c, 0xe0, 0xf5, 0x30, 0x90, 
-0x10, 0x1e, 0xe0, 0x20, 0xe1, 0xf3, 0x90, 0x10, 0x1c, 0xe0, 0x90, 0x70, 0x28, 0xf0, 0x90, 0x10, 
-0x1d, 0xe0, 0x90, 0x70, 0x29, 0xf0, 0x90, 0x10, 0x1e, 0xe0, 0x90, 0x70, 0x2a, 0xf0, 0x30, 0x4a, 
-0x0d, 0x90, 0x70, 0x24, 0xe0, 0x44, 0x01, 0xf0, 0x90, 0x02, 0x2c, 0x74, 0xff, 0xf0, 0xc2, 0x05, 
-0xd2, 0xaf, 0x22, 0xc0, 0xe0, 0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0xe8, 0xc0, 0xe0, 
-0xe9, 0xc0, 0xe0, 0xea, 0xc0, 0xe0, 0xeb, 0xc0, 0xe0, 0xec, 0xc0, 0xe0, 0xed, 0xc0, 0xe0, 0xee, 
-0xc0, 0xe0, 0xef, 0xc0, 0xe0, 0xc2, 0xaf, 0x30, 0x45, 0x03, 0x12, 0x10, 0x12, 0xd2, 0xaf, 0xd0, 
-0xe0, 0xff, 0xd0, 0xe0, 0xfe, 0xd0, 0xe0, 0xfd, 0xd0, 0xe0, 0xfc, 0xd0, 0xe0, 0xfb, 0xd0, 0xe0, 
-0xfa, 0xd0, 0xe0, 0xf9, 0xd0, 0xe0, 0xf8, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xf0, 0xd0, 
-0xe0, 0x32, 0xc0, 0xe0, 0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0x75, 0xd0, 0x10, 0xc2, 
-0xaf, 0x30, 0x45, 0x03, 0x12, 0x10, 0x0c, 0x30, 0x58, 0x0a, 0xe5, 0x54, 0x60, 0x04, 0x15, 0x54, 
-0x80, 0x02, 0xc2, 0x58, 0x30, 0x59, 0x0a, 0xe5, 0x50, 0x60, 0x04, 0x15, 0x50, 0x80, 0x02, 0xc2, 
-0x59, 0xd5, 0x53, 0x07, 0x30, 0x60, 0x04, 0x15, 0x46, 0xd2, 0x04, 0x30, 0x45, 0x03, 0x12, 0x10, 
-0x0f, 0xc2, 0x8d, 0xd2, 0xaf, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xf0, 0xd0, 0xe0, 0x32, 
-0x12, 0x02, 0xd3, 0x30, 0x45, 0x03, 0x12, 0x10, 0x03, 0x30, 0x01, 0x06, 0x20, 0x09, 0x03, 0x12, 
-0x10, 0x1c, 0x30, 0x02, 0x06, 0x20, 0x0a, 0x03, 0x12, 0x10, 0x1f, 0x30, 0x03, 0x06, 0x20, 0x0b, 
-0x03, 0x12, 0x10, 0x1f, 0x30, 0x04, 0x06, 0x20, 0x0c, 0x03, 0x12, 0x10, 0x22, 0x20, 0x13, 0x09, 
-0x20, 0x11, 0x06, 0xe5, 0x2b, 0x45, 0x2c, 0x60, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0xa9, 0x12, 
-0x02, 0xec, 0x80, 0xbf, 0xc2, 0x43, 0xd2, 0x45, 0xe4, 0xf5, 0x20, 0xf5, 0x21, 0xf5, 0x53, 0xf5, 
-0x46, 0xf5, 0x2b, 0xf5, 0x2c, 0xc2, 0x42, 0xf5, 0x51, 0xf5, 0x52, 0xf5, 0x55, 0x90, 0x04, 0x18, 
-0x74, 0x80, 0xf0, 0x90, 0x04, 0x1a, 0x74, 0x08, 0xf0, 0xc2, 0x19, 0xc2, 0x18, 0xc2, 0x1a, 0x22, 
-0xc8, 0xef, 0xc8, 0xe6, 0xfa, 0x08, 0xe6, 0x4a, 0x60, 0x0c, 0xc8, 0xef, 0xc8, 0x08, 0xe6, 0x16, 
-0x18, 0x70, 0x01, 0x16, 0xc3, 0x22, 0xed, 0x24, 0xff, 0xfd, 0xec, 0x34, 0xff, 0xc8, 0xef, 0xc8, 
-0xf6, 0x08, 0xc6, 0xed, 0xc6, 0xd3, 0x22, 0xd0, 0x83, 0xd0, 0x82, 0xf8, 0xe4, 0x93, 0x70, 0x12, 
-0x74, 0x01, 0x93, 0x70, 0x0d, 0xa3, 0xa3, 0x93, 0xf8, 0x74, 0x01, 0x93, 0xf5, 0x82, 0x88, 0x83, 
-0xe4, 0x73, 0x74, 0x02, 0x93, 0x68, 0x60, 0xef, 0xa3, 0xa3, 0xa3, 0x80, 0xdf, 0xef, 0xf4, 0x60, 
-0x1f, 0xe4, 0xfe, 0x12, 0x03, 0x6a, 0xe0, 0xb4, 0xff, 0x12, 0x12, 0x03, 0x6a, 0xef, 0xf0, 0x74, 
-0x1c, 0x2e, 0xf5, 0x82, 0xe4, 0x34, 0x70, 0xf5, 0x83, 0xed, 0xf0, 0x22, 0x0e, 0xbe, 0x04, 0xe3, 
-0x22, 0xc0, 0xe0, 0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0x75, 0xd0, 0x08, 0xc2, 0xaf, 
-0x30, 0x45, 0x03, 0x12, 0x10, 0x06, 0xd2, 0xaf, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xf0, 
-0xd0, 0xe0, 0x32, 0xc2, 0xaf, 0x12, 0x00, 0x06, 0x12, 0x02, 0x14, 0x12, 0x03, 0x1c, 0xe4, 0xf5, 
-0x22, 0xf5, 0x47, 0x90, 0x04, 0x00, 0x74, 0x80, 0xf0, 0xd2, 0xaf, 0x22, 0x30, 0x45, 0x03, 0x12, 
-0x10, 0x15, 0xe5, 0x20, 0x70, 0x03, 0x20, 0x10, 0x03, 0x30, 0x11, 0x03, 0x43, 0x87, 0x01, 0x22, 
-0xc0, 0x2a, 0x74, 0x03, 0xc0, 0xe0, 0xc0, 0x82, 0xc0, 0x83, 0x75, 0x2a, 0x0a, 0x22, 0xc0, 0x2a, 
-0x74, 0x03, 0xc0, 0xe0, 0xc0, 0x82, 0xc0, 0x83, 0x75, 0x2a, 0x18, 0x22, 0x75, 0x89, 0x02, 0xe4, 
-0xf5, 0x8c, 0xf5, 0x8a, 0xf5, 0x88, 0xf5, 0xb8, 0xf5, 0xe8, 0x75, 0x90, 0x18, 0xd2, 0x8c, 0x75, 
-0xa8, 0x05, 0x22, 0xce, 0xef, 0xce, 0xee, 0x60, 0x08, 0x7f, 0xff, 0x12, 0x03, 0x80, 0x1e, 0x80, 
-0xf5, 0x22, 0xc8, 0xef, 0xc8, 0xe6, 0x60, 0x03, 0x16, 0xc3, 0x22, 0xed, 0x14, 0xf6, 0xd3, 0x22, 
-0xc8, 0xef, 0xc8, 0xe6, 0x60, 0x06, 0x16, 0xe6, 0x24, 0xff, 0xb3, 0x22, 0xc3, 0x22, 0x78, 0x7f, 
-0xe4, 0xf6, 0xd8, 0xfd, 0x75, 0x81, 0x5f, 0x02, 0x01, 0xd0, 0x74, 0x14, 0x2e, 0xf5, 0x82, 0xe4, 
-0x34, 0x70, 0xf5, 0x83, 0x22, 0xef, 0x90, 0x03, 0x7e, 0x93, 0x90, 0x03, 0x00, 0x73, 0x0a, 0x18, 
-0xef, 0x60, 0x03, 0x1f, 0x80, 0xfa, 0x22, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
-0xff, 0xff, 0xff, 0x02, 0x10, 0x28, 0x02, 0x10, 0x3b, 0x02, 0x10, 0x3c, 0x02, 0x12, 0xb8, 0x02, 
-0x12, 0xb9, 0x02, 0x13, 0x3e, 0x02, 0x13, 0x3f, 0xc3, 0x22, 0xff, 0xff, 0x02, 0x16, 0x56, 0x02, 
-0x17, 0x6b, 0x02, 0x14, 0x2a, 0x02, 0x13, 0x40, 0x30, 0x05, 0x06, 0x20, 0x0d, 0x03, 0x12, 0x00, 
-0xd8, 0x30, 0x06, 0x06, 0x20, 0x0e, 0x03, 0x12, 0x18, 0x5e, 0x22, 0x22, 0x90, 0x04, 0x14, 0xe0, 
-0x20, 0xe7, 0x03, 0x02, 0x12, 0xb7, 0x90, 0x70, 0x12, 0xe0, 0xf5, 0x56, 0x90, 0x04, 0x04, 0xe0, 
-0x12, 0x02, 0x67, 0x11, 0x4e, 0x30, 0x11, 0x25, 0x31, 0x10, 0x87, 0x33, 0x10, 0xaa, 0x34, 0x10, 
-0xc3, 0x35, 0x11, 0x57, 0x50, 0x11, 0x7b, 0x51, 0x11, 0x84, 0x52, 0x11, 0x84, 0x53, 0x11, 0x84, 
-0x54, 0x11, 0xc5, 0x55, 0x11, 0xdc, 0x70, 0x12, 0x07, 0x71, 0x12, 0x34, 0x72, 0x12, 0x5e, 0x80, 
-0x12, 0x81, 0x83, 0x00, 0x00, 0x12, 0xb7, 0x75, 0x24, 0x05, 0x75, 0x25, 0xdc, 0x90, 0x70, 0x9f, 
-0x74, 0x12, 0xf0, 0xd2, 0x18, 0xd2, 0x61, 0x75, 0x35, 0x0d, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 
-0x56, 0xf4, 0x70, 0x03, 0x02, 0x12, 0xb7, 0x02, 0x12, 0xaa, 0xc2, 0x18, 0x90, 0x01, 0x14, 0xe0, 
-0x54, 0xfd, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x70, 0x03, 0x02, 0x12, 0xb7, 
-0x02, 0x12, 0xaa, 0xe5, 0x55, 0x64, 0x02, 0x70, 0x37, 0x90, 0x70, 0x10, 0xe0, 0x60, 0x08, 0x90, 
-0x01, 0x0d, 0x74, 0x09, 0xf0, 0x80, 0x25, 0xe5, 0x34, 0x14, 0x60, 0x0a, 0x14, 0x60, 0x0f, 0x14, 
-0x60, 0x14, 0x24, 0x03, 0x70, 0x16, 0x90, 0x01, 0x0d, 0x74, 0x08, 0xf0, 0x80, 0x0e, 0x90, 0x01, 
-0x0d, 0x74, 0x0b, 0xf0, 0x80, 0x06, 0x90, 0x01, 0x0d, 0x74, 0x1b, 0xf0, 0x7d, 0x01, 0x80, 0x02, 
-0x7d, 0x02, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0x90, 0x70, 0x11, 0xe0, 0x24, 0xff, 0x92, 0x1b, 0x90, 
-0x04, 0x14, 0x74, 0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x70, 0x03, 0x02, 
-0x12, 0xb7, 0x02, 0x12, 0xaa, 0x20, 0x02, 0x03, 0x30, 0x03, 0x1d, 0x7d, 0x02, 0xaf, 0x56, 0x12, 
-0x02, 0x8d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 
-0x70, 0x03, 0x02, 0x12, 0xb7, 0x02, 0x12, 0xaa, 0x85, 0x56, 0x41, 0xd2, 0x02, 0x22, 0x90, 0x70, 
-0x11, 0xe0, 0x24, 0xff, 0x92, 0x1b, 0x22, 0x90, 0x70, 0x10, 0xe0, 0x54, 0x7f, 0x64, 0x02, 0x60, 
-0x03, 0x02, 0x12, 0xb7, 0x90, 0x70, 0x11, 0xe0, 0x64, 0x08, 0x60, 0x08, 0xe0, 0x64, 0x20, 0x60, 
-0x03, 0x02, 0x12, 0xb7, 0x75, 0x4e, 0x03, 0x75, 0x4f, 0x20, 0x22, 0x90, 0x70, 0x11, 0xe0, 0x24, 
-0xff, 0x92, 0x47, 0x22, 0x90, 0x04, 0x04, 0xe0, 0x25, 0xe0, 0x24, 0x5d, 0xf5, 0x57, 0x90, 0x70, 
-0x10, 0xe0, 0xff, 0x74, 0x47, 0x25, 0x57, 0xf8, 0xc6, 0xef, 0xc6, 0x90, 0x70, 0x11, 0xe0, 0xff, 
-0x74, 0x48, 0x25, 0x57, 0xf8, 0xc6, 0xef, 0xc6, 0xe4, 0xfd, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0x90, 
-0x04, 0x14, 0x74, 0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x70, 0x03, 0x02, 
-0x12, 0xb7, 0x02, 0x12, 0xaa, 0xe5, 0x47, 0xb4, 0x07, 0x08, 0x90, 0x70, 0x11, 0xe0, 0x54, 0x07, 
-0xf5, 0x26, 0xe4, 0xfd, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0xd2, 0x04, 0x22, 0x90, 0x70, 0x10, 0xe0, 
-0xfe, 0x90, 0x70, 0x11, 0xe0, 0xfd, 0xed, 0xf8, 0xe6, 0xf5, 0x57, 0xfd, 0xaf, 0x56, 0x12, 0x02, 
-0x8d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x70, 
-0x03, 0x02, 0x12, 0xb7, 0x02, 0x12, 0xaa, 0x90, 0x70, 0x10, 0xe0, 0xfe, 0x90, 0x70, 0x11, 0xe0, 
-0xfd, 0xed, 0xf5, 0x82, 0x8e, 0x83, 0xe0, 0xf5, 0x57, 0xfd, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0x90, 
-0x04, 0x14, 0x74, 0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x70, 0x03, 0x02, 
-0x12, 0xb7, 0x80, 0x76, 0xe4, 0xf5, 0x4e, 0xf5, 0x4f, 0x75, 0x26, 0xff, 0xc2, 0x19, 0xc2, 0x18, 
-0xc2, 0x1a, 0x75, 0x34, 0xff, 0xad, 0x57, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0x90, 0x04, 0x14, 0x74, 
-0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x60, 0x5b, 0x80, 0x4c, 0x90, 0x70, 
-0x10, 0xe0, 0x24, 0xff, 0x92, 0x4a, 0xd2, 0x05, 0xad, 0x57, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0x90, 
-0x04, 0x14, 0x74, 0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x60, 0x38, 0x80, 
-0x29, 0x90, 0x70, 0x10, 0xe0, 0xf5, 0x34, 0xd3, 0x94, 0x00, 0x40, 0x07, 0x90, 0x01, 0x0d, 0xe0, 
-0x54, 0xfb, 0xf0, 0xad, 0x57, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0, 
-0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x60, 0x0d, 0x90, 0x70, 0x25, 0xe0, 0x44, 0x01, 
-0xf0, 0x90, 0x02, 0x2c, 0x74, 0xff, 0xf0, 0x22, 0x22, 0xe5, 0x53, 0x60, 0x03, 0x02, 0x13, 0x3d, 
-0xe5, 0x4f, 0x45, 0x4e, 0x60, 0x08, 0xe5, 0x4f, 0x15, 0x4f, 0x70, 0x02, 0x15, 0x4e, 0xa2, 0x19, 
-0xe4, 0x33, 0x90, 0x70, 0x90, 0xf0, 0xa2, 0x18, 0xe4, 0x33, 0xa3, 0xf0, 0x30, 0x19, 0x4d, 0x90, 
-0x70, 0x98, 0x74, 0x23, 0xf0, 0xa3, 0xe5, 0x25, 0xf0, 0xe5, 0x24, 0xa3, 0xf0, 0x7f, 0x35, 0x7d, 
-0x32, 0x12, 0x03, 0x42, 0x50, 0x09, 0x90, 0x10, 0x04, 0xe0, 0x54, 0xf7, 0xf0, 0xd2, 0x06, 0xe5, 
-0x35, 0xd3, 0x94, 0x10, 0x40, 0x1e, 0x30, 0x1a, 0x1b, 0xc2, 0x1a, 0xa2, 0x18, 0x92, 0x19, 0x20, 
-0x19, 0x12, 0x90, 0x04, 0x09, 0xe0, 0x54, 0xdd, 0xf0, 0x90, 0x10, 0x04, 0xe0, 0x44, 0x08, 0xf0, 
-0xc2, 0x61, 0xd2, 0x03, 0xe5, 0x35, 0xb4, 0x0b, 0x14, 0xd2, 0x03, 0x22, 0xe4, 0xf5, 0x35, 0xa2, 
-0x18, 0x92, 0x19, 0x30, 0x19, 0x07, 0x90, 0x04, 0x09, 0xe0, 0x44, 0x22, 0xf0, 0x22, 0x22, 0x22, 
-0xc2, 0x4b, 0xc2, 0x4c, 0xe5, 0x44, 0x12, 0x02, 0x67, 0x13, 0x62, 0x00, 0x13, 0xf5, 0x04, 0x13, 
-0xf1, 0x08, 0x13, 0xcc, 0x10, 0x13, 0x76, 0x20, 0x13, 0x96, 0x60, 0x13, 0xa7, 0xa0, 0x00, 0x00, 
-0x13, 0xf7, 0x85, 0x48, 0x43, 0x85, 0x4a, 0x42, 0x85, 0x4c, 0x5e, 0xe5, 0x47, 0x64, 0x06, 0x60, 
-0x03, 0x02, 0x13, 0xf7, 0x80, 0x1b, 0xe5, 0x48, 0xc4, 0x54, 0x0f, 0xf5, 0x43, 0xe5, 0x4a, 0xc4, 
-0x54, 0x0f, 0xf5, 0x42, 0xe5, 0x4c, 0xc4, 0x54, 0x0f, 0xf5, 0x5e, 0xe5, 0x47, 0x64, 0x06, 0x70, 
-0x66, 0x53, 0x43, 0x0f, 0x80, 0x61, 0x85, 0x49, 0x43, 0x85, 0x4b, 0x42, 0x85, 0x4d, 0x5e, 0xe5, 
-0x47, 0x64, 0x06, 0x70, 0x52, 0x80, 0x1b, 0xe5, 0x49, 0xc4, 0x54, 0x0f, 0xf5, 0x43, 0xe5, 0x4b, 
-0xc4, 0x54, 0x0f, 0xf5, 0x42, 0xe5, 0x4d, 0xc4, 0x54, 0x0f, 0xf5, 0x5e, 0xe5, 0x47, 0x64, 0x06, 
-0x70, 0x35, 0xe5, 0x43, 0x54, 0x0f, 0x44, 0x10, 0xf5, 0x43, 0x80, 0x2b, 0xe5, 0x47, 0xb4, 0x04, 
-0x06, 0x53, 0x5e, 0xfb, 0x75, 0x42, 0x09, 0xe5, 0x47, 0xb4, 0x05, 0x06, 0x43, 0x5e, 0x04, 0x75, 
-0x42, 0x09, 0xe5, 0x47, 0xb4, 0x06, 0x10, 0xe5, 0x43, 0x54, 0x0f, 0x44, 0x30, 0xf5, 0x43, 0x80, 
-0x06, 0xd2, 0x4b, 0x80, 0x02, 0xd2, 0x4c, 0xe4, 0xf5, 0x38, 0xe5, 0x42, 0xc4, 0x54, 0xf0, 0xff, 
-0xe5, 0x43, 0x54, 0x0f, 0x4f, 0xf5, 0x5f, 0x90, 0x70, 0x44, 0xf0, 0xa3, 0xe5, 0x5e, 0xf0, 0xa3, 
-0xe5, 0x4a, 0xf0, 0xa3, 0xe5, 0x48, 0xf0, 0xa3, 0xe5, 0x4c, 0xf0, 0xa3, 0xe5, 0x44, 0xf0, 0xa3, 
-0xe5, 0x42, 0xf0, 0xa3, 0xe5, 0x43, 0xf0, 0xd2, 0x60, 0x22, 0xe5, 0x47, 0x60, 0x10, 0x24, 0xc0, 
-0x70, 0x03, 0x12, 0x16, 0x36, 0x12, 0x14, 0x3f, 0xc2, 0xaf, 0xc2, 0x04, 0xd2, 0xaf, 0x22, 0xc2, 
-0xaf, 0x90, 0x04, 0x14, 0xe0, 0x54, 0x0e, 0x60, 0x04, 0xd2, 0x1c, 0x80, 0x08, 0xe5, 0x4e, 0x45, 
-0x4f, 0x24, 0xff, 0x92, 0x1c, 0xd2, 0xaf, 0x90, 0x04, 0x14, 0xe0, 0xa2, 0xe4, 0x92, 0x1d, 0x74, 
-0x1e, 0xf0, 0xe5, 0x5f, 0x54, 0x0f, 0xf5, 0x2d, 0xe5, 0x38, 0x70, 0x13, 0x30, 0x1c, 0x05, 0xe5, 
-0x5f, 0x20, 0xe5, 0x0b, 0x30, 0x1d, 0x19, 0xe5, 0x5f, 0x54, 0x30, 0xff, 0xbf, 0x30, 0x11, 0xe5, 
-0x38, 0x70, 0x05, 0x75, 0x38, 0x0c, 0x80, 0x02, 0x15, 0x38, 0xd2, 0x6c, 0xd2, 0x6d, 0x80, 0x0f, 
-0xe5, 0x5f, 0x30, 0xe6, 0x06, 0xc2, 0x6c, 0xd2, 0x6d, 0x80, 0x04, 0xd2, 0x6c, 0xc2, 0x6d, 0xe5, 
-0x47, 0x64, 0x03, 0x70, 0x21, 0x30, 0x4b, 0x06, 0xc2, 0x6c, 0xd2, 0x6d, 0x80, 0x18, 0xe5, 0x38, 
-0x70, 0x03, 0x30, 0x4c, 0x11, 0xc2, 0x4c, 0xe5, 0x38, 0x70, 0x05, 0x75, 0x38, 0x07, 0x80, 0x02, 
-0x15, 0x38, 0xd2, 0x6c, 0xd2, 0x6d, 0x90, 0x70, 0x46, 0xe5, 0x2d, 0xf0, 0x20, 0x69, 0x07, 0xe5, 
-0x5e, 0x20, 0xe0, 0x02, 0xb2, 0x68, 0x20, 0x6b, 0x07, 0xe5, 0x5e, 0x20, 0xe1, 0x02, 0xb2, 0x6a, 
-0x20, 0x6d, 0x07, 0xe5, 0x5e, 0x20, 0xe2, 0x02, 0xb2, 0x6c, 0x90, 0x70, 0x47, 0xe5, 0x2d, 0xf0, 
-0x75, 0x2e, 0x40, 0x20, 0x69, 0x04, 0xa2, 0x68, 0x80, 0x15, 0x30, 0x68, 0x06, 0xe5, 0x46, 0xa2, 
-0xe3, 0x80, 0x0c, 0xe5, 0x46, 0x54, 0xf0, 0xff, 0xbf, 0xf0, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 
-0x73, 0x92, 0x72, 0x20, 0x6b, 0x04, 0xa2, 0x6a, 0x80, 0x15, 0x30, 0x6a, 0x06, 0xe5, 0x46, 0xa2, 
-0xe3, 0x80, 0x0c, 0xe5, 0x46, 0x54, 0xf0, 0xff, 0xbf, 0xf0, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 
-0x75, 0x92, 0x74, 0x20, 0x6d, 0x04, 0xa2, 0x6c, 0x80, 0x15, 0x30, 0x6c, 0x06, 0xe5, 0x46, 0xa2, 
-0xe3, 0x80, 0x0c, 0xe5, 0x46, 0x54, 0xf0, 0xff, 0xbf, 0xf0, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 
-0x71, 0x92, 0x70, 0x90, 0x10, 0x2f, 0xe5, 0x2e, 0xf0, 0xe5, 0x47, 0x64, 0x06, 0x70, 0x46, 0x90, 
-0x02, 0x29, 0xe0, 0x54, 0xfe, 0xf0, 0xe5, 0x43, 0xc4, 0x54, 0x0f, 0x14, 0x60, 0x14, 0x24, 0xfe, 
-0x60, 0x1f, 0x24, 0x03, 0x60, 0x03, 0x02, 0x16, 0x35, 0x90, 0x02, 0x28, 0xe0, 0x30, 0x47, 0x0d, 
-0x80, 0x07, 0x90, 0x02, 0x28, 0xe0, 0x20, 0x47, 0x04, 0x54, 0xfe, 0xf0, 0x22, 0x44, 0x01, 0xf0, 
-0x22, 0xe5, 0x46, 0x30, 0xe3, 0x04, 0x7f, 0x01, 0x80, 0x02, 0x7f, 0x00, 0x90, 0x02, 0x28, 0xe0, 
-0x54, 0xfe, 0x4f, 0xf0, 0x22, 0xe5, 0x47, 0x64, 0x07, 0x60, 0x03, 0x02, 0x16, 0x35, 0xf5, 0x27, 
-0x90, 0x02, 0x29, 0xe0, 0x54, 0xfc, 0xf0, 0xe5, 0x26, 0x14, 0x60, 0x26, 0x14, 0x60, 0x2e, 0x14, 
-0x60, 0x36, 0x24, 0x03, 0x70, 0x5f, 0xe5, 0x46, 0x13, 0x13, 0x13, 0x54, 0x1f, 0x75, 0xf0, 0x03, 
-0x84, 0xaf, 0xf0, 0x20, 0x47, 0x04, 0x7e, 0x01, 0x80, 0x02, 0x7e, 0x00, 0xef, 0x6e, 0x24, 0xff, 
-0x80, 0x02, 0xa2, 0x47, 0x92, 0x39, 0xa2, 0x47, 0xb3, 0x92, 0x38, 0x80, 0x3f, 0xe5, 0x46, 0x30, 
-0xe3, 0x03, 0xd3, 0x80, 0x27, 0xc3, 0x80, 0x24, 0xe5, 0x46, 0x30, 0xe3, 0x0d, 0x54, 0x70, 0xc3, 
-0x94, 0x60, 0x50, 0x06, 0x7e, 0x00, 0x7f, 0x01, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0x20, 0x47, 
-0x04, 0x7d, 0x01, 0x80, 0x02, 0x7d, 0x00, 0xef, 0x6d, 0x4e, 0x24, 0xff, 0x92, 0x38, 0xa2, 0x47, 
-0xb3, 0x92, 0x39, 0x80, 0x07, 0xa2, 0x47, 0xb3, 0x92, 0x38, 0x92, 0x39, 0x90, 0x02, 0x28, 0xe0, 
-0x54, 0xfc, 0x45, 0x27, 0xf0, 0x22, 0xe4, 0x90, 0x02, 0x29, 0xf0, 0x30, 0x47, 0x04, 0xaf, 0x45, 
-0x80, 0x04, 0xe5, 0x45, 0xf4, 0xff, 0x90, 0x02, 0x28, 0xef, 0xf0, 0x22, 0x8f, 0x50, 0xd2, 0x59, 
-0x22, 0x8f, 0x54, 0xd2, 0x58, 0x22, 0xe4, 0xf5, 0x30, 0xc2, 0xaf, 0xe5, 0x51, 0x14, 0x60, 0x4a, 
-0x14, 0x60, 0x6a, 0x24, 0x02, 0x60, 0x03, 0x02, 0x17, 0x4c, 0xd2, 0x59, 0x75, 0x55, 0x01, 0x20, 
-0x19, 0x1c, 0x90, 0x02, 0x08, 0xe0, 0x54, 0xfe, 0xf0, 0xe0, 0x20, 0xe1, 0x23, 0x90, 0x04, 0x34, 
-0xe0, 0xb4, 0x02, 0x1c, 0xa3, 0xe0, 0xb4, 0x02, 0x17, 0xa3, 0xe0, 0xb4, 0x02, 0x12, 0x7f, 0x20, 
-0x12, 0x16, 0x4c, 0x90, 0x10, 0x04, 0xe0, 0x54, 0xf3, 0xf0, 0x75, 0x51, 0x01, 0x02, 0x17, 0x4c, 
-0xe5, 0x50, 0x70, 0x06, 0x75, 0x30, 0x03, 0x02, 0x17, 0x4c, 0x90, 0x12, 0x00, 0xe0, 0x54, 0x03, 
-0x70, 0x15, 0x7f, 0x20, 0x12, 0x16, 0x4c, 0x20, 0x19, 0x07, 0x90, 0x02, 0x08, 0xe0, 0x54, 0xfb, 
-0xf0, 0x75, 0x51, 0x02, 0x02, 0x17, 0x4c, 0xe5, 0x50, 0x70, 0x02, 0x80, 0x7a, 0x20, 0x19, 0x0f, 
-0x90, 0x02, 0x08, 0xe0, 0x20, 0xe3, 0x6c, 0x90, 0x04, 0x37, 0xe0, 0x64, 0x22, 0x70, 0x64, 0x90, 
-0x12, 0x04, 0x74, 0x0a, 0xf0, 0x30, 0x1b, 0x11, 0x90, 0x13, 0x28, 0xe0, 0x54, 0xf0, 0xf0, 0xa3, 
-0xe0, 0x54, 0xf0, 0xf0, 0xa3, 0xe0, 0x54, 0xfa, 0xf0, 0x20, 0x19, 0x07, 0x90, 0x04, 0x01, 0xe0, 
-0x44, 0x10, 0xf0, 0xe5, 0x34, 0xf4, 0x90, 0x04, 0x01, 0x60, 0x06, 0xe0, 0x54, 0xfb, 0xf0, 0x80, 
-0x04, 0xe0, 0x54, 0xf9, 0xf0, 0x20, 0x19, 0x07, 0x90, 0x12, 0x04, 0xe0, 0x44, 0x04, 0xf0, 0xe5, 
-0x34, 0xf4, 0x60, 0x14, 0x90, 0x01, 0x0d, 0xe0, 0xf5, 0x33, 0xe5, 0x34, 0xd3, 0x94, 0x02, 0x40, 
-0x07, 0x90, 0x12, 0x04, 0xe0, 0x54, 0xfd, 0xf0, 0x75, 0x30, 0x01, 0x75, 0x55, 0x02, 0xe4, 0xf5, 
-0x51, 0x80, 0x09, 0xe5, 0x50, 0x70, 0x05, 0x75, 0x30, 0x03, 0xf5, 0x51, 0xe5, 0x30, 0x60, 0x18, 
-0xc2, 0x01, 0xe4, 0xf5, 0x51, 0xc2, 0x59, 0x20, 0x19, 0x0e, 0xad, 0x30, 0xaf, 0x40, 0x12, 0x18, 
-0x2a, 0xe5, 0x30, 0xb4, 0x03, 0x02, 0xd2, 0x03, 0xd2, 0xaf, 0x22, 0xc2, 0xaf, 0x30, 0x01, 0x0e, 
-0xe4, 0xf5, 0x51, 0xc2, 0x59, 0xc2, 0x01, 0x7d, 0x02, 0xaf, 0x40, 0x12, 0x18, 0x2a, 0xe5, 0x52, 
-0x14, 0x60, 0x55, 0x14, 0x60, 0x2f, 0x24, 0x02, 0x60, 0x03, 0x02, 0x18, 0x27, 0xe5, 0x34, 0xf4, 
-0x60, 0x23, 0xe5, 0x34, 0xd3, 0x94, 0x02, 0x40, 0x16, 0x90, 0x12, 0x04, 0xe0, 0x44, 0x02, 0xf0, 
-0x90, 0x01, 0x0d, 0xe0, 0x20, 0xe3, 0x03, 0x02, 0x18, 0x27, 0x7f, 0x50, 0x12, 0x16, 0x51, 0x75, 
-0x52, 0x02, 0x75, 0x55, 0x03, 0xe5, 0x34, 0xf4, 0x60, 0x0a, 0xe5, 0x54, 0x70, 0x69, 0x90, 0x01, 
-0x0d, 0xe5, 0x33, 0xf0, 0x90, 0x12, 0x04, 0xe0, 0x54, 0xfb, 0xf0, 0x7f, 0x20, 0x12, 0x16, 0x51, 
-0x75, 0x52, 0x01, 0x75, 0x55, 0x03, 0x80, 0x4f, 0xe5, 0x54, 0x70, 0x4b, 0x90, 0x04, 0x01, 0xe0, 
-0x44, 0x0e, 0xf0, 0x20, 0x19, 0x04, 0xe0, 0x54, 0xef, 0xf0, 0x90, 0x13, 0x28, 0xe0, 0x44, 0x0f, 
-0xf0, 0xa3, 0xe0, 0x44, 0x0f, 0xf0, 0xa3, 0xe0, 0x44, 0x05, 0xf0, 0x90, 0x12, 0x04, 0x74, 0x03, 
-0xf0, 0x20, 0x19, 0x07, 0x90, 0x02, 0x08, 0xe0, 0x44, 0x05, 0xf0, 0x90, 0x10, 0x04, 0xe0, 0x44, 
-0x0c, 0xf0, 0xe4, 0xf5, 0x52, 0xf5, 0x55, 0x30, 0x02, 0x0b, 0xc2, 0x02, 0x7d, 0x01, 0xaf, 0x41, 
-0x12, 0x18, 0x2a, 0x80, 0x02, 0xc2, 0x03, 0xd2, 0xaf, 0x22, 0xef, 0xf4, 0x60, 0x2d, 0xe4, 0xfe, 
-0x74, 0x14, 0x2e, 0xf5, 0x82, 0xe4, 0x34, 0x70, 0xf5, 0x83, 0xe0, 0xb4, 0xff, 0x19, 0x74, 0x14, 
-0x2e, 0xf5, 0x82, 0xe4, 0x34, 0x70, 0xf5, 0x83, 0xef, 0xf0, 0x74, 0x1c, 0x2e, 0xf5, 0x82, 0xe4, 
-0x34, 0x70, 0xf5, 0x83, 0xed, 0xf0, 0x22, 0x0e, 0xbe, 0x04, 0xd5, 0x22, 0x22, 0x22, 0x20, 0x19, 
-0x03, 0x02, 0x19, 0x0f, 0x90, 0x70, 0x80, 0xe0, 0x04, 0xf0, 0x90, 0x04, 0x37, 0xe0, 0x30, 0xe5, 
-0x03, 0x02, 0x19, 0x0b, 0x90, 0x04, 0x28, 0xe0, 0xf5, 0x31, 0xa3, 0xe0, 0xf5, 0x30, 0xf5, 0x32, 
-0xe4, 0xf5, 0x37, 0x90, 0x70, 0x81, 0xe0, 0x04, 0xf0, 0x90, 0x70, 0x82, 0xe0, 0x04, 0xf0, 0xe5, 
-0x32, 0x75, 0xf0, 0x80, 0xa4, 0x24, 0x00, 0xff, 0xe5, 0xf0, 0x34, 0x80, 0xfe, 0xe5, 0x30, 0x65, 
-0x32, 0x70, 0x05, 0xfc, 0x7d, 0x18, 0x80, 0x04, 0x7c, 0x00, 0x7d, 0x00, 0xef, 0x2d, 0xff, 0xee, 
-0x3c, 0xfe, 0x12, 0x19, 0x10, 0x50, 0x25, 0x90, 0x70, 0x83, 0xe0, 0x04, 0xf0, 0x90, 0x01, 0x14, 
-0xe0, 0x44, 0x02, 0xf0, 0xe0, 0x30, 0xe1, 0x06, 0x90, 0x70, 0x92, 0x74, 0x45, 0xf0, 0x90, 0x70, 
-0x93, 0xe0, 0x04, 0xf0, 0x90, 0x04, 0x01, 0xe0, 0x90, 0x70, 0x94, 0xf0, 0xe5, 0x32, 0x65, 0x31, 
-0x60, 0x10, 0xe4, 0x25, 0x32, 0xff, 0xe4, 0x34, 0x80, 0x8f, 0x82, 0xf5, 0x83, 0xe0, 0xf5, 0x32, 
-0x80, 0x97, 0x90, 0x04, 0x10, 0x74, 0x01, 0xf0, 0x90, 0x04, 0x28, 0xe5, 0x31, 0xf0, 0xa3, 0xe5, 
-0x30, 0xf0, 0x90, 0x04, 0x11, 0x74, 0x01, 0xf0, 0x02, 0x18, 0x6a, 0xc2, 0x06, 0xd2, 0x1a, 0x22, 
-0x90, 0x70, 0x84, 0xe5, 0x37, 0xf0, 0xc3, 0x94, 0x06, 0x50, 0x19, 0x8f, 0x82, 0x8e, 0x83, 0xe0, 
-0xb4, 0xff, 0x07, 0x05, 0x37, 0xe4, 0xf5, 0x36, 0x80, 0x59, 0xe4, 0xf5, 0x37, 0x8f, 0x82, 0x8e, 
-0x83, 0xf0, 0x80, 0x4f, 0xe5, 0x36, 0x75, 0xf0, 0x06, 0x84, 0x74, 0x08, 0x25, 0xf0, 0xf5, 0x82, 
-0xe4, 0x34, 0x10, 0xf5, 0x83, 0xe0, 0xfd, 0x8f, 0x82, 0x8e, 0x83, 0xe0, 0xfc, 0x6d, 0x70, 0x30, 
-0x90, 0x70, 0x88, 0xe0, 0x04, 0xf0, 0xa3, 0xe0, 0xfd, 0xd3, 0x95, 0x37, 0x40, 0x02, 0x80, 0x02, 
-0xad, 0x37, 0x90, 0x70, 0x89, 0xed, 0xf0, 0x05, 0x37, 0x05, 0x36, 0xe5, 0x36, 0x75, 0xf0, 0x06, 
-0x84, 0x74, 0x8a, 0x25, 0xf0, 0xf5, 0x82, 0xe4, 0x34, 0x70, 0xf5, 0x83, 0xec, 0xf0, 0x80, 0x03, 
-0xe4, 0xf5, 0x37, 0x0f, 0xbf, 0x00, 0x01, 0x0e, 0xef, 0x54, 0x7f, 0x60, 0x0a, 0xe5, 0x37, 0xc3, 
-0x94, 0x4e, 0x50, 0x03, 0x02, 0x19, 0x10, 0xe5, 0x37, 0xb4, 0x4e, 0x03, 0xd3, 0x80, 0x01, 0xc3, 
-0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+UCHAR FirmwareImage [] = {
+0x02, 0x03, 0x5e, 0x02, 0x02, 0xb1, 0x22, 0x22, 0xff, 0xff, 0xff, 0x02, 0x01, 0x82, 0xff, 0xff,
+0xff, 0xff, 0xff, 0x02, 0x00, 0x1e, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x01, 0x33, 0xc0, 0xe0,
+0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0x75, 0xd0, 0x18, 0xc2, 0xaf, 0x30, 0x45, 0x03,
+0x12, 0x10, 0x09, 0x90, 0x04, 0x16, 0xe0, 0x30, 0xe3, 0x03, 0x74, 0x08, 0xf0, 0x90, 0x04, 0x14,
+0xe0, 0x20, 0xe7, 0x03, 0x02, 0x00, 0xcb, 0x74, 0x80, 0xf0, 0x90, 0x70, 0x12, 0xe0, 0xf5, 0x2f,
+0x90, 0x04, 0x04, 0xe0, 0x24, 0xcf, 0x60, 0x30, 0x14, 0x60, 0x42, 0x24, 0xe2, 0x60, 0x47, 0x14,
+0x60, 0x55, 0x24, 0x21, 0x70, 0x60, 0xe5, 0x55, 0x24, 0xfe, 0x60, 0x07, 0x14, 0x60, 0x08, 0x24,
+0x02, 0x70, 0x08, 0x7d, 0x01, 0x80, 0x28, 0x7d, 0x02, 0x80, 0x24, 0x90, 0x70, 0x10, 0xe0, 0xf5,
+0x50, 0x85, 0x2f, 0x40, 0xd2, 0x01, 0x80, 0x3e, 0xe5, 0x55, 0x64, 0x03, 0x60, 0x04, 0xe5, 0x55,
+0x70, 0x04, 0x7d, 0x02, 0x80, 0x09, 0x85, 0x2f, 0x41, 0xd2, 0x02, 0x80, 0x29, 0xad, 0x55, 0xaf,
+0x2f, 0x12, 0x02, 0x8d, 0x80, 0x20, 0x90, 0x70, 0x10, 0xe0, 0xf5, 0x47, 0x90, 0x70, 0x11, 0xe0,
+0xf5, 0x44, 0x12, 0x10, 0x25, 0x80, 0x06, 0x90, 0x70, 0x10, 0xe0, 0xf5, 0x45, 0xe4, 0xfd, 0xaf,
+0x2f, 0x12, 0x02, 0x8d, 0xd2, 0x04, 0x90, 0x70, 0x13, 0xe4, 0xf0, 0xd2, 0xaf, 0xd0, 0xd0, 0xd0,
+0x82, 0xd0, 0x83, 0xd0, 0xf0, 0xd0, 0xe0, 0x32, 0x90, 0x70, 0x2a, 0xe0, 0x30, 0xe1, 0x53, 0xc2,
+0xaf, 0x90, 0x70, 0x28, 0xe0, 0x90, 0x10, 0x1c, 0xf0, 0x90, 0x70, 0x29, 0xe0, 0x90, 0x10, 0x1d,
+0xf0, 0x90, 0x70, 0x2a, 0xe0, 0x90, 0x10, 0x1e, 0xf0, 0x90, 0x10, 0x1c, 0xe0, 0xf5, 0x30, 0x90,
+0x10, 0x1e, 0xe0, 0x20, 0xe1, 0xf3, 0x90, 0x10, 0x1c, 0xe0, 0x90, 0x70, 0x28, 0xf0, 0x90, 0x10,
+0x1d, 0xe0, 0x90, 0x70, 0x29, 0xf0, 0x90, 0x10, 0x1e, 0xe0, 0x90, 0x70, 0x2a, 0xf0, 0x30, 0x4a,
+0x0d, 0x90, 0x70, 0x24, 0xe0, 0x44, 0x01, 0xf0, 0x90, 0x02, 0x2c, 0x74, 0xff, 0xf0, 0xc2, 0x05,
+0xd2, 0xaf, 0x22, 0xc0, 0xe0, 0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0xe8, 0xc0, 0xe0,
+0xe9, 0xc0, 0xe0, 0xea, 0xc0, 0xe0, 0xeb, 0xc0, 0xe0, 0xec, 0xc0, 0xe0, 0xed, 0xc0, 0xe0, 0xee,
+0xc0, 0xe0, 0xef, 0xc0, 0xe0, 0xc2, 0xaf, 0x30, 0x45, 0x03, 0x12, 0x10, 0x12, 0xd2, 0xaf, 0xd0,
+0xe0, 0xff, 0xd0, 0xe0, 0xfe, 0xd0, 0xe0, 0xfd, 0xd0, 0xe0, 0xfc, 0xd0, 0xe0, 0xfb, 0xd0, 0xe0,
+0xfa, 0xd0, 0xe0, 0xf9, 0xd0, 0xe0, 0xf8, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xf0, 0xd0,
+0xe0, 0x32, 0xc0, 0xe0, 0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0x75, 0xd0, 0x10, 0xc2,
+0xaf, 0x30, 0x45, 0x03, 0x12, 0x10, 0x0c, 0x30, 0x58, 0x0a, 0xe5, 0x54, 0x60, 0x04, 0x15, 0x54,
+0x80, 0x02, 0xc2, 0x58, 0x30, 0x59, 0x0a, 0xe5, 0x50, 0x60, 0x04, 0x15, 0x50, 0x80, 0x02, 0xc2,
+0x59, 0xd5, 0x53, 0x07, 0x30, 0x60, 0x04, 0x15, 0x46, 0xd2, 0x04, 0x30, 0x45, 0x03, 0x12, 0x10,
+0x0f, 0xc2, 0x8d, 0xd2, 0xaf, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xf0, 0xd0, 0xe0, 0x32,
+0x12, 0x02, 0xd3, 0x30, 0x45, 0x03, 0x12, 0x10, 0x03, 0x30, 0x01, 0x06, 0x20, 0x09, 0x03, 0x12,
+0x10, 0x1c, 0x30, 0x02, 0x06, 0x20, 0x0a, 0x03, 0x12, 0x10, 0x1f, 0x30, 0x03, 0x06, 0x20, 0x0b,
+0x03, 0x12, 0x10, 0x1f, 0x30, 0x04, 0x06, 0x20, 0x0c, 0x03, 0x12, 0x10, 0x22, 0x20, 0x13, 0x09,
+0x20, 0x11, 0x06, 0xe5, 0x2b, 0x45, 0x2c, 0x60, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0xa9, 0x12,
+0x02, 0xec, 0x80, 0xbf, 0xc2, 0x43, 0xd2, 0x45, 0xe4, 0xf5, 0x20, 0xf5, 0x21, 0xf5, 0x53, 0xf5,
+0x46, 0xf5, 0x2b, 0xf5, 0x2c, 0xc2, 0x42, 0xf5, 0x51, 0xf5, 0x52, 0xf5, 0x55, 0x90, 0x04, 0x18,
+0x74, 0x80, 0xf0, 0x90, 0x04, 0x1a, 0x74, 0x08, 0xf0, 0xc2, 0x19, 0xc2, 0x18, 0xc2, 0x1a, 0x22,
+0xc8, 0xef, 0xc8, 0xe6, 0xfa, 0x08, 0xe6, 0x4a, 0x60, 0x0c, 0xc8, 0xef, 0xc8, 0x08, 0xe6, 0x16,
+0x18, 0x70, 0x01, 0x16, 0xc3, 0x22, 0xed, 0x24, 0xff, 0xfd, 0xec, 0x34, 0xff, 0xc8, 0xef, 0xc8,
+0xf6, 0x08, 0xc6, 0xed, 0xc6, 0xd3, 0x22, 0xd0, 0x83, 0xd0, 0x82, 0xf8, 0xe4, 0x93, 0x70, 0x12,
+0x74, 0x01, 0x93, 0x70, 0x0d, 0xa3, 0xa3, 0x93, 0xf8, 0x74, 0x01, 0x93, 0xf5, 0x82, 0x88, 0x83,
+0xe4, 0x73, 0x74, 0x02, 0x93, 0x68, 0x60, 0xef, 0xa3, 0xa3, 0xa3, 0x80, 0xdf, 0xef, 0xf4, 0x60,
+0x1f, 0xe4, 0xfe, 0x12, 0x03, 0x6a, 0xe0, 0xb4, 0xff, 0x12, 0x12, 0x03, 0x6a, 0xef, 0xf0, 0x74,
+0x1c, 0x2e, 0xf5, 0x82, 0xe4, 0x34, 0x70, 0xf5, 0x83, 0xed, 0xf0, 0x22, 0x0e, 0xbe, 0x04, 0xe3,
+0x22, 0xc0, 0xe0, 0xc0, 0xf0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, 0xd0, 0x75, 0xd0, 0x08, 0xc2, 0xaf,
+0x30, 0x45, 0x03, 0x12, 0x10, 0x06, 0xd2, 0xaf, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xf0,
+0xd0, 0xe0, 0x32, 0xc2, 0xaf, 0x12, 0x00, 0x06, 0x12, 0x02, 0x14, 0x12, 0x03, 0x1c, 0xe4, 0xf5,
+0x22, 0xf5, 0x47, 0x90, 0x04, 0x00, 0x74, 0x80, 0xf0, 0xd2, 0xaf, 0x22, 0x30, 0x45, 0x03, 0x12,
+0x10, 0x15, 0xe5, 0x20, 0x70, 0x03, 0x20, 0x10, 0x03, 0x30, 0x11, 0x03, 0x43, 0x87, 0x01, 0x22,
+0xc0, 0x2a, 0x74, 0x03, 0xc0, 0xe0, 0xc0, 0x82, 0xc0, 0x83, 0x75, 0x2a, 0x0a, 0x22, 0xc0, 0x2a,
+0x74, 0x03, 0xc0, 0xe0, 0xc0, 0x82, 0xc0, 0x83, 0x75, 0x2a, 0x18, 0x22, 0x75, 0x89, 0x02, 0xe4,
+0xf5, 0x8c, 0xf5, 0x8a, 0xf5, 0x88, 0xf5, 0xb8, 0xf5, 0xe8, 0x75, 0x90, 0x18, 0xd2, 0x8c, 0x75,
+0xa8, 0x05, 0x22, 0xce, 0xef, 0xce, 0xee, 0x60, 0x08, 0x7f, 0xff, 0x12, 0x03, 0x80, 0x1e, 0x80,
+0xf5, 0x22, 0xc8, 0xef, 0xc8, 0xe6, 0x60, 0x03, 0x16, 0xc3, 0x22, 0xed, 0x14, 0xf6, 0xd3, 0x22,
+0xc8, 0xef, 0xc8, 0xe6, 0x60, 0x06, 0x16, 0xe6, 0x24, 0xff, 0xb3, 0x22, 0xc3, 0x22, 0x78, 0x7f,
+0xe4, 0xf6, 0xd8, 0xfd, 0x75, 0x81, 0x5f, 0x02, 0x01, 0xd0, 0x74, 0x14, 0x2e, 0xf5, 0x82, 0xe4,
+0x34, 0x70, 0xf5, 0x83, 0x22, 0xef, 0x90, 0x03, 0x7e, 0x93, 0x90, 0x03, 0x00, 0x73, 0x0a, 0x18,
+0xef, 0x60, 0x03, 0x1f, 0x80, 0xfa, 0x22, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+0xff, 0xff, 0xff, 0x02, 0x10, 0x28, 0x02, 0x10, 0x3b, 0x02, 0x10, 0x3c, 0x02, 0x12, 0xb8, 0x02,
+0x12, 0xb9, 0x02, 0x13, 0x3e, 0x02, 0x13, 0x3f, 0xc3, 0x22, 0xff, 0xff, 0x02, 0x16, 0x56, 0x02,
+0x17, 0x6b, 0x02, 0x14, 0x2a, 0x02, 0x13, 0x40, 0x30, 0x05, 0x06, 0x20, 0x0d, 0x03, 0x12, 0x00,
+0xd8, 0x30, 0x06, 0x06, 0x20, 0x0e, 0x03, 0x12, 0x18, 0x5e, 0x22, 0x22, 0x90, 0x04, 0x14, 0xe0,
+0x20, 0xe7, 0x03, 0x02, 0x12, 0xb7, 0x90, 0x70, 0x12, 0xe0, 0xf5, 0x56, 0x90, 0x04, 0x04, 0xe0,
+0x12, 0x02, 0x67, 0x11, 0x4e, 0x30, 0x11, 0x25, 0x31, 0x10, 0x87, 0x33, 0x10, 0xaa, 0x34, 0x10,
+0xc3, 0x35, 0x11, 0x57, 0x50, 0x11, 0x7b, 0x51, 0x11, 0x84, 0x52, 0x11, 0x84, 0x53, 0x11, 0x84,
+0x54, 0x11, 0xc5, 0x55, 0x11, 0xdc, 0x70, 0x12, 0x07, 0x71, 0x12, 0x34, 0x72, 0x12, 0x5e, 0x80,
+0x12, 0x81, 0x83, 0x00, 0x00, 0x12, 0xb7, 0x75, 0x24, 0x05, 0x75, 0x25, 0xdc, 0x90, 0x70, 0x9f,
+0x74, 0x12, 0xf0, 0xd2, 0x18, 0xd2, 0x61, 0x75, 0x35, 0x0d, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5,
+0x56, 0xf4, 0x70, 0x03, 0x02, 0x12, 0xb7, 0x02, 0x12, 0xaa, 0xc2, 0x18, 0x90, 0x01, 0x14, 0xe0,
+0x54, 0xfd, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x70, 0x03, 0x02, 0x12, 0xb7,
+0x02, 0x12, 0xaa, 0xe5, 0x55, 0x64, 0x02, 0x70, 0x37, 0x90, 0x70, 0x10, 0xe0, 0x60, 0x08, 0x90,
+0x01, 0x0d, 0x74, 0x09, 0xf0, 0x80, 0x25, 0xe5, 0x34, 0x14, 0x60, 0x0a, 0x14, 0x60, 0x0f, 0x14,
+0x60, 0x14, 0x24, 0x03, 0x70, 0x16, 0x90, 0x01, 0x0d, 0x74, 0x08, 0xf0, 0x80, 0x0e, 0x90, 0x01,
+0x0d, 0x74, 0x0b, 0xf0, 0x80, 0x06, 0x90, 0x01, 0x0d, 0x74, 0x1b, 0xf0, 0x7d, 0x01, 0x80, 0x02,
+0x7d, 0x02, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0x90, 0x70, 0x11, 0xe0, 0x24, 0xff, 0x92, 0x1b, 0x90,
+0x04, 0x14, 0x74, 0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x70, 0x03, 0x02,
+0x12, 0xb7, 0x02, 0x12, 0xaa, 0x20, 0x02, 0x03, 0x30, 0x03, 0x1d, 0x7d, 0x02, 0xaf, 0x56, 0x12,
+0x02, 0x8d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4,
+0x70, 0x03, 0x02, 0x12, 0xb7, 0x02, 0x12, 0xaa, 0x85, 0x56, 0x41, 0xd2, 0x02, 0x22, 0x90, 0x70,
+0x11, 0xe0, 0x24, 0xff, 0x92, 0x1b, 0x22, 0x90, 0x70, 0x10, 0xe0, 0x54, 0x7f, 0x64, 0x02, 0x60,
+0x03, 0x02, 0x12, 0xb7, 0x90, 0x70, 0x11, 0xe0, 0x64, 0x08, 0x60, 0x08, 0xe0, 0x64, 0x20, 0x60,
+0x03, 0x02, 0x12, 0xb7, 0x75, 0x4e, 0x03, 0x75, 0x4f, 0x20, 0x22, 0x90, 0x70, 0x11, 0xe0, 0x24,
+0xff, 0x92, 0x47, 0x22, 0x90, 0x04, 0x04, 0xe0, 0x25, 0xe0, 0x24, 0x5d, 0xf5, 0x57, 0x90, 0x70,
+0x10, 0xe0, 0xff, 0x74, 0x47, 0x25, 0x57, 0xf8, 0xc6, 0xef, 0xc6, 0x90, 0x70, 0x11, 0xe0, 0xff,
+0x74, 0x48, 0x25, 0x57, 0xf8, 0xc6, 0xef, 0xc6, 0xe4, 0xfd, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0x90,
+0x04, 0x14, 0x74, 0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x70, 0x03, 0x02,
+0x12, 0xb7, 0x02, 0x12, 0xaa, 0xe5, 0x47, 0xb4, 0x07, 0x08, 0x90, 0x70, 0x11, 0xe0, 0x54, 0x07,
+0xf5, 0x26, 0xe4, 0xfd, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0xd2, 0x04, 0x22, 0x90, 0x70, 0x10, 0xe0,
+0xfe, 0x90, 0x70, 0x11, 0xe0, 0xfd, 0xed, 0xf8, 0xe6, 0xf5, 0x57, 0xfd, 0xaf, 0x56, 0x12, 0x02,
+0x8d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x70,
+0x03, 0x02, 0x12, 0xb7, 0x02, 0x12, 0xaa, 0x90, 0x70, 0x10, 0xe0, 0xfe, 0x90, 0x70, 0x11, 0xe0,
+0xfd, 0xed, 0xf5, 0x82, 0x8e, 0x83, 0xe0, 0xf5, 0x57, 0xfd, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0x90,
+0x04, 0x14, 0x74, 0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x70, 0x03, 0x02,
+0x12, 0xb7, 0x80, 0x76, 0xe4, 0xf5, 0x4e, 0xf5, 0x4f, 0x75, 0x26, 0xff, 0xc2, 0x19, 0xc2, 0x18,
+0xc2, 0x1a, 0x75, 0x34, 0xff, 0xad, 0x57, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0x90, 0x04, 0x14, 0x74,
+0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x60, 0x5b, 0x80, 0x4c, 0x90, 0x70,
+0x10, 0xe0, 0x24, 0xff, 0x92, 0x4a, 0xd2, 0x05, 0xad, 0x57, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0x90,
+0x04, 0x14, 0x74, 0x80, 0xf0, 0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x60, 0x38, 0x80,
+0x29, 0x90, 0x70, 0x10, 0xe0, 0xf5, 0x34, 0xd3, 0x94, 0x00, 0x40, 0x07, 0x90, 0x01, 0x0d, 0xe0,
+0x54, 0xfb, 0xf0, 0xad, 0x57, 0xaf, 0x56, 0x12, 0x02, 0x8d, 0x90, 0x04, 0x14, 0x74, 0x80, 0xf0,
+0xe4, 0x90, 0x70, 0x13, 0xf0, 0xe5, 0x56, 0xf4, 0x60, 0x0d, 0x90, 0x70, 0x25, 0xe0, 0x44, 0x01,
+0xf0, 0x90, 0x02, 0x2c, 0x74, 0xff, 0xf0, 0x22, 0x22, 0xe5, 0x53, 0x60, 0x03, 0x02, 0x13, 0x3d,
+0xe5, 0x4f, 0x45, 0x4e, 0x60, 0x08, 0xe5, 0x4f, 0x15, 0x4f, 0x70, 0x02, 0x15, 0x4e, 0xa2, 0x19,
+0xe4, 0x33, 0x90, 0x70, 0x90, 0xf0, 0xa2, 0x18, 0xe4, 0x33, 0xa3, 0xf0, 0x30, 0x19, 0x4d, 0x90,
+0x70, 0x98, 0x74, 0x23, 0xf0, 0xa3, 0xe5, 0x25, 0xf0, 0xe5, 0x24, 0xa3, 0xf0, 0x7f, 0x35, 0x7d,
+0x32, 0x12, 0x03, 0x42, 0x50, 0x09, 0x90, 0x10, 0x04, 0xe0, 0x54, 0xf7, 0xf0, 0xd2, 0x06, 0xe5,
+0x35, 0xd3, 0x94, 0x10, 0x40, 0x1e, 0x30, 0x1a, 0x1b, 0xc2, 0x1a, 0xa2, 0x18, 0x92, 0x19, 0x20,
+0x19, 0x12, 0x90, 0x04, 0x09, 0xe0, 0x54, 0xdd, 0xf0, 0x90, 0x10, 0x04, 0xe0, 0x44, 0x08, 0xf0,
+0xc2, 0x61, 0xd2, 0x03, 0xe5, 0x35, 0xb4, 0x0b, 0x14, 0xd2, 0x03, 0x22, 0xe4, 0xf5, 0x35, 0xa2,
+0x18, 0x92, 0x19, 0x30, 0x19, 0x07, 0x90, 0x04, 0x09, 0xe0, 0x44, 0x22, 0xf0, 0x22, 0x22, 0x22,
+0xc2, 0x4b, 0xc2, 0x4c, 0xe5, 0x44, 0x12, 0x02, 0x67, 0x13, 0x62, 0x00, 0x13, 0xf5, 0x04, 0x13,
+0xf1, 0x08, 0x13, 0xcc, 0x10, 0x13, 0x76, 0x20, 0x13, 0x96, 0x60, 0x13, 0xa7, 0xa0, 0x00, 0x00,
+0x13, 0xf7, 0x85, 0x48, 0x43, 0x85, 0x4a, 0x42, 0x85, 0x4c, 0x5e, 0xe5, 0x47, 0x64, 0x06, 0x60,
+0x03, 0x02, 0x13, 0xf7, 0x80, 0x1b, 0xe5, 0x48, 0xc4, 0x54, 0x0f, 0xf5, 0x43, 0xe5, 0x4a, 0xc4,
+0x54, 0x0f, 0xf5, 0x42, 0xe5, 0x4c, 0xc4, 0x54, 0x0f, 0xf5, 0x5e, 0xe5, 0x47, 0x64, 0x06, 0x70,
+0x66, 0x53, 0x43, 0x0f, 0x80, 0x61, 0x85, 0x49, 0x43, 0x85, 0x4b, 0x42, 0x85, 0x4d, 0x5e, 0xe5,
+0x47, 0x64, 0x06, 0x70, 0x52, 0x80, 0x1b, 0xe5, 0x49, 0xc4, 0x54, 0x0f, 0xf5, 0x43, 0xe5, 0x4b,
+0xc4, 0x54, 0x0f, 0xf5, 0x42, 0xe5, 0x4d, 0xc4, 0x54, 0x0f, 0xf5, 0x5e, 0xe5, 0x47, 0x64, 0x06,
+0x70, 0x35, 0xe5, 0x43, 0x54, 0x0f, 0x44, 0x10, 0xf5, 0x43, 0x80, 0x2b, 0xe5, 0x47, 0xb4, 0x04,
+0x06, 0x53, 0x5e, 0xfb, 0x75, 0x42, 0x09, 0xe5, 0x47, 0xb4, 0x05, 0x06, 0x43, 0x5e, 0x04, 0x75,
+0x42, 0x09, 0xe5, 0x47, 0xb4, 0x06, 0x10, 0xe5, 0x43, 0x54, 0x0f, 0x44, 0x30, 0xf5, 0x43, 0x80,
+0x06, 0xd2, 0x4b, 0x80, 0x02, 0xd2, 0x4c, 0xe4, 0xf5, 0x38, 0xe5, 0x42, 0xc4, 0x54, 0xf0, 0xff,
+0xe5, 0x43, 0x54, 0x0f, 0x4f, 0xf5, 0x5f, 0x90, 0x70, 0x44, 0xf0, 0xa3, 0xe5, 0x5e, 0xf0, 0xa3,
+0xe5, 0x4a, 0xf0, 0xa3, 0xe5, 0x48, 0xf0, 0xa3, 0xe5, 0x4c, 0xf0, 0xa3, 0xe5, 0x44, 0xf0, 0xa3,
+0xe5, 0x42, 0xf0, 0xa3, 0xe5, 0x43, 0xf0, 0xd2, 0x60, 0x22, 0xe5, 0x47, 0x60, 0x10, 0x24, 0xc0,
+0x70, 0x03, 0x12, 0x16, 0x36, 0x12, 0x14, 0x3f, 0xc2, 0xaf, 0xc2, 0x04, 0xd2, 0xaf, 0x22, 0xc2,
+0xaf, 0x90, 0x04, 0x14, 0xe0, 0x54, 0x0e, 0x60, 0x04, 0xd2, 0x1c, 0x80, 0x08, 0xe5, 0x4e, 0x45,
+0x4f, 0x24, 0xff, 0x92, 0x1c, 0xd2, 0xaf, 0x90, 0x04, 0x14, 0xe0, 0xa2, 0xe4, 0x92, 0x1d, 0x74,
+0x1e, 0xf0, 0xe5, 0x5f, 0x54, 0x0f, 0xf5, 0x2d, 0xe5, 0x38, 0x70, 0x13, 0x30, 0x1c, 0x05, 0xe5,
+0x5f, 0x20, 0xe5, 0x0b, 0x30, 0x1d, 0x19, 0xe5, 0x5f, 0x54, 0x30, 0xff, 0xbf, 0x30, 0x11, 0xe5,
+0x38, 0x70, 0x05, 0x75, 0x38, 0x0c, 0x80, 0x02, 0x15, 0x38, 0xd2, 0x6c, 0xd2, 0x6d, 0x80, 0x0f,
+0xe5, 0x5f, 0x30, 0xe6, 0x06, 0xc2, 0x6c, 0xd2, 0x6d, 0x80, 0x04, 0xd2, 0x6c, 0xc2, 0x6d, 0xe5,
+0x47, 0x64, 0x03, 0x70, 0x21, 0x30, 0x4b, 0x06, 0xc2, 0x6c, 0xd2, 0x6d, 0x80, 0x18, 0xe5, 0x38,
+0x70, 0x03, 0x30, 0x4c, 0x11, 0xc2, 0x4c, 0xe5, 0x38, 0x70, 0x05, 0x75, 0x38, 0x07, 0x80, 0x02,
+0x15, 0x38, 0xd2, 0x6c, 0xd2, 0x6d, 0x90, 0x70, 0x46, 0xe5, 0x2d, 0xf0, 0x20, 0x69, 0x07, 0xe5,
+0x5e, 0x20, 0xe0, 0x02, 0xb2, 0x68, 0x20, 0x6b, 0x07, 0xe5, 0x5e, 0x20, 0xe1, 0x02, 0xb2, 0x6a,
+0x20, 0x6d, 0x07, 0xe5, 0x5e, 0x20, 0xe2, 0x02, 0xb2, 0x6c, 0x90, 0x70, 0x47, 0xe5, 0x2d, 0xf0,
+0x75, 0x2e, 0x40, 0x20, 0x69, 0x04, 0xa2, 0x68, 0x80, 0x15, 0x30, 0x68, 0x06, 0xe5, 0x46, 0xa2,
+0xe3, 0x80, 0x0c, 0xe5, 0x46, 0x54, 0xf0, 0xff, 0xbf, 0xf0, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92,
+0x73, 0x92, 0x72, 0x20, 0x6b, 0x04, 0xa2, 0x6a, 0x80, 0x15, 0x30, 0x6a, 0x06, 0xe5, 0x46, 0xa2,
+0xe3, 0x80, 0x0c, 0xe5, 0x46, 0x54, 0xf0, 0xff, 0xbf, 0xf0, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92,
+0x75, 0x92, 0x74, 0x20, 0x6d, 0x04, 0xa2, 0x6c, 0x80, 0x15, 0x30, 0x6c, 0x06, 0xe5, 0x46, 0xa2,
+0xe3, 0x80, 0x0c, 0xe5, 0x46, 0x54, 0xf0, 0xff, 0xbf, 0xf0, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92,
+0x71, 0x92, 0x70, 0x90, 0x10, 0x2f, 0xe5, 0x2e, 0xf0, 0xe5, 0x47, 0x64, 0x06, 0x70, 0x46, 0x90,
+0x02, 0x29, 0xe0, 0x54, 0xfe, 0xf0, 0xe5, 0x43, 0xc4, 0x54, 0x0f, 0x14, 0x60, 0x14, 0x24, 0xfe,
+0x60, 0x1f, 0x24, 0x03, 0x60, 0x03, 0x02, 0x16, 0x35, 0x90, 0x02, 0x28, 0xe0, 0x30, 0x47, 0x0d,
+0x80, 0x07, 0x90, 0x02, 0x28, 0xe0, 0x20, 0x47, 0x04, 0x54, 0xfe, 0xf0, 0x22, 0x44, 0x01, 0xf0,
+0x22, 0xe5, 0x46, 0x30, 0xe3, 0x04, 0x7f, 0x01, 0x80, 0x02, 0x7f, 0x00, 0x90, 0x02, 0x28, 0xe0,
+0x54, 0xfe, 0x4f, 0xf0, 0x22, 0xe5, 0x47, 0x64, 0x07, 0x60, 0x03, 0x02, 0x16, 0x35, 0xf5, 0x27,
+0x90, 0x02, 0x29, 0xe0, 0x54, 0xfc, 0xf0, 0xe5, 0x26, 0x14, 0x60, 0x26, 0x14, 0x60, 0x2e, 0x14,
+0x60, 0x36, 0x24, 0x03, 0x70, 0x5f, 0xe5, 0x46, 0x13, 0x13, 0x13, 0x54, 0x1f, 0x75, 0xf0, 0x03,
+0x84, 0xaf, 0xf0, 0x20, 0x47, 0x04, 0x7e, 0x01, 0x80, 0x02, 0x7e, 0x00, 0xef, 0x6e, 0x24, 0xff,
+0x80, 0x02, 0xa2, 0x47, 0x92, 0x39, 0xa2, 0x47, 0xb3, 0x92, 0x38, 0x80, 0x3f, 0xe5, 0x46, 0x30,
+0xe3, 0x03, 0xd3, 0x80, 0x27, 0xc3, 0x80, 0x24, 0xe5, 0x46, 0x30, 0xe3, 0x0d, 0x54, 0x70, 0xc3,
+0x94, 0x60, 0x50, 0x06, 0x7e, 0x00, 0x7f, 0x01, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0x20, 0x47,
+0x04, 0x7d, 0x01, 0x80, 0x02, 0x7d, 0x00, 0xef, 0x6d, 0x4e, 0x24, 0xff, 0x92, 0x38, 0xa2, 0x47,
+0xb3, 0x92, 0x39, 0x80, 0x07, 0xa2, 0x47, 0xb3, 0x92, 0x38, 0x92, 0x39, 0x90, 0x02, 0x28, 0xe0,
+0x54, 0xfc, 0x45, 0x27, 0xf0, 0x22, 0xe4, 0x90, 0x02, 0x29, 0xf0, 0x30, 0x47, 0x04, 0xaf, 0x45,
+0x80, 0x04, 0xe5, 0x45, 0xf4, 0xff, 0x90, 0x02, 0x28, 0xef, 0xf0, 0x22, 0x8f, 0x50, 0xd2, 0x59,
+0x22, 0x8f, 0x54, 0xd2, 0x58, 0x22, 0xe4, 0xf5, 0x30, 0xc2, 0xaf, 0xe5, 0x51, 0x14, 0x60, 0x4a,
+0x14, 0x60, 0x6a, 0x24, 0x02, 0x60, 0x03, 0x02, 0x17, 0x4c, 0xd2, 0x59, 0x75, 0x55, 0x01, 0x20,
+0x19, 0x1c, 0x90, 0x02, 0x08, 0xe0, 0x54, 0xfe, 0xf0, 0xe0, 0x20, 0xe1, 0x23, 0x90, 0x04, 0x34,
+0xe0, 0xb4, 0x02, 0x1c, 0xa3, 0xe0, 0xb4, 0x02, 0x17, 0xa3, 0xe0, 0xb4, 0x02, 0x12, 0x7f, 0x20,
+0x12, 0x16, 0x4c, 0x90, 0x10, 0x04, 0xe0, 0x54, 0xf3, 0xf0, 0x75, 0x51, 0x01, 0x02, 0x17, 0x4c,
+0xe5, 0x50, 0x70, 0x06, 0x75, 0x30, 0x03, 0x02, 0x17, 0x4c, 0x90, 0x12, 0x00, 0xe0, 0x54, 0x03,
+0x70, 0x15, 0x7f, 0x20, 0x12, 0x16, 0x4c, 0x20, 0x19, 0x07, 0x90, 0x02, 0x08, 0xe0, 0x54, 0xfb,
+0xf0, 0x75, 0x51, 0x02, 0x02, 0x17, 0x4c, 0xe5, 0x50, 0x70, 0x02, 0x80, 0x7a, 0x20, 0x19, 0x0f,
+0x90, 0x02, 0x08, 0xe0, 0x20, 0xe3, 0x6c, 0x90, 0x04, 0x37, 0xe0, 0x64, 0x22, 0x70, 0x64, 0x90,
+0x12, 0x04, 0x74, 0x0a, 0xf0, 0x30, 0x1b, 0x11, 0x90, 0x13, 0x28, 0xe0, 0x54, 0xf0, 0xf0, 0xa3,
+0xe0, 0x54, 0xf0, 0xf0, 0xa3, 0xe0, 0x54, 0xfa, 0xf0, 0x20, 0x19, 0x07, 0x90, 0x04, 0x01, 0xe0,
+0x44, 0x10, 0xf0, 0xe5, 0x34, 0xf4, 0x90, 0x04, 0x01, 0x60, 0x06, 0xe0, 0x54, 0xfb, 0xf0, 0x80,
+0x04, 0xe0, 0x54, 0xf9, 0xf0, 0x20, 0x19, 0x07, 0x90, 0x12, 0x04, 0xe0, 0x44, 0x04, 0xf0, 0xe5,
+0x34, 0xf4, 0x60, 0x14, 0x90, 0x01, 0x0d, 0xe0, 0xf5, 0x33, 0xe5, 0x34, 0xd3, 0x94, 0x02, 0x40,
+0x07, 0x90, 0x12, 0x04, 0xe0, 0x54, 0xfd, 0xf0, 0x75, 0x30, 0x01, 0x75, 0x55, 0x02, 0xe4, 0xf5,
+0x51, 0x80, 0x09, 0xe5, 0x50, 0x70, 0x05, 0x75, 0x30, 0x03, 0xf5, 0x51, 0xe5, 0x30, 0x60, 0x18,
+0xc2, 0x01, 0xe4, 0xf5, 0x51, 0xc2, 0x59, 0x20, 0x19, 0x0e, 0xad, 0x30, 0xaf, 0x40, 0x12, 0x18,
+0x2a, 0xe5, 0x30, 0xb4, 0x03, 0x02, 0xd2, 0x03, 0xd2, 0xaf, 0x22, 0xc2, 0xaf, 0x30, 0x01, 0x0e,
+0xe4, 0xf5, 0x51, 0xc2, 0x59, 0xc2, 0x01, 0x7d, 0x02, 0xaf, 0x40, 0x12, 0x18, 0x2a, 0xe5, 0x52,
+0x14, 0x60, 0x55, 0x14, 0x60, 0x2f, 0x24, 0x02, 0x60, 0x03, 0x02, 0x18, 0x27, 0xe5, 0x34, 0xf4,
+0x60, 0x23, 0xe5, 0x34, 0xd3, 0x94, 0x02, 0x40, 0x16, 0x90, 0x12, 0x04, 0xe0, 0x44, 0x02, 0xf0,
+0x90, 0x01, 0x0d, 0xe0, 0x20, 0xe3, 0x03, 0x02, 0x18, 0x27, 0x7f, 0x50, 0x12, 0x16, 0x51, 0x75,
+0x52, 0x02, 0x75, 0x55, 0x03, 0xe5, 0x34, 0xf4, 0x60, 0x0a, 0xe5, 0x54, 0x70, 0x69, 0x90, 0x01,
+0x0d, 0xe5, 0x33, 0xf0, 0x90, 0x12, 0x04, 0xe0, 0x54, 0xfb, 0xf0, 0x7f, 0x20, 0x12, 0x16, 0x51,
+0x75, 0x52, 0x01, 0x75, 0x55, 0x03, 0x80, 0x4f, 0xe5, 0x54, 0x70, 0x4b, 0x90, 0x04, 0x01, 0xe0,
+0x44, 0x0e, 0xf0, 0x20, 0x19, 0x04, 0xe0, 0x54, 0xef, 0xf0, 0x90, 0x13, 0x28, 0xe0, 0x44, 0x0f,
+0xf0, 0xa3, 0xe0, 0x44, 0x0f, 0xf0, 0xa3, 0xe0, 0x44, 0x05, 0xf0, 0x90, 0x12, 0x04, 0x74, 0x03,
+0xf0, 0x20, 0x19, 0x07, 0x90, 0x02, 0x08, 0xe0, 0x44, 0x05, 0xf0, 0x90, 0x10, 0x04, 0xe0, 0x44,
+0x0c, 0xf0, 0xe4, 0xf5, 0x52, 0xf5, 0x55, 0x30, 0x02, 0x0b, 0xc2, 0x02, 0x7d, 0x01, 0xaf, 0x41,
+0x12, 0x18, 0x2a, 0x80, 0x02, 0xc2, 0x03, 0xd2, 0xaf, 0x22, 0xef, 0xf4, 0x60, 0x2d, 0xe4, 0xfe,
+0x74, 0x14, 0x2e, 0xf5, 0x82, 0xe4, 0x34, 0x70, 0xf5, 0x83, 0xe0, 0xb4, 0xff, 0x19, 0x74, 0x14,
+0x2e, 0xf5, 0x82, 0xe4, 0x34, 0x70, 0xf5, 0x83, 0xef, 0xf0, 0x74, 0x1c, 0x2e, 0xf5, 0x82, 0xe4,
+0x34, 0x70, 0xf5, 0x83, 0xed, 0xf0, 0x22, 0x0e, 0xbe, 0x04, 0xd5, 0x22, 0x22, 0x22, 0x20, 0x19,
+0x03, 0x02, 0x19, 0x0f, 0x90, 0x70, 0x80, 0xe0, 0x04, 0xf0, 0x90, 0x04, 0x37, 0xe0, 0x30, 0xe5,
+0x03, 0x02, 0x19, 0x0b, 0x90, 0x04, 0x28, 0xe0, 0xf5, 0x31, 0xa3, 0xe0, 0xf5, 0x30, 0xf5, 0x32,
+0xe4, 0xf5, 0x37, 0x90, 0x70, 0x81, 0xe0, 0x04, 0xf0, 0x90, 0x70, 0x82, 0xe0, 0x04, 0xf0, 0xe5,
+0x32, 0x75, 0xf0, 0x80, 0xa4, 0x24, 0x00, 0xff, 0xe5, 0xf0, 0x34, 0x80, 0xfe, 0xe5, 0x30, 0x65,
+0x32, 0x70, 0x05, 0xfc, 0x7d, 0x18, 0x80, 0x04, 0x7c, 0x00, 0x7d, 0x00, 0xef, 0x2d, 0xff, 0xee,
+0x3c, 0xfe, 0x12, 0x19, 0x10, 0x50, 0x25, 0x90, 0x70, 0x83, 0xe0, 0x04, 0xf0, 0x90, 0x01, 0x14,
+0xe0, 0x44, 0x02, 0xf0, 0xe0, 0x30, 0xe1, 0x06, 0x90, 0x70, 0x92, 0x74, 0x45, 0xf0, 0x90, 0x70,
+0x93, 0xe0, 0x04, 0xf0, 0x90, 0x04, 0x01, 0xe0, 0x90, 0x70, 0x94, 0xf0, 0xe5, 0x32, 0x65, 0x31,
+0x60, 0x10, 0xe4, 0x25, 0x32, 0xff, 0xe4, 0x34, 0x80, 0x8f, 0x82, 0xf5, 0x83, 0xe0, 0xf5, 0x32,
+0x80, 0x97, 0x90, 0x04, 0x10, 0x74, 0x01, 0xf0, 0x90, 0x04, 0x28, 0xe5, 0x31, 0xf0, 0xa3, 0xe5,
+0x30, 0xf0, 0x90, 0x04, 0x11, 0x74, 0x01, 0xf0, 0x02, 0x18, 0x6a, 0xc2, 0x06, 0xd2, 0x1a, 0x22,
+0x90, 0x70, 0x84, 0xe5, 0x37, 0xf0, 0xc3, 0x94, 0x06, 0x50, 0x19, 0x8f, 0x82, 0x8e, 0x83, 0xe0,
+0xb4, 0xff, 0x07, 0x05, 0x37, 0xe4, 0xf5, 0x36, 0x80, 0x59, 0xe4, 0xf5, 0x37, 0x8f, 0x82, 0x8e,
+0x83, 0xf0, 0x80, 0x4f, 0xe5, 0x36, 0x75, 0xf0, 0x06, 0x84, 0x74, 0x08, 0x25, 0xf0, 0xf5, 0x82,
+0xe4, 0x34, 0x10, 0xf5, 0x83, 0xe0, 0xfd, 0x8f, 0x82, 0x8e, 0x83, 0xe0, 0xfc, 0x6d, 0x70, 0x30,
+0x90, 0x70, 0x88, 0xe0, 0x04, 0xf0, 0xa3, 0xe0, 0xfd, 0xd3, 0x95, 0x37, 0x40, 0x02, 0x80, 0x02,
+0xad, 0x37, 0x90, 0x70, 0x89, 0xed, 0xf0, 0x05, 0x37, 0x05, 0x36, 0xe5, 0x36, 0x75, 0xf0, 0x06,
+0x84, 0x74, 0x8a, 0x25, 0xf0, 0xf5, 0x82, 0xe4, 0x34, 0x70, 0xf5, 0x83, 0xec, 0xf0, 0x80, 0x03,
+0xe4, 0xf5, 0x37, 0x0f, 0xbf, 0x00, 0x01, 0x0e, 0xef, 0x54, 0x7f, 0x60, 0x0a, 0xe5, 0x37, 0xc3,
+0x94, 0x4e, 0x50, 0x03, 0x02, 0x19, 0x10, 0xe5, 0x37, 0xb4, 0x4e, 0x03, 0xd3, 0x80, 0x01, 0xc3,
+0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x94, 0xeb, } ;
diff --git a/common/md5.c b/common/md5.c
index b93c3de..774776b 100644
--- a/common/md5.c
+++ b/common/md5.c
@@ -7,23 +7,23 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
-	
+
     Module Name:
     md5.c
 
@@ -37,7 +37,7 @@
 	Rita    	11-23-04		Modify MD5 and SHA-1
 	Rita		10-14-05		Modify SHA-1 in big-endian platform
  */
-#include "rt_config.h"
+#include "../rt_config.h"
 
 /**
  * md5_mac:
@@ -145,10 +145,10 @@ void byteReverse(unsigned char *buf, unsigned longs)
 #endif
 
 
-/* ==========================  MD5 implementation =========================== */ 
-// four base functions for MD5 
-#define MD5_F1(x, y, z) (((x) & (y)) | ((~x) & (z))) 
-#define MD5_F2(x, y, z) (((x) & (z)) | ((y) & (~z))) 
+/* ==========================  MD5 implementation =========================== */
+// four base functions for MD5
+#define MD5_F1(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define MD5_F2(x, y, z) (((x) & (z)) | ((y) & (~z)))
 #define MD5_F3(x, y, z) ((x) ^ (y) ^ (z))
 #define MD5_F4(x, y, z) ((y) ^ ((x) | (~z)))
 #define CYCLIC_LEFT_SHIFT(w, s) (((w) << (s)) | ((w) >> (32-(s))))
@@ -165,7 +165,7 @@ void byteReverse(unsigned char *buf, unsigned longs)
  *      pCtx        Pointer	to MD5 context
  *
  *  Return Value:
- *      None	    
+ *      None
  */
 VOID MD5Init(MD5_CTX *pCtx)
 {
@@ -181,9 +181,9 @@ VOID MD5Init(MD5_CTX *pCtx)
 
 /*
  *  Function Description:
- *      Update MD5 Context, allow of an arrary of octets as the next portion 
+ *      Update MD5 Context, allow of an arrary of octets as the next portion
  *      of the message
- *      
+ *
  *  Arguments:
  *      pCtx		Pointer	to MD5 context
  * 	    pData       Pointer to input data
@@ -193,47 +193,47 @@ VOID MD5Init(MD5_CTX *pCtx)
  *      None
  *
  *  Note:
- *      Called after MD5Init or MD5Update(itself)   
+ *      Called after MD5Init or MD5Update(itself)
  */
 VOID MD5Update(MD5_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes)
 {
-    
+
     UINT32 TfTimes;
     UINT32 temp;
 	unsigned int i;
-    
+
     temp = pCtx->LenInBitCount[0];
 
     pCtx->LenInBitCount[0] = (UINT32) (pCtx->LenInBitCount[0] + (LenInBytes << 3));
- 
+
     if (pCtx->LenInBitCount[0] < temp)
         pCtx->LenInBitCount[1]++;   //carry in
 
     pCtx->LenInBitCount[1] += LenInBytes >> 29;
 
     // mod 64 bytes
-    temp = (temp >> 3) & 0x3f;  
-    
-    // process lacks of 64-byte data 
-    if (temp) 
+    temp = (temp >> 3) & 0x3f;
+
+    // process lacks of 64-byte data
+    if (temp)
     {
         UCHAR *pAds = (UCHAR *) pCtx->Input + temp;
-        
+
         if ((temp+LenInBytes) < 64)
         {
-            NdisMoveMemory(pAds, (UCHAR *)pData, LenInBytes);   
+            NdisMoveMemory(pAds, (UCHAR *)pData, LenInBytes);
             return;
         }
-        
-        NdisMoveMemory(pAds, (UCHAR *)pData, 64-temp);               
+
+        NdisMoveMemory(pAds, (UCHAR *)pData, 64-temp);
         byteReverse(pCtx->Input, 16);
         MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
 
         pData += 64-temp;
-        LenInBytes -= 64-temp; 
+        LenInBytes -= 64-temp;
     } // end of if (temp)
-    
-     
+
+
     TfTimes = (LenInBytes >> 6);
 
     for (i=TfTimes; i>0; i--)
@@ -247,25 +247,25 @@ VOID MD5Update(MD5_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes)
 
     // buffering lacks of 64-byte data
     if(LenInBytes)
-        NdisMoveMemory(pCtx->Input, (UCHAR *)pData, LenInBytes);   
-   
+        NdisMoveMemory(pCtx->Input, (UCHAR *)pData, LenInBytes);
+
 }
 
 
 /*
  *  Function Description:
- *      Append padding bits and length of original message in the tail 
- *      The message digest has to be completed in the end  
- *  
+ *      Append padding bits and length of original message in the tail
+ *      The message digest has to be completed in the end
+ *
  *  Arguments:
  *      Digest		Output of Digest-Message for MD5
  *  	pCtx        Pointer	to MD5 context
- * 	
+ *
  *  Return Value:
  *      None
- *  
+ *
  *  Note:
- *      Called after MD5Update  
+ *      Called after MD5Update
  */
 VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx)
 {
@@ -273,11 +273,11 @@ VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx)
     UCHAR PadLenInBytes;
     UCHAR *pAppend=0;
     unsigned int i;
-    
+
     Remainder = (UCHAR)((pCtx->LenInBitCount[0] >> 3) & 0x3f);
 
     PadLenInBytes = (Remainder < 56) ? (56-Remainder) : (120-Remainder);
-    
+
     pAppend = (UCHAR *)pCtx->Input + Remainder;
 
     // padding bits without crossing block(64-byte based) boundary
@@ -285,36 +285,36 @@ VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx)
     {
         *pAppend = 0x80;
         PadLenInBytes --;
-        
-        NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, PadLenInBytes); 
-		
+
+        NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, PadLenInBytes);
+
 		// add data-length field, from low to high
        	for (i=0; i<4; i++)
         {
         	pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[0] >> (i << 3)) & 0xff);
         	pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[1] >> (i << 3)) & 0xff);
       	}
-      	
+
         byteReverse(pCtx->Input, 16);
         MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
     } // end of if
-    
+
     // padding bits with crossing block(64-byte based) boundary
     else
     {
         // the first block ===
         *pAppend = 0x80;
         PadLenInBytes --;
-       
-        NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, (64-Remainder-1)); 
+
+        NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, (64-Remainder-1));
         PadLenInBytes -= (64 - Remainder - 1);
-        
+
         byteReverse(pCtx->Input, 16);
         MD5Transform(pCtx->Buf, (UINT32 *)pCtx->Input);
-        
+
 
         // the second block ===
-        NdisZeroMemory((UCHAR *)pCtx->Input, PadLenInBytes); 
+        NdisZeroMemory((UCHAR *)pCtx->Input, PadLenInBytes);
 
         // add data-length field
         for (i=0; i<4; i++)
@@ -330,119 +330,119 @@ VOID MD5Final(UCHAR Digest[16], MD5_CTX *pCtx)
 
     NdisMoveMemory((UCHAR *)Digest, (UINT32 *)pCtx->Buf, 16); // output
     byteReverse((UCHAR *)Digest, 4);
-    NdisZeroMemory(pCtx, sizeof(pCtx)); // memory free 
+    NdisZeroMemory(pCtx, sizeof(pCtx)); // memory free
 }
 
 
 /*
  *  Function Description:
- *      The central algorithm of MD5, consists of four rounds and sixteen 
+ *      The central algorithm of MD5, consists of four rounds and sixteen
  *  	steps per round
- * 
+ *
  *  Arguments:
- *      Buf     Buffers of four states (output: 16 bytes)		
- * 	    Mes     Input data (input: 64 bytes) 
- *  
+ *      Buf     Buffers of four states (output: 16 bytes)
+ * 	    Mes     Input data (input: 64 bytes)
+ *
  *  Return Value:
  *      None
- *  	
+ *
  *  Note:
  *      Called by MD5Update or MD5Final
  */
 VOID MD5Transform(UINT32 Buf[4], UINT32 Mes[16])
-{  
-    UINT32 Reg[4], Temp; 
+{
+    UINT32 Reg[4], Temp;
 	unsigned int i;
-    
-    static UCHAR LShiftVal[16] = 
-    { 	
-        7, 12, 17, 22, 	
-		5, 9 , 14, 20, 
-		4, 11, 16, 23, 
- 		6, 10, 15, 21, 
+
+    static UCHAR LShiftVal[16] =
+    {
+        7, 12, 17, 22,
+		5, 9 , 14, 20,
+		4, 11, 16, 23,
+ 		6, 10, 15, 21,
  	};
 
-	
+
 	// [equal to 4294967296*abs(sin(index))]
-    static UINT32 MD5Table[64] = 
-	{ 
-		0xd76aa478,	0xe8c7b756,	0x242070db,	0xc1bdceee,	
-		0xf57c0faf,	0x4787c62a,	0xa8304613, 0xfd469501,	
+    static UINT32 MD5Table[64] =
+	{
+		0xd76aa478,	0xe8c7b756,	0x242070db,	0xc1bdceee,
+		0xf57c0faf,	0x4787c62a,	0xa8304613, 0xfd469501,
 		0x698098d8,	0x8b44f7af,	0xffff5bb1,	0x895cd7be,
     	0x6b901122,	0xfd987193,	0xa679438e,	0x49b40821,
-    	
+
     	0xf61e2562,	0xc040b340,	0x265e5a51,	0xe9b6c7aa,
     	0xd62f105d,	0x02441453,	0xd8a1e681,	0xe7d3fbc8,
     	0x21e1cde6,	0xc33707d6,	0xf4d50d87,	0x455a14ed,
     	0xa9e3e905,	0xfcefa3f8,	0x676f02d9,	0x8d2a4c8a,
-    	           
+
     	0xfffa3942,	0x8771f681,	0x6d9d6122,	0xfde5380c,
     	0xa4beea44,	0x4bdecfa9,	0xf6bb4b60,	0xbebfbc70,
     	0x289b7ec6,	0xeaa127fa,	0xd4ef3085,	0x04881d05,
     	0xd9d4d039,	0xe6db99e5,	0x1fa27cf8,	0xc4ac5665,
-    	           
+
     	0xf4292244,	0x432aff97,	0xab9423a7,	0xfc93a039,
    		0x655b59c3,	0x8f0ccc92,	0xffeff47d,	0x85845dd1,
     	0x6fa87e4f,	0xfe2ce6e0,	0xa3014314,	0x4e0811a1,
     	0xf7537e82,	0xbd3af235,	0x2ad7d2bb,	0xeb86d391
 	};
- 
-				
+
+
     for (i=0; i<4; i++)
         Reg[i]=Buf[i];
-			
-				
+
+
     // 64 steps in MD5 algorithm
-    for (i=0; i<16; i++)                    
+    for (i=0; i<16; i++)
     {
-        MD5Step(MD5_F1, Reg[0], Reg[1], Reg[2], Reg[3], Mes[i],               
+        MD5Step(MD5_F1, Reg[0], Reg[1], Reg[2], Reg[3], Mes[i],
                 MD5Table[i], LShiftVal[i & 0x3]);
 
         // one-word right shift
-        Temp   = Reg[3]; 
+        Temp   = Reg[3];
         Reg[3] = Reg[2];
         Reg[2] = Reg[1];
         Reg[1] = Reg[0];
-        Reg[0] = Temp;            
+        Reg[0] = Temp;
     }
-    for (i=16; i<32; i++)                    
+    for (i=16; i<32; i++)
     {
-        MD5Step(MD5_F2, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(5*(i & 0xf)+1) & 0xf], 
-                MD5Table[i], LShiftVal[(0x1 << 2)+(i & 0x3)]);    
+        MD5Step(MD5_F2, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(5*(i & 0xf)+1) & 0xf],
+                MD5Table[i], LShiftVal[(0x1 << 2)+(i & 0x3)]);
 
         // one-word right shift
-        Temp   = Reg[3]; 
+        Temp   = Reg[3];
         Reg[3] = Reg[2];
         Reg[2] = Reg[1];
         Reg[1] = Reg[0];
-        Reg[0] = Temp;           
+        Reg[0] = Temp;
     }
-    for (i=32; i<48; i++)                    
+    for (i=32; i<48; i++)
     {
-        MD5Step(MD5_F3, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(3*(i & 0xf)+5) & 0xf], 
-                MD5Table[i], LShiftVal[(0x1 << 3)+(i & 0x3)]);        
+        MD5Step(MD5_F3, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(3*(i & 0xf)+5) & 0xf],
+                MD5Table[i], LShiftVal[(0x1 << 3)+(i & 0x3)]);
 
         // one-word right shift
-        Temp   = Reg[3]; 
+        Temp   = Reg[3];
         Reg[3] = Reg[2];
         Reg[2] = Reg[1];
         Reg[1] = Reg[0];
-        Reg[0] = Temp;          
+        Reg[0] = Temp;
     }
-    for (i=48; i<64; i++)                    
+    for (i=48; i<64; i++)
     {
-        MD5Step(MD5_F4, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(7*(i & 0xf)) & 0xf], 
-                MD5Table[i], LShiftVal[(0x3 << 2)+(i & 0x3)]);   
+        MD5Step(MD5_F4, Reg[0], Reg[1], Reg[2], Reg[3], Mes[(7*(i & 0xf)) & 0xf],
+                MD5Table[i], LShiftVal[(0x3 << 2)+(i & 0x3)]);
 
         // one-word right shift
-        Temp   = Reg[3]; 
+        Temp   = Reg[3];
         Reg[3] = Reg[2];
         Reg[2] = Reg[1];
         Reg[1] = Reg[0];
-        Reg[0] = Temp;           
+        Reg[0] = Temp;
     }
-    
-      
+
+
     // (temporary)output
     for (i=0; i<4; i++)
         Buf[i] += Reg[i];
@@ -453,8 +453,8 @@ VOID MD5Transform(UINT32 Buf[4], UINT32 Mes[16])
 
 /* =========================  SHA-1 implementation ========================== */
 // four base functions for SHA-1
-#define SHA1_F1(b, c, d)    (((b) & (c)) | ((~b) & (d)))         
-#define SHA1_F2(b, c, d)    ((b) ^ (c) ^ (d)) 
+#define SHA1_F1(b, c, d)    (((b) & (c)) | ((~b) & (d)))
+#define SHA1_F2(b, c, d)    ((b) ^ (c) ^ (d))
 #define SHA1_F3(b, c, d)    (((b) & (c)) | ((b) & (d)) | ((c) & (d)))
 
 
@@ -462,7 +462,7 @@ VOID MD5Transform(UINT32 Buf[4], UINT32 Mes[16])
     ( e	+= ( f(b, c, d) + w + k + CYCLIC_LEFT_SHIFT(a, 5)) & 0xffffffff, \
       b = CYCLIC_LEFT_SHIFT(b, 30) )
 
-//Initiate SHA-1 Context satisfied in RFC 3174  
+//Initiate SHA-1 Context satisfied in RFC 3174
 VOID SHAInit(SHA_CTX *pCtx)
 {
     pCtx->Buf[0]=0x67452301;
@@ -470,7 +470,7 @@ VOID SHAInit(SHA_CTX *pCtx)
     pCtx->Buf[2]=0x98badcfe;
     pCtx->Buf[3]=0x10325476;
     pCtx->Buf[4]=0xc3d2e1f0;
-    
+
     pCtx->LenInBitCount[0]=0;
     pCtx->LenInBitCount[1]=0;
 }
@@ -479,17 +479,17 @@ VOID SHAInit(SHA_CTX *pCtx)
  *  Function Description:
  *      Update SHA-1 Context, allow of an arrary of octets as the next
  *      portion of the message
- *      
+ *
  *  Arguments:
  *      pCtx		Pointer	to SHA-1 context
  * 	    pData       Pointer to input data
  *      LenInBytes  The length of input data (unit: byte)
  *
  *  Return Value:
- *      error       indicate more than pow(2,64) bits of data  
+ *      error       indicate more than pow(2,64) bits of data
  *
  *  Note:
- *      Called after SHAInit or SHAUpdate(itself)   
+ *      Called after SHAInit or SHAUpdate(itself)
  */
 UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes)
 {
@@ -497,7 +497,7 @@ UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes)
     UINT32 temp1,temp2;
 	unsigned int i;
 	UCHAR err=1;
-    
+
     temp1 = pCtx->LenInBitCount[0];
     temp2 = pCtx->LenInBitCount[1];
 
@@ -509,40 +509,40 @@ UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes)
     pCtx->LenInBitCount[1] = (UINT32) (pCtx->LenInBitCount[1] +(LenInBytes >> 29));
     if (pCtx->LenInBitCount[1] < temp2)
         return (err);   //check total length of original data
- 
+
 
     // mod 64 bytes
-    temp1 = (temp1 >> 3) & 0x3f;  
-    
-    // process lacks of 64-byte data 
-    if (temp1) 
+    temp1 = (temp1 >> 3) & 0x3f;
+
+    // process lacks of 64-byte data
+    if (temp1)
     {
         UCHAR *pAds = (UCHAR *) pCtx->Input + temp1;
-        
+
         if ((temp1+LenInBytes) < 64)
         {
-            NdisMoveMemory(pAds, (UCHAR *)pData, LenInBytes);   
+            NdisMoveMemory(pAds, (UCHAR *)pData, LenInBytes);
             return (0);
         }
-        
-        NdisMoveMemory(pAds, (UCHAR *)pData, 64-temp1);              
-        byteReverse((UCHAR *)pCtx->Input, 16);               
-        
+
+        NdisMoveMemory(pAds, (UCHAR *)pData, 64-temp1);
+        byteReverse((UCHAR *)pCtx->Input, 16);
+
         NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16);
         SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
 
         pData += 64-temp1;
-        LenInBytes -= 64-temp1; 
+        LenInBytes -= 64-temp1;
     } // end of if (temp1)
-    
-     
+
+
     TfTimes = (LenInBytes >> 6);
 
     for (i=TfTimes; i>0; i--)
     {
         NdisMoveMemory(pCtx->Input, (UCHAR *)pData, 64);
         byteReverse((UCHAR *)pCtx->Input, 16);
-        
+
         NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16);
         SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
         pData += 64;
@@ -557,8 +557,8 @@ UCHAR SHAUpdate(SHA_CTX *pCtx, UCHAR *pData, UINT32 LenInBytes)
 
 }
 
-// Append padding bits and length of original message in the tail 
-// The message digest has to be completed in the end 
+// Append padding bits and length of original message in the tail
+// The message digest has to be completed in the end
 VOID SHAFinal(SHA_CTX *pCtx, UCHAR Digest[20])
 {
     UCHAR Remainder;
@@ -571,79 +571,79 @@ VOID SHAFinal(SHA_CTX *pCtx, UCHAR Digest[20])
     pAppend = (UCHAR *)pCtx->Input + Remainder;
 
     PadLenInBytes = (Remainder < 56) ? (56-Remainder) : (120-Remainder);
-    
+
     // padding bits without crossing block(64-byte based) boundary
     if (Remainder < 56)
-    {       
+    {
         *pAppend = 0x80;
         PadLenInBytes --;
-        
-        NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, PadLenInBytes); 
-		 
+
+        NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, PadLenInBytes);
+
 		// add data-length field, from high to low
         for (i=0; i<4; i++)
         {
         	pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[1] >> ((3-i) << 3)) & 0xff);
         	pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[0] >> ((3-i) << 3)) & 0xff);
       	}
-      	
+
         byteReverse((UCHAR *)pCtx->Input, 16);
         NdisZeroMemory((UCHAR *)pCtx->Input + 64, 14);
         SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
     } // end of if
-    
+
     // padding bits with crossing block(64-byte based) boundary
     else
     {
         // the first block ===
         *pAppend = 0x80;
         PadLenInBytes --;
-        
-        NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, (64-Remainder-1)); 
+
+        NdisZeroMemory((UCHAR *)pCtx->Input + Remainder+1, (64-Remainder-1));
         PadLenInBytes -= (64 - Remainder - 1);
-        
+
         byteReverse((UCHAR *)pCtx->Input, 16);
         NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16);
         SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
 
 
         // the second block ===
-        NdisZeroMemory((UCHAR *)pCtx->Input, PadLenInBytes); 
-			
+        NdisZeroMemory((UCHAR *)pCtx->Input, PadLenInBytes);
+
 		// add data-length field
 		for (i=0; i<4; i++)
         {
         	pCtx->Input[56+i] = (UCHAR)((pCtx->LenInBitCount[1] >> ((3-i) << 3)) & 0xff);
         	pCtx->Input[60+i] = (UCHAR)((pCtx->LenInBitCount[0] >> ((3-i) << 3)) & 0xff);
       	}
-      	
+
         byteReverse((UCHAR *)pCtx->Input, 16);
-        NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16); 
+        NdisZeroMemory((UCHAR *)pCtx->Input + 64, 16);
         SHATransform(pCtx->Buf, (UINT32 *)pCtx->Input);
     } // end of else
-	
-		
+
+
     //Output, bytereverse
     for (i=0; i<20; i++)
     {
         Digest [i] = (UCHAR)(pCtx->Buf[i>>2] >> 8*(3-(i & 0x3)));
     }
-    
-    NdisZeroMemory(pCtx, sizeof(pCtx)); // memory free 
+
+    NdisZeroMemory(pCtx, sizeof(pCtx)); // memory free
 }
 
 
-// The central algorithm of SHA-1, consists of four rounds and 
+// The central algorithm of SHA-1, consists of four rounds and
 // twenty steps per round
 VOID SHATransform(UINT32 Buf[5], UINT32 Mes[20])
-{ 
-    UINT32 Reg[5],Temp; 
+{
+    UINT32 Reg[5],Temp;
 	unsigned int i;
-    UINT32 W[80]; 
-  
-    static UINT32 SHA1Table[4] = { 0x5a827999, 0x6ed9eba1, 
+    UINT32 W[80];
+
+    static UINT32 SHA1Table[4] = { 0x5a827999, 0x6ed9eba1,
                                   0x8f1bbcdc, 0xca62c1d6 };
- 
+
     Reg[0]=Buf[0];
 	Reg[1]=Buf[1];
 	Reg[2]=Buf[2];
@@ -652,37 +652,37 @@ VOID SHATransform(UINT32 Buf[5], UINT32 Mes[20])
 
     //the first octet of a word is stored in the 0th element, bytereverse
 	for(i = 0; i < 16; i++)
-    { 
+    {
     	W[i]  = (Mes[i] >> 24) & 0xff;
         W[i] |= (Mes[i] >> 8 ) & 0xff00;
         W[i] |= (Mes[i] << 8 ) & 0xff0000;
         W[i] |= (Mes[i] << 24) & 0xff000000;
     }
-    
-		 
+
+
     for	(i = 0; i < 64; i++)
 	    W[16+i] = CYCLIC_LEFT_SHIFT(W[i] ^ W[2+i] ^ W[8+i] ^ W[13+i], 1);
-	    
-    
+
+
     // 80 steps in SHA-1 algorithm
-    for (i=0; i<80; i++)                    
+    for (i=0; i<80; i++)
     {
         if (i<20)
-            SHA1Step(SHA1_F1, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4], 
+            SHA1Step(SHA1_F1, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4],
                      W[i], SHA1Table[0]);
-        
+
         else if (i>=20 && i<40)
-            SHA1Step(SHA1_F2, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4], 
+            SHA1Step(SHA1_F2, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4],
                      W[i], SHA1Table[1]);
-			
+
 		else if (i>=40 && i<60)
-            SHA1Step(SHA1_F3, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4], 
+            SHA1Step(SHA1_F3, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4],
                       W[i], SHA1Table[2]);
-			
+
         else
-            SHA1Step(SHA1_F2, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4], 
+            SHA1Step(SHA1_F2, Reg[0], Reg[1], Reg[2], Reg[3], Reg[4],
                      W[i], SHA1Table[3]);
-			
+
 
        // one-word right shift
 		Temp   = Reg[4];
@@ -690,15 +690,15 @@ VOID SHATransform(UINT32 Buf[5], UINT32 Mes[20])
         Reg[3] = Reg[2];
         Reg[2] = Reg[1];
         Reg[1] = Reg[0];
-        Reg[0] = Temp;       
-  
+        Reg[0] = Temp;
+
     } // end of for-loop
 
 
     // (temporary)output
     for (i=0; i<5; i++)
         Buf[i] += Reg[i];
-    
+
 }
 
 
@@ -1313,16 +1313,16 @@ void rtmp_aes_decrypt( aes_context *ctx,	uint8 input[16], uint8 output[16] )
 
 /*
 	========================================================================
-	
+
 	Routine Description:
-		SHA1 function 
+		SHA1 function
 
 	Arguments:
-		
+
 	Return Value:
 
 	Note:
-		
+
 	========================================================================
 */
 VOID	HMAC_SHA1(
@@ -1337,8 +1337,8 @@ VOID	HMAC_SHA1(
 	UCHAR	k_opad[65]; /* outer padding - key XORd with opad	*/
 	INT		i;
 
-	// if key is longer	than 64	bytes reset	it to key=SHA1(key)	
-	if (key_len	> 64) 
+	// if key is longer	than 64	bytes reset	it to key=SHA1(key)
+	if (key_len	> 64)
 	{
 		SHA_CTX		 tctx;
 		SHAInit(&tctx);
@@ -1351,20 +1351,20 @@ VOID	HMAC_SHA1(
 	NdisMoveMemory(k_ipad, key,	key_len);
 	NdisMoveMemory(k_opad, key,	key_len);
 
-	// XOR key with	ipad and opad values  
-	for	(i = 0;	i <	64;	i++) 
-	{	
+	// XOR key with	ipad and opad values
+	for	(i = 0;	i <	64;	i++)
+	{
 		k_ipad[i] ^= 0x36;
 		k_opad[i] ^= 0x5c;
 	}
 
-	// perform inner SHA1 
+	// perform inner SHA1
 	SHAInit(&context); 						/* init context for 1st pass */
 	SHAUpdate(&context,	k_ipad,	64);		/*	start with inner pad */
 	SHAUpdate(&context,	text, text_len);	/*	then text of datagram */
 	SHAFinal(&context, digest);				/* finish up 1st pass */
 
-	//perform outer	SHA1  
+	//perform outer	SHA1
 	SHAInit(&context);					/* init context for 2nd pass */
 	SHAUpdate(&context,	k_opad,	64);	/*	start with outer pad */
 	SHAUpdate(&context,	digest,	20);	/*	then results of	1st	hash */
@@ -1373,55 +1373,55 @@ VOID	HMAC_SHA1(
 }
 
 /*
-* F(P, S, c, i) = U1 xor U2 xor ... Uc 
-* U1 = PRF(P, S || Int(i)) 
-* U2 = PRF(P, U1) 
-* Uc = PRF(P, Uc-1) 
-*/ 
-
-void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output) 
-{ 
-    unsigned char digest[36], digest1[SHA_DIGEST_LEN]; 
-    int i, j; 
-
-    /* U1 = PRF(P, S || int(i)) */ 
-    memcpy(digest, ssid, ssidlength); 
-    digest[ssidlength] = (unsigned char)((count>>24) & 0xff); 
-    digest[ssidlength+1] = (unsigned char)((count>>16) & 0xff); 
-    digest[ssidlength+2] = (unsigned char)((count>>8) & 0xff); 
-    digest[ssidlength+3] = (unsigned char)(count & 0xff); 
+* F(P, S, c, i) = U1 xor U2 xor ... Uc
+* U1 = PRF(P, S || Int(i))
+* U2 = PRF(P, U1)
+* Uc = PRF(P, Uc-1)
+*/
+
+void F(char *password, unsigned char *ssid, int ssidlength, int iterations, int count, unsigned char *output)
+{
+    unsigned char digest[36], digest1[SHA_DIGEST_LEN];
+    int i, j;
+
+    /* U1 = PRF(P, S || int(i)) */
+    memcpy(digest, ssid, ssidlength);
+    digest[ssidlength] = (unsigned char)((count>>24) & 0xff);
+    digest[ssidlength+1] = (unsigned char)((count>>16) & 0xff);
+    digest[ssidlength+2] = (unsigned char)((count>>8) & 0xff);
+    digest[ssidlength+3] = (unsigned char)(count & 0xff);
     HMAC_SHA1(digest, ssidlength+4, (unsigned char*) password, (int) strlen(password), digest1); // for WPA update
 
-    /* output = U1 */ 
-    memcpy(output, digest1, SHA_DIGEST_LEN); 
+    /* output = U1 */
+    memcpy(output, digest1, SHA_DIGEST_LEN);
 
-    for (i = 1; i < iterations; i++) 
-    { 
-        /* Un = PRF(P, Un-1) */ 
+    for (i = 1; i < iterations; i++)
+    {
+        /* Un = PRF(P, Un-1) */
         HMAC_SHA1(digest1, SHA_DIGEST_LEN, (unsigned char*) password, (int) strlen(password), digest); // for WPA update
-        memcpy(digest1, digest, SHA_DIGEST_LEN); 
-
-        /* output = output xor Un */ 
-        for (j = 0; j < SHA_DIGEST_LEN; j++) 
-        { 
-            output[j] ^= digest[j]; 
-        } 
-    } 
+        memcpy(digest1, digest, SHA_DIGEST_LEN);
+
+        /* output = output xor Un */
+        for (j = 0; j < SHA_DIGEST_LEN; j++)
+        {
+            output[j] ^= digest[j];
+        }
+    }
 }
-/* 
-* password - ascii string up to 63 characters in length 
-* ssid - octet string up to 32 octets 
-* ssidlength - length of ssid in octets 
-* output must be 40 octets in length and outputs 256 bits of key 
-*/ 
-int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output) 
-{ 
-    if ((strlen(password) > 63) || (ssidlength > 32)) 
-        return 0; 
-
-    F(password, ssid, ssidlength, 4096, 1, output); 
-    F(password, ssid, ssidlength, 4096, 2, &output[SHA_DIGEST_LEN]); 
-    return 1; 
+/*
+* password - ascii string up to 63 characters in length
+* ssid - octet string up to 32 octets
+* ssidlength - length of ssid in octets
+* output must be 40 octets in length and outputs 256 bits of key
+*/
+int PasswordHash(char *password, unsigned char *ssid, int ssidlength, unsigned char *output)
+{
+    if ((strlen(password) > 63) || (ssidlength > 32))
+        return 0;
+
+    F(password, ssid, ssidlength, 4096, 1, output);
+    F(password, ssid, ssidlength, 4096, 2, &output[SHA_DIGEST_LEN]);
+    return 1;
 }
 
 
diff --git a/common/mlme.c b/common/mlme.c
index 6676eb7..2297470 100644
--- a/common/mlme.c
+++ b/common/mlme.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -36,7 +36,7 @@
 	John Chang	2004-09-06		modified for RT2600
 */
 
-#include "rt_config.h"
+#include "../rt_config.h"
 #include <stdarg.h>
 
 UCHAR	CISCO_OUI[] = {0x00, 0x40, 0x96};
@@ -322,8 +322,8 @@ UCHAR MULTICAST_ADDR[MAC_ADDR_LEN] = {0x1,  0x00, 0x00, 0x00, 0x00, 0x00};
 UCHAR BROADCAST_ADDR[MAC_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN]  = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
 
-// e.g. RssiSafeLevelForTxRate[RATE_36]" means if the current RSSI is greater than 
-//		this value, then it's quaranteed capable of operating in 36 mbps TX rate in 
+// e.g. RssiSafeLevelForTxRate[RATE_36]" means if the current RSSI is greater than
+//		this value, then it's quaranteed capable of operating in 36 mbps TX rate in
 //		clean environment.
 //								  TxRate: 1   2   5.5	11	 6	  9    12	18	 24   36   48	54	 72  100
 CHAR RssiSafeLevelForTxRate[] ={  -92, -91, -90, -87, -88, -86, -85, -83, -81, -78, -72, -71, -40, -40 };
@@ -357,7 +357,7 @@ UCHAR	SES_OUI[] = {0x00, 0x90, 0x4c};
 UCHAR	ZeroSsid[32] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
 
-// Reset the RFIC setting to new series    
+// Reset the RFIC setting to new series
 RTMP_RF_REGS RF2850RegTable[] = {
 //		ch	 R1 		 R2 		 R3(TX0~4=0) R4
 		{1,  0x98402ecc, 0x984c0786, 0x9816b455, 0x9800510b},
@@ -391,9 +391,9 @@ RTMP_RF_REGS RF2850RegTable[] = {
 
 		// 802.11 HyperLan 2
 		{100, 0x98402ec8, 0x984c06b2, 0x98178a55, 0x980ed783},
-		
-		// 2008.04.30 modified 
-		// The system team has AN to improve the EVM value 
+
+		// 2008.04.30 modified
+		// The system team has AN to improve the EVM value
 		// for channel 102 to 108 for the RT2850/RT2750 dual band solution.
 		{102, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed793},
 		{104, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed1a3},
@@ -435,7 +435,7 @@ RTMP_RF_REGS RF2850RegTable[] = {
 UCHAR	NUM_OF_2850_CHNL = (sizeof(RF2850RegTable) / sizeof(RTMP_RF_REGS));
 
 FREQUENCY_ITEM FreqItems3020[] =
-{	
+{
 	/**************************************************/
 	// ISM : 2.4 to 2.483 GHz                         //
 	/**************************************************/
@@ -462,7 +462,7 @@ FREQUENCY_ITEM FreqItems3020[] =
 /*
 	==========================================================================
 	Description:
-		initialize the MLME task and its data structure (queue, spinlock, 
+		initialize the MLME task and its data structure (queue, spinlock,
 		timer, state machines).
 
 	IRQL = PASSIVE_LEVEL
@@ -473,16 +473,16 @@ FREQUENCY_ITEM FreqItems3020[] =
 	==========================================================================
 */
 NDIS_STATUS MlmeInit(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
 
 	DBGPRINT(RT_DEBUG_TRACE, ("--> MLME Initialize\n"));
 
-	do 
+	do
 	{
 		Status = MlmeQueueInit(&pAd->Mlme.Queue);
-		if(Status != NDIS_STATUS_SUCCESS) 
+		if(Status != NDIS_STATUS_SUCCESS)
 			break;
 
 		pAd->Mlme.bRunning = FALSE;
@@ -499,19 +499,19 @@ NDIS_STATUS MlmeInit(
 			AuthRspStateMachineInit(pAd, &pAd->Mlme.AuthRspMachine, pAd->Mlme.AuthRspFunc);
 			SyncStateMachineInit(pAd, &pAd->Mlme.SyncMachine, pAd->Mlme.SyncFunc);
 			WpaPskStateMachineInit(pAd, &pAd->Mlme.WpaPskMachine, pAd->Mlme.WpaPskFunc);
-			AironetStateMachineInit(pAd, &pAd->Mlme.AironetMachine, pAd->Mlme.AironetFunc);		
+			AironetStateMachineInit(pAd, &pAd->Mlme.AironetMachine, pAd->Mlme.AironetFunc);
 
 #ifdef QOS_DLS_SUPPORT
 			DlsStateMachineInit(pAd, &pAd->Mlme.DlsMachine, pAd->Mlme.DlsFunc);
 #endif // QOS_DLS_SUPPORT //
 
 
-			// Since we are using switch/case to implement it, the init is different from the above 
+			// Since we are using switch/case to implement it, the init is different from the above
 			// state machine init
 			MlmeCntlInit(pAd, &pAd->Mlme.CntlMachine, NULL);
 		}
 #endif // CONFIG_STA_SUPPORT //
-		
+
 
 
 		ActionStateMachineInit(pAd, &pAd->Mlme.ActMachine, pAd->Mlme.ActFunc);
@@ -555,14 +555,14 @@ NDIS_STATUS MlmeInit(
 		Mlme has to be initialized, and there are something inside the queue
 	Note:
 		This function is invoked from MPSetInformation and MPReceive;
-		This task guarantee only one MlmeHandler will run. 
+		This task guarantee only one MlmeHandler will run.
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID MlmeHandler(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	MLME_QUEUE_ELEM 	   *Elem = NULL;
 #ifdef APCLI_SUPPORT
@@ -573,18 +573,18 @@ VOID MlmeHandler(
 	// get into this state machine
 
 	NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
-	if(pAd->Mlme.bRunning) 
+	if(pAd->Mlme.bRunning)
 	{
 		NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
 		return;
-	} 
-	else 
+	}
+	else
 	{
 		pAd->Mlme.bRunning = TRUE;
 	}
 	NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
 
-	while (!MlmeQueueEmpty(&pAd->Mlme.Queue)) 
+	while (!MlmeQueueEmpty(&pAd->Mlme.Queue))
 	{
 		if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS) ||
 			RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS) ||
@@ -593,21 +593,21 @@ VOID MlmeHandler(
 			DBGPRINT(RT_DEBUG_TRACE, ("Device Halted or Removed or MlmeRest, exit MlmeHandler! (queue num = %ld)\n", pAd->Mlme.Queue.Num));
 			break;
 		}
-		
-#ifdef RALINK_ATE			
+
+#ifdef RALINK_ATE
 		if(ATE_ON(pAd))
 		{
 			DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now in MlmeHandler\n"));
 			break;
-		}	
+		}
 #endif // RALINK_ATE //
 
 		//From message type, determine which state machine I should drive
-		if (MlmeDequeue(&pAd->Mlme.Queue, &Elem)) 
+		if (MlmeDequeue(&pAd->Mlme.Queue, &Elem))
 		{
 
 			// if dequeue success
-			switch (Elem->Machine) 
+			switch (Elem->Machine)
 			{
 				// STA state machines
 #ifdef	CONFIG_STA_SUPPORT
@@ -628,7 +628,7 @@ VOID MlmeHandler(
 					break;
 				case WPA_PSK_STATE_MACHINE:
 					StateMachinePerformAction(pAd, &pAd->Mlme.WpaPskMachine, Elem);
-					break;	
+					break;
 #ifdef LEAP_SUPPORT
 				case LEAP_STATE_MACHINE:
 					LeapMachinePerformAction(pAd, &pAd->Mlme.LeapMachine, Elem);
@@ -643,11 +643,11 @@ VOID MlmeHandler(
 					StateMachinePerformAction(pAd, &pAd->Mlme.DlsMachine, Elem);
 					break;
 #endif // QOS_DLS_SUPPORT //
-#endif // CONFIG_STA_SUPPORT //						
+#endif // CONFIG_STA_SUPPORT //
 
 				case ACTION_STATE_MACHINE:
 					StateMachinePerformAction(pAd, &pAd->Mlme.ActMachine, Elem);
-					break;	
+					break;
 
 
 
@@ -686,7 +686,7 @@ VOID MlmeHandler(
 	==========================================================================
  */
 VOID MlmeHalt(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	BOOLEAN 	  Cancelled;
 
@@ -786,12 +786,12 @@ unsigned long rx_Total;
 	==========================================================================
 	Description:
 		This routine is executed periodically to -
-		1. Decide if it's a right time to turn on PwrMgmt bit of all 
+		1. Decide if it's a right time to turn on PwrMgmt bit of all
 		   outgoiing frames
 		2. Calculate ChannelQuality based on statistics of the last
-		   period, so that TX rate won't toggling very frequently between a 
+		   period, so that TX rate won't toggling very frequently between a
 		   successful TX and a failed TX.
-		3. If the calculated ChannelQuality indicated current connection not 
+		3. If the calculated ChannelQuality indicated current connection not
 		   healthy, then a ROAMing attempt is tried here.
 
 	IRQL = DISPATCH_LEVEL
@@ -800,10 +800,10 @@ unsigned long rx_Total;
  */
 #define ADHOC_BEACON_LOST_TIME		(8*OS_HZ)  // 8 sec
 VOID MlmePeriodicExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
-	IN PVOID SystemSpecific3) 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
+	IN PVOID SystemSpecific3)
 {
 	ULONG			TxTotalCnt;
 	PRTMP_ADAPTER	pAd = (RTMP_ADAPTER *)FunctionContext;
@@ -841,12 +841,12 @@ VOID MlmePeriodicExec(
 					pAd->ExtraInfo = EXTRA_INFO_CLEAR;
 				}
 				else
-				{			    
+				{
 					MlmeRadioOff(pAd);
 					// Update extra information
 					pAd->ExtraInfo = HW_RADIO_OFF;
 				}
-			}		
+			}
 		}
 	}
 #endif // RT2860 //
@@ -859,7 +859,7 @@ VOID MlmePeriodicExec(
 								fRTMP_ADAPTER_RADIO_MEASUREMENT |
 								fRTMP_ADAPTER_RESET_IN_PROGRESS))))
 		return;
-	
+
 	RT28XX_MLME_PRE_SANITY_CHECK(pAd);
 
 #ifdef RALINK_ATE
@@ -884,7 +884,7 @@ VOID MlmePeriodicExec(
 		if (pAd->Mlme.PeriodicRound & 0x1)
 		{
 			// This is the fix for wifi 11n extension channel overlapping test case.  for 2860D
-			if (((pAd->MACVersion & 0xffff) == 0x0101) && 
+			if (((pAd->MACVersion & 0xffff) == 0x0101) &&
 				(STA_TGN_WIFI_ON(pAd)) &&
 				(pAd->CommonCfg.IOTestParm.bToggle == FALSE))
 
@@ -903,11 +903,11 @@ VOID MlmePeriodicExec(
 #endif // CONFIG_STA_SUPPORT //
 
 	pAd->bUpdateBcnCntDone = FALSE;
-	
+
 //	RECBATimerTimeout(SystemSpecific1,FunctionContext,SystemSpecific2,SystemSpecific3);
 	pAd->Mlme.PeriodicRound ++;
 
-	// execute every 500ms 
+	// execute every 500ms
 	if ((pAd->Mlme.PeriodicRound % 5 == 0) && RTMPAutoRateSwitchCheck(pAd)/*(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED))*/)
 	{
 #ifdef CONFIG_STA_SUPPORT
@@ -953,21 +953,21 @@ VOID MlmePeriodicExec(
 
 		if (rx_Total)
 		{
-			
+
 			// reset counters
 			rx_AMSDU = 0;
 			rx_Total = 0;
 		}
 
 		// Media status changed, report to NDIS
-		if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE)) 
+		if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE))
 		{
 			RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_MEDIA_STATE_CHANGE);
 			if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
 			{
 				pAd->IndicateMediaState = NdisMediaStateConnected;
 				RTMP_IndicateMediaState(pAd);
-					
+
 			}
 			else
 			{
@@ -980,7 +980,7 @@ VOID MlmePeriodicExec(
 
 		// add the most up-to-date h/w raw counters into software variable, so that
 		// the dynamic tuning mechanism below are based on most up-to-date information
-		NICUpdateRawCounters(pAd);																										
+		NICUpdateRawCounters(pAd);
 
 
 #ifdef DOT11_N_SUPPORT
@@ -992,8 +992,8 @@ VOID MlmePeriodicExec(
 		// The time period for checking antenna is according to traffic
 		if (pAd->Mlme.bEnableAutoAntennaCheck)
 		{
-			TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount + 
-							 pAd->RalinkCounters.OneSecTxRetryOkCount + 
+			TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
+							 pAd->RalinkCounters.OneSecTxRetryOkCount +
 							 pAd->RalinkCounters.OneSecTxFailCount;
 
 			if (TxTotalCnt > 50)
@@ -1022,19 +1022,19 @@ VOID MlmePeriodicExec(
 #ifdef CONFIG_STA_SUPPORT
 		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 		{
-#ifdef RT2860		
+#ifdef RT2860
 			if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) && (pAd->bPCIclkOff == FALSE))
 #endif // RT2860 //
 			{
 				// When Adhoc beacon is enabled and RTS/CTS is enabled, there is a chance that hardware MAC FSM will run into a deadlock
 				// and sending CTS-to-self over and over.
-				// Software Patch Solution: 
+				// Software Patch Solution:
 				// 1. Polling debug state register 0x10F4 every one second.
 				// 2. If in 0x10F4 the ((bit29==1) && (bit7==1)) OR ((bit29==1) && (bit5==1)), it means the deadlock has occurred.
 				// 3. If the deadlock occurred, reset MAC/BBP by setting 0x1004 to 0x0001 for a while then setting it back to 0x000C again.
 
 				UINT32	MacReg = 0;
-				
+
 				RTMP_IO_READ32(pAd, 0x10F4, &MacReg);
 				if (((MacReg & 0x20000000) && (MacReg & 0x80)) || ((MacReg & 0x20000000) && (MacReg & 0x20)))
 				{
@@ -1062,7 +1062,7 @@ VOID STAMlmePeriodicExec(
 	ULONG			    TxTotalCnt;
 
 //
-// We return here in ATE mode, because the statistics 
+// We return here in ATE mode, because the statistics
 // that ATE needs are not collected via this routine.
 //
 #ifdef RALINK_ATE
@@ -1073,8 +1073,8 @@ VOID STAMlmePeriodicExec(
 #endif // RALINK_ATE //
 
 #ifdef WPA_SUPPLICANT_SUPPORT
-    if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)    
-#endif // WPA_SUPPLICANT_SUPPORT //        
+    if (pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_DISABLE)
+#endif // WPA_SUPPLICANT_SUPPORT //
     {
     	// WPA MIC error should block association attempt for 60 seconds
     	if (pAd->StaCfg.bBlockAssoc && (pAd->StaCfg.LastMicErrorTime + (60 * OS_HZ) < pAd->Mlme.Now32))
@@ -1085,21 +1085,21 @@ VOID STAMlmePeriodicExec(
 	{
 		if (pAd->IndicateMediaState == NdisMediaStateConnected)
 		{
-			RTMPSendWirelessEvent(pAd, IW_STA_LINKUP_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); 
+			RTMPSendWirelessEvent(pAd, IW_STA_LINKUP_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
 		}
-		pAd->PreMediaState = pAd->IndicateMediaState;  
+		pAd->PreMediaState = pAd->IndicateMediaState;
 	}
 
 
-	
+
 
    	AsicStaBbpTuning(pAd);
 
-	TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount + 
-					 pAd->RalinkCounters.OneSecTxRetryOkCount + 
+	TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
+					 pAd->RalinkCounters.OneSecTxRetryOkCount +
 					 pAd->RalinkCounters.OneSecTxFailCount;
 
-	if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) 
+	if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
 	{
 		// update channel quality for Roaming and UI LinkQuality display
 		MlmeCalculateChannelQuality(pAd, pAd->Mlme.Now32);
@@ -1107,7 +1107,7 @@ VOID STAMlmePeriodicExec(
 
 	// must be AFTER MlmeDynamicTxRateSwitching() because it needs to know if
 	// Radio is currently in noisy environment
-	if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) 
+	if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
 		AsicAdjustTxPower(pAd);
 
 	if (INFRA_ON(pAd))
@@ -1143,7 +1143,7 @@ VOID STAMlmePeriodicExec(
     		{
     		    // Send out a NULL frame every 10 sec to inform AP that STA is still alive (Avoid being age out)
     			if ((pAd->Mlme.OneSecPeriodicRound % 10) == 8)
-                {         
+                {
                     if (pAd->CommonCfg.bWmmCapable)
     					RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, TRUE);
                     else
@@ -1160,28 +1160,28 @@ VOID STAMlmePeriodicExec(
 
 			// Lost AP, send disconnect & link down event
 			LinkDown(pAd, FALSE);
-			
+
 #ifdef WPA_SUPPLICANT_SUPPORT
 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
-            if (pAd->StaCfg.WpaSupplicantUP) 
+            if (pAd->StaCfg.WpaSupplicantUP)
 			{
                 union iwreq_data    wrqu;
                 //send disassociate event to wpa_supplicant
                 memset(&wrqu, 0, sizeof(wrqu));
                 wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
                 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
-            } 
+            }
 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
 #endif // WPA_SUPPLICANT_SUPPORT //
-			
+
 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
             {
                 union iwreq_data    wrqu;
                 memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
                 wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
             }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //        
-			
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+
 			MlmeAutoReconnectLastSSID(pAd);
 		}
 		else if (CQI_IS_BAD(pAd->Mlme.ChannelQuality))
@@ -1190,14 +1190,14 @@ VOID STAMlmePeriodicExec(
 			DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Bad CQI. Auto Recovery attempt #%ld\n", pAd->RalinkCounters.BadCQIAutoRecoveryCount));
 			MlmeAutoReconnectLastSSID(pAd);
 		}
-		
+
 		// Add auto seamless roaming
 		if (pAd->StaCfg.bFastRoaming)
 		{
 			SHORT	dBmToRoam = (SHORT)pAd->StaCfg.dBmToRoam;
-			
+
 			DBGPRINT(RT_DEBUG_TRACE, ("Rssi=%d, dBmToRoam=%d\n", RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2), (CHAR)dBmToRoam));
-			
+
 			if (RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2) <= (CHAR)dBmToRoam)
 			{
 				MlmeCheckForFastRoaming(pAd, pAd->Mlme.Now32);
@@ -1213,7 +1213,7 @@ VOID STAMlmePeriodicExec(
 		// minimum BEACON to tell the peer I'm alive.
 		// drawback is that this BEACON won't be well aligned at TBTT boundary.
 		// EnqueueBeaconFrame(pAd);			  // software send BEACON
-		
+
 		// if all 11b peers leave this BSS more than 5 seconds, update Tx rate,
 		// restore outgoing BEACON to support B/G-mixed mode
 		if ((pAd->CommonCfg.Channel <= 14)			   &&
@@ -1221,7 +1221,7 @@ VOID STAMlmePeriodicExec(
 			(pAd->CommonCfg.MaxDesiredRate > RATE_11)  &&
 			((pAd->StaCfg.Last11bBeaconRxTime + 5*OS_HZ) < pAd->Mlme.Now32))
 		{
-			DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - last 11B peer left, update Tx rates\n")); 
+			DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - last 11B peer left, update Tx rates\n"));
 			NdisMoveMemory(pAd->StaActive.SupRate, pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
 			pAd->StaActive.SupRateLen = pAd->CommonCfg.SupRateLen;
 			MlmeUpdateTxRates(pAd, FALSE, 0);
@@ -1264,8 +1264,8 @@ VOID STAMlmePeriodicExec(
 			OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
 		{
 			MLME_START_REQ_STRUCT     StartReq;
-			
-			DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - excessive BEACON lost, last STA in this IBSS, MediaState=Disconnected\n")); 
+
+			DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - excessive BEACON lost, last STA in this IBSS, MediaState=Disconnected\n"));
 			LinkDown(pAd, FALSE);
 
 			StartParmFill(pAd, &StartReq, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
@@ -1281,7 +1281,7 @@ VOID STAMlmePeriodicExec(
 			goto SKIP_AUTO_SCAN_CONN;
         else
             pAd->StaCfg.bScanReqIsFromWebUI = FALSE;
-      
+
 		if ((pAd->StaCfg.bAutoReconnect == TRUE)
 			&& RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP)
 			&& (MlmeValidateSSID(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen) == TRUE))
@@ -1318,7 +1318,7 @@ VOID STAMlmePeriodicExec(
 							MlmeAutoReconnectLastSSID(pAd);
 					}
 					else
-#endif // CARRIER_DETECTION_SUPPORT // 
+#endif // CARRIER_DETECTION_SUPPORT //
 						MlmeAutoReconnectLastSSID(pAd);
 				}
 			}
@@ -1353,15 +1353,15 @@ SKIP_AUTO_SCAN_CONN:
 
 // Link down report
 VOID LinkDownExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
-	IN PVOID SystemSpecific3) 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
+	IN PVOID SystemSpecific3)
 {
 
 	RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-	
-	pAd->IndicateMediaState = NdisMediaStateDisconnected;	
+
+	pAd->IndicateMediaState = NdisMediaStateDisconnected;
 	RTMP_IndicateMediaState(pAd);
     pAd->ExtraInfo = GENERAL_LINK_DOWN;
 }
@@ -1374,15 +1374,15 @@ VOID MlmeAutoScan(
 	if (pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE)
 	{
 		DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - Driver auto scan\n"));
-		MlmeEnqueue(pAd, 
-					MLME_CNTL_STATE_MACHINE, 
-					OID_802_11_BSSID_LIST_SCAN, 
-					0, 
+		MlmeEnqueue(pAd,
+					MLME_CNTL_STATE_MACHINE,
+					OID_802_11_BSSID_LIST_SCAN,
+					0,
 					NULL);
 		RT28XX_MLME_HANDLER(pAd);
 	}
 }
-	
+
 // IRQL = DISPATCH_LEVEL
 VOID MlmeAutoReconnectLastSSID(
 	IN PRTMP_ADAPTER pAd)
@@ -1390,7 +1390,7 @@ VOID MlmeAutoReconnectLastSSID(
 
 
 	// check CntlMachine.CurrState to avoid collision with NDIS SetOID request
-	if ((pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) && 
+	if ((pAd->Mlme.CntlMachine.CurrState == CNTL_IDLE) &&
 		(MlmeValidateSSID(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen) == TRUE))
 	{
 		NDIS_802_11_SSID OidSsid;
@@ -1398,10 +1398,10 @@ VOID MlmeAutoReconnectLastSSID(
 		NdisMoveMemory(OidSsid.Ssid, pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);
 
 		DBGPRINT(RT_DEBUG_TRACE, ("Driver auto reconnect to last OID_802_11_SSID setting - %s, len - %d\n", pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen));
-		MlmeEnqueue(pAd, 
-					MLME_CNTL_STATE_MACHINE, 
-					OID_802_11_SSID, 
-					sizeof(NDIS_802_11_SSID), 
+		MlmeEnqueue(pAd,
+					MLME_CNTL_STATE_MACHINE,
+					OID_802_11_SSID,
+					sizeof(NDIS_802_11_SSID),
 					&OidSsid);
 		RT28XX_MLME_HANDLER(pAd);
 	}
@@ -1451,7 +1451,7 @@ VOID MlmeSelectTxRateTable(
 			*ppTable = RateSwitchTable;
 			*pTableSize = RateSwitchTable[0];
 			*pInitTxRateIdx = RateSwitchTable[1];
-			
+
 			break;
 		}
 
@@ -1459,21 +1459,21 @@ VOID MlmeSelectTxRateTable(
 		if ((pAd->OpMode == OPMODE_STA) && ADHOC_ON(pAd))
 		{
 #ifdef DOT11_N_SUPPORT
-			if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && 
-				!pAd->StaCfg.AdhocBOnlyJoined && 
+			if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) &&
+				!pAd->StaCfg.AdhocBOnlyJoined &&
 				!pAd->StaCfg.AdhocBGJoined &&
-				(pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) && 
+				(pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) &&
 				((pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0x00) || (pAd->Antenna.field.TxPath == 1)))
 			{// 11N 1S Adhoc
 				*ppTable = RateSwitchTable11N1S;
 				*pTableSize = RateSwitchTable11N1S[0];
 				*pInitTxRateIdx = RateSwitchTable11N1S[1];
-				
+
 			}
-			else if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && 
-					!pAd->StaCfg.AdhocBOnlyJoined && 
+			else if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) &&
+					!pAd->StaCfg.AdhocBOnlyJoined &&
 					!pAd->StaCfg.AdhocBGJoined &&
-					(pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) && 
+					(pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0xff) &&
 					(pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0xff) &&
 					(pAd->Antenna.field.TxPath == 2))
 			{// 11N 2S Adhoc
@@ -1489,16 +1489,16 @@ VOID MlmeSelectTxRateTable(
 					*pTableSize = RateSwitchTable11N2SForABand[0];
 					*pInitTxRateIdx = RateSwitchTable11N2SForABand[1];
 				}
-				
+
 			}
 			else
-#endif // DOT11_N_SUPPORT //				
+#endif // DOT11_N_SUPPORT //
 				if (pAd->CommonCfg.PhyMode == PHY_11B)
 			{
 				*ppTable = RateSwitchTable11B;
 				*pTableSize = RateSwitchTable11B[0];
 				*pInitTxRateIdx = RateSwitchTable11B[1];
-				
+
 			}
 	        else if((pAd->LatchRfRegs.Channel <= 14) && (pAd->StaCfg.AdhocBOnlyJoined == TRUE))
 			{
@@ -1506,21 +1506,21 @@ VOID MlmeSelectTxRateTable(
 				*ppTable = RateSwitchTable11B;
 				*pTableSize = RateSwitchTable11B[0];
 				*pInitTxRateIdx = RateSwitchTable11B[1];
-				
+
 			}
 			else if (pAd->LatchRfRegs.Channel <= 14)
 			{
 				*ppTable = RateSwitchTable11BG;
 				*pTableSize = RateSwitchTable11BG[0];
 				*pInitTxRateIdx = RateSwitchTable11BG[1];
-				
+
 			}
 			else
 			{
 				*ppTable = RateSwitchTable11G;
 				*pTableSize = RateSwitchTable11G[0];
 				*pInitTxRateIdx = RateSwitchTable11G[1];
-				
+
 			}
 			break;
 		}
@@ -1533,7 +1533,7 @@ VOID MlmeSelectTxRateTable(
 			*ppTable = RateSwitchTable11BGN1S;
 			*pTableSize = RateSwitchTable11BGN1S[0];
 			*pInitTxRateIdx = RateSwitchTable11BGN1S[1];
-			
+
 			break;
 		}
 
@@ -1545,14 +1545,14 @@ VOID MlmeSelectTxRateTable(
 				*ppTable = RateSwitchTable11BGN2S;
 				*pTableSize = RateSwitchTable11BGN2S[0];
 				*pInitTxRateIdx = RateSwitchTable11BGN2S[1];
-				
+
 			}
 			else
 			{
 				*ppTable = RateSwitchTable11BGN2SForABand;
 				*pTableSize = RateSwitchTable11BGN2SForABand[0];
 				*pInitTxRateIdx = RateSwitchTable11BGN2SForABand[1];
-                		
+
 			}
 			break;
 		}
@@ -1562,7 +1562,7 @@ VOID MlmeSelectTxRateTable(
 			*ppTable = RateSwitchTable11N1S;
 			*pTableSize = RateSwitchTable11N1S[0];
 			*pInitTxRateIdx = RateSwitchTable11N1S[1];
-			
+
 			break;
 		}
 
@@ -1580,12 +1580,12 @@ VOID MlmeSelectTxRateTable(
 				*pTableSize = RateSwitchTable11N2SForABand[0];
 				*pInitTxRateIdx = RateSwitchTable11N2SForABand[1];
 			}
-			
+
 			break;
 		}
 #endif // DOT11_N_SUPPORT //
 		//else if ((pAd->StaActive.SupRateLen == 4) && (pAd->StaActive.ExtRateLen == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
-		if ((pEntry->RateLen == 4) 
+		if ((pEntry->RateLen == 4)
 #ifdef DOT11_N_SUPPORT
 			&& (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
 #endif // DOT11_N_SUPPORT //
@@ -1594,12 +1594,12 @@ VOID MlmeSelectTxRateTable(
 			*ppTable = RateSwitchTable11B;
 			*pTableSize = RateSwitchTable11B[0];
 			*pInitTxRateIdx = RateSwitchTable11B[1];
-			
+
 			break;
 		}
 
 		//else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen > 8) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
-		if ((pEntry->RateLen > 8) 
+		if ((pEntry->RateLen > 8)
 #ifdef DOT11_N_SUPPORT
 			&& (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
 #endif // DOT11_N_SUPPORT //
@@ -1608,12 +1608,12 @@ VOID MlmeSelectTxRateTable(
 			*ppTable = RateSwitchTable11BG;
 			*pTableSize = RateSwitchTable11BG[0];
 			*pInitTxRateIdx = RateSwitchTable11BG[1];
-			
+
 			break;
 		}
 
 		//else if ((pAd->StaActive.SupRateLen + pAd->StaActive.ExtRateLen == 8) && (pAd->StaActive.SupportedPhyInfo.MCSSet[0] == 0) && (pAd->StaActive.SupportedPhyInfo.MCSSet[1] == 0))
-		if ((pEntry->RateLen == 8) 
+		if ((pEntry->RateLen == 8)
 #ifdef DOT11_N_SUPPORT
 			&& (pEntry->HTCapability.MCSSet[0] == 0) && (pEntry->HTCapability.MCSSet[1] == 0)
 #endif // DOT11_N_SUPPORT //
@@ -1622,7 +1622,7 @@ VOID MlmeSelectTxRateTable(
 			*ppTable = RateSwitchTable11G;
 			*pTableSize = RateSwitchTable11G[0];
 			*pInitTxRateIdx = RateSwitchTable11G[1];
-			
+
 			break;
 		}
 #ifdef DOT11_N_SUPPORT
@@ -1647,9 +1647,9 @@ VOID MlmeSelectTxRateTable(
 					*ppTable = RateSwitchTable11G;
 					*pTableSize = RateSwitchTable11G[0];
 					*pInitTxRateIdx = RateSwitchTable11G[1];
-					
+
 				}
-				else		
+				else
 				{
 					*ppTable = RateSwitchTable11BG;
 					*pTableSize = RateSwitchTable11BG[0];
@@ -1672,7 +1672,7 @@ VOID MlmeSelectTxRateTable(
 					*ppTable = RateSwitchTable11N2S;
 					*pTableSize = RateSwitchTable11N2S[0];
 					*pInitTxRateIdx = RateSwitchTable11N2S[1];
-					DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 2S AP \n"));					
+					DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 2S AP \n"));
 				}
 			}
 			else
@@ -1689,7 +1689,7 @@ VOID MlmeSelectTxRateTable(
 					*ppTable = RateSwitchTable11N2SForABand;
 					*pTableSize = RateSwitchTable11N2SForABand[0];
 					*pInitTxRateIdx = RateSwitchTable11N2SForABand[1];
-					DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 2S AP \n"));					
+					DBGPRINT_RAW(RT_DEBUG_ERROR,("DRS: unkown mode,default use 11N 2S AP \n"));
 				}
 			}
 #endif // DOT11_N_SUPPORT //
@@ -1728,7 +1728,7 @@ VOID MlmeCheckForRoaming(
 	{
 		pBss = &pAd->ScanTab.BssEntry[i];
 
-		if ((pBss->LastBeaconRxTime + BEACON_LOST_TIME) < Now32) 
+		if ((pBss->LastBeaconRxTime + BEACON_LOST_TIME) < Now32)
 			continue;	 // AP disappear
 		if (pBss->Rssi <= RSSI_THRESHOLD_FOR_ROAMING)
 			continue;	 // RSSI too weak. forget it.
@@ -1737,7 +1737,7 @@ VOID MlmeCheckForRoaming(
 		if (pBss->Rssi < (pAd->StaCfg.RssiSample.LastRssi0 + RSSI_DELTA))
 			continue;	 // only AP with stronger RSSI is eligible for roaming
 
-		// AP passing all above rules is put into roaming candidate table		 
+		// AP passing all above rules is put into roaming candidate table
 		NdisMoveMemory(&pRoamTab->BssEntry[pRoamTab->BssNr], pBss, sizeof(BSS_ENTRY));
 		pRoamTab->BssNr += 1;
 	}
@@ -1753,7 +1753,7 @@ VOID MlmeCheckForRoaming(
 			RT28XX_MLME_HANDLER(pAd);
 		}
 	}
-	DBGPRINT(RT_DEBUG_TRACE, ("<== MlmeCheckForRoaming(# of candidate= %d)\n",pRoamTab->BssNr));   
+	DBGPRINT(RT_DEBUG_TRACE, ("<== MlmeCheckForRoaming(# of candidate= %d)\n",pRoamTab->BssNr));
 }
 
 /*
@@ -1789,11 +1789,11 @@ VOID MlmeCheckForFastRoaming(
 			continue;	 // skip current AP
 		if (!SSID_EQUAL(pBss->Ssid, pBss->SsidLen, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen))
 			continue;	 // skip different SSID
-        if (pBss->Rssi < (RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2) + RSSI_DELTA)) 
+        if (pBss->Rssi < (RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2) + RSSI_DELTA))
 			continue;	 // skip AP without better RSSI
-		
+
         DBGPRINT(RT_DEBUG_TRACE, ("LastRssi0 = %d, pBss->Rssi = %d\n", RTMPMaxRssi(pAd, pAd->StaCfg.RssiSample.LastRssi0, pAd->StaCfg.RssiSample.LastRssi1, pAd->StaCfg.RssiSample.LastRssi2), pBss->Rssi));
-		// AP passing all above rules is put into roaming candidate table		 
+		// AP passing all above rules is put into roaming candidate table
 		NdisMoveMemory(&pRoamTab->BssEntry[pRoamTab->BssNr], pBss, sizeof(BSS_ENTRY));
 		pRoamTab->BssNr += 1;
 	}
@@ -1828,9 +1828,9 @@ VOID MlmeCheckForFastRoaming(
 /*
 	==========================================================================
 	Description:
-		This routine calculates TxPER, RxPER of the past N-sec period. And 
-		according to the calculation result, ChannelQuality is calculated here 
-		to decide if current AP is still doing the job. 
+		This routine calculates TxPER, RxPER of the past N-sec period. And
+		according to the calculation result, ChannelQuality is calculated here
+		to decide if current AP is still doing the job.
 
 		If ChannelQuality is not good, a ROAMing attempt may be tried later.
 	Output:
@@ -1869,14 +1869,14 @@ VOID MlmeCalculateChannelQuality(
 	//
 	TxOkCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount + pAd->RalinkCounters.OneSecTxRetryOkCount;
 	TxCnt = TxOkCnt + pAd->RalinkCounters.OneSecTxFailCount;
-	if (TxCnt < 5) 
+	if (TxCnt < 5)
 	{
 		TxPER = 0;
 		TxPRR = 0;
 	}
-	else 
+	else
 	{
-		TxPER = (pAd->RalinkCounters.OneSecTxFailCount * 100) / TxCnt; 
+		TxPER = (pAd->RalinkCounters.OneSecTxFailCount * 100) / TxCnt;
 		TxPRR = ((TxCnt - pAd->RalinkCounters.OneSecTxNoRetryOkCount) * 100) / TxCnt;
 	}
 
@@ -1885,18 +1885,18 @@ VOID MlmeCalculateChannelQuality(
 	//
 	RxCnt = pAd->RalinkCounters.OneSecRxOkCnt + pAd->RalinkCounters.OneSecRxFcsErrCnt;
 	if (RxCnt < 5)
-		RxPER = 0;	
+		RxPER = 0;
 	else
 		RxPER = (pAd->RalinkCounters.OneSecRxFcsErrCnt * 100) / RxCnt;
 
 	//
 	// decide ChannelQuality based on: 1)last BEACON received time, 2)last RSSI, 3)TxPER, and 4)RxPER
 	//
-	if (INFRA_ON(pAd) && 
+	if (INFRA_ON(pAd) &&
 		(pAd->RalinkCounters.OneSecTxNoRetryOkCount < 2) && // no heavy traffic
 		(pAd->StaCfg.LastBeaconRxTime + BeaconLostTime < Now32))
 	{
-		DBGPRINT(RT_DEBUG_TRACE, ("BEACON lost > %ld msec with TxOkCnt=%ld -> CQI=0\n", BeaconLostTime, TxOkCnt)); 
+		DBGPRINT(RT_DEBUG_TRACE, ("BEACON lost > %ld msec with TxOkCnt=%ld -> CQI=0\n", BeaconLostTime, TxOkCnt));
 		pAd->Mlme.ChannelQuality = 0;
 	}
 	else
@@ -1908,15 +1908,15 @@ VOID MlmeCalculateChannelQuality(
 			NorRssi = 0;
 		else
 			NorRssi = (MaxRssi + 90) * 2;
-		
+
 		// ChannelQuality = W1*RSSI + W2*TxPRR + W3*RxPER	 (RSSI 0..100), (TxPER 100..0), (RxPER 100..0)
-		pAd->Mlme.ChannelQuality = (RSSI_WEIGHTING * NorRssi + 
-								   TX_WEIGHTING * (100 - TxPRR) + 
+		pAd->Mlme.ChannelQuality = (RSSI_WEIGHTING * NorRssi +
+								   TX_WEIGHTING * (100 - TxPRR) +
 								   RX_WEIGHTING* (100 - RxPER)) / 100;
 		if (pAd->Mlme.ChannelQuality >= 100)
 			pAd->Mlme.ChannelQuality = 100;
 	}
-	
+
 }
 
 VOID MlmeSetTxRate(
@@ -1925,7 +1925,7 @@ VOID MlmeSetTxRate(
 	IN PRTMP_TX_RATE_SWITCH	pTxRate)
 {
 	UCHAR	MaxMode = MODE_OFDM;
-	
+
 #ifdef DOT11_N_SUPPORT
 	MaxMode = MODE_HTGREENFIELD;
 
@@ -1939,8 +1939,8 @@ VOID MlmeSetTxRate(
 		pAd->StaCfg.HTPhyMode.field.MCS = pTxRate->CurrMCS;
 
 	if (pAd->StaCfg.HTPhyMode.field.MCS > 7)
-		pAd->StaCfg.HTPhyMode.field.STBC = STBC_NONE; 
-	
+		pAd->StaCfg.HTPhyMode.field.STBC = STBC_NONE;
+
    	if (ADHOC_ON(pAd))
 	{
 		// If peer adhoc is b-only mode, we can't send 11g rate.
@@ -2025,20 +2025,20 @@ VOID MlmeSetTxRate(
 		    pEntry->HTPhyMode.field.MODE = MODE_HTGREENFIELD;
 #endif // DOT11_N_SUPPORT //
 	}
-	
+
 	pAd->LastTxRate = (USHORT)(pEntry->HTPhyMode.word);
 }
 
 /*
 	==========================================================================
 	Description:
-		This routine calculates the acumulated TxPER of eaxh TxRate. And 
-		according to the calculation result, change CommonCfg.TxRate which 
-		is the stable TX Rate we expect the Radio situation could sustained. 
+		This routine calculates the acumulated TxPER of eaxh TxRate. And
+		according to the calculation result, change CommonCfg.TxRate which
+		is the stable TX Rate we expect the Radio situation could sustained.
 
-		CommonCfg.TxRate will change dynamically within {RATE_1/RATE_6, MaxTxRate} 
+		CommonCfg.TxRate will change dynamically within {RATE_1/RATE_6, MaxTxRate}
 	Output:
-		CommonCfg.TxRate - 
+		CommonCfg.TxRate -
 
 	IRQL = DISPATCH_LEVEL
 
@@ -2069,19 +2069,19 @@ VOID MlmeDynamicTxRateSwitching(
 		return;
 	}
 #endif // RALINK_ATE //
-	
+
 	/*if (pAd->Antenna.field.RxPath > 1)
 		Rssi = (pAd->StaCfg.RssiSample.AvgRssi0 + pAd->StaCfg.RssiSample.AvgRssi1) >> 1;
 	else
-		Rssi = pAd->StaCfg.RssiSample.AvgRssi0;*/	
+		Rssi = pAd->StaCfg.RssiSample.AvgRssi0;*/
 
 	//
 	// walk through MAC table, see if need to change AP's TX rate toward each entry
 	//
-   	for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) 
+   	for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++)
 	{
 		pEntry = &pAd->MacTab.Content[i];
-		
+
 		// check if this entry need to switch rate automatically
 		if (RTMPCheckEntryEnableAutoRateSwitch(pAd, pEntry) == FALSE)
 			continue;
@@ -2089,7 +2089,7 @@ VOID MlmeDynamicTxRateSwitching(
 		if ((pAd->MacTab.Size == 1) || (pEntry->ValidAsDls))
 		{
 			Rssi = RTMPMaxRssi(pAd, (CHAR)pAd->StaCfg.RssiSample.AvgRssi0, (CHAR)pAd->StaCfg.RssiSample.AvgRssi1, (CHAR)pAd->StaCfg.RssiSample.AvgRssi2);
-			
+
 			// Update statistic counter
 			RTMP_IO_READ32(pAd, TX_STA_CNT0, &TxStaCnt0.word);
 			RTMP_IO_READ32(pAd, TX_STA_CNT1, &StaTx1.word);
@@ -2105,23 +2105,23 @@ VOID MlmeDynamicTxRateSwitching(
 			pAd->WlanCounters.TransmittedFragmentCount.u.LowPart += StaTx1.field.TxSuccess;
 			pAd->WlanCounters.RetryCount.u.LowPart += StaTx1.field.TxRetransmit;
 			pAd->WlanCounters.FailedCount.u.LowPart += TxStaCnt0.field.TxFailCount;
-		
+
 			// if no traffic in the past 1-sec period, don't change TX rate,
-			// but clear all bad history. because the bad history may affect the next 
+			// but clear all bad history. because the bad history may affect the next
 			// Chariot throughput test
-			AccuTxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount + 
-						 pAd->RalinkCounters.OneSecTxRetryOkCount + 
+			AccuTxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
+						 pAd->RalinkCounters.OneSecTxRetryOkCount +
 						 pAd->RalinkCounters.OneSecTxFailCount;
-			
+
 			if (TxTotalCnt)
 				TxErrorRatio = ((TxRetransmit + TxFailCount) * 100) / TxTotalCnt;
 		}
 		else
 		{
 			Rssi = RTMPMaxRssi(pAd, (CHAR)pEntry->RssiSample.AvgRssi0, (CHAR)pEntry->RssiSample.AvgRssi1, (CHAR)pEntry->RssiSample.AvgRssi2);
-			
-			TxTotalCnt = pEntry->OneSecTxNoRetryOkCount + 
-				 pEntry->OneSecTxRetryOkCount + 
+
+			TxTotalCnt = pEntry->OneSecTxNoRetryOkCount +
+				 pEntry->OneSecTxRetryOkCount +
 				 pEntry->OneSecTxFailCount;
 
 			if (TxTotalCnt)
@@ -2140,12 +2140,12 @@ VOID MlmeDynamicTxRateSwitching(
 		// When switch from Fixed rate -> auto rate, the REAL TX rate might be different from pAd->CommonCfg.TxRateIndex.
 		// So need to sync here.
 		pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(CurrRateIdx+1)*5];
-		if ((pEntry->HTPhyMode.field.MCS != pCurrTxRate->CurrMCS) 
+		if ((pEntry->HTPhyMode.field.MCS != pCurrTxRate->CurrMCS)
 			//&& (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
 			)
 		{
-			
-			// Need to sync Real Tx rate and our record. 
+
+			// Need to sync Real Tx rate and our record.
 			// Then return for next DRS.
 			pCurrTxRate = (PRTMP_TX_RATE_SWITCH) &pTable[(InitTxRateIdx+1)*5];
 			pEntry->CurrTxRateIndex = InitTxRateIdx;
@@ -2189,13 +2189,13 @@ VOID MlmeDynamicTxRateSwitching(
 		}
 
 		//pAd->DrsCounters.LastTimeTxRateChangeAction = pAd->DrsCounters.LastSecTxRateChangeAction;
-		
+
 		//
 		// Keep the last time TxRateChangeAction status.
 		//
 		pEntry->LastTimeTxRateChangeAction = pEntry->LastSecTxRateChangeAction;
 
-		
+
 
 		//
 		// CASE 1. when TX samples are fewer than 15, then decide TX rate solely on RSSI
@@ -2206,7 +2206,7 @@ VOID MlmeDynamicTxRateSwitching(
 			CHAR	idx = 0;
 			UCHAR	TxRateIdx;
 			//UCHAR	MCS0 = 0, MCS1 = 0, MCS2 = 0, MCS3 = 0, MCS4 = 0, MCS7 = 0, MCS12 = 0, MCS13 = 0, MCS14 = 0, MCS15 = 0;
-			UCHAR	MCS0 = 0, MCS1 = 0, MCS2 = 0, MCS3 = 0, MCS4 = 0,  MCS5 =0, MCS6 = 0, MCS7 = 0;			
+			UCHAR	MCS0 = 0, MCS1 = 0, MCS2 = 0, MCS3 = 0, MCS4 = 0,  MCS5 =0, MCS6 = 0, MCS7 = 0;
 	        UCHAR	MCS12 = 0, MCS13 = 0, MCS14 = 0, MCS15 = 0;
 			UCHAR	MCS20 = 0, MCS21 = 0, MCS22 = 0, MCS23 = 0; // 3*3
 
@@ -2306,7 +2306,7 @@ VOID MlmeDynamicTxRateSwitching(
 					RssiOffset = 8;
 				}
 			}
-#ifdef DOT11_N_SUPPORT			
+#ifdef DOT11_N_SUPPORT
 			/*if (MCS15)*/
 			if ((pTable == RateSwitchTable11BGN3S) ||
 				(pTable == RateSwitchTable11N3S) ||
@@ -2422,7 +2422,7 @@ VOID MlmeDynamicTxRateSwitching(
 		do
 		{
 			BOOLEAN	bTrainUpDown = FALSE;
-			
+
 			pEntry->CurrTxRateStableTime ++;
 
 			// downgrade TX quality if PER >= Rate-Down threshold
@@ -2472,7 +2472,7 @@ VOID MlmeDynamicTxRateSwitching(
 
 			//
 			// For TxRate fast train up
-			// 
+			//
 			if (!pAd->StaCfg.StaQuickResponeForRateUpTimerRunning)
 			{
 				RTMPSetTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, 100);
@@ -2492,7 +2492,7 @@ VOID MlmeDynamicTxRateSwitching(
 
 			//
 			// For TxRate fast train down
-			// 
+			//
 			if (!pAd->StaCfg.StaQuickResponeForRateUpTimerRunning)
 			{
 				RTMPSetTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, 100);
@@ -2537,10 +2537,10 @@ VOID MlmeDynamicTxRateSwitching(
 	========================================================================
 */
 VOID StaQuickResponeForRateUpExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
-	IN PVOID SystemSpecific3) 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
+	IN PVOID SystemSpecific3)
 {
 	PRTMP_ADAPTER			pAd = (PRTMP_ADAPTER)FunctionContext;
 	UCHAR					UpRateIdx = 0, DownRateIdx = 0, CurrRateIdx = 0;
@@ -2563,7 +2563,7 @@ VOID StaQuickResponeForRateUpExec(
     //
     // walk through MAC table, see if need to change AP's TX rate toward each entry
     //
-	for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++) 
+	for (i = 1; i < MAX_LEN_OF_MAC_TABLE; i++)
 	{
 		pEntry = &pAd->MacTab.Content[i];
 
@@ -2636,15 +2636,15 @@ VOID StaQuickResponeForRateUpExec(
 		}
 		else
 		{
-			TxTotalCnt = pEntry->OneSecTxNoRetryOkCount + 
-				 pEntry->OneSecTxRetryOkCount + 
+			TxTotalCnt = pEntry->OneSecTxNoRetryOkCount +
+				 pEntry->OneSecTxRetryOkCount +
 				 pEntry->OneSecTxFailCount;
 
 			if (TxTotalCnt)
 				TxErrorRatio = ((pEntry->OneSecTxRetryOkCount + pEntry->OneSecTxFailCount) * 100) / TxTotalCnt;
 		}
 
-		
+
 		//
 		// CASE 1. when TX samples are fewer than 15, then decide TX rate solely on RSSI
 		//         (criteria copied from RT2500 for Netopia case)
@@ -2694,15 +2694,15 @@ VOID StaQuickResponeForRateUpExec(
 				{
 					pAd->CommonCfg.TxRateIndex = DownRateIdx;
 					pAd->DrsCounters.TxQuality[CurrRateIdx] = DRS_TX_QUALITY_WORST_BOUND;
-					
+
 				}
-				
+
 			}
 			else if ((pAd->DrsCounters.LastSecTxRateChangeAction == 2) && (CurrRateIdx != UpRateIdx))
 			{
 				if ((TxErrorRatio >= 50) || (TxErrorRatio >= TrainDown))
 				{
-					
+
 				}
 				else if ((pAd->DrsCounters.LastTxOkCount + 2) >= OneSecTxNoRetryOKRationCount)
 				{
@@ -2722,7 +2722,7 @@ VOID StaQuickResponeForRateUpExec(
 		else if (pAd->CommonCfg.TxRateIndex < CurrRateIdx)
 		{
 			DBGPRINT_RAW(RT_DEBUG_TRACE,("QuickDRS: --TX rate from %d to %d \n", CurrRateIdx, pAd->CommonCfg.TxRateIndex));
-			
+
 			pAd->DrsCounters.TxRateUpPenalty = 0;           // no penalty
 			pAd->DrsCounters.TxQuality[pAd->CommonCfg.TxRateIndex] = 0;
 			pAd->DrsCounters.PER[pAd->CommonCfg.TxRateIndex] = 0;
@@ -2743,10 +2743,10 @@ VOID StaQuickResponeForRateUpExec(
 /*
 	==========================================================================
 	Description:
-		This routine is executed periodically inside MlmePeriodicExec() after 
+		This routine is executed periodically inside MlmePeriodicExec() after
 		association with an AP.
 		It checks if StaCfg.Psm is consistent with user policy (recorded in
-		StaCfg.WindowsPowerMode). If not, enforce user policy. However, 
+		StaCfg.WindowsPowerMode). If not, enforce user policy. However,
 		there're some conditions to consider:
 		1. we don't support power-saving in ADHOC mode, so Psm=PWR_ACTIVE all
 		   the time when Mibss==TRUE
@@ -2800,12 +2800,12 @@ VOID MlmeCheckPsmChange(
 // IRQL = PASSIVE_LEVEL
 // IRQL = DISPATCH_LEVEL
 VOID MlmeSetPsmBit(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN USHORT psm)
 {
 	AUTO_RSP_CFG_STRUC csr4;
 
-	pAd->StaCfg.Psm = psm;	  
+	pAd->StaCfg.Psm = psm;
 	RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &csr4.word);
 	csr4.field.AckCtsPsmBit = (psm == PWR_SAVE)? 1:0;
 	RTMP_IO_WRITE32(pAd, AUTO_RSP_CFG, csr4.word);
@@ -2816,7 +2816,7 @@ VOID MlmeSetPsmBit(
 
 // IRQL = DISPATCH_LEVEL
 VOID MlmeSetTxPreamble(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN USHORT TxPreamble)
 {
 	AUTO_RSP_CFG_STRUC csr4;
@@ -2826,12 +2826,12 @@ VOID MlmeSetTxPreamble(
 	// Todo: remove the following line if short preamble functionality works
 	//
 	//TxPreamble = Rt802_11PreambleLong;
-	
+
 	RTMP_IO_READ32(pAd, AUTO_RSP_CFG, &csr4.word);
 	if (TxPreamble == Rt802_11PreambleLong)
 	{
 		DBGPRINT(RT_DEBUG_TRACE, ("MlmeSetTxPreamble (= LONG PREAMBLE)\n"));
-		OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED); 
+		OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED);
 		csr4.field.AutoResponderPreamble = 0;
 	}
 	else
@@ -2851,7 +2851,7 @@ VOID MlmeSetTxPreamble(
         Update basic rate bitmap
     ==========================================================================
  */
- 
+
 VOID UpdateBasicRateBitmap(
     IN  PRTMP_ADAPTER   pAdapter)
 {
@@ -2919,13 +2919,13 @@ VOID MlmeUpdateTxRates(
 	UCHAR *pSupRate, SupRateLen, *pExtRate, ExtRateLen;
 	PHTTRANSMIT_SETTING		pHtPhy = NULL;
 	PHTTRANSMIT_SETTING		pMaxHtPhy = NULL;
-	PHTTRANSMIT_SETTING		pMinHtPhy = NULL;	
+	PHTTRANSMIT_SETTING		pMinHtPhy = NULL;
 	BOOLEAN 				*auto_rate_cur_p;
 	UCHAR					HtMcs = MCS_AUTO;
 
 	// find max desired rate
 	UpdateBasicRateBitmap(pAd);
-	
+
 	num = 0;
 	auto_rate_cur_p = NULL;
 	for (i=0; i<MAX_LEN_OF_SUPPORTED_RATES; i++)
@@ -2957,13 +2957,13 @@ VOID MlmeUpdateTxRates(
 	{
 		pHtPhy 		= &pAd->StaCfg.HTPhyMode;
 		pMaxHtPhy	= &pAd->StaCfg.MaxHTPhyMode;
-		pMinHtPhy	= &pAd->StaCfg.MinHTPhyMode;		
-		
+		pMinHtPhy	= &pAd->StaCfg.MinHTPhyMode;
+
 		auto_rate_cur_p = &pAd->StaCfg.bAutoTxRateSwitch;
 		HtMcs 		= pAd->StaCfg.DesiredTransmitSetting.field.MCS;
-	
+
 		if ((pAd->StaCfg.BssType == BSS_ADHOC) &&
-			(pAd->CommonCfg.PhyMode == PHY_11B) && 
+			(pAd->CommonCfg.PhyMode == PHY_11B) &&
 			(MaxDesire > RATE_11))
 		{
 			MaxDesire = RATE_11;
@@ -2976,7 +2976,7 @@ VOID MlmeUpdateTxRates(
 	pMaxHtPhy->word = 0;
 	pHtPhy->word = 0;
 
-	// Auto rate switching is enabled only if more than one DESIRED RATES are 
+	// Auto rate switching is enabled only if more than one DESIRED RATES are
 	// specified; otherwise disabled
 	if (num <= 1)
 	{
@@ -3007,7 +3007,7 @@ VOID MlmeUpdateTxRates(
 		ExtRateLen = pAd->StaActive.ExtRateLen;
 	}
 	else
-#endif // CONFIG_STA_SUPPORT //	
+#endif // CONFIG_STA_SUPPORT //
 	{
 		pSupRate = &pAd->CommonCfg.SupRate[0];
 		pExtRate = &pAd->CommonCfg.ExtRate[0];
@@ -3036,9 +3036,9 @@ VOID MlmeUpdateTxRates(
 		}
 		if (MaxSupport < Rate)	MaxSupport = Rate;
 
-		if (MinSupport > Rate) MinSupport = Rate;		
+		if (MinSupport > Rate) MinSupport = Rate;
 	}
-	
+
 	for (i=0; i<ExtRateLen; i++)
 	{
 		switch (pExtRate[i] & 0x7f)
@@ -3059,11 +3059,11 @@ VOID MlmeUpdateTxRates(
 		}
 		if (MaxSupport < Rate)	MaxSupport = Rate;
 
-		if (MinSupport > Rate) MinSupport = Rate;		
+		if (MinSupport > Rate) MinSupport = Rate;
 	}
 
 	RTMP_IO_WRITE32(pAd, LEGACY_BASIC_RATE, BasicRateBitmap);
-	
+
 	// calculate the exptected ACK rate for each TX rate. This info is used to caculate
 	// the DURATION field of outgoing uniicast DATA/MGMT frame
 	for (i=0; i<MAX_LEN_OF_SUPPORTED_RATES; i++)
@@ -3091,7 +3091,7 @@ VOID MlmeUpdateTxRates(
 		if (bLinkUp == TRUE)
 			pAd->CommonCfg.TxRate = RATE_24;
 		else
-			pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate; 
+			pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate;
 
 		if (dbm < -75)
 			pAd->CommonCfg.TxRate = RATE_11;
@@ -3100,7 +3100,7 @@ VOID MlmeUpdateTxRates(
 
 		// should never exceed MaxTxRate (consider 11B-only mode)
 		if (pAd->CommonCfg.TxRate > pAd->CommonCfg.MaxTxRate)
-			pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate; 
+			pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate;
 
 		pAd->CommonCfg.TxRateIndex = 0;
 	}
@@ -3109,7 +3109,7 @@ VOID MlmeUpdateTxRates(
 		pAd->CommonCfg.TxRate = pAd->CommonCfg.MaxTxRate;
 		pHtPhy->field.MCS	= (pAd->CommonCfg.MaxTxRate > 3) ? (pAd->CommonCfg.MaxTxRate - 4) : pAd->CommonCfg.MaxTxRate;
 		pHtPhy->field.MODE	= (pAd->CommonCfg.MaxTxRate > 3) ? MODE_OFDM : MODE_CCK;
-		
+
 		pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC	= pHtPhy->field.STBC;
 		pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI	= pHtPhy->field.ShortGI;
 		pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS		= pHtPhy->field.MCS;
@@ -3141,7 +3141,7 @@ VOID MlmeUpdateTxRates(
 	}
 	else
 	{
-		switch (pAd->CommonCfg.PhyMode) 
+		switch (pAd->CommonCfg.PhyMode)
 		{
 			case PHY_11BG_MIXED:
 			case PHY_11B:
@@ -3160,7 +3160,7 @@ VOID MlmeUpdateTxRates(
 			case PHY_11GN_MIXED:
 			case PHY_11N_2_4G:
 			case PHY_11AN_MIXED:
-			case PHY_11N_5G:	
+			case PHY_11N_5G:
 #endif // DOT11_N_SUPPORT //
 				pAd->CommonCfg.MlmeRate = RATE_6;
 				pAd->CommonCfg.RtsRate = RATE_6;
@@ -3204,12 +3204,12 @@ VOID MlmeUpdateTxRates(
 		pAd->CommonCfg.BasicMlmeRate = pAd->CommonCfg.MlmeRate;
 	}
 
-	DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (MaxDesire=%d, MaxSupport=%d, MaxTxRate=%d, MinRate=%d, Rate Switching =%d)\n", 
-			 RateIdToMbps[MaxDesire], RateIdToMbps[MaxSupport], RateIdToMbps[pAd->CommonCfg.MaxTxRate], RateIdToMbps[pAd->CommonCfg.MinTxRate], 
+	DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (MaxDesire=%d, MaxSupport=%d, MaxTxRate=%d, MinRate=%d, Rate Switching =%d)\n",
+			 RateIdToMbps[MaxDesire], RateIdToMbps[MaxSupport], RateIdToMbps[pAd->CommonCfg.MaxTxRate], RateIdToMbps[pAd->CommonCfg.MinTxRate],
 			 /*OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED)*/*auto_rate_cur_p));
-	DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (TxRate=%d, RtsRate=%d, BasicRateBitmap=0x%04lx)\n", 
+	DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateTxRates (TxRate=%d, RtsRate=%d, BasicRateBitmap=0x%04lx)\n",
 			 RateIdToMbps[pAd->CommonCfg.TxRate], RateIdToMbps[pAd->CommonCfg.RtsRate], BasicRateBitmap));
-	DBGPRINT(RT_DEBUG_TRACE, ("MlmeUpdateTxRates (MlmeTransmit=0x%x, MinHTPhyMode=%x, MaxHTPhyMode=0x%x, HTPhyMode=0x%x)\n", 
+	DBGPRINT(RT_DEBUG_TRACE, ("MlmeUpdateTxRates (MlmeTransmit=0x%x, MinHTPhyMode=%x, MaxHTPhyMode=0x%x, HTPhyMode=0x%x)\n",
 			 pAd->CommonCfg.MlmeTransmit.word, pAd->MacTab.Content[BSSID_WCID].MinHTPhyMode.word ,pAd->MacTab.Content[BSSID_WCID].MaxHTPhyMode.word ,pAd->MacTab.Content[BSSID_WCID].HTPhyMode.word ));
 }
 
@@ -3220,7 +3220,7 @@ VOID MlmeUpdateTxRates(
 		This function update HT Rate setting.
 		Input Wcid value is valid for 2 case :
 		1. it's used for Station in infra mode that copy AP rate to Mactable.
-		2. OR Station 	in adhoc mode to copy peer's HT rate to Mactable. 
+		2. OR Station 	in adhoc mode to copy peer's HT rate to Mactable.
 
 	IRQL = DISPATCH_LEVEL
 
@@ -3233,33 +3233,33 @@ VOID MlmeUpdateHtTxRates(
 	UCHAR	StbcMcs; //j, StbcMcs, bitmask;
 	CHAR 	i; // 3*3
 	RT_HT_CAPABILITY 	*pRtHtCap = NULL;
-	RT_HT_PHY_INFO		*pActiveHtPhy = NULL;	
+	RT_HT_PHY_INFO		*pActiveHtPhy = NULL;
 	ULONG		BasicMCS;
 	UCHAR j, bitmask;
 	PRT_HT_PHY_INFO			pDesireHtPhy = NULL;
 	PHTTRANSMIT_SETTING		pHtPhy = NULL;
 	PHTTRANSMIT_SETTING		pMaxHtPhy = NULL;
-	PHTTRANSMIT_SETTING		pMinHtPhy = NULL;	
+	PHTTRANSMIT_SETTING		pMinHtPhy = NULL;
 	BOOLEAN 				*auto_rate_cur_p;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE,("MlmeUpdateHtTxRates===> \n"));
 
 	auto_rate_cur_p = NULL;
 
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
-	{		
+	{
 		pDesireHtPhy	= &pAd->StaCfg.DesiredHtPhyInfo;
 		pActiveHtPhy	= &pAd->StaCfg.DesiredHtPhyInfo;
 		pHtPhy 		= &pAd->StaCfg.HTPhyMode;
 		pMaxHtPhy	= &pAd->StaCfg.MaxHTPhyMode;
-		pMinHtPhy	= &pAd->StaCfg.MinHTPhyMode;		
-		
+		pMinHtPhy	= &pAd->StaCfg.MinHTPhyMode;
+
 		auto_rate_cur_p = &pAd->StaCfg.bAutoTxRateSwitch;
-	}		
+	}
 #endif // CONFIG_STA_SUPPORT //
 
-#ifdef CONFIG_STA_SUPPORT	
+#ifdef CONFIG_STA_SUPPORT
 	if ((ADHOC_ON(pAd) || INFRA_ON(pAd)) && (pAd->OpMode == OPMODE_STA))
 	{
 		if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
@@ -3306,8 +3306,8 @@ VOID MlmeUpdateHtTxRates(
 		pMaxHtPhy->field.ShortGI = (pAd->CommonCfg.DesiredHtPhy.ShortGIfor40 & pRtHtCap->ShortGIfor40);
 
 	for (i=23; i>=0; i--) // 3*3
-	{ 
-		j = i/8; 
+	{
+		j = i/8;
 		bitmask = (1<<(i-(j*8)));
 
 		if ((pActiveHtPhy->MCSSet[j] & bitmask) && (pDesireHtPhy->MCSSet[j] & bitmask))
@@ -3335,10 +3335,10 @@ VOID MlmeUpdateHtTxRates(
 			pMinHtPhy->field.MCS = 32;
 			DBGPRINT(RT_DEBUG_TRACE,("MlmeUpdateHtTxRates<=== Use Fixed MCS = %d\n",pMinHtPhy->field.MCS));
 		}
-		
+
 		for (i=23; (CHAR)i >= 0; i--) // 3*3
-		{	
-			j = i/8;	
+		{
+			j = i/8;
 			bitmask = (1<<(i-(j*8)));
 			if ( (pDesireHtPhy->MCSSet[j] & bitmask) && (pActiveHtPhy->MCSSet[j] & bitmask))
 			{
@@ -3351,8 +3351,8 @@ VOID MlmeUpdateHtTxRates(
 		}
 	}
 #endif // CONFIG_STA_SUPPORT //
-	
-	
+
+
 	// Decide ht rate
 	pHtPhy->field.STBC = pMaxHtPhy->field.STBC;
 	pHtPhy->field.BW = pMaxHtPhy->field.BW;
@@ -3365,7 +3365,7 @@ VOID MlmeUpdateHtTxRates(
 		*auto_rate_cur_p = FALSE;
 	else
 		*auto_rate_cur_p = TRUE;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, (" MlmeUpdateHtTxRates<---.AMsduSize = %d  \n", pAd->CommonCfg.DesiredHtPhy.AmsduSize ));
 	DBGPRINT(RT_DEBUG_TRACE,("TX: MCS[0] = %x (choose %d), BW = %d, ShortGI = %d, MODE = %d,  \n", pActiveHtPhy->MCSSet[0],pHtPhy->field.MCS,
 		pHtPhy->field.BW, pHtPhy->field.ShortGI, pHtPhy->field.MODE));
@@ -3383,7 +3383,7 @@ VOID MlmeRadioOff(
 // IRQL = DISPATCH_LEVEL
 VOID MlmeRadioOn(
 	IN PRTMP_ADAPTER pAd)
-{	
+{
 	RT28XX_MLME_RADIO_ON(pAd);
 }
 
@@ -3400,38 +3400,38 @@ VOID MlmeRadioOn(
 
  IRQL = PASSIVE_LEVEL
  IRQL = DISPATCH_LEVEL
-  
+
  */
 VOID BssTableInit(
-	IN BSS_TABLE *Tab) 
+	IN BSS_TABLE *Tab)
 {
 	int i;
 
 	Tab->BssNr = 0;
     Tab->BssOverlapNr = 0;
-	for (i = 0; i < MAX_LEN_OF_BSS_TABLE; i++) 
+	for (i = 0; i < MAX_LEN_OF_BSS_TABLE; i++)
 	{
 		NdisZeroMemory(&Tab->BssEntry[i], sizeof(BSS_ENTRY));
-		Tab->BssEntry[i].Rssi = -127;	// initial the rssi as a minimum value 
+		Tab->BssEntry[i].Rssi = -127;	// initial the rssi as a minimum value
 	}
 }
 
 #ifdef DOT11_N_SUPPORT
 VOID BATableInit(
-	IN PRTMP_ADAPTER pAd, 
-    IN BA_TABLE *Tab) 
+	IN PRTMP_ADAPTER pAd,
+    IN BA_TABLE *Tab)
 {
 	int i;
 
 	Tab->numAsOriginator = 0;
 	Tab->numAsRecipient = 0;
 	NdisAllocateSpinLock(&pAd->BATabLock);
-	for (i = 0; i < MAX_LEN_OF_BA_REC_TABLE; i++) 
+	for (i = 0; i < MAX_LEN_OF_BA_REC_TABLE; i++)
 	{
 		Tab->BARecEntry[i].REC_BA_Status = Recipient_NONE;
 		NdisAllocateSpinLock(&(Tab->BARecEntry[i].RxReRingLock));
 	}
-	for (i = 0; i < MAX_LEN_OF_BA_ORI_TABLE; i++) 
+	for (i = 0; i < MAX_LEN_OF_BA_ORI_TABLE; i++)
 	{
 		Tab->BAOriEntry[i].ORI_BA_Status = Originator_NONE;
 	}
@@ -3440,7 +3440,7 @@ VOID BATableInit(
 
 /*! \brief search the BSS table by SSID
  *	\param p_tab pointer to the bss table
- *	\param ssid SSID string 
+ *	\param ssid SSID string
  *	\return index of the table, BSS_NOT_FOUND if not in the table
  *	\pre
  *	\post
@@ -3450,22 +3450,22 @@ VOID BATableInit(
 
  */
 ULONG BssTableSearch(
-	IN BSS_TABLE *Tab, 
+	IN BSS_TABLE *Tab,
 	IN PUCHAR	 pBssid,
-	IN UCHAR	 Channel) 
+	IN UCHAR	 Channel)
 {
 	UCHAR i;
 
-	for (i = 0; i < Tab->BssNr; i++) 
+	for (i = 0; i < Tab->BssNr; i++)
 	{
 		//
 		// Some AP that support A/B/G mode that may used the same BSSID on 11A and 11B/G.
 		// We should distinguish this case.
-		//		
+		//
 		if ((((Tab->BssEntry[i].Channel <= 14) && (Channel <= 14)) ||
 			 ((Tab->BssEntry[i].Channel > 14) && (Channel > 14))) &&
-			MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid)) 
-		{ 
+			MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid))
+		{
 			return i;
 		}
 	}
@@ -3473,25 +3473,25 @@ ULONG BssTableSearch(
 }
 
 ULONG BssSsidTableSearch(
-	IN BSS_TABLE *Tab, 
+	IN BSS_TABLE *Tab,
 	IN PUCHAR	 pBssid,
 	IN PUCHAR	 pSsid,
 	IN UCHAR	 SsidLen,
-	IN UCHAR	 Channel) 
+	IN UCHAR	 Channel)
 {
 	UCHAR i;
 
-	for (i = 0; i < Tab->BssNr; i++) 
+	for (i = 0; i < Tab->BssNr; i++)
 	{
 		//
 		// Some AP that support A/B/G mode that may used the same BSSID on 11A and 11B/G.
 		// We should distinguish this case.
-		//		
+		//
 		if ((((Tab->BssEntry[i].Channel <= 14) && (Channel <= 14)) ||
 			 ((Tab->BssEntry[i].Channel > 14) && (Channel > 14))) &&
 			MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid) &&
-			SSID_EQUAL(pSsid, SsidLen, Tab->BssEntry[i].Ssid, Tab->BssEntry[i].SsidLen)) 
-		{ 
+			SSID_EQUAL(pSsid, SsidLen, Tab->BssEntry[i].Ssid, Tab->BssEntry[i].SsidLen))
+		{
 			return i;
 		}
 	}
@@ -3499,7 +3499,7 @@ ULONG BssSsidTableSearch(
 }
 
 ULONG BssTableSearchWithSSID(
-	IN BSS_TABLE *Tab, 
+	IN BSS_TABLE *Tab,
 	IN PUCHAR	 Bssid,
 	IN PUCHAR	 pSsid,
 	IN UCHAR	 SsidLen,
@@ -3507,15 +3507,15 @@ ULONG BssTableSearchWithSSID(
 {
 	UCHAR i;
 
-	for (i = 0; i < Tab->BssNr; i++) 
+	for (i = 0; i < Tab->BssNr; i++)
 	{
 		if ((((Tab->BssEntry[i].Channel <= 14) && (Channel <= 14)) ||
 			((Tab->BssEntry[i].Channel > 14) && (Channel > 14))) &&
 			MAC_ADDR_EQUAL(&(Tab->BssEntry[i].Bssid), Bssid) &&
 			(SSID_EQUAL(pSsid, SsidLen, Tab->BssEntry[i].Ssid, Tab->BssEntry[i].SsidLen) ||
-			(NdisEqualMemory(pSsid, ZeroSsid, SsidLen)) || 
+			(NdisEqualMemory(pSsid, ZeroSsid, SsidLen)) ||
 			(NdisEqualMemory(Tab->BssEntry[i].Ssid, ZeroSsid, Tab->BssEntry[i].SsidLen))))
-		{ 
+		{
 			return i;
 		}
 	}
@@ -3524,15 +3524,15 @@ ULONG BssTableSearchWithSSID(
 
 // IRQL = DISPATCH_LEVEL
 VOID BssTableDeleteEntry(
-	IN OUT	BSS_TABLE *Tab, 
+	IN OUT	BSS_TABLE *Tab,
 	IN		PUCHAR	  pBssid,
 	IN		UCHAR	  Channel)
 {
 	UCHAR i, j;
 
-	for (i = 0; i < Tab->BssNr; i++) 
+	for (i = 0; i < Tab->BssNr; i++)
 	{
-		if ((Tab->BssEntry[i].Channel == Channel) && 
+		if ((Tab->BssEntry[i].Channel == Channel) &&
 			(MAC_ADDR_EQUAL(Tab->BssEntry[i].Bssid, pBssid)))
 		{
 			for (j = i; j < Tab->BssNr - 1; j++)
@@ -3540,7 +3540,7 @@ VOID BssTableDeleteEntry(
 				NdisMoveMemory(&(Tab->BssEntry[j]), &(Tab->BssEntry[j + 1]), sizeof(BSS_ENTRY));
 			}
 			NdisZeroMemory(&(Tab->BssEntry[Tab->BssNr - 1]), sizeof(BSS_ENTRY));
-			Tab->BssNr -= 1;			
+			Tab->BssNr -= 1;
 			return;
 		}
 	}
@@ -3551,13 +3551,13 @@ VOID BssTableDeleteEntry(
 	========================================================================
 	Routine Description:
 		Delete the Originator Entry in BAtable. Or decrease numAs Originator by 1 if needed.
-		
+
 	Arguments:
 	// IRQL = DISPATCH_LEVEL
 	========================================================================
 */
 VOID BATableDeleteORIEntry(
-	IN OUT	PRTMP_ADAPTER pAd, 
+	IN OUT	PRTMP_ADAPTER pAd,
 	IN		BA_ORI_ENTRY	*pBAORIEntry)
 {
 
@@ -3581,31 +3581,31 @@ VOID BATableDeleteORIEntry(
 #endif // DOT11_N_SUPPORT //
 
 /*! \brief
- *	\param 
+ *	\param
  *	\return
  *	\pre
  *	\post
-	 
+
  IRQL = DISPATCH_LEVEL
- 
+
  */
 VOID BssEntrySet(
-	IN PRTMP_ADAPTER	pAd, 
-	OUT BSS_ENTRY *pBss, 
-	IN PUCHAR pBssid, 
-	IN CHAR Ssid[], 
-	IN UCHAR SsidLen, 
-	IN UCHAR BssType, 
-	IN USHORT BeaconPeriod, 
-	IN PCF_PARM pCfParm, 
-	IN USHORT AtimWin, 
-	IN USHORT CapabilityInfo, 
-	IN UCHAR SupRate[], 
+	IN PRTMP_ADAPTER	pAd,
+	OUT BSS_ENTRY *pBss,
+	IN PUCHAR pBssid,
+	IN CHAR Ssid[],
+	IN UCHAR SsidLen,
+	IN UCHAR BssType,
+	IN USHORT BeaconPeriod,
+	IN PCF_PARM pCfParm,
+	IN USHORT AtimWin,
+	IN USHORT CapabilityInfo,
+	IN UCHAR SupRate[],
 	IN UCHAR SupRateLen,
-	IN UCHAR ExtRate[], 
+	IN UCHAR ExtRate[],
 	IN UCHAR ExtRateLen,
 	IN HT_CAPABILITY_IE *pHtCapability,
-	IN ADD_HT_INFO_IE *pAddHtInfo,	// AP might use this additional ht info IE 
+	IN ADD_HT_INFO_IE *pAddHtInfo,	// AP might use this additional ht info IE
 	IN UCHAR			HtCapabilityLen,
 	IN UCHAR			AddHtInfoLen,
 	IN UCHAR			NewExtChanOffset,
@@ -3616,12 +3616,12 @@ VOID BssEntrySet(
 	IN PEDCA_PARM pEdcaParm,
 	IN PQOS_CAPABILITY_PARM pQosCapability,
 	IN PQBSS_LOAD_PARM pQbssLoad,
-	IN USHORT LengthVIE,	
-	IN PNDIS_802_11_VARIABLE_IEs pVIE) 
+	IN USHORT LengthVIE,
+	IN PNDIS_802_11_VARIABLE_IEs pVIE)
 {
 	COPY_MAC_ADDR(pBss->Bssid, pBssid);
 	// Default Hidden SSID to be TRUE, it will be turned to FALSE after coping SSID
-	pBss->Hidden = 1;	
+	pBss->Hidden = 1;
 	if (SsidLen > 0)
 	{
 		// For hidden SSID AP, it might send beacon with SSID len equal to 0
@@ -3640,17 +3640,17 @@ VOID BssEntrySet(
 		pBss->SsidLen = 0;
 	pBss->BssType = BssType;
 	pBss->BeaconPeriod = BeaconPeriod;
-	if (BssType == BSS_INFRA) 
+	if (BssType == BSS_INFRA)
 	{
-		if (pCfParm->bValid) 
+		if (pCfParm->bValid)
 		{
 			pBss->CfpCount = pCfParm->CfpCount;
 			pBss->CfpPeriod = pCfParm->CfpPeriod;
 			pBss->CfpMaxDuration = pCfParm->CfpMaxDuration;
 			pBss->CfpDurRemaining = pCfParm->CfpDurRemaining;
 		}
-	} 
-	else 
+	}
+	else
 	{
 		pBss->AtimWin = AtimWin;
 	}
@@ -3660,10 +3660,10 @@ VOID BssEntrySet(
 	// Combine with AuthMode, they will decide the connection methods.
 	pBss->Privacy = CAP_IS_PRIVACY_ON(pBss->CapabilityInfo);
 	ASSERT(SupRateLen <= MAX_LEN_OF_SUPPORTED_RATES);
-	if (SupRateLen <= MAX_LEN_OF_SUPPORTED_RATES)		
-		NdisMoveMemory(pBss->SupRate, SupRate, SupRateLen);	
-	else		
-		NdisMoveMemory(pBss->SupRate, SupRate, MAX_LEN_OF_SUPPORTED_RATES);	
+	if (SupRateLen <= MAX_LEN_OF_SUPPORTED_RATES)
+		NdisMoveMemory(pBss->SupRate, SupRate, SupRateLen);
+	else
+		NdisMoveMemory(pBss->SupRate, SupRate, MAX_LEN_OF_SUPPORTED_RATES);
 	pBss->SupRateLen = SupRateLen;
 	ASSERT(ExtRateLen <= MAX_LEN_OF_SUPPORTED_RATES);
 	NdisMoveMemory(pBss->ExtRate, ExtRate, ExtRateLen);
@@ -3704,7 +3704,7 @@ VOID BssEntrySet(
 		{
 			pBss->AddHtInfoLen = AddHtInfoLen;
 			NdisMoveMemory(&pBss->AddHtInfo, pAddHtInfo, AddHtInfoLen);
-			
+
 	 			if ((pAddHtInfo->ControlChan > 2)&& (pAddHtInfo->AddHtInfo.ExtChanOffset == EXTCHA_BELOW) && (pHtCapability->HtCapInfo.ChannelWidth == BW_40))
 	 			{
 	 				pBss->CentralChannel = pAddHtInfo->ControlChan - 2;
@@ -3716,7 +3716,7 @@ VOID BssEntrySet(
 		}
 	}
 #endif // DOT11_N_SUPPORT //
-	
+
 	BssCipherParse(pBss);
 
 	// new for QOS
@@ -3747,7 +3747,7 @@ VOID BssEntrySet(
 		pBss->bHasCountryIE = FALSE;
 #endif // EXT_BUILD_CHANNEL_LIST //
 		pEid = (PEID_STRUCT) pVIE;
-		while ((Length + 2 + (USHORT)pEid->Len) <= LengthVIE)    
+		while ((Length + 2 + (USHORT)pEid->Len) <= LengthVIE)
 		{
 			switch(pEid->Eid)
 			{
@@ -3775,21 +3775,21 @@ VOID BssEntrySet(
 						NdisMoveMemory(pBss->RsnIE.IE, pEid, pBss->RsnIE.IELen);
 			}
 				break;
-#ifdef EXT_BUILD_CHANNEL_LIST					
-				case IE_COUNTRY:					
+#ifdef EXT_BUILD_CHANNEL_LIST
+				case IE_COUNTRY:
 					NdisMoveMemory(&pBss->CountryString[0], pEid->Octet, 3);
 					pBss->bHasCountryIE = TRUE;
 					break;
 #endif // EXT_BUILD_CHANNEL_LIST //
             }
 			Length = Length + 2 + (USHORT)pEid->Len;  // Eid[1] + Len[1]+ content[Len]
-			pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);        
+			pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
 		}
 	}
 #endif // CONFIG_STA_SUPPORT //
 }
 
-/*! 
+/*!
  *	\brief insert an entry into the bss table
  *	\param p_tab The BSS table
  *	\param Bssid BSSID
@@ -3808,27 +3808,27 @@ VOID BssEntrySet(
  *	\pre
  *	\post
  *	\note If SSID is identical, the old entry will be replaced by the new one
-	 
+
  IRQL = DISPATCH_LEVEL
- 
+
  */
 ULONG BssTableSetEntry(
-	IN	PRTMP_ADAPTER	pAd, 
-	OUT BSS_TABLE *Tab, 
-	IN PUCHAR pBssid, 
-	IN CHAR Ssid[], 
-	IN UCHAR SsidLen, 
-	IN UCHAR BssType, 
-	IN USHORT BeaconPeriod, 
-	IN CF_PARM *CfParm, 
-	IN USHORT AtimWin, 
-	IN USHORT CapabilityInfo, 
+	IN	PRTMP_ADAPTER	pAd,
+	OUT BSS_TABLE *Tab,
+	IN PUCHAR pBssid,
+	IN CHAR Ssid[],
+	IN UCHAR SsidLen,
+	IN UCHAR BssType,
+	IN USHORT BeaconPeriod,
+	IN CF_PARM *CfParm,
+	IN USHORT AtimWin,
+	IN USHORT CapabilityInfo,
 	IN UCHAR SupRate[],
 	IN UCHAR SupRateLen,
 	IN UCHAR ExtRate[],
 	IN UCHAR ExtRateLen,
 	IN HT_CAPABILITY_IE *pHtCapability,
-	IN ADD_HT_INFO_IE *pAddHtInfo,	// AP might use this additional ht info IE 
+	IN ADD_HT_INFO_IE *pAddHtInfo,	// AP might use this additional ht info IE
 	IN UCHAR			HtCapabilityLen,
 	IN UCHAR			AddHtInfoLen,
 	IN UCHAR			NewExtChanOffset,
@@ -3839,13 +3839,13 @@ ULONG BssTableSetEntry(
 	IN PEDCA_PARM pEdcaParm,
 	IN PQOS_CAPABILITY_PARM pQosCapability,
 	IN PQBSS_LOAD_PARM pQbssLoad,
-	IN USHORT LengthVIE,	
+	IN USHORT LengthVIE,
 	IN PNDIS_802_11_VARIABLE_IEs pVIE)
 {
 	ULONG	Idx;
 
 	Idx = BssTableSearchWithSSID(Tab, pBssid,  Ssid, SsidLen, ChannelNo);
-	if (Idx == BSS_NOT_FOUND) 
+	if (Idx == BSS_NOT_FOUND)
 	{
 		if (Tab->BssNr >= MAX_LEN_OF_BSS_TABLE)
 	    {
@@ -3860,7 +3860,7 @@ ULONG BssTableSetEntry(
 					SSID_EQUAL(pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, Ssid, SsidLen))
 				{
 					Idx = Tab->BssOverlapNr;
-					BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod, CfParm, AtimWin, 
+					BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod, CfParm, AtimWin,
 						CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,pHtCapability, pAddHtInfo,HtCapabilityLen, AddHtInfoLen,
 						NewExtChanOffset, ChannelNo, Rssi, TimeStamp, CkipFlag, pEdcaParm, pQosCapability, pQbssLoad, LengthVIE, pVIE);
                     Tab->BssOverlapNr = (Tab->BssOverlapNr++) % MAX_LEN_OF_BSS_TABLE;
@@ -3873,14 +3873,14 @@ ULONG BssTableSetEntry(
 			}
 		}
 		Idx = Tab->BssNr;
-		BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod, CfParm, AtimWin, 
+		BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod, CfParm, AtimWin,
 					CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,pHtCapability, pAddHtInfo,HtCapabilityLen, AddHtInfoLen,
 					NewExtChanOffset, ChannelNo, Rssi, TimeStamp, CkipFlag, pEdcaParm, pQosCapability, pQbssLoad, LengthVIE, pVIE);
 		Tab->BssNr++;
-	} 
+	}
 	else
 	{
-		BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod,CfParm, AtimWin, 
+		BssEntrySet(pAd, &Tab->BssEntry[Idx], pBssid, Ssid, SsidLen, BssType, BeaconPeriod,CfParm, AtimWin,
 					CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,pHtCapability, pAddHtInfo,HtCapabilityLen, AddHtInfoLen,
 					NewExtChanOffset, ChannelNo, Rssi, TimeStamp, CkipFlag, pEdcaParm, pQosCapability, pQbssLoad, LengthVIE, pVIE);
 	}
@@ -3892,21 +3892,21 @@ ULONG BssTableSetEntry(
 #ifdef DOT11_N_SUPPORT
 #ifdef DOT11N_DRAFT3
 VOID  TriEventInit(
-	IN	PRTMP_ADAPTER	pAd) 
+	IN	PRTMP_ADAPTER	pAd)
 {
 	UCHAR		i;
 
 	for (i = 0;i < MAX_TRIGGER_EVENT;i++)
 		pAd->CommonCfg.TriggerEventTab.EventA[i].bValid = FALSE;
-	
+
 	pAd->CommonCfg.TriggerEventTab.EventANo = 0;
 	pAd->CommonCfg.TriggerEventTab.EventBCountDown = 0;
 }
 
 ULONG TriEventTableSetEntry(
-	IN	PRTMP_ADAPTER	pAd, 
-	OUT TRIGGER_EVENT_TAB *Tab, 
-	IN PUCHAR pBssid, 
+	IN	PRTMP_ADAPTER	pAd,
+	OUT TRIGGER_EVENT_TAB *Tab,
+	IN PUCHAR pBssid,
 	IN HT_CAPABILITY_IE *pHtCapability,
 	IN UCHAR			HtCapabilityLen,
 	IN UCHAR			RegClass,
@@ -3940,9 +3940,9 @@ ULONG TriEventTableSetEntry(
 				}
 				else
 					Tab->EventA[Tab->EventANo].RegClass = ??;
-					
+
 			}
-				
+
 			Tab->EventANo ++;
 		}
 	}
@@ -3950,20 +3950,20 @@ ULONG TriEventTableSetEntry(
 	{
 		Tab->EventBCountDown = pAd->CommonCfg.Dot11BssWidthChanTranDelay;
 	}
-	
+
 }
 
 /*
 	========================================================================
 	Routine Description:
 		Trigger Event table Maintainence called once every second.
-		
+
 	Arguments:
 	// IRQL = DISPATCH_LEVEL
 	========================================================================
 */
 VOID TriEventCounterMaintenance(
-	IN	PRTMP_ADAPTER	pAd) 
+	IN	PRTMP_ADAPTER	pAd)
 {
 	UCHAR		i;
 	BOOLEAN			bNotify = FALSE;
@@ -3974,7 +3974,7 @@ VOID TriEventCounterMaintenance(
 			pAd->CommonCfg.TriggerEventTab.EventA[i].CDCounter--;
 			if (pAd->CommonCfg.TriggerEventTab.EventA[i].CDCounter == 0)
 			{
-				pAd->CommonCfg.TriggerEventTab.EventA[i].bValid = FALSE;				
+				pAd->CommonCfg.TriggerEventTab.EventA[i].bValid = FALSE;
 				pAd->CommonCfg.TriggerEventTab.EventANo --;
 				// Need to send 20/40 Coexistence Notify frame if has status change.
 				bNotify = TRUE;
@@ -3996,23 +3996,23 @@ VOID TriEventCounterMaintenance(
 
 // IRQL = DISPATCH_LEVEL
 VOID BssTableSsidSort(
-	IN	PRTMP_ADAPTER	pAd, 
-	OUT BSS_TABLE *OutTab, 
-	IN	CHAR Ssid[], 
-	IN	UCHAR SsidLen) 
+	IN	PRTMP_ADAPTER	pAd,
+	OUT BSS_TABLE *OutTab,
+	IN	CHAR Ssid[],
+	IN	UCHAR SsidLen)
 {
 	INT i;
 	BssTableInit(OutTab);
 
-	for (i = 0; i < pAd->ScanTab.BssNr; i++) 
+	for (i = 0; i < pAd->ScanTab.BssNr; i++)
 	{
 		BSS_ENTRY *pInBss = &pAd->ScanTab.BssEntry[i];
 		BOOLEAN	bIsHiddenApIncluded = FALSE;
 
-		if (((pAd->CommonCfg.bIEEE80211H == 1) && 
-            (pAd->MlmeAux.Channel > 14) && 
+		if (((pAd->CommonCfg.bIEEE80211H == 1) &&
+            (pAd->MlmeAux.Channel > 14) &&
              RadarChannelCheck(pAd, pInBss->Channel))
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier             
+#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
              || (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
 #endif // CARRIER_DETECTION_SUPPORT //
             )
@@ -4021,7 +4021,7 @@ VOID BssTableSsidSort(
 				bIsHiddenApIncluded = TRUE;
 		}
 
-		if ((pInBss->BssType == pAd->StaCfg.BssType) && 
+		if ((pInBss->BssType == pAd->StaCfg.BssType) &&
 			(SSID_EQUAL(Ssid, SsidLen, pInBss->Ssid, pInBss->SsidLen) || bIsHiddenApIncluded))
 		{
 			BSS_ENTRY *pOutBss = &OutTab->BssEntry[OutTab->BssNr];
@@ -4055,7 +4055,7 @@ VOID BssTableSsidSort(
 				if ((pAd->StaCfg.AuthMode != pInBss->AuthMode) && (pAd->StaCfg.AuthMode != pInBss->AuthModeAux))
 					// None matched
 					continue;
-				
+
 				// Check cipher suite, AP must have more secured cipher than station setting
 				if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
 				{
@@ -4063,7 +4063,7 @@ VOID BssTableSsidSort(
 					if (pInBss->WPA.bMixMode == FALSE)
 						if (pAd->StaCfg.WepStatus != pInBss->WPA.GroupCipher)
 							continue;
-						
+
 					// check group cipher
 					if (pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher)
 						continue;
@@ -4071,10 +4071,10 @@ VOID BssTableSsidSort(
 					// check pairwise cipher, skip if none matched
 					// If profile set to AES, let it pass without question.
 					// If profile set to TKIP, we must find one mateched
-					if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) && 
-						(pAd->StaCfg.WepStatus != pInBss->WPA.PairCipher) && 
+					if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
+						(pAd->StaCfg.WepStatus != pInBss->WPA.PairCipher) &&
 						(pAd->StaCfg.WepStatus != pInBss->WPA.PairCipherAux))
-						continue;						
+						continue;
 				}
 				else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
 				{
@@ -4082,7 +4082,7 @@ VOID BssTableSsidSort(
 					if (pInBss->WPA2.bMixMode == FALSE)
 						if (pAd->StaCfg.WepStatus != pInBss->WPA2.GroupCipher)
 							continue;
-						
+
 					// check group cipher
 					if (pAd->StaCfg.WepStatus < pInBss->WPA2.GroupCipher)
 						continue;
@@ -4090,13 +4090,13 @@ VOID BssTableSsidSort(
 					// check pairwise cipher, skip if none matched
 					// If profile set to AES, let it pass without question.
 					// If profile set to TKIP, we must find one mateched
-					if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) && 
-						(pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipher) && 
+					if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
+						(pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipher) &&
 						(pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipherAux))
-						continue;						
+						continue;
 				}
-			}			
-			// Bss Type matched, SSID matched. 
+			}
+			// Bss Type matched, SSID matched.
 			// We will check wepstatus for qualification Bss
 			else if (pAd->StaCfg.WepStatus != pInBss->WepStatus)
 			{
@@ -4113,8 +4113,8 @@ VOID BssTableSsidSort(
 			// CCX also require not even try to connect it!!
 			if (SsidLen == 0)
 				continue;
-			
-#ifdef DOT11_N_SUPPORT			
+
+#ifdef DOT11_N_SUPPORT
 			// If both station and AP use 40MHz, still need to check if the 40MHZ band's legality in my country region
 			// If this 40MHz wideband is not allowed in my country list, use bandwidth 20MHZ instead,
 			if ((pInBss->CentralChannel != pInBss->Channel) &&
@@ -4135,7 +4135,7 @@ VOID BssTableSsidSort(
 				}
 			}
 #endif // DOT11_N_SUPPORT //
-			
+
 			// copy matching BSS from InTab to OutTab
 			NdisMoveMemory(pOutBss, pInBss, sizeof(BSS_ENTRY));
 
@@ -4164,7 +4164,7 @@ VOID BssTableSsidSort(
 				if ((pAd->StaCfg.AuthMode != pInBss->AuthMode) && (pAd->StaCfg.AuthMode != pInBss->AuthModeAux))
 					// None matched
 					continue;
-				
+
 				// Check cipher suite, AP must have more secured cipher than station setting
 				if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
 				{
@@ -4172,7 +4172,7 @@ VOID BssTableSsidSort(
 					if (pInBss->WPA.bMixMode == FALSE)
 						if (pAd->StaCfg.WepStatus != pInBss->WPA.GroupCipher)
 							continue;
-						
+
 					// check group cipher
 					if (pAd->StaCfg.WepStatus < pInBss->WPA.GroupCipher)
 						continue;
@@ -4180,10 +4180,10 @@ VOID BssTableSsidSort(
 					// check pairwise cipher, skip if none matched
 					// If profile set to AES, let it pass without question.
 					// If profile set to TKIP, we must find one mateched
-					if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) && 
-						(pAd->StaCfg.WepStatus != pInBss->WPA.PairCipher) && 
+					if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
+						(pAd->StaCfg.WepStatus != pInBss->WPA.PairCipher) &&
 						(pAd->StaCfg.WepStatus != pInBss->WPA.PairCipherAux))
-						continue;						
+						continue;
 				}
 				else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
 				{
@@ -4191,7 +4191,7 @@ VOID BssTableSsidSort(
 					if (pInBss->WPA2.bMixMode == FALSE)
 						if (pAd->StaCfg.WepStatus != pInBss->WPA2.GroupCipher)
 							continue;
-						
+
 					// check group cipher
 					if (pAd->StaCfg.WepStatus < pInBss->WPA2.GroupCipher)
 						continue;
@@ -4199,17 +4199,17 @@ VOID BssTableSsidSort(
 					// check pairwise cipher, skip if none matched
 					// If profile set to AES, let it pass without question.
 					// If profile set to TKIP, we must find one mateched
-					if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) && 
-						(pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipher) && 
+					if ((pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) &&
+						(pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipher) &&
 						(pAd->StaCfg.WepStatus != pInBss->WPA2.PairCipherAux))
-						continue;						
+						continue;
 				}
 			}
-			// Bss Type matched, SSID matched. 
+			// Bss Type matched, SSID matched.
 			// We will check wepstatus for qualification Bss
 			else if (pAd->StaCfg.WepStatus != pInBss->WepStatus)
 					continue;
-			
+
 #ifdef DOT11_N_SUPPORT
 			// If both station and AP use 40MHz, still need to check if the 40MHZ band's legality in my country region
 			// If this 40MHz wideband is not allowed in my country list, use bandwidth 20MHZ instead,
@@ -4224,7 +4224,7 @@ VOID BssTableSsidSort(
 				}
 			}
 #endif // DOT11_N_SUPPORT //
-			
+
 			// copy matching BSS from InTab to OutTab
 			NdisMoveMemory(pOutBss, pInBss, sizeof(BSS_ENTRY));
 
@@ -4241,16 +4241,16 @@ VOID BssTableSsidSort(
 
 // IRQL = DISPATCH_LEVEL
 VOID BssTableSortByRssi(
-	IN OUT BSS_TABLE *OutTab) 
+	IN OUT BSS_TABLE *OutTab)
 {
 	INT 	  i, j;
 	BSS_ENTRY TmpBss;
 
-	for (i = 0; i < OutTab->BssNr - 1; i++) 
+	for (i = 0; i < OutTab->BssNr - 1; i++)
 	{
-		for (j = i+1; j < OutTab->BssNr; j++) 
+		for (j = i+1; j < OutTab->BssNr; j++)
 		{
-			if (OutTab->BssEntry[j].Rssi > OutTab->BssEntry[i].Rssi) 
+			if (OutTab->BssEntry[j].Rssi > OutTab->BssEntry[i].Rssi)
 			{
 				NdisMoveMemory(&TmpBss, &OutTab->BssEntry[j], sizeof(BSS_ENTRY));
 				NdisMoveMemory(&OutTab->BssEntry[j], &OutTab->BssEntry[i], sizeof(BSS_ENTRY));
@@ -4303,7 +4303,7 @@ VOID BssCipherParse(
 	pBss->WPA2.RsnCapability = 0;
 	pBss->WPA2.bMixMode 	 = FALSE;
 
-	
+
 	Length = (INT) pBss->VarIELen;
 
 	while (Length > 0)
@@ -4338,8 +4338,8 @@ VOID BssCipherParse(
 							break;
 						default:
 							break;
-					}	
-	
+					}
+
 					// if Cisco IE_WPA, break
 					break;
 				}
@@ -4347,12 +4347,12 @@ VOID BssCipherParse(
 				{
 					pBss->bSES = TRUE;
 					break;
-				}				
+				}
 				else if (NdisEqualMemory(pEid->Octet, WPA_OUI, 4) != 1)
 				{
 					// if unsupported vendor specific IE
 					break;
-				}				
+				}
 				// Skip OUI, version, and multicast suite
 				// This part should be improved in the future when AP supported multiple cipher suite.
 				// For now, it's OK since almost all APs have fixed cipher suite supported.
@@ -4361,7 +4361,7 @@ VOID BssCipherParse(
 
 				// Cipher Suite Selectors from Spec P802.11i/D3.2 P26.
 				//	Value	   Meaning
-				//	0			None 
+				//	0			None
 				//	1			WEP-40
 				//	2			Tkip
 				//	3			WRAP
@@ -4387,7 +4387,7 @@ VOID BssCipherParse(
 				pTmp   += 1;
 
 				// skip all unicast cipher suites
-				//Count = *(PUSHORT) pTmp;				
+				//Count = *(PUSHORT) pTmp;
 				Count = (pTmp[1]<<8) + pTmp[0];
 				pTmp   += sizeof(USHORT);
 
@@ -4425,13 +4425,13 @@ VOID BssCipherParse(
 					pTmp++;
 					Count--;
 				}
-				
+
 				// 4. get AKM suite counts
 				//Count	= *(PUSHORT) pTmp;
 				Count = (pTmp[1]<<8) + pTmp[0];
 				pTmp   += sizeof(USHORT);
 				pTmp   += 3;
-				
+
 				switch (*pTmp)
 				{
 					case 1:
@@ -4464,17 +4464,17 @@ VOID BssCipherParse(
 						pBss->WPA.PairCipherAux = pBss->WPA.GroupCipher;
 				}
 				else
-					pBss->WepStatus   = pBss->WPA.PairCipher;					
-				
+					pBss->WepStatus   = pBss->WPA.PairCipher;
+
 				// Check the Pair & Group, if different, turn on mixed mode flag
 				if (pBss->WPA.GroupCipher != pBss->WPA.PairCipher)
 					pBss->WPA.bMixMode = TRUE;
-				
+
 				break;
 
 			case IE_RSN:
 				pRsnHeader = (PRSN_IE_HEADER_STRUCT) pTmp;
-				
+
 				// 0. Version must be 1
 				if (le2cpu16(pRsnHeader->Version) != 1)
 					break;
@@ -4507,7 +4507,7 @@ VOID BssCipherParse(
 				// 2. Get pairwise cipher counts
 				//Count = *(PUSHORT) pTmp;
 				Count = (pTmp[1]<<8) + pTmp[0];
-				pTmp   += sizeof(USHORT);			
+				pTmp   += sizeof(USHORT);
 
 				// 3. Get pairwise cipher
 				// Parsing all unicast cipher suite
@@ -4544,7 +4544,7 @@ VOID BssCipherParse(
 					pTmp += sizeof(CIPHER_SUITE_STRUCT);
 					Count--;
 				}
-				
+
 				// 4. get AKM suite counts
 				//Count	= *(PUSHORT) pTmp;
 				Count = (pTmp[1]<<8) + pTmp[0];
@@ -4588,17 +4588,17 @@ VOID BssCipherParse(
 					if (pBss->WPA.PairCipherAux == Ndis802_11WEPDisabled)
 						pBss->WPA.PairCipherAux = pBss->WPA.GroupCipher;
 				}
-				pBss->WepStatus   = pBss->WPA2.PairCipher;					
-				
+				pBss->WepStatus   = pBss->WPA2.PairCipher;
+
 				// 6. Get RSN capability
 				//pBss->WPA2.RsnCapability = *(PUSHORT) pTmp;
 				pBss->WPA2.RsnCapability = (pTmp[1]<<8) + pTmp[0];
 				pTmp += sizeof(USHORT);
-				
+
 				// Check the Pair & Group, if different, turn on mixed mode flag
 				if (pBss->WPA2.GroupCipher != pBss->WPA2.PairCipher)
 					pBss->WPA2.bMixMode = TRUE;
-				
+
 				break;
 			default:
 				break;
@@ -4618,12 +4618,12 @@ VOID BssCipherParse(
  *	\post
  */
 VOID MacAddrRandomBssid(
-	IN PRTMP_ADAPTER pAd, 
-	OUT PUCHAR pAddr) 
+	IN PRTMP_ADAPTER pAd,
+	OUT PUCHAR pAddr)
 {
 	INT i;
 
-	for (i = 0; i < MAC_ADDR_LEN; i++) 
+	for (i = 0; i < MAC_ADDR_LEN; i++)
 	{
 		pAddr[i] = RandomByte(pAd);
 	}
@@ -4644,18 +4644,18 @@ VOID MacAddrRandomBssid(
 
  IRQL = PASSIVE_LEVEL
  IRQL = DISPATCH_LEVEL
-  
+
  */
 VOID MgtMacHeaderInit(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN OUT PHEADER_802_11 pHdr80211, 
-	IN UCHAR SubType, 
-	IN UCHAR ToDs, 
-	IN PUCHAR pDA, 
-	IN PUCHAR pBssid) 
+	IN	PRTMP_ADAPTER	pAd,
+	IN OUT PHEADER_802_11 pHdr80211,
+	IN UCHAR SubType,
+	IN UCHAR ToDs,
+	IN PUCHAR pDA,
+	IN PUCHAR pBssid)
 {
 	NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
-	
+
 	pHdr80211->FC.Type = BTYPE_MGMT;
 	pHdr80211->FC.SubType = SubType;
 	pHdr80211->FC.ToDs = ToDs;
@@ -4672,8 +4672,8 @@ VOID MgtMacHeaderInit(
 // ===========================================================================================
 
 /*!***************************************************************************
- * This routine build an outgoing frame, and fill all information specified 
- * in argument list to the frame body. The actual frame size is the summation 
+ * This routine build an outgoing frame, and fill all information specified
+ * in argument list to the frame body. The actual frame size is the summation
  * of all arguments.
  * input params:
  *		Buffer - pointer to a pre-allocated memory segment
@@ -4682,16 +4682,16 @@ VOID MgtMacHeaderInit(
  *						   function will FAIL!!!
  * return:
  *		Size of the buffer
- * usage:  
+ * usage:
  *		MakeOutgoingFrame(Buffer, output_length, 2, &fc, 2, &dur, 6, p_addr1, 6,p_addr2, END_OF_ARGS);
 
  IRQL = PASSIVE_LEVEL
  IRQL = DISPATCH_LEVEL
-  
+
  ****************************************************************************/
 ULONG MakeOutgoingFrame(
-	OUT CHAR *Buffer, 
-	OUT ULONG *FrameLen, ...) 
+	OUT CHAR *Buffer,
+	OUT ULONG *FrameLen, ...)
 {
 	CHAR   *p;
 	int 	leng;
@@ -4701,10 +4701,10 @@ ULONG MakeOutgoingFrame(
 	// calculates the total length
 	TotLeng = 0;
 	va_start(Args, FrameLen);
-	do 
+	do
 	{
 		leng = va_arg(Args, int);
-		if (leng == END_OF_ARGS) 
+		if (leng == END_OF_ARGS)
 		{
 			break;
 		}
@@ -4730,10 +4730,10 @@ ULONG MakeOutgoingFrame(
  *	\note	Because this is done only once (at the init stage), no need to be locked
 
  IRQL = PASSIVE_LEVEL
- 
+
  */
 NDIS_STATUS MlmeQueueInit(
-	IN MLME_QUEUE *Queue) 
+	IN MLME_QUEUE *Queue)
 {
 	INT i;
 
@@ -4743,7 +4743,7 @@ NDIS_STATUS MlmeQueueInit(
 	Queue->Head = 0;
 	Queue->Tail = 0;
 
-	for (i = 0; i < MAX_LEN_OF_MLME_QUEUE; i++) 
+	for (i = 0; i < MAX_LEN_OF_MLME_QUEUE; i++)
 	{
 		Queue->Entry[i].Occupied = FALSE;
 		Queue->Entry[i].MsgLen = 0;
@@ -4766,14 +4766,14 @@ NDIS_STATUS MlmeQueueInit(
 
  IRQL = PASSIVE_LEVEL
  IRQL = DISPATCH_LEVEL
-  
+
  */
 BOOLEAN MlmeEnqueue(
 	IN	PRTMP_ADAPTER	pAd,
-	IN ULONG Machine, 
-	IN ULONG MsgType, 
-	IN ULONG MsgLen, 
-	IN VOID *Msg) 
+	IN ULONG Machine,
+	IN ULONG MsgType,
+	IN ULONG MsgLen,
+	IN VOID *Msg)
 {
 	INT Tail;
 	MLME_QUEUE	*Queue = (MLME_QUEUE *)&pAd->Mlme.Queue;
@@ -4789,8 +4789,8 @@ BOOLEAN MlmeEnqueue(
 		DBGPRINT_ERR(("MlmeEnqueue: msg too large, size = %ld \n", MsgLen));
 		return FALSE;
 	}
-	
-	if (MlmeQueueFull(Queue)) 
+
+	if (MlmeQueueFull(Queue))
 	{
 		return FALSE;
 	}
@@ -4799,22 +4799,22 @@ BOOLEAN MlmeEnqueue(
 	Tail = Queue->Tail;
 	Queue->Tail++;
 	Queue->Num++;
-	if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE) 
+	if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE)
 	{
 		Queue->Tail = 0;
 	}
-	
+
 	Queue->Entry[Tail].Wcid = RESERVED_WCID;
 	Queue->Entry[Tail].Occupied = TRUE;
 	Queue->Entry[Tail].Machine = Machine;
 	Queue->Entry[Tail].MsgType = MsgType;
-	Queue->Entry[Tail].MsgLen  = MsgLen;	
-	
+	Queue->Entry[Tail].MsgLen  = MsgLen;
+
 	if (Msg != NULL)
 	{
 		NdisMoveMemory(Queue->Entry[Tail].Msg, Msg, MsgLen);
 	}
-		
+
 	NdisReleaseSpinLock(&(Queue->Lock));
 	return TRUE;
 }
@@ -4829,28 +4829,28 @@ BOOLEAN MlmeEnqueue(
  *	\return  TRUE if everything ok, FALSE otherwise (like Queue Full)
  *	\pre
  *	\post
- 
+
  IRQL = DISPATCH_LEVEL
- 
+
  */
 BOOLEAN MlmeEnqueueForRecv(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN ULONG Wcid, 
-	IN ULONG TimeStampHigh, 
+	IN	PRTMP_ADAPTER	pAd,
+	IN ULONG Wcid,
+	IN ULONG TimeStampHigh,
 	IN ULONG TimeStampLow,
-	IN UCHAR Rssi0, 
-	IN UCHAR Rssi1, 
-	IN UCHAR Rssi2, 
-	IN ULONG MsgLen, 
+	IN UCHAR Rssi0,
+	IN UCHAR Rssi1,
+	IN UCHAR Rssi2,
+	IN ULONG MsgLen,
 	IN VOID *Msg,
-	IN UCHAR Signal) 
+	IN UCHAR Signal)
 {
 	INT 		 Tail, Machine;
 	PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
 	INT		 MsgType;
 	MLME_QUEUE	*Queue = (MLME_QUEUE *)&pAd->Mlme.Queue;
 
-#ifdef RALINK_ATE			
+#ifdef RALINK_ATE
 	/* Nothing to do in ATE mode */
 	if(ATE_ON(pAd))
 		return FALSE;
@@ -4871,7 +4871,7 @@ BOOLEAN MlmeEnqueueForRecv(
 		return FALSE;
 	}
 
-	if (MlmeQueueFull(Queue)) 
+	if (MlmeQueueFull(Queue))
 	{
 		return FALSE;
 	}
@@ -4879,7 +4879,7 @@ BOOLEAN MlmeEnqueueForRecv(
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 	{
-		if (!MsgTypeSubst(pAd, pFrame, &Machine, &MsgType)) 
+		if (!MsgTypeSubst(pAd, pFrame, &Machine, &MsgType))
 		{
 			DBGPRINT_ERR(("MlmeEnqueueForRecv: un-recongnized mgmt->subtype=%d\n",pFrame->Hdr.FC.SubType));
 			return FALSE;
@@ -4892,7 +4892,7 @@ BOOLEAN MlmeEnqueueForRecv(
 	Tail = Queue->Tail;
 	Queue->Tail++;
 	Queue->Num++;
-	if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE) 
+	if (Queue->Tail == MAX_LEN_OF_MLME_QUEUE)
 	{
 		Queue->Tail = 0;
 	}
@@ -4909,7 +4909,7 @@ BOOLEAN MlmeEnqueueForRecv(
 	Queue->Entry[Tail].Wcid = (UCHAR)Wcid;
 
 	Queue->Entry[Tail].Channel = pAd->LatchRfRegs.Channel;
-	
+
 	if (Msg != NULL)
 	{
 		NdisMoveMemory(Queue->Entry[Tail].Msg, Msg, MsgLen);
@@ -4934,14 +4934,14 @@ BOOLEAN MlmeEnqueueForRecv(
 
  */
 BOOLEAN MlmeDequeue(
-	IN MLME_QUEUE *Queue, 
-	OUT MLME_QUEUE_ELEM **Elem) 
+	IN MLME_QUEUE *Queue,
+	OUT MLME_QUEUE_ELEM **Elem)
 {
 	NdisAcquireSpinLock(&(Queue->Lock));
-	*Elem = &(Queue->Entry[Queue->Head]);    
+	*Elem = &(Queue->Entry[Queue->Head]);
 	Queue->Num--;
 	Queue->Head++;
-	if (Queue->Head == MAX_LEN_OF_MLME_QUEUE) 
+	if (Queue->Head == MAX_LEN_OF_MLME_QUEUE)
 	{
 		Queue->Head = 0;
 	}
@@ -4959,27 +4959,27 @@ VOID	MlmeRestartStateMachine(
 #ifdef CONFIG_STA_SUPPORT
 	BOOLEAN				Cancelled;
 #endif // CONFIG_STA_SUPPORT //
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("MlmeRestartStateMachine \n"));
 
 #ifdef RT2860
 	NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
-	if(pAd->Mlme.bRunning) 
+	if(pAd->Mlme.bRunning)
 	{
 		NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
 		return;
-	} 
-	else 
+	}
+	else
 	{
 		pAd->Mlme.bRunning = TRUE;
 	}
 	NdisReleaseSpinLock(&pAd->Mlme.TaskLock);
 
 	// Remove all Mlme queues elements
-	while (!MlmeQueueEmpty(&pAd->Mlme.Queue)) 
+	while (!MlmeQueueEmpty(&pAd->Mlme.Queue))
 	{
 		//From message type, determine which state machine I should drive
-		if (MlmeDequeue(&pAd->Mlme.Queue, &Elem)) 
+		if (MlmeDequeue(&pAd->Mlme.Queue, &Elem))
 		{
 			// free MLME element
 			Elem->Occupied = FALSE;
@@ -5038,8 +5038,8 @@ VOID	MlmeRestartStateMachine(
 #endif // QOS_DLS_SUPPORT //
 	}
 #endif // CONFIG_STA_SUPPORT //
-	
-#ifdef RT2860	
+
+#ifdef RT2860
 	// Remove running state
 	NdisAcquireSpinLock(&pAd->Mlme.TaskLock);
 	pAd->Mlme.bRunning = FALSE;
@@ -5052,12 +5052,12 @@ VOID	MlmeRestartStateMachine(
  *	\return TRUE if the Queue is empty, FALSE otherwise
  *	\pre
  *	\post
- 
+
  IRQL = DISPATCH_LEVEL
- 
+
  */
 BOOLEAN MlmeQueueEmpty(
-	IN MLME_QUEUE *Queue) 
+	IN MLME_QUEUE *Queue)
 {
 	BOOLEAN Ans;
 
@@ -5079,7 +5079,7 @@ BOOLEAN MlmeQueueEmpty(
 
  */
 BOOLEAN MlmeQueueFull(
-	IN MLME_QUEUE *Queue) 
+	IN MLME_QUEUE *Queue)
 {
 	BOOLEAN Ans;
 
@@ -5091,17 +5091,17 @@ BOOLEAN MlmeQueueFull(
 }
 
 /*! \brief	 The destructor of MLME Queue
- *	\param 
+ *	\param
  *	\return
  *	\pre
  *	\post
  *	\note	Clear Mlme Queue, Set Queue->Num to Zero.
 
  IRQL = PASSIVE_LEVEL
- 
+
  */
 VOID MlmeQueueDestroy(
-	IN MLME_QUEUE *pQueue) 
+	IN MLME_QUEUE *pQueue)
 {
 	NdisAcquireSpinLock(&(pQueue->Lock));
 	pQueue->Num  = 0;
@@ -5125,9 +5125,9 @@ VOID MlmeQueueDestroy(
 #ifdef CONFIG_STA_SUPPORT
 BOOLEAN MsgTypeSubst(
 	IN PRTMP_ADAPTER  pAd,
-	IN PFRAME_802_11 pFrame, 
-	OUT INT *Machine, 
-	OUT INT *MsgType) 
+	IN PFRAME_802_11 pFrame,
+	OUT INT *Machine,
+	OUT INT *MsgType)
 {
 	USHORT	Seq;
 	UCHAR	EAPType;
@@ -5137,16 +5137,16 @@ BOOLEAN MsgTypeSubst(
 	pData = (PUCHAR) pFrame + LENGTH_802_11;
 
 	// The only data type will pass to this function is EAPOL frame
-	if (pFrame->Hdr.FC.Type == BTYPE_DATA) 
-	{	 
+	if (pFrame->Hdr.FC.Type == BTYPE_DATA)
+	{
 		if (NdisEqualMemory(SNAP_AIRONET, pData, LENGTH_802_1_H))
 		{
 			// Cisco Aironet SNAP header
 			*Machine = AIRONET_STATE_MACHINE;
 			*MsgType = MT2_AIRONET_MSG;
-			return (TRUE);			
+			return (TRUE);
 		}
-#ifdef LEAP_SUPPORT		
+#ifdef LEAP_SUPPORT
 		if ( pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP ) //LEAP
 		{
 			// LEAP frames
@@ -5163,7 +5163,7 @@ BOOLEAN MsgTypeSubst(
 		}
 	}
 
-	switch (pFrame->Hdr.FC.SubType) 
+	switch (pFrame->Hdr.FC.SubType)
 	{
 		case SUBTYPE_ASSOC_REQ:
 			*Machine = ASSOC_STATE_MACHINE;
@@ -5204,17 +5204,17 @@ BOOLEAN MsgTypeSubst(
 		case SUBTYPE_AUTH:
 			// get the sequence number from payload 24 Mac Header + 2 bytes algorithm
 			NdisMoveMemory(&Seq, &pFrame->Octet[2], sizeof(USHORT));
-			if (Seq == 1 || Seq == 3) 
+			if (Seq == 1 || Seq == 3)
 			{
 				*Machine = AUTH_RSP_STATE_MACHINE;
 				*MsgType = MT2_PEER_AUTH_ODD;
-			} 
-			else if (Seq == 2 || Seq == 4) 
+			}
+			else if (Seq == 2 || Seq == 4)
 			{
 				*Machine = AUTH_STATE_MACHINE;
 				*MsgType = MT2_PEER_AUTH_EVEN;
-			} 
-			else 
+			}
+			else
 			{
 				return FALSE;
 			}
@@ -5226,14 +5226,14 @@ BOOLEAN MsgTypeSubst(
 		case SUBTYPE_ACTION:
 			*Machine = ACTION_STATE_MACHINE;
 			//  Sometimes Sta will return with category bytes with MSB = 1, if they receive catogory out of their support
-			if ((pFrame->Octet[0]&0x7F) > MAX_PEER_CATE_MSG) 
+			if ((pFrame->Octet[0]&0x7F) > MAX_PEER_CATE_MSG)
 			{
 				*MsgType = MT2_ACT_INVALID;
-			} 
+			}
 			else
 			{
 				*MsgType = (pFrame->Octet[0]&0x7F);
-			} 
+			}
 			break;
 		default:
 			return FALSE;
@@ -5249,27 +5249,27 @@ BOOLEAN MsgTypeSubst(
 // ===========================================================================================
 
 /*! \brief Initialize the state machine.
- *	\param *S			pointer to the state machine 
+ *	\param *S			pointer to the state machine
  *	\param	Trans		State machine transition function
- *	\param	StNr		number of states 
- *	\param	MsgNr		number of messages 
- *	\param	DefFunc 	default function, when there is invalid state/message combination 
- *	\param	InitState	initial state of the state machine 
+ *	\param	StNr		number of states
+ *	\param	MsgNr		number of messages
+ *	\param	DefFunc 	default function, when there is invalid state/message combination
+ *	\param	InitState	initial state of the state machine
  *	\param	Base		StateMachine base, internal use only
  *	\pre p_sm should be a legal pointer
  *	\post
 
  IRQL = PASSIVE_LEVEL
- 
+
  */
 VOID StateMachineInit(
-	IN STATE_MACHINE *S, 
-	IN STATE_MACHINE_FUNC Trans[], 
-	IN ULONG StNr, 
-	IN ULONG MsgNr, 
-	IN STATE_MACHINE_FUNC DefFunc, 
-	IN ULONG InitState, 
-	IN ULONG Base) 
+	IN STATE_MACHINE *S,
+	IN STATE_MACHINE_FUNC Trans[],
+	IN ULONG StNr,
+	IN ULONG MsgNr,
+	IN STATE_MACHINE_FUNC DefFunc,
+	IN ULONG InitState,
+	IN ULONG Base)
 {
 	ULONG i, j;
 
@@ -5281,9 +5281,9 @@ VOID StateMachineInit(
 	S->TransFunc  = Trans;
 
 	// init all state transition to default function
-	for (i = 0; i < StNr; i++) 
+	for (i = 0; i < StNr; i++)
 	{
-		for (j = 0; j < MsgNr; j++) 
+		for (j = 0; j < MsgNr; j++)
 		{
 			S->TransFunc[i * MsgNr + j] = DefFunc;
 		}
@@ -5293,7 +5293,7 @@ VOID StateMachineInit(
 	S->CurrState = InitState;
 }
 
-/*! \brief This function fills in the function pointer into the cell in the state machine 
+/*! \brief This function fills in the function pointer into the cell in the state machine
  *	\param *S	pointer to the state machine
  *	\param St	state
  *	\param Msg	incoming message
@@ -5302,23 +5302,23 @@ VOID StateMachineInit(
  *	\post
 
  IRQL = PASSIVE_LEVEL
- 
+
  */
 VOID StateMachineSetAction(
-	IN STATE_MACHINE *S, 
-	IN ULONG St, 
-	IN ULONG Msg, 
-	IN STATE_MACHINE_FUNC Func) 
+	IN STATE_MACHINE *S,
+	IN ULONG St,
+	IN ULONG Msg,
+	IN STATE_MACHINE_FUNC Func)
 {
 	ULONG MsgIdx;
 
 	MsgIdx = Msg - S->Base;
 
-	if (St < S->NrState && MsgIdx < S->NrMsg) 
+	if (St < S->NrState && MsgIdx < S->NrMsg)
 	{
 		// boundary checking before setting the action
 		S->TransFunc[St * S->NrMsg + MsgIdx] = Func;
-	} 
+	}
 }
 
 /*! \brief	 This function does the state transition
@@ -5326,14 +5326,14 @@ VOID StateMachineSetAction(
  *	\param	 *S 	  the state machine
  *	\param	 *Elem	  the message to be executed
  *	\return   None
- 
+
  IRQL = DISPATCH_LEVEL
- 
+
  */
 VOID StateMachinePerformAction(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN STATE_MACHINE *S, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN	PRTMP_ADAPTER	pAd,
+	IN STATE_MACHINE *S,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	(*(S->TransFunc[S->CurrState * S->NrMsg + Elem->MsgType - S->Base]))(pAd, Elem);
 }
@@ -5341,14 +5341,14 @@ VOID StateMachinePerformAction(
 /*
 	==========================================================================
 	Description:
-		The drop function, when machine executes this, the message is simply 
-		ignored. This function does nothing, the message is freed in 
+		The drop function, when machine executes this, the message is simply
+		ignored. This function does nothing, the message is freed in
 		StateMachinePerformAction()
 	==========================================================================
  */
 VOID Drop(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 }
 
@@ -5365,12 +5365,12 @@ VOID Drop(
 	==========================================================================
  */
 VOID LfsrInit(
-	IN PRTMP_ADAPTER pAd, 
-	IN ULONG Seed) 
+	IN PRTMP_ADAPTER pAd,
+	IN ULONG Seed)
 {
-	if (Seed == 0) 
+	if (Seed == 0)
 		pAd->Mlme.ShiftReg = 1;
-	else 
+	else
 		pAd->Mlme.ShiftReg = Seed;
 }
 
@@ -5380,7 +5380,7 @@ VOID LfsrInit(
 	==========================================================================
  */
 UCHAR RandomByte(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	ULONG i;
 	UCHAR R, Result;
@@ -5390,14 +5390,14 @@ UCHAR RandomByte(
 	if (pAd->Mlme.ShiftReg == 0)
 	NdisGetSystemUpTime((ULONG *)&pAd->Mlme.ShiftReg);
 
-	for (i = 0; i < 8; i++) 
+	for (i = 0; i < 8; i++)
 	{
-		if (pAd->Mlme.ShiftReg & 0x00000001) 
+		if (pAd->Mlme.ShiftReg & 0x00000001)
 		{
 			pAd->Mlme.ShiftReg = ((pAd->Mlme.ShiftReg ^ LFSR_MASK) >> 1) | 0x80000000;
 			Result = 1;
-		} 
-		else 
+		}
+		else
 		{
 			pAd->Mlme.ShiftReg = pAd->Mlme.ShiftReg >> 1;
 			Result = 0;
@@ -5545,7 +5545,7 @@ VOID AsicUpdateAutoFallBackTable(
 		Set MAC register value according operation mode.
 		OperationMode AND bNonGFExist are for MM and GF Proteciton.
 		If MM or GF mask is not set, those passing argument doesn't not take effect.
-		
+
 		Operation mode meaning:
 		= 0 : Pure HT, no preotection.
 		= 0x01; there may be non-HT devices in both the control and extension channel, protection is optional in BSS.
@@ -5560,7 +5560,7 @@ VOID 	AsicUpdateProtect(
 	IN 		USHORT			OperationMode,
 	IN 		UCHAR			SetMask,
 	IN		BOOLEAN			bDisableBGProtect,
-	IN		BOOLEAN			bNonGFExist)	
+	IN		BOOLEAN			bNonGFExist)
 {
 	PROT_CFG_STRUC	ProtCfg, ProtCfg4;
 	UINT32 Protect[6];
@@ -5581,9 +5581,9 @@ VOID 	AsicUpdateProtect(
 
 	if (pAd->BATable.numAsOriginator)
 	{
-		// 
+		//
 		// enable the RTS/CTS to avoid channel collision
-		// 
+		//
 		SetMask = ALLN_SETPROTECT;
 		OperationMode = 8;
 	}
@@ -5598,7 +5598,7 @@ VOID 	AsicUpdateProtect(
 	// If the user want disable RtsThreshold and enbale Amsdu/Ralink-Aggregation, set the RtsThreshold as 4096
         if ((
 #ifdef DOT11_N_SUPPORT
-			(pAd->CommonCfg.BACapability.field.AmsduEnable) || 
+			(pAd->CommonCfg.BACapability.field.AmsduEnable) ||
 #endif // DOT11_N_SUPPORT //
 			(pAd->CommonCfg.bAggregationCapable == TRUE))
             && pAd->CommonCfg.RtsThreshold == MAX_RTS_THRESHOLD)
@@ -5629,7 +5629,7 @@ VOID 	AsicUpdateProtect(
 	// update PHY mode and rate
 	if (pAd->CommonCfg.Channel > 14)
 		ProtCfg.field.ProtectRate = 0x4000;
-	ProtCfg.field.ProtectRate |= pAd->CommonCfg.RtsRate;	
+	ProtCfg.field.ProtectRate |= pAd->CommonCfg.RtsRate;
 
 	// Handle legacy(B/G) protection
 	if (bDisableBGProtect)
@@ -5655,7 +5655,7 @@ VOID 	AsicUpdateProtect(
 		switch(OperationMode)
 		{
 			case 0x0:
-				// NO PROTECT 
+				// NO PROTECT
 				// 1.All STAs in the BSS are 20/40 MHz HT
 				// 2. in ai 20/40MHz BSS
 				// 3. all STAs are 20MHz in a 20MHz BSS
@@ -5667,13 +5667,13 @@ VOID 	AsicUpdateProtect(
 				//	PROT_NAV(19:18)  -- 01 (Short NAV protection)
 				//  PROT_CTRL(17:16) -- 00 (None)
 				// 	PROT_RATE(15:0)  -- 0x4004 (OFDM 24M)
-				Protect[2] = 0x01744004;	
+				Protect[2] = 0x01744004;
 
 				// MM40_PROT_CFG
 				//	Reserved (31:27)
 				// 	PROT_TXOP(25:20) -- 111111
 				//	PROT_NAV(19:18)  -- 01 (Short NAV protection)
-				//  PROT_CTRL(17:16) -- 00 (None) 
+				//  PROT_CTRL(17:16) -- 00 (None)
 				// 	PROT_RATE(15:0)  -- 0x4084 (duplicate OFDM 24M)
 				Protect[3] = 0x03f44084;
 
@@ -5702,7 +5702,7 @@ VOID 	AsicUpdateProtect(
 				}
 				pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;
 				break;
-				
+
  			case 1:
 				// This is "HT non-member protection mode."
 				// If there may be non-HT STAs my BSS
@@ -5711,7 +5711,7 @@ VOID 	AsicUpdateProtect(
 				if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED))
 				{
 					ProtCfg.word = 0x01740003;	//ERP use Protection bit is set, use protection rate at Clause 18..
-					ProtCfg4.word = 0x03f40003; // Don't duplicate RTS/CTS in CCK mode. 0x03f40083; 
+					ProtCfg4.word = 0x03f40003; // Don't duplicate RTS/CTS in CCK mode. 0x03f40083;
 				}
 				//Assign Protection method for 20&40 MHz packets
 				ProtCfg.field.ProtectCtrl = ASIC_RTS;
@@ -5724,7 +5724,7 @@ VOID 	AsicUpdateProtect(
 				Protect[5] = ProtCfg4.word;
 				pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;
 				break;
-				
+
 			case 2:
 				// If only HT STAs are in BSS. at least one is 20MHz. Only protect 40MHz packets
 				ProtCfg.word = 0x01744004;  // PROT_CTRL(17:16) : 0 (None)
@@ -5745,7 +5745,7 @@ VOID 	AsicUpdateProtect(
 
 				pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;
 				break;
-				
+
 			case 3:
 				// HT mixed mode.	 PROTECT ALL!
 				// Assign Rate
@@ -5767,8 +5767,8 @@ VOID 	AsicUpdateProtect(
 				Protect[4] = ProtCfg.word;
 				Protect[5] = ProtCfg4.word;
 				pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;
-				break;	
-				
+				break;
+
 			case 8:
 				// Special on for Atheros problem n chip.
 				Protect[2] = 0x01754004;
@@ -5776,7 +5776,7 @@ VOID 	AsicUpdateProtect(
 				Protect[4] = 0x01754004;
 				Protect[5] = 0x03f54084;
 				pAd->CommonCfg.IOTestParm.bRTSLongProtOn = TRUE;
-				break;		
+				break;
 		}
 	}
 #endif // DOT11_N_SUPPORT //
@@ -5797,13 +5797,13 @@ VOID 	AsicUpdateProtect(
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID AsicSwitchChannel(
-					  IN PRTMP_ADAPTER pAd, 
+					  IN PRTMP_ADAPTER pAd,
 	IN	UCHAR			Channel,
-	IN	BOOLEAN			bScan) 
+	IN	BOOLEAN			bScan)
 {
 	ULONG			R2 = 0, R3 = DEFAULT_RF_TX_POWER, R4 = 0;
 	CHAR    TxPwer = 0, TxPwer2 = DEFAULT_RF_TX_POWER; //Bbp94 = BBPR94_DEFAULT, TxPwer2 = DEFAULT_RF_TX_POWER;
@@ -5889,7 +5889,7 @@ VOID AsicSwitchChannel(
 						{
 							TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2);
 							R4 |= (TxPwer2 << 7) | (1 << 6);
-						}                        
+						}
 					}
 					else
 					{
@@ -5946,7 +5946,7 @@ VOID AsicSwitchChannel(
 	if (Channel <= 14)
 	{
 	    ULONG	TxPinCfg = 0x00050F0A;//Gary 2007/08/09 0x050A0A
-		
+
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
@@ -5986,11 +5986,11 @@ VOID AsicSwitchChannel(
 	else
 	{
 	    ULONG	TxPinCfg = 0x00050F05;//Gary 2007/8/9 0x050505
-		
+
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
-		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0);//(0x44 - GET_LNA_GAIN(pAd)));   // According the Rory's suggestion to solve the middle range issue.     
+		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0);//(0x44 - GET_LNA_GAIN(pAd)));   // According the Rory's suggestion to solve the middle range issue.
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0xF2);
 
 		// Rx High power VGA offset for LNA select
@@ -6031,20 +6031,20 @@ VOID AsicSwitchChannel(
 
 	//
 	// On 11A, We should delay and wait RF/BBP to be stable
-	// and the appropriate time should be 1000 micro seconds 
+	// and the appropriate time should be 1000 micro seconds
 	// 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL.
 	//
-	RTMPusecDelay(1000);  
+	RTMPusecDelay(1000);
 
 	DBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%lu, Pwr1=%lu, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
-							  Channel, 
-							  pAd->RfIcType, 
+							  Channel,
+							  pAd->RfIcType,
 							  (R3 & 0x00003e00) >> 9,
 							  (R4 & 0x000007c0) >> 6,
 							  pAd->Antenna.field.TxPath,
-							  pAd->LatchRfRegs.R1, 
-							  pAd->LatchRfRegs.R2, 
-							  pAd->LatchRfRegs.R3, 
+							  pAd->LatchRfRegs.R1,
+							  pAd->LatchRfRegs.R2,
+							  pAd->LatchRfRegs.R3,
 							  pAd->LatchRfRegs.R4));
 }
 
@@ -6058,12 +6058,12 @@ VOID AsicSwitchChannel(
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID AsicLockChannel(
-	IN PRTMP_ADAPTER pAd, 
-	IN UCHAR Channel) 
+	IN PRTMP_ADAPTER pAd,
+	IN UCHAR Channel)
 {
 }
 
@@ -6073,18 +6073,18 @@ VOID AsicLockChannel(
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID	AsicAntennaSelect(
 	IN	PRTMP_ADAPTER	pAd,
-	IN	UCHAR			Channel) 
+	IN	UCHAR			Channel)
 {
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Antenna miscellaneous setting.
 
@@ -6096,13 +6096,13 @@ VOID	AsicAntennaSelect(
 		None
 
 	IRQL <= DISPATCH_LEVEL
-	
+
 	Note:
 		1.) Frame End type control
 			only valid for G only (RF_2527 & RF_2529)
 			0: means DPDT, set BBP R4 bit 5 to 1
 			1: means SPDT, set BBP R4 bit 5 to 0
-			
+
 
 	========================================================================
 */
@@ -6138,7 +6138,7 @@ VOID AsicRfTuningExec(
 	==========================================================================
  */
 VOID AsicAdjustTxPower(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	INT			i, j;
 	CHAR		DeltaPwr = 0;
@@ -6241,10 +6241,10 @@ VOID AsicAdjustTxPower(
 				}
 				// The index is the step we should decrease, idx = 0 means there is nothing to compensate
 				*pTxAgcCompensate = -(TxAgcStep * (idx-1));
-				
+
 				DeltaPwr += (*pTxAgcCompensate);
 				DBGPRINT(RT_DEBUG_TRACE, ("-- Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = -%d\n",
-					BbpR49, TssiRef, TxAgcStep, idx-1));                    
+					BbpR49, TssiRef, TxAgcStep, idx-1));
 			}
 			else if (BbpR49 < pTssiPlusBoundary[1])
 			{
@@ -6294,25 +6294,25 @@ VOID AsicAdjustTxPower(
 	do
 	{
 		UCHAR    TxPwrInEEPROM = 0xFF, CountryTxPwr = 0xFF, criterion;
-		UCHAR    AdjustMaxTxPwr[40]; 
+		UCHAR    AdjustMaxTxPwr[40];
 
 		if (pAd->CommonCfg.Channel > 14) // 5G band
 			TxPwrInEEPROM = ((pAd->CommonCfg.DefineMaxTxPwr & 0xFF00) >> 8);
 		else // 2.4G band
 			TxPwrInEEPROM = (pAd->CommonCfg.DefineMaxTxPwr & 0x00FF);
 		CountryTxPwr = GetCuntryMaxTxPwr(pAd, pAd->CommonCfg.Channel);
- 
+
 		// error handling, range check
 		if ((TxPwrInEEPROM > 0x50) || (CountryTxPwr > 0x50))
 		{
 			DBGPRINT(RT_DEBUG_ERROR,("AsicAdjustTxPower - Invalid max tx power (=0x%02x), CountryTxPwr=%d\n", TxPwrInEEPROM, CountryTxPwr));
 			break;
 		}
- 
+
 		criterion = *((PUCHAR)TxPwr + 2) & 0xF;        // FAE use OFDM 6M as criterion
 
 		DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (criterion=%d, TxPwrInEEPROM=%d, CountryTxPwr=%d)\n", criterion, TxPwrInEEPROM, CountryTxPwr));
- 
+
 		// Adjust max tx power according to the relationship of tx power in E2PROM
 		for (i=0; i<5; i++)
 		{
@@ -6323,7 +6323,7 @@ VOID AsicAdjustTxPower(
 				for (j=0; j<8; j++)
 				{
 					Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F);
- 
+
 					if (j < 4)
 					{
 						// CCK will have 4dBm larger than OFDM
@@ -6341,13 +6341,13 @@ VOID AsicAdjustTxPower(
 				for (j=0; j<8; j++)
 				{
 					Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F);
- 
+
 					AdjustMaxTxPwr[i*8+j] = TxPwrInEEPROM + (Value - criterion);
 					DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
 				}
 			}
 		}
- 
+
 		// Adjust tx power according to the relationship
 		for (i=0; i<5; i++)
 		{
@@ -6356,7 +6356,7 @@ VOID AsicAdjustTxPower(
 				for (j=0; j<8; j++)
 				{
 					Value = (CHAR)((TxPwr[i] >> j*4) & 0x0F);
- 
+
 					// The system tx power is larger than the regulatory, the power should be restrain
 					if (AdjustMaxTxPwr[i*8+j] > CountryTxPwr)
 					{
@@ -6365,12 +6365,12 @@ VOID AsicAdjustTxPower(
 							Value -= (AdjustMaxTxPwr[i*8+j] - CountryTxPwr);
 						else
 							Value = 0;
- 
+
 						DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
 					}
 					else
 						DBGPRINT_RAW(RT_DEBUG_TRACE,("AsicAdjustTxPower (i/j=%d/%d, Value=%d, %d, no change)\n", i, j, Value, AdjustMaxTxPwr[i*8+j]));
- 
+
 						TxPwr[i] = (TxPwr[i] & ~(0x0000000F << j*4)) | (Value << j*4);
 				}
 			}
@@ -6451,7 +6451,7 @@ VOID AsicAdjustTxPower(
 /*
 	==========================================================================
 	Description:
-		put PHY to sleep here, and set next wakeup timer. PHY doesn't not wakeup 
+		put PHY to sleep here, and set next wakeup timer. PHY doesn't not wakeup
 		automatically. Instead, MCU will issue a TwakeUpInterrupt to host after
 		the wakeup timer timeout. Driver has to issue a separate command to wake
 		PHY up.
@@ -6461,8 +6461,8 @@ VOID AsicAdjustTxPower(
 	==========================================================================
  */
 VOID AsicSleepThenAutoWakeup(
-	IN PRTMP_ADAPTER pAd, 
-	IN USHORT TbttNumToNextWakeUp) 
+	IN PRTMP_ADAPTER pAd,
+	IN USHORT TbttNumToNextWakeUp)
 {
     RT28XX_STA_SLEEP_THEN_AUTO_WAKEUP(pAd, TbttNumToNextWakeUp);
 }
@@ -6496,7 +6496,7 @@ VOID AsicForceWakeup(
 	IN BOOLEAN    bFromTx)
 {
     DBGPRINT(RT_DEBUG_TRACE, ("--> AsicForceWakeup \n"));
-    RT28XX_STA_FORCE_WAKEUP(pAd, bFromTx);	
+    RT28XX_STA_FORCE_WAKEUP(pAd, bFromTx);
 }
 #endif // CONFIG_STA_SUPPORT //
 /*
@@ -6509,15 +6509,15 @@ VOID AsicForceWakeup(
 	==========================================================================
  */
 VOID AsicSetBssid(
-	IN PRTMP_ADAPTER pAd, 
-	IN PUCHAR pBssid) 
+	IN PRTMP_ADAPTER pAd,
+	IN PUCHAR pBssid)
 {
 	ULONG		  Addr4;
 	DBGPRINT(RT_DEBUG_TRACE, ("==============> AsicSetBssid %x:%x:%x:%x:%x:%x\n",
 		pBssid[0],pBssid[1],pBssid[2],pBssid[3], pBssid[4],pBssid[5]));
-	
-	Addr4 = (ULONG)(pBssid[0])		 | 
-			(ULONG)(pBssid[1] << 8)  | 
+
+	Addr4 = (ULONG)(pBssid[0])		 |
+			(ULONG)(pBssid[1] << 8)  |
 			(ULONG)(pBssid[2] << 16) |
 			(ULONG)(pBssid[3] << 24);
 	RTMP_IO_WRITE32(pAd, MAC_BSSID_DW0, Addr4);
@@ -6530,21 +6530,21 @@ VOID AsicSetBssid(
 }
 
 VOID AsicSetMcastWC(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	MAC_TABLE_ENTRY *pEntry = &pAd->MacTab.Content[MCAST_WCID];
 	USHORT		offset;
-	
+
 	pEntry->Sst        = SST_ASSOC;
 	pEntry->Aid        = MCAST_WCID;	// Softap supports 1 BSSID and use WCID=0 as multicast Wcid index
 	pEntry->PsMode     = PWR_ACTIVE;
-	pEntry->CurrTxRate = pAd->CommonCfg.MlmeRate; 
+	pEntry->CurrTxRate = pAd->CommonCfg.MlmeRate;
 	offset = MAC_WCID_BASE + BSS0Mcast_WCID * HW_WCID_ENTRY_SIZE;
 }
 
 /*
 	==========================================================================
-	Description:   
+	Description:
 
 	IRQL = DISPATCH_LEVEL
 
@@ -6552,7 +6552,7 @@ VOID AsicSetMcastWC(
  */
 VOID AsicDelWcidTab(
 	IN PRTMP_ADAPTER pAd,
-	IN UCHAR	Wcid) 
+	IN UCHAR	Wcid)
 {
 	ULONG		  Addr0 = 0x0, Addr1 = 0x0;
 	ULONG 		offset;
@@ -6569,11 +6569,11 @@ VOID AsicDelWcidTab(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID AsicEnableRDG(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	TX_LINK_CFG_STRUC	TxLinkCfg;
 	UINT32				Data = 0;
@@ -6595,24 +6595,24 @@ VOID AsicEnableRDG(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID AsicDisableRDG(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	TX_LINK_CFG_STRUC	TxLinkCfg;
 	UINT32				Data = 0;
 
-	
+
 	RTMP_IO_READ32(pAd, TX_LINK_CFG, &TxLinkCfg.word);
 	TxLinkCfg.field.TxRDGEn = 0;
 	RTMP_IO_WRITE32(pAd, TX_LINK_CFG, TxLinkCfg.word);
 
 	RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
-	
+
 	Data  &= 0xFFFFFF00;
-	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_DYNAMIC_BE_TXOP_ACTIVE) 
+	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_DYNAMIC_BE_TXOP_ACTIVE)
 #ifdef DOT11_N_SUPPORT
 		&& (pAd->MacTab.fAnyStationMIMOPSDynamic == FALSE)
 #endif // DOT11_N_SUPPORT //
@@ -6631,18 +6631,18 @@ VOID AsicDisableRDG(
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID AsicDisableSync(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	BCN_TIME_CFG_STRUC csr;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("--->Disable TSF synchronization\n"));
 
 	// 2003-12-20 disable TSF and TBTT while NIC in power-saving have side effect
-	//			  that NIC will never wakes up because TSF stops and no more 
+	//			  that NIC will never wakes up because TSF stops and no more
 	//			  TBTT interrupts
 	pAd->TbttTickCount = 0;
 	RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
@@ -6659,18 +6659,18 @@ VOID AsicDisableSync(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID AsicEnableBssSync(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	BCN_TIME_CFG_STRUC csr;
 
 	DBGPRINT(RT_DEBUG_TRACE, ("--->AsicEnableBssSync(INFRA mode)\n"));
 
 	RTMP_IO_READ32(pAd, BCN_TIME_CFG, &csr.word);
-#ifdef CONFIG_STA_SUPPORT	
+#ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 	{
 		csr.field.BeaconInterval = pAd->CommonCfg.BeaconPeriod << 4; // ASIC register in units of 1/16 TU
@@ -6679,20 +6679,20 @@ VOID AsicEnableBssSync(
 		csr.field.bBeaconGen  = 0; // do NOT generate BEACON
 		csr.field.bTBTTEnable = 1;
 	}
-#endif // CONFIG_STA_SUPPORT //	
+#endif // CONFIG_STA_SUPPORT //
 	RTMP_IO_WRITE32(pAd, BCN_TIME_CFG, csr.word);
 }
 
 /*
 	==========================================================================
 	Description:
-	Note: 
+	Note:
 		BEACON frame in shared memory should be built ok before this routine
 		can be called. Otherwise, a garbage frame maybe transmitted out every
 		Beacon period.
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID AsicEnableIbssSync(
@@ -6745,7 +6745,7 @@ VOID AsicEnableIbssSync(
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID AsicSetEdcaParm(
@@ -6777,7 +6777,7 @@ VOID AsicSetEdcaParm(
 		//========================================================
 		//      MAC Register has a copy .
 		//========================================================
-		if( pAd->CommonCfg.bEnableTxBurst )		
+		if( pAd->CommonCfg.bEnableTxBurst )
 		{
 			// For CWC test, change txop from 0x30 to 0x20 in TxBurst mode
 			Ac0Cfg.field.AcTxop = 0x20; // Suggest by John for TxBurst in HT Mode
@@ -6860,7 +6860,7 @@ VOID AsicSetEdcaParm(
 		// Modify Cwmin/Cwmax/Txop on queue[QID_AC_VI], Recommend by Jerry 2005/07/27
 		// To degrade our VIDO Queue's throughput for WiFi WMM S3T07 Issue.
 		//
-		//pEdcaParm->Txop[QID_AC_VI] = pEdcaParm->Txop[QID_AC_VI] * 7 / 10; // rt2860c need this		
+		//pEdcaParm->Txop[QID_AC_VI] = pEdcaParm->Txop[QID_AC_VI] * 7 / 10; // rt2860c need this
 
 		Ac0Cfg.field.AcTxop =  pEdcaParm->Txop[QID_AC_BE];
 		Ac0Cfg.field.Cwmin= pEdcaParm->Cwmin[QID_AC_BE];
@@ -6868,7 +6868,7 @@ VOID AsicSetEdcaParm(
 		Ac0Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BE]; //+1;
 
 		Ac1Cfg.field.AcTxop =  pEdcaParm->Txop[QID_AC_BK];
-		Ac1Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_BK]; //+2; 
+		Ac1Cfg.field.Cwmin = pEdcaParm->Cwmin[QID_AC_BK]; //+2;
 		Ac1Cfg.field.Cwmax = pEdcaParm->Cwmax[QID_AC_BK];
 		Ac1Cfg.field.Aifsn = pEdcaParm->Aifsn[QID_AC_BK]; //+1;
 
@@ -6880,13 +6880,13 @@ VOID AsicSetEdcaParm(
 		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 		{
 			// Tuning for Wi-Fi WMM S06
-			if (pAd->CommonCfg.bWiFiTest && 
+			if (pAd->CommonCfg.bWiFiTest &&
 				pEdcaParm->Aifsn[QID_AC_VI] == 10)
-				Ac2Cfg.field.Aifsn -= 1; 
+				Ac2Cfg.field.Aifsn -= 1;
 
 			// Tuning for TGn Wi-Fi 5.2.32
 			// STA TestBed changes in this item: conexant legacy sta ==> broadcom 11n sta
-			if (STA_TGN_WIFI_ON(pAd) && 
+			if (STA_TGN_WIFI_ON(pAd) &&
 				pEdcaParm->Aifsn[QID_AC_VI] == 10)
 			{
 				Ac0Cfg.field.Aifsn = 3;
@@ -6962,7 +6962,7 @@ VOID AsicSetEdcaParm(
 
 			// Tuning for TGn Wi-Fi 5.2.32
 			// STA TestBed changes in this item: conexant legacy sta ==> broadcom 11n sta
-			if (STA_TGN_WIFI_ON(pAd) && 
+			if (STA_TGN_WIFI_ON(pAd) &&
 				pEdcaParm->Aifsn[QID_AC_VI] == 10)
 			{
 				AifsnCsr.field.Aifsn0 = 3;
@@ -7015,12 +7015,12 @@ VOID AsicSetEdcaParm(
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID 	AsicSetSlotTime(
 	IN PRTMP_ADAPTER pAd,
-	IN BOOLEAN bUseShortSlotTime) 
+	IN BOOLEAN bUseShortSlotTime)
 {
 	ULONG	SlotTime;
 	UINT32	RegValue = 0;
@@ -7057,13 +7057,13 @@ VOID 	AsicSetSlotTime(
 
 	//
 	// For some reasons, always set it to short slot time.
-	// 
+	//
 	// ToDo: Should consider capability with 11B
 	//
-#ifdef CONFIG_STA_SUPPORT 
+#ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 	{
-		if (pAd->StaCfg.BssType == BSS_ADHOC)	
+		if (pAd->StaCfg.BssType == BSS_ADHOC)
 			SlotTime = 20;
 	}
 #endif // CONFIG_STA_SUPPORT //
@@ -7079,10 +7079,10 @@ VOID 	AsicSetSlotTime(
 /*
 	========================================================================
 	Description:
-		Add Shared key information into ASIC. 
+		Add Shared key information into ASIC.
 		Update shared key, TxMic and RxMic to Asic Shared key table
 		Update its cipherAlg to Asic Shared key Mode.
-		
+
     Return:
 	========================================================================
 */
@@ -7123,7 +7123,7 @@ VOID AsicAddSharedKeyEntry(
 	//
 #ifdef RT2860
 	offset = SHARED_KEY_TABLE_BASE + (4*BssIndex + KeyIdx)*HW_KEY_ENTRY_SIZE;
-	for (i=0; i<MAX_LEN_OF_SHARE_KEY; i++) 
+	for (i=0; i<MAX_LEN_OF_SHARE_KEY; i++)
 	{
 		RTMP_IO_WRITE8(pAd, offset + i, pKey[i]);
 	}
@@ -7177,7 +7177,7 @@ VOID AsicAddSharedKeyEntry(
 	}
 	DBGPRINT(RT_DEBUG_TRACE,("Write: SHARED_KEY_MODE_BASE at this Bss[%d] = 0x%x \n", BssIndex, csr1.word));
 	RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE+4*(BssIndex/2), csr1.word);
-		
+
 }
 
 //	IRQL = DISPATCH_LEVEL
@@ -7261,14 +7261,14 @@ VOID AsicUpdateRxWCIDTable(
 {
 	ULONG offset;
 	ULONG Addr;
-	
-	offset = MAC_WCID_BASE + (WCID * HW_WCID_ENTRY_SIZE);	
+
+	offset = MAC_WCID_BASE + (WCID * HW_WCID_ENTRY_SIZE);
 	Addr = pAddr[0] + (pAddr[1] << 8) +(pAddr[2] << 16) +(pAddr[3] << 24);
 	RTMP_IO_WRITE32(pAd, offset, Addr);
 	Addr = pAddr[4] + (pAddr[5] << 8);
-	RTMP_IO_WRITE32(pAd, offset + 4, Addr);	
+	RTMP_IO_WRITE32(pAd, offset + 4, Addr);
 }
-	
+
 
 /*
     ========================================================================
@@ -7279,25 +7279,25 @@ VOID AsicUpdateRxWCIDTable(
     Arguments:
         pAd                     Pointer to our adapter
         WCID                    WCID Entry number.
-        BssIndex                BSSID index, station or none multiple BSSID support 
+        BssIndex                BSSID index, station or none multiple BSSID support
                                 this value should be 0.
         KeyIdx                  This KeyIdx will set to IV's KeyID if bTxKey enabled
         pCipherKey              Pointer to Cipher Key.
-        bUsePairewiseKeyTable   TRUE means saved the key in SharedKey table, 
+        bUsePairewiseKeyTable   TRUE means saved the key in SharedKey table,
                                 otherwise PairewiseKey table
         bTxKey                  This is the transmit key if enabled.
 
     Return Value:
-        None 
+        None
 
     Note:
         This routine will set the relative key stuff to Asic including WCID attribute,
         Cipher Key, Cipher algorithm and IV/EIV.
 
-        IV/EIV will be update if this CipherKey is the transmission key because 
+        IV/EIV will be update if this CipherKey is the transmission key because
         ASIC will base on IV's KeyID value to select Cipher Key.
 
-        If bTxKey sets to FALSE, this is not the TX key, but it could be 
+        If bTxKey sets to FALSE, this is not the TX key, but it could be
         RX key
 
     	For AP mode bTxKey must be always set to TRUE.
@@ -7308,7 +7308,7 @@ VOID AsicAddKeyEntry(
 	IN USHORT		WCID,
 	IN UCHAR		BssIndex,
 	IN UCHAR		KeyIdx,
-	IN PCIPHER_KEY	pCipherKey,	
+	IN PCIPHER_KEY	pCipherKey,
 	IN BOOLEAN		bUsePairewiseKeyTable,
 	IN BOOLEAN		bTxKey)
 {
@@ -7321,7 +7321,7 @@ VOID AsicAddKeyEntry(
 	UCHAR		CipherAlg = pCipherKey->CipherAlg;
 	SHAREDKEY_MODE_STRUC csr1;
 #ifdef RT2860
-	UCHAR		i; 
+	UCHAR		i;
 #endif // RT2860 //
 
 	DBGPRINT(RT_DEBUG_TRACE, ("==> AsicAddKeyEntry\n"));
@@ -7355,7 +7355,7 @@ VOID AsicAddKeyEntry(
 		}
 	}
 	offset += LEN_TKIP_TXMICK;
-		
+
 	if (pRxMic)
 	{
 		for (i = 0; i < 8; i++)
@@ -7428,19 +7428,19 @@ VOID AsicAddKeyEntry(
 			else
 				csr1.field.Bss1Key3CipherAlg = CipherAlg;
 		}
-		RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE + 4 * (BssIndex / 2), csr1.word);			
+		RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE + 4 * (BssIndex / 2), csr1.word);
 	}
 
-	DBGPRINT(RT_DEBUG_TRACE, ("<== AsicAddKeyEntry\n"));	
+	DBGPRINT(RT_DEBUG_TRACE, ("<== AsicAddKeyEntry\n"));
 }
 
 
 /*
 	========================================================================
 	Description:
-		Add Pair-wise key material into ASIC. 
+		Add Pair-wise key material into ASIC.
 		Update pairwise key, TxMic and RxMic to Asic Pair-wise key table
-				
+
     Return:
 	========================================================================
 */
@@ -7455,10 +7455,10 @@ VOID AsicAddPairwiseKeyEntry(
 	PUCHAR		 pKey = pCipherKey->Key;
 	PUCHAR		 pTxMic = pCipherKey->TxMic;
 	PUCHAR		 pRxMic = pCipherKey->RxMic;
-#ifdef DBG    
+#ifdef DBG
 	UCHAR		CipherAlg = pCipherKey->CipherAlg;
 #endif // DBG //
-	
+
 	// EKEY
 	offset = PAIRWISE_KEY_TABLE_BASE + (WCID * HW_KEY_ENTRY_SIZE);
 #ifdef RT2860
@@ -7474,7 +7474,7 @@ VOID AsicAddPairwiseKeyEntry(
 	}
 
 	offset += MAX_LEN_OF_PEER_KEY;
-	
+
 	//  MIC KEY
 	if (pTxMic)
 	{
@@ -7513,11 +7513,11 @@ VOID AsicAddPairwiseKeyEntry(
 /*
 	========================================================================
 	Description:
-		Remove Pair-wise key material from ASIC. 
+		Remove Pair-wise key material from ASIC.
 
     Return:
 	========================================================================
-*/	
+*/
 VOID AsicRemovePairwiseKeyEntry(
 	IN PRTMP_ADAPTER pAd,
 	IN UCHAR		 BssIdx,
@@ -7528,7 +7528,7 @@ VOID AsicRemovePairwiseKeyEntry(
 
 	// re-set the entry's WCID attribute as OPEN-NONE.
 	offset = MAC_WCID_ATTRIBUTE_BASE + (Wcid * HW_WCID_ATTRI_SIZE);
-	WCIDAttri = (BssIdx<<4) | PAIRWISEKEYTABLE;		
+	WCIDAttri = (BssIdx<<4) | PAIRWISEKEYTABLE;
 	RTMP_IO_WRITE32(pAd, offset, WCIDAttri);
 }
 
@@ -7615,7 +7615,7 @@ BOOLEAN AsicSendCommandToMcu(
 	if (Command != 0x80)
 	{
 	}
-	
+
 	return TRUE;
 }
 
@@ -7626,7 +7626,7 @@ BOOLEAN AsicCheckCommanOk(
 {
 	UINT32	CmdStatus = 0, CID = 0, i;
 	UINT32	ThisCIDMask = 0;
-	
+
 	i = 0;
 	do
 	{
@@ -7659,12 +7659,12 @@ BOOLEAN AsicCheckCommanOk(
 
 	// Get CommandStatus Value
 	RTMP_IO_READ32(pAd, H2M_MAILBOX_STATUS, &CmdStatus);
-	
-	// This command's status is at the same position as command. So AND command position's bitmask to read status.	
+
+	// This command's status is at the same position as command. So AND command position's bitmask to read status.
 	if (i < 200)
 	{
 		// If Status is 1, the comamnd is success.
-		if (((CmdStatus & ThisCIDMask) == 0x1) || ((CmdStatus & ThisCIDMask) == 0x100) 
+		if (((CmdStatus & ThisCIDMask) == 0x1) || ((CmdStatus & ThisCIDMask) == 0x100)
 			|| ((CmdStatus & ThisCIDMask) == 0x10000) || ((CmdStatus & ThisCIDMask) == 0x1000000))
 		{
 			DBGPRINT(RT_DEBUG_TRACE, ("--> AsicCheckCommanOk CID = 0x%x, CmdStatus= 0x%x \n", CID, CmdStatus));
@@ -7681,7 +7681,7 @@ BOOLEAN AsicCheckCommanOk(
 	// Clear Command and Status.
 	RTMP_IO_WRITE32(pAd, H2M_MAILBOX_STATUS, 0xffffffff);
 	RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CID, 0xffffffff);
-    
+
 	return FALSE;
 }
 #endif // RT2860 //
@@ -7709,20 +7709,20 @@ VOID	RTMPCheckRates(
 {
 	UCHAR	RateIdx, i, j;
 	UCHAR	NewRate[12], NewRateLen;
-	
+
 	NewRateLen = 0;
-	
+
 	if (pAd->CommonCfg.PhyMode == PHY_11B)
 		RateIdx = 4;
 	else
 		RateIdx = 12;
 
-	// Check for support rates exclude basic rate bit	
+	// Check for support rates exclude basic rate bit
 	for (i = 0; i < *SupRateLen; i++)
 		for (j = 0; j < RateIdx; j++)
 			if ((SupRate[i] & 0x7f) == RateIdTo500Kbps[j])
 				NewRate[NewRateLen++] = SupRate[i];
-			
+
 	*SupRateLen = NewRateLen;
 	NdisMoveMemory(SupRate, NewRate, NewRateLen);
 }
@@ -7737,8 +7737,8 @@ BOOLEAN RTMPCheckChannel(
 	UCHAR		k;
 	UCHAR		UpperChannel = 0, LowerChannel = 0;
 	UCHAR		NoEffectChannelinList = 0;
-	
-	// Find upper and lower channel according to 40MHz current operation. 
+
+	// Find upper and lower channel according to 40MHz current operation.
 	if (CentralChannel < Channel)
 	{
 		UpperChannel = Channel;
@@ -7813,7 +7813,7 @@ BOOLEAN 	RTMPCheckHt(
 	{
 		CLIENT_STATUS_SET_FLAG(&pAd->MacTab.Content[Wcid], fCLIENT_STATUS_RDG_CAPABLE);
 	}
-	
+
 	if (Wcid < MAX_LEN_OF_MAC_TABLE)
 	{
 		pAd->MacTab.Content[Wcid].MpduDensity = pHtCapability->HtCapParm.MpduDensity;
@@ -7823,7 +7823,7 @@ BOOLEAN 	RTMPCheckHt(
 	pAd->MlmeAux.HtCapability.MCSSet[4] = 0x1;
     switch (pAd->CommonCfg.RxStream)
 	{
-		case 1:			
+		case 1:
 			pAd->MlmeAux.HtCapability.MCSSet[0] = 0xff;
 			pAd->MlmeAux.HtCapability.MCSSet[1] = 0x00;
             pAd->MlmeAux.HtCapability.MCSSet[2] = 0x00;
@@ -7835,20 +7835,20 @@ BOOLEAN 	RTMPCheckHt(
             pAd->MlmeAux.HtCapability.MCSSet[2] = 0x00;
             pAd->MlmeAux.HtCapability.MCSSet[3] = 0x00;
 			break;
-		case 3:				
+		case 3:
 			pAd->MlmeAux.HtCapability.MCSSet[0] = 0xff;
 			pAd->MlmeAux.HtCapability.MCSSet[1] = 0xff;
             pAd->MlmeAux.HtCapability.MCSSet[2] = 0xff;
             pAd->MlmeAux.HtCapability.MCSSet[3] = 0x00;
 			break;
-	}	
+	}
 
 	pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth = pAddHtInfo->AddHtInfo.RecomWidth & pAd->CommonCfg.DesiredHtPhy.ChannelWidth;
-		
+
     DBGPRINT(RT_DEBUG_TRACE, ("RTMPCheckHt:: HtCapInfo.ChannelWidth=%d, RecomWidth=%d, DesiredHtPhy.ChannelWidth=%d, BW40MAvailForA/G=%d/%d, PhyMode=%d \n",
 		pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth, pAddHtInfo->AddHtInfo.RecomWidth, pAd->CommonCfg.DesiredHtPhy.ChannelWidth,
 		pAd->NicConfig2.field.BW40MAvailForA, pAd->NicConfig2.field.BW40MAvailForG, pAd->CommonCfg.PhyMode));
-    
+
 	pAd->MlmeAux.HtCapability.HtCapInfo.GF =  pHtCapability->HtCapInfo.GF &pAd->CommonCfg.DesiredHtPhy.GF;
 
 	// Send Assoc Req with my HT capability.
@@ -7867,7 +7867,7 @@ BOOLEAN 	RTMPCheckHt(
 		pAd->MlmeAux.HtCapability.ExtHtCapInfo.RDGSupport = pHtCapability->ExtHtCapInfo.RDGSupport;
         pAd->MlmeAux.HtCapability.ExtHtCapInfo.PlusHTC = 1;
 	}
-	
+
     if (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_20)
         pAd->MlmeAux.HtCapability.MCSSet[4] = 0x0;  // BW20 can't transmit MCS32
 
@@ -7901,7 +7901,7 @@ VOID RTMPUpdateMlmeRate(
 	UCHAR	i, j, RateIdx = 12; //1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
 	BOOLEAN	bMatch = FALSE;
 
-	switch (pAd->CommonCfg.PhyMode) 
+	switch (pAd->CommonCfg.PhyMode)
 	{
 		case PHY_11B:
 			ProperMlmeRate = RATE_11;
@@ -7918,7 +7918,7 @@ VOID RTMPUpdateMlmeRate(
 				ProperMlmeRate = RATE_11;
 			else
 				ProperMlmeRate = RATE_24;
-			
+
 			if (pAd->MlmeAux.Channel <= 14)
 				MinimumRate = RATE_1;
 			else
@@ -7930,7 +7930,7 @@ VOID RTMPUpdateMlmeRate(
 		case PHY_11GN_MIXED:
 		case PHY_11AGN_MIXED:
 		case PHY_11AN_MIXED:
-		case PHY_11N_5G:	
+		case PHY_11N_5G:
 #endif // DOT11_N_SUPPORT //
 			ProperMlmeRate = RATE_24;
 			MinimumRate = RATE_6;
@@ -7959,7 +7959,7 @@ VOID RTMPUpdateMlmeRate(
 					bMatch = TRUE;
 					break;
 				}
-			}			
+			}
 		}
 
 		if (bMatch)
@@ -7979,11 +7979,11 @@ VOID RTMPUpdateMlmeRate(
 						bMatch = TRUE;
 						break;
 					}
-				}				
+				}
 			}
-			
+
 			if (bMatch)
-				break;		
+				break;
 		}
 	}
 
@@ -8019,7 +8019,7 @@ CHAR RTMPMaxRssi(
 	IN CHAR				Rssi2)
 {
 	CHAR	larger = -127;
-	
+
 	if ((pAd->Antenna.field.RxPath == 1) && (Rssi0 != 0))
 	{
 		larger = Rssi0;
@@ -8029,7 +8029,7 @@ CHAR RTMPMaxRssi(
 	{
 		larger = max(Rssi0, Rssi1);
 	}
-	
+
 	if ((pAd->Antenna.field.RxPath == 3) && (Rssi2 != 0))
 	{
 		larger = max(larger, Rssi2);
@@ -8045,13 +8045,13 @@ CHAR RTMPMaxRssi(
     ========================================================================
     Routine Description:
         Periodic evaluate antenna link status
-        
+
     Arguments:
         pAd         - Adapter pointer
-        
+
     Return Value:
         None
-        
+
     ========================================================================
 */
 VOID AsicEvaluateRxAnt(
@@ -8104,8 +8104,8 @@ VOID AsicEvaluateRxAnt(
 	if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
 		)
 	{
-		ULONG	TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount + 
-								pAd->RalinkCounters.OneSecTxRetryOkCount + 
+		ULONG	TxTotalCnt = pAd->RalinkCounters.OneSecTxNoRetryOkCount +
+								pAd->RalinkCounters.OneSecTxRetryOkCount +
 								pAd->RalinkCounters.OneSecTxFailCount;
 
 		if (TxTotalCnt > 50)
@@ -8125,20 +8125,20 @@ VOID AsicEvaluateRxAnt(
     ========================================================================
     Routine Description:
         After evaluation, check antenna link status
-        
+
     Arguments:
         pAd         - Adapter pointer
-        
+
     Return Value:
         None
-        
+
     ========================================================================
 */
 VOID AsicRxAntEvalTimeout(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
-	IN PVOID SystemSpecific3) 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
+	IN PVOID SystemSpecific3)
 {
 	RTMP_ADAPTER	*pAd = (RTMP_ADAPTER *)FunctionContext;
 #ifdef CONFIG_STA_SUPPORT
@@ -8211,7 +8211,7 @@ VOID AsicRxAntEvalTimeout(
 			BBPR3 |= (0x0);
 		}
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);
-#ifdef RT2860    
+#ifdef RT2860
     pAd->StaCfg.BBPR3 = BBPR3;
 #endif // RT2860 //
 	}
@@ -8223,10 +8223,10 @@ VOID AsicRxAntEvalTimeout(
 
 
 VOID APSDPeriodicExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
-	IN PVOID SystemSpecific3) 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
+	IN PVOID SystemSpecific3)
 {
 	RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
 
@@ -8241,14 +8241,14 @@ VOID APSDPeriodicExec(
     ========================================================================
     Routine Description:
         Set/reset MAC registers according to bPiggyBack parameter
-        
+
     Arguments:
         pAd         - Adapter pointer
         bPiggyBack  - Enable / Disable Piggy-Back
 
     Return Value:
         None
-        
+
     ========================================================================
 */
 VOID RTMPSetPiggyBack(
@@ -8256,7 +8256,7 @@ VOID RTMPSetPiggyBack(
     IN BOOLEAN          bPiggyBack)
 {
 	TX_LINK_CFG_STRUC  TxLinkCfg;
-    
+
 	RTMP_IO_READ32(pAd, TX_LINK_CFG, &TxLinkCfg.word);
 
 	TxLinkCfg.field.TxCFAckEn = bPiggyBack;
@@ -8267,20 +8267,20 @@ VOID RTMPSetPiggyBack(
     ========================================================================
     Routine Description:
         check if this entry need to switch rate automatically
-        
+
     Arguments:
-        pAd         
-        pEntry 	 	
+        pAd
+        pEntry
 
     Return Value:
         TURE
         FALSE
-        
+
     ========================================================================
 */
 BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(
 	IN PRTMP_ADAPTER    pAd,
-	IN PMAC_TABLE_ENTRY	pEntry)	
+	IN PMAC_TABLE_ENTRY	pEntry)
 {
 	BOOLEAN		result = TRUE;
 
@@ -8310,8 +8310,8 @@ BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(
 
 
 BOOLEAN RTMPAutoRateSwitchCheck(
-	IN PRTMP_ADAPTER    pAd)	
-{			
+	IN PRTMP_ADAPTER    pAd)
+{
 
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
@@ -8328,20 +8328,20 @@ BOOLEAN RTMPAutoRateSwitchCheck(
     ========================================================================
     Routine Description:
         check if this entry need to fix tx legacy rate
-        
+
     Arguments:
-        pAd         
-        pEntry 	 	
+        pAd
+        pEntry
 
     Return Value:
         TURE
         FALSE
-        
+
     ========================================================================
 */
 UCHAR RTMPStaFixedTxMode(
 	IN PRTMP_ADAPTER    pAd,
-	IN PMAC_TABLE_ENTRY	pEntry)	
+	IN PMAC_TABLE_ENTRY	pEntry)
 {
 	UCHAR	tx_mode = FIXED_TXMODE_HT;
 
@@ -8360,15 +8360,15 @@ UCHAR RTMPStaFixedTxMode(
     ========================================================================
     Routine Description:
         Overwrite HT Tx Mode by Fixed Legency Tx Mode, if specified.
-        
+
     Arguments:
-        pAd         
-        pEntry 	 	
+        pAd
+        pEntry
 
     Return Value:
         TURE
         FALSE
-        
+
     ========================================================================
 */
 VOID RTMPUpdateLegacyTxSetting(
@@ -8376,15 +8376,15 @@ VOID RTMPUpdateLegacyTxSetting(
 		PMAC_TABLE_ENTRY	pEntry)
 {
 	HTTRANSMIT_SETTING TransmitSetting;
-	
+
 	if (fixed_tx_mode == FIXED_TXMODE_HT)
 		return;
-							 				
+
 	TransmitSetting.word = 0;
 
 	TransmitSetting.field.MODE = pEntry->HTPhyMode.field.MODE;
 	TransmitSetting.field.MCS = pEntry->HTPhyMode.field.MCS;
-						
+
 	if (fixed_tx_mode == FIXED_TXMODE_CCK)
 	{
 		TransmitSetting.field.MODE = MODE_CCK;
@@ -8392,27 +8392,27 @@ VOID RTMPUpdateLegacyTxSetting(
 		if (TransmitSetting.field.MCS > MCS_3)
 			TransmitSetting.field.MCS = MCS_3;
 	}
-	else 
+	else
 	{
 		TransmitSetting.field.MODE = MODE_OFDM;
 		// OFDM mode allow MCS 0~7
 		if (TransmitSetting.field.MCS > MCS_7)
 			TransmitSetting.field.MCS = MCS_7;
 	}
-	
+
 	if (pEntry->HTPhyMode.field.MODE >= TransmitSetting.field.MODE)
 	{
 		pEntry->HTPhyMode.word = TransmitSetting.word;
-		DBGPRINT(RT_DEBUG_TRACE, ("RTMPUpdateLegacyTxSetting : wcid-%d, MODE=%s, MCS=%d \n", 
-				pEntry->Aid, GetPhyMode(pEntry->HTPhyMode.field.MODE), pEntry->HTPhyMode.field.MCS));		
-	}													
+		DBGPRINT(RT_DEBUG_TRACE, ("RTMPUpdateLegacyTxSetting : wcid-%d, MODE=%s, MCS=%d \n",
+				pEntry->Aid, GetPhyMode(pEntry->HTPhyMode.field.MODE), pEntry->HTPhyMode.field.MCS));
+	}
 }
 
 #ifdef CONFIG_STA_SUPPORT
 /*
 	==========================================================================
 	Description:
-		dynamic tune BBP R66 to find a balance between sensibility and 
+		dynamic tune BBP R66 to find a balance between sensibility and
 		noise isolation
 
 	IRQL = DISPATCH_LEVEL
@@ -8435,23 +8435,23 @@ VOID AsicStaBbpTuning(
 	if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)  // no R66 tuning when SCANNING
 		return;
 
-	if ((pAd->OpMode == OPMODE_STA) 
+	if ((pAd->OpMode == OPMODE_STA)
 		&& (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
 			)
 		&& !(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
-#ifdef RT2860		
+#ifdef RT2860
 		&& (pAd->bPCIclkOff == FALSE)
 #endif // RT2860 //
 		)
 	{
 		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &OrigR66Value);
 		R66 = OrigR66Value;
-		
+
 		if (pAd->Antenna.field.RxPath > 1)
 			Rssi = (pAd->StaCfg.RssiSample.AvgRssi0 + pAd->StaCfg.RssiSample.AvgRssi1) >> 1;
 		else
 			Rssi = pAd->StaCfg.RssiSample.AvgRssi0;
-	
+
 		if (pAd->LatchRfRegs.Channel <= 14)
 		{	//BG band
 			{
@@ -8515,7 +8515,7 @@ VOID AsicStaBbpTuning(
 			}
 		}
 
-		
+
 	}
 }
 #endif // CONFIG_STA_SUPPORT //
@@ -8525,7 +8525,7 @@ VOID RTMPSetAGCInitValue(
 	IN UCHAR			BandWidth)
 {
 	UCHAR	R66 = 0x30;
-	
+
 	if (pAd->LatchRfRegs.Channel <= 14)
 	{	// BG band
 		R66 = 0x2E + GET_LNA_GAIN(pAd);
@@ -8550,8 +8550,8 @@ VOID RTMPSetAGCInitValue(
 }
 
 VOID AsicTurnOffRFClk(
-	IN PRTMP_ADAPTER pAd, 
-	IN	UCHAR		Channel) 
+	IN PRTMP_ADAPTER pAd,
+	IN	UCHAR		Channel)
 {
 
 	// RF R2 bit 18 = 0
@@ -8567,7 +8567,7 @@ VOID AsicTurnOffRFClk(
 		case RFIC_2850:
 		case RFIC_2720:
 		case RFIC_2750:
-			
+
 			for (index = 0; index < NUM_OF_2850_CHNL; index++)
 			{
 				if (Channel == RFRegTable[index].Channel)
@@ -8579,7 +8579,7 @@ VOID AsicTurnOffRFClk(
 					RTMP_RF_IO_WRITE32(pAd, R1);
 					RTMP_RF_IO_WRITE32(pAd, R2);
 
-					// Program R1b13 to 1, R3/b18,19 to 0, R2b18 to 0. 
+					// Program R1b13 to 1, R3/b18,19 to 0, R2b18 to 0.
 					// Set RF R2 bit18=0, R3 bit[18:19]=0
 					//if (pAd->StaCfg.bRadio == FALSE)
 					if (1)
@@ -8604,8 +8604,8 @@ VOID AsicTurnOffRFClk(
 
 
 VOID AsicTurnOnRFClk(
-	IN PRTMP_ADAPTER pAd, 
-	IN	UCHAR			Channel) 
+	IN PRTMP_ADAPTER pAd,
+	IN	UCHAR			Channel)
 {
 
 	// RF R2 bit 18 = 0
@@ -8621,7 +8621,7 @@ VOID AsicTurnOnRFClk(
 		case RFIC_2850:
 		case RFIC_2720:
 		case RFIC_2750:
-			
+
 			for (index = 0; index < NUM_OF_2850_CHNL; index++)
 			{
 				if (Channel == RFRegTable[index].Channel)
@@ -8630,7 +8630,7 @@ VOID AsicTurnOnRFClk(
 					R3 &= 0xfff3ffff;
 					R3 |= 0x00080000;
 					RTMP_RF_IO_WRITE32(pAd, R3);
-					
+
 					R1 = RFRegTable[index].R1;
 					RTMP_RF_IO_WRITE32(pAd, R1);
 
@@ -8639,7 +8639,7 @@ VOID AsicTurnOnRFClk(
 					{
 						R2 |= 0x4000;	// If TXpath is 1, bit 14 = 1;
 					}
-					
+
 					if (pAd->Antenna.field.RxPath == 2)
 					{
 						R2 |= 0x40;	// write 1 to off Rxpath.
@@ -8649,7 +8649,7 @@ VOID AsicTurnOnRFClk(
 						R2 |= 0x20040;	// write 1 to off RxPath
 					}
 					RTMP_RF_IO_WRITE32(pAd, R2);
-					
+
 					break;
 				}
 			}
@@ -8660,8 +8660,8 @@ VOID AsicTurnOnRFClk(
 	}
 
 	DBGPRINT(RT_DEBUG_TRACE, ("AsicTurnOnRFClk#%d(RF=%d, ) , R2=0x%08x\n",
-		Channel, 
-		pAd->RfIcType, 
+		Channel,
+		pAd->RfIcType,
 		R2));
 }
 
diff --git a/common/netif_block.c b/common/netif_block.c
index 2e77147..d3f7d08 100644
--- a/common/netif_block.c
+++ b/common/netif_block.c
@@ -7,25 +7,25 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
- */ 
+ */
 
-#include "rt_config.h"
+#include "../rt_config.h"
 #include "netif_block.h"
 
 static NETIF_ENTRY freeNetIfEntryPool[FREE_NETIF_POOL_SIZE];
@@ -51,7 +51,7 @@ BOOLEAN blockNetIf(
 	IN PNET_DEV pNetDev)
 {
 	PNETIF_ENTRY pNetIfEntry = NULL;
-	
+
 	if ((pNetIfEntry = (PNETIF_ENTRY)removeHeadList(&freeNetIfEntryList)) != NULL)
 	{
 		netif_stop_queue(pNetDev);
diff --git a/include/netif_block.h b/common/netif_block.h
similarity index 89%
rename from include/netif_block.h
rename to common/netif_block.h
index 97b121d..6e5151c 100644
--- a/include/netif_block.h
+++ b/common/netif_block.h
@@ -7,28 +7,28 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
- */ 
+ */
 
 #ifndef __NET_IF_BLOCK_H__
 #define __NET_IF_BLOCK_H__
 
-//#include <linux/device.h> 
+//#include <linux/device.h>
 #include "link_list.h"
 #include "rtmp.h"
 
diff --git a/common/rt2860.bin b/common/rt2860.bin
deleted file mode 100644
index 778a771..0000000
Binary files a/common/rt2860.bin and /dev/null differ
diff --git a/common/rtmp_init.c b/common/rtmp_init.c
index db9b9d8..9b81443 100644
--- a/common/rtmp_init.c
+++ b/common/rtmp_init.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -37,7 +37,7 @@
     John Chang  2004-08-20    RT2561/2661 use scatter-gather scheme
     Jan Lee  2006-09-15    RT2860. Change for 802.11n , EEPROM, Led, BA, HT.
 */
-#include	"rt_config.h"
+#include "../rt_config.h"
 #include 	"firmware.h"
 
 UCHAR    BIT8[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
@@ -116,7 +116,7 @@ REG_PAIR   BBPRegTable[] = {
 	{BBP_R82,		0x62},
 	{BBP_R83,		0x6A},
 	{BBP_R84,		0x99},	// 0x19 is for rt2860E and after. This is for extension channel overlapping IOT. 0x99 is for rt2860D and before
-	{BBP_R86,		0x00},	// middle range issue, Rory @2008-01-28 	
+	{BBP_R86,		0x00},	// middle range issue, Rory @2008-01-28
 	{BBP_R91,		0x04},	// middle range issue, Rory @2008-01-28
 	{BBP_R92,		0x00},	// middle range issue, Rory @2008-01-28
 	{BBP_R103,  	0x00}, 	// near range high-power issue, requested from Gary @2008-0528
@@ -146,27 +146,27 @@ RTMP_REG_PAIR	MACRegTable[] =	{
 	{LEGACY_BASIC_RATE,		0x0000013f}, //  Basic rate set bitmap
 	{HT_BASIC_RATE,		0x00008003}, // Basic HT rate set , 20M, MCS=3, MM. Format is the same as in TXWI.
 	{MAC_SYS_CTRL,		0x00}, // 0x1004, , default Disable RX
-	{RX_FILTR_CFG,		0x17f97}, //0x1400  , RX filter control,  
-	{BKOFF_SLOT_CFG,	0x209}, // default set short slot time, CC_DELAY_TIME should be 2	 
-	{TX_SW_CFG0,		0x0}, 		// Gary,2008-05-21 for CWC test 
-	{TX_SW_CFG1,		0x80606}, // Gary,2006-08-23 
-	{TX_LINK_CFG,		0x1020},		// Gary,2006-08-23 
+	{RX_FILTR_CFG,		0x17f97}, //0x1400  , RX filter control,
+	{BKOFF_SLOT_CFG,	0x209}, // default set short slot time, CC_DELAY_TIME should be 2
+	{TX_SW_CFG0,		0x0}, 		// Gary,2008-05-21 for CWC test
+	{TX_SW_CFG1,		0x80606}, // Gary,2006-08-23
+	{TX_LINK_CFG,		0x1020},		// Gary,2006-08-23
 	{TX_TIMEOUT_CFG,	0x000a2090},	// CCK has some problem. So increase timieout value. 2006-10-09// MArvek RT , Modify for 2860E ,2007-08-01
 	{MAX_LEN_CFG,		MAX_AGGREGATION_SIZE | 0x00001000},	// 0x3018, MAX frame length. Max PSDU = 16kbytes.
 	{LED_CFG,		0x7f031e46}, // Gary, 2006-08-23
 	{PBF_MAX_PCNT,			0x1F3FBF9F}, 	//0x1F3f7f9f},		//Jan, 2006/04/20
 	{TX_RTY_CFG,			0x47d01f0f},	// Jan, 2006/11/16, Set TxWI->ACK =0 in Probe Rsp Modify for 2860E ,2007-08-03
 	{AUTO_RSP_CFG,			0x00000013},	// Initial Auto_Responder, because QA will turn off Auto-Responder
-	{CCK_PROT_CFG,			0x05740003 /*0x01740003*/},	// Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled. 
-	{OFDM_PROT_CFG,			0x05740003 /*0x01740003*/},	// Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled. 
+	{CCK_PROT_CFG,			0x05740003 /*0x01740003*/},	// Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled.
+	{OFDM_PROT_CFG,			0x05740003 /*0x01740003*/},	// Initial Auto_Responder, because QA will turn off Auto-Responder. And RTS threshold is enabled.
 	{GF20_PROT_CFG,			0x01744004},    // set 19:18 --> Short NAV for MIMO PS
-	{GF40_PROT_CFG,			0x03F44084},    
-	{MM20_PROT_CFG,			0x01744004},    
+	{GF40_PROT_CFG,			0x03F44084},
+	{MM20_PROT_CFG,			0x01744004},
 #ifdef RT2860
-	{MM40_PROT_CFG,			0x03F54084},	
+	{MM40_PROT_CFG,			0x03F54084},
 #endif // RT2860 //
 	{TXOP_CTRL_CFG,			0x0000583f, /*0x0000243f*/ /*0x000024bf*/},	//Extension channel backoff.
-	{TX_RTS_CFG,			0x00092b20},	
+	{TX_RTS_CFG,			0x00092b20},
 	{EXP_ACK_TIME,			0x002400ca},	// default value
 	{TXOP_HLDR_ET, 			0x00000002},
 
@@ -208,7 +208,7 @@ RTMP_REG_PAIR	STAMACRegTable[] =	{
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Allocate RTMP_ADAPTER data block and do some initialization
 
@@ -222,7 +222,7 @@ RTMP_REG_PAIR	STAMACRegTable[] =	{
 	IRQL = PASSIVE_LEVEL
 
 	Note:
-	
+
 	========================================================================
 */
 NDIS_STATUS	RTMPAllocAdapterBlock(
@@ -258,7 +258,7 @@ NDIS_STATUS	RTMPAllocAdapterBlock(
 		pAd->BeaconBuf = pBeaconBuf;
 		printk("\n\n=== pAd = %p, size = %d ===\n\n", pAd, (UINT32)sizeof(RTMP_ADAPTER));
 
-		
+
 		// Init spin locks
 		NdisAllocateSpinLock(&pAd->MgmtRingLock);
 #ifdef RT2860
@@ -278,7 +278,7 @@ NDIS_STATUS	RTMPAllocAdapterBlock(
 
 	if ((Status != NDIS_STATUS_SUCCESS) && (pBeaconBuf))
 		kfree(pBeaconBuf);
-	
+
 	*ppAdapter = pAd;
 
 	DBGPRINT_S(Status, ("<-- RTMPAllocAdapterBlock, Status=%x\n", Status));
@@ -287,10 +287,10 @@ NDIS_STATUS	RTMPAllocAdapterBlock(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Read initial Tx power per MCS and BW from EEPROM
-		
+
 	Arguments:
 		Adapter						Pointer to our adapter
 
@@ -300,7 +300,7 @@ NDIS_STATUS	RTMPAllocAdapterBlock(
 	IRQL = PASSIVE_LEVEL
 
 	Note:
-		
+
 	========================================================================
 */
 VOID	RTMPReadTxPwrPerRate(
@@ -311,7 +311,7 @@ VOID	RTMPReadTxPwrPerRate(
 	INT			Apwrdelta, Gpwrdelta;
 	UCHAR		t1,t2,t3,t4;
 	BOOLEAN		bValid, bApwrdeltaMinus = TRUE, bGpwrdeltaMinus = TRUE;
-	
+
 	//
 	// Get power delta for 20MHz and 40MHz.
 	//
@@ -324,7 +324,7 @@ VOID	RTMPReadTxPwrPerRate(
 	{
 		if ((value2 & 0x80))
 			Gpwrdelta = (value2&0xf);
-		
+
 		if ((value2 & 0x40))
 			bGpwrdeltaMinus = FALSE;
 		else
@@ -339,7 +339,7 @@ VOID	RTMPReadTxPwrPerRate(
 			bApwrdeltaMinus = FALSE;
 		else
 			bApwrdeltaMinus = TRUE;
-	}	
+	}
 	DBGPRINT(RT_DEBUG_TRACE, ("Gpwrdelta = %x, Apwrdelta = %x .\n", Gpwrdelta, Apwrdelta));
 
 	//
@@ -382,7 +382,7 @@ VOID	RTMPReadTxPwrPerRate(
 				t4 = ((value&0xf000)>>12)-(Apwrdelta);
 			else
 				t4 = 0;
-		}				
+		}
 		Adata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
 		if (bGpwrdeltaMinus == FALSE)
 		{
@@ -417,9 +417,9 @@ VOID	RTMPReadTxPwrPerRate(
 				t4 = ((value&0xf000)>>12)-(Gpwrdelta);
 			else
 				t4 = 0;
-		}				
+		}
 		Gdata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
-		
+
 		RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_20MHZ_2_4G + i*4 + 2, value);
 		if (bApwrdeltaMinus == FALSE)
 		{
@@ -454,7 +454,7 @@ VOID	RTMPReadTxPwrPerRate(
 				t4 = ((value&0xf000)>>12)-(Apwrdelta);
 			else
 				t4 = 0;
-		}				
+		}
 		Adata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
 		if (bGpwrdeltaMinus == FALSE)
 		{
@@ -489,13 +489,13 @@ VOID	RTMPReadTxPwrPerRate(
 				t4 = ((value&0xf000)>>12)-(Gpwrdelta);
 			else
 				t4 = 0;
-		}				
+		}
 		Gdata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
 		data |= (value<<16);
-		
+
 		pAd->Tx20MPwrCfgABand[i] = pAd->Tx40MPwrCfgABand[i] = Adata;
 		pAd->Tx20MPwrCfgGBand[i] = pAd->Tx40MPwrCfgGBand[i] = Gdata;
-		
+
 		if (data != 0xffffffff)
 			RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, data);
 		DBGPRINT_RAW(RT_DEBUG_TRACE, ("20MHz BW, 2.4G band-%lx,  Adata = %lx,  Gdata = %lx \n", data, Adata, Gdata));
@@ -556,7 +556,7 @@ VOID	RTMPReadTxPwrPerRate(
 					t4 = ((value&0xf000)>>12)-(Gpwrdelta);
 				else
 					t4 = 0;
-			}				
+			}
 			Gdata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
 
 			RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_2_4G + i*4 + 2, value);
@@ -593,7 +593,7 @@ VOID	RTMPReadTxPwrPerRate(
 					t4 = ((value&0xf000)>>12)-(Gpwrdelta);
 				else
 					t4 = 0;
-			}				
+			}
 			Gdata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
 
 			if (i == 0)
@@ -660,9 +660,9 @@ VOID	RTMPReadTxPwrPerRate(
 					t4 = ((value&0xf000)>>12)-(Apwrdelta);
 				else
 					t4 = 0;
-			}				
+			}
 			Adata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
-			
+
 			RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_20MHZ_5G + i*4 + 2, value);
 			if (bApwrdeltaMinus == FALSE)
 			{
@@ -697,7 +697,7 @@ VOID	RTMPReadTxPwrPerRate(
 					t4 = ((value&0xf000)>>12)-(Apwrdelta);
 				else
 					t4 = 0;
-			}				
+			}
 			Adata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
 
 			if (i == 0)
@@ -764,9 +764,9 @@ VOID	RTMPReadTxPwrPerRate(
 					t4 = ((value&0xf000)>>12)-(Apwrdelta);
 				else
 					t4 = 0;
-			}				
+			}
 			Adata = t1 + (t2<<4) + (t3<<8) + (t4<<12);
-			
+
 			RT28xx_EEPROM_READ16(pAd, EEPROM_TXPOWER_BYRATE_40MHZ_5G + i*4 + 2, value);
 			if (bApwrdeltaMinus == FALSE)
 			{
@@ -801,7 +801,7 @@ VOID	RTMPReadTxPwrPerRate(
 					t4 = ((value&0xf000)>>12)-(Apwrdelta);
 				else
 					t4 = 0;
-			}				
+			}
 			Adata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));
 
 			if (i == 0)
@@ -817,10 +817,10 @@ VOID	RTMPReadTxPwrPerRate(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Read initial channel power parameters from EEPROM
-		
+
 	Arguments:
 		Adapter						Pointer to our adapter
 
@@ -830,7 +830,7 @@ VOID	RTMPReadTxPwrPerRate(
 	IRQL = PASSIVE_LEVEL
 
 	Note:
-		
+
 	========================================================================
 */
 VOID	RTMPReadChannelPwr(
@@ -839,12 +839,12 @@ VOID	RTMPReadChannelPwr(
 	UCHAR				i, choffset;
 	EEPROM_TX_PWR_STRUC	    Power;
 	EEPROM_TX_PWR_STRUC	    Power2;
-	
+
 	// Read Tx power value for all channels
 	// Value from 1 - 0x7f. Default value is 24.
 	// Power value : 2.4G 0x00 (0) ~ 0x1F (31)
 	//             : 5.5G 0xF9 (-7) ~ 0x0F (15)
-	
+
 	// 0. 11b/g, ch1 - ch 14
 	for (i = 0; i < 7; i++)
 	{
@@ -873,7 +873,7 @@ VOID	RTMPReadChannelPwr(
 		else
 			pAd->TxPower[i * 2 + 1].Power2 = Power2.field.Byte1;
 	}
-	
+
 	// 1. U-NII lower/middle band: 36, 38, 40; 44, 46, 48; 52, 54, 56; 60, 62, 64 (including central frequency in BW 40MHz)
 	// 1.1 Fill up channel
 	choffset = 14;
@@ -902,15 +902,15 @@ VOID	RTMPReadChannelPwr(
 			pAd->TxPower[i * 2 + choffset + 0].Power = Power.field.Byte0;
 
 		if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))
-			pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;			
+			pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;
 
 		if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))
 			pAd->TxPower[i * 2 + choffset + 0].Power2 = Power2.field.Byte0;
 
 		if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))
-			pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;			
+			pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;
 	}
-	
+
 	// 2. HipperLAN 2 100, 102 ,104; 108, 110, 112; 116, 118, 120; 124, 126, 128; 132, 134, 136; 140 (including central frequency in BW 40MHz)
 	// 2.1 Fill up channel
 	choffset = 14 + 12;
@@ -942,13 +942,13 @@ VOID	RTMPReadChannelPwr(
 			pAd->TxPower[i * 2 + choffset + 0].Power = Power.field.Byte0;
 
 		if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))
-			pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;			
+			pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;
 
 		if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))
 			pAd->TxPower[i * 2 + choffset + 0].Power2 = Power2.field.Byte0;
 
 		if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))
-			pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;			
+			pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;
 	}
 
 	// 3. U-NII upper band: 149, 151, 153; 157, 159, 161; 165 (including central frequency in BW 40MHz)
@@ -982,28 +982,28 @@ VOID	RTMPReadChannelPwr(
 			pAd->TxPower[i * 2 + choffset + 0].Power = Power.field.Byte0;
 
 		if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))
-			pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;			
+			pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;
 
 		if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))
 			pAd->TxPower[i * 2 + choffset + 0].Power2 = Power2.field.Byte0;
 
 		if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))
-			pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;			
+			pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;
 	}
 
 	// 4. Print and Debug
 	choffset = 14 + 12 + 16 + 7;
-	
+
 
 #if 0
 	// Init the 802.11j channel number for TX channel power
-	// 0. 20MHz 
+	// 0. 20MHz
 	for (i = 0; i < 3; i++)
 	{
 		pAd->TxPower11J[i].Channel = 8 + i * 4;
 		pAd->TxPower11J[i].BW = BW_20;
 	}
-	
+
 	for (i = 0; i < 4; i++)
 	{
 		pAd->TxPower11J[i + 3].Channel = 34 + i * 4;
@@ -1016,7 +1016,7 @@ VOID	RTMPReadChannelPwr(
 		pAd->TxPower11J[i + 7].BW = BW_20;
 	}
 
-	// 0. 10MHz 
+	// 0. 10MHz
 	for (i = 0; i < 2; i++)
 	{
 		pAd->TxPower11J[i + 11].Channel = 7 + i;
@@ -1024,7 +1024,7 @@ VOID	RTMPReadChannelPwr(
 	}
 	pAd->TxPower11J[13].Channel = 11;
 	pAd->TxPower11J[13].BW = BW_10;
-	
+
 	for (i = 0; i < 3; i++)
 	{
 		pAd->TxPower11J[i + 14].Channel = 183 + i;
@@ -1045,20 +1045,20 @@ VOID	RTMPReadChannelPwr(
 			pAd->TxPower11J[i * 2].Power = Power.field.Byte0;
 
 		if ((Power.field.Byte1 < 36) && (Power.field.Byte1 > -6))
-			pAd->TxPower11J[i * 2 + 1].Power = Power.field.Byte1;			
+			pAd->TxPower11J[i * 2 + 1].Power = Power.field.Byte1;
 
 		if ((Power2.field.Byte0 < 36) && (Power2.field.Byte0 > -6))
 			pAd->TxPower11J[i * 2].Power2 = Power2.field.Byte0;
 
 		if ((Power2.field.Byte1 < 36) && (Power2.field.Byte1 > -6))
-			pAd->TxPower11J[i * 2 + 1].Power2 = Power2.field.Byte1;			
+			pAd->TxPower11J[i * 2 + 1].Power2 = Power2.field.Byte1;
 	}
 #endif
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Read the following from the registry
 		1. All the parameters
@@ -1076,7 +1076,7 @@ VOID	RTMPReadChannelPwr(
 	IRQL = PASSIVE_LEVEL
 
 	Note:
-	
+
 	========================================================================
 */
 NDIS_STATUS	NICReadRegParameters(
@@ -1094,10 +1094,10 @@ NDIS_STATUS	NICReadRegParameters(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Read initial parameters from EEPROM
-		
+
 	Arguments:
 		Adapter						Pointer to our adapter
 
@@ -1107,7 +1107,7 @@ NDIS_STATUS	NICReadRegParameters(
 	IRQL = PASSIVE_LEVEL
 
 	Note:
-		
+
 	========================================================================
 */
 VOID	NICReadEEPROMParameters(
@@ -1122,7 +1122,7 @@ VOID	NICReadEEPROMParameters(
 	EEPROM_ANTENNA_STRUC	Antenna;
 	EEPROM_NIC_CONFIG2_STRUC    NicConfig2;
 
-	DBGPRINT(RT_DEBUG_TRACE, ("--> NICReadEEPROMParameters\n"));	
+	DBGPRINT(RT_DEBUG_TRACE, ("--> NICReadEEPROMParameters\n"));
 
 	// Init EEPROM Address Number, before access EEPROM; if 93c46, EEPROMAddressNum=6, else if 93c66, EEPROMAddressNum=8
 	RTMP_IO_READ32(pAd, E2PROM_CSR, &data);
@@ -1139,7 +1139,7 @@ VOID	NICReadEEPROMParameters(
 	// RT2860 MAC no longer auto load MAC address from E2PROM. Driver has to intialize
 	// MAC address registers according to E2PROM setting
 	if (mac_addr == NULL ||
-		strlen(mac_addr) != 17 || 
+		strlen(mac_addr) != 17 ||
 		mac_addr[2] != ':'  || mac_addr[5] != ':'  || mac_addr[8] != ':' ||
 		mac_addr[11] != ':' || mac_addr[14] != ':')
 	{
@@ -1169,23 +1169,23 @@ VOID	NICReadEEPROMParameters(
 		{
 			AtoH(macptr, &pAd->PermanentAddress[j], 1);
 			macptr=macptr+3;
-		}	
-		
+		}
+
 		DBGPRINT(RT_DEBUG_TRACE, ("Initialize MAC Address from module parameter \n"));
 	}
-	
-	
+
+
 	{
 		//more conveninet to test mbssid, so ap's bssid &0xf1
 		if (pAd->PermanentAddress[0] == 0xff)
 			pAd->PermanentAddress[0] = RandomByte(pAd)&0xf8;
-		
+
 		//if (pAd->PermanentAddress[5] == 0xff)
 		//	pAd->PermanentAddress[5] = RandomByte(pAd)&0xf8;
-			
+
 		DBGPRINT_RAW(RT_DEBUG_TRACE,("E2PROM MAC: =%02x:%02x:%02x:%02x:%02x:%02x\n",
-			pAd->PermanentAddress[0], pAd->PermanentAddress[1], 
-			pAd->PermanentAddress[2], pAd->PermanentAddress[3], 
+			pAd->PermanentAddress[0], pAd->PermanentAddress[1],
+			pAd->PermanentAddress[2], pAd->PermanentAddress[3],
 			pAd->PermanentAddress[4], pAd->PermanentAddress[5]));
 		if (pAd->bLocalAdminMAC == FALSE)
 		{
@@ -1203,14 +1203,14 @@ VOID	NICReadEEPROMParameters(
 			csr3.field.U2MeMask = 0xff;
 			RTMP_IO_WRITE32(pAd, MAC_ADDR_DW1, csr3.word);
 			DBGPRINT_RAW(RT_DEBUG_TRACE,("E2PROM MAC: =%02x:%02x:%02x:%02x:%02x:%02x\n",
-				pAd->PermanentAddress[0], pAd->PermanentAddress[1], 
-				pAd->PermanentAddress[2], pAd->PermanentAddress[3], 
+				pAd->PermanentAddress[0], pAd->PermanentAddress[1],
+				pAd->PermanentAddress[2], pAd->PermanentAddress[3],
 				pAd->PermanentAddress[4], pAd->PermanentAddress[5]));
 		}
-	}   
+	}
 
 	// if not return early. cause fail at emulation.
-	// Init the channel number for TX channel power	
+	// Init the channel number for TX channel power
 	RTMPReadChannelPwr(pAd);
 
 	// if E2PROM version mismatch with driver's expectation, then skip
@@ -1235,7 +1235,7 @@ VOID	NICReadEEPROMParameters(
 		// Default the channel power
 		for (i = 0; i < MAX_NUM_OF_11JCHANNELS; i++)
 			pAd->TxPower11J[i].Power = DEFAULT_RF_TX_POWER;
-		
+
 		for(i = 0; i < NUM_EEPROM_BBP_PARMS; i++)
 			pAd->EEPROMDefaultValue[i] = 0xffff;
 		return;  */
@@ -1278,7 +1278,7 @@ VOID	NICReadEEPROMParameters(
 	if ((pAd->CommonCfg.RxStream == 0) || (pAd->CommonCfg.RxStream > Antenna.field.RxPath))
 	{
 		pAd->CommonCfg.RxStream = Antenna.field.RxPath;
-	
+
 		if ((pAd->MACVersion < RALINK_2883_VERSION) &&
 			(pAd->CommonCfg.RxStream > 2))
 		{
@@ -1318,7 +1318,7 @@ VOID	NICReadEEPROMParameters(
 		pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = TRUE;
 	else
 		pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = FALSE;
-	
+
 	DBGPRINT_RAW(RT_DEBUG_TRACE, ("NICReadEEPROMParameters: RxPath = %d, TxPath = %d\n", Antenna.field.RxPath, Antenna.field.TxPath));
 
 	// Save the antenna for future use
@@ -1330,18 +1330,18 @@ VOID	NICReadEEPROMParameters(
 	//
 	if ((Antenna.field.RfIcType != RFIC_2850) && (Antenna.field.RfIcType != RFIC_2750))
 	{
-		if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED) || 
+		if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED) ||
 			(pAd->CommonCfg.PhyMode == PHY_11A))
 			pAd->CommonCfg.PhyMode = PHY_11BG_MIXED;
 #ifdef DOT11_N_SUPPORT
-		else if ((pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED)	|| 
-				 (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED) 	|| 
+		else if ((pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED)	||
+				 (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED) 	||
 				 (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED) 	||
 				 (pAd->CommonCfg.PhyMode == PHY_11N_5G))
 			pAd->CommonCfg.PhyMode = PHY_11BGN_MIXED;
 #endif // DOT11_N_SUPPORT //
 	}
-	
+
 	// Read TSSI reference and TSSI boundary for temperature compensation. This is ugly
 	// 0. 11b/g
 	{
@@ -1363,7 +1363,7 @@ VOID	NICReadEEPROMParameters(
 		pAd->TssiPlusBoundaryG[3] = Power.field.Byte1;
 		RT28xx_EEPROM_READ16(pAd, 0x76, Power.word);
 		pAd->TssiPlusBoundaryG[4] = Power.field.Byte0;
-		pAd->TxAgcStepG = Power.field.Byte1;    
+		pAd->TxAgcStepG = Power.field.Byte1;
 		pAd->TxAgcCompensateG = 0;
 		pAd->TssiMinusBoundaryG[0] = pAd->TssiRefG;
 		pAd->TssiPlusBoundaryG[0]  = pAd->TssiRefG;
@@ -1377,7 +1377,7 @@ VOID	NICReadEEPROMParameters(
 			pAd->TssiRefG,
 			pAd->TssiPlusBoundaryG[1], pAd->TssiPlusBoundaryG[2], pAd->TssiPlusBoundaryG[3], pAd->TssiPlusBoundaryG[4],
 			pAd->TxAgcStepG, pAd->bAutoTxAgcG));
-	}	
+	}
 	// 1. 11a
 	{
 		RT28xx_EEPROM_READ16(pAd, 0xD4, Power.word);
@@ -1394,7 +1394,7 @@ VOID	NICReadEEPROMParameters(
 		pAd->TssiPlusBoundaryA[3] = Power.field.Byte1;
 		RT28xx_EEPROM_READ16(pAd, 0xDC, Power.word);
 		pAd->TssiPlusBoundaryA[4] = Power.field.Byte0;
-		pAd->TxAgcStepA = Power.field.Byte1;    
+		pAd->TxAgcStepA = Power.field.Byte1;
 		pAd->TxAgcCompensateA = 0;
 		pAd->TssiMinusBoundaryA[0] = pAd->TssiRefA;
 		pAd->TssiPlusBoundaryA[0]  = pAd->TssiRefA;
@@ -1408,9 +1408,9 @@ VOID	NICReadEEPROMParameters(
 			pAd->TssiRefA,
 			pAd->TssiPlusBoundaryA[1], pAd->TssiPlusBoundaryA[2], pAd->TssiPlusBoundaryA[3], pAd->TssiPlusBoundaryA[4],
 			pAd->TxAgcStepA, pAd->bAutoTxAgcA));
-	}	
+	}
 	pAd->BbpRssiToDbmDelta = 0x0;
-	
+
 	// Read frequency offset setting for RF
 	RT28xx_EEPROM_READ16(pAd, EEPROM_FREQ_OFFSET, value);
 	if ((value & 0x00FF) != 0x00FF)
@@ -1422,7 +1422,7 @@ VOID	NICReadEEPROMParameters(
 	//CountryRegion byte offset (38h)
 	value = pAd->EEPROMDefaultValue[2] >> 8;		// 2.4G band
 	value2 = pAd->EEPROMDefaultValue[2] & 0x00FF;	// 5G band
-	
+
 	if ((value <= REGION_MAXIMUM_BG_BAND) && (value2 <= REGION_MAXIMUM_A_BAND))
 	{
 		pAd->CommonCfg.CountryRegion = ((UCHAR) value) | 0x80;
@@ -1437,8 +1437,8 @@ VOID	NICReadEEPROMParameters(
 
 	//
 	// Get RSSI Offset on EEPROM 0x9Ah & 0x9Ch.
-	// The valid value are (-10 ~ 10) 
-	// 
+	// The valid value are (-10 ~ 10)
+	//
 	RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET, value);
 	pAd->BGRssiOffset0 = value & 0x00ff;
 	pAd->BGRssiOffset1 = (value >> 8);
@@ -1448,7 +1448,7 @@ VOID	NICReadEEPROMParameters(
 	RT28xx_EEPROM_READ16(pAd, EEPROM_LNA_OFFSET, value);
 	pAd->BLNAGain = value & 0x00ff;
 	pAd->ALNAGain0 = (value >> 8);
-	
+
 	// Validate 11b/g RSSI_0 offset.
 	if ((pAd->BGRssiOffset0 < -10) || (pAd->BGRssiOffset0 > 10))
 		pAd->BGRssiOffset0 = 0;
@@ -1460,7 +1460,7 @@ VOID	NICReadEEPROMParameters(
 	// Validate 11b/g RSSI_2 offset.
 	if ((pAd->BGRssiOffset2 < -10) || (pAd->BGRssiOffset2 > 10))
 		pAd->BGRssiOffset2 = 0;
-		
+
 	RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_A_OFFSET, value);
 	pAd->ARssiOffset0 = value & 0x00ff;
 	pAd->ARssiOffset1 = (value >> 8);
@@ -1496,8 +1496,8 @@ VOID	NICReadEEPROMParameters(
 	pAd->Led2 = value;
 	RT28xx_EEPROM_READ16(pAd, EEPROM_LED3_OFFSET, value);
 	pAd->Led3 = value;
-		
-	RTMPReadTxPwrPerRate(pAd);	
+
+	RTMPReadTxPwrPerRate(pAd);
 
 #ifdef SINGLE_SKU
 	//pAd->CommonCfg.DefineMaxTxPwr = RTMP_EEPROM_READ16(pAd, EEPROM_DEFINE_MAX_TXPWR);
@@ -1509,10 +1509,10 @@ VOID	NICReadEEPROMParameters(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Set default value from EEPROM
-		
+
 	Arguments:
 		Adapter						Pointer to our adapter
 
@@ -1520,9 +1520,9 @@ VOID	NICReadEEPROMParameters(
 		None
 
 	IRQL = PASSIVE_LEVEL
-	
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	NICInitAsicFromEEPROM(
@@ -1530,18 +1530,18 @@ VOID	NICInitAsicFromEEPROM(
 {
 #ifdef CONFIG_STA_SUPPORT
 	UINT32					data = 0;
-	UCHAR	BBPR1 = 0; 
+	UCHAR	BBPR1 = 0;
 #endif // CONFIG_STA_SUPPORT //
 	USHORT					i;
 	EEPROM_ANTENNA_STRUC	Antenna;
 	EEPROM_NIC_CONFIG2_STRUC    NicConfig2;
 	UCHAR	BBPR3 = 0;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitAsicFromEEPROM\n"));
 	for(i = 3; i < NUM_EEPROM_BBP_PARMS; i++)
 	{
 		UCHAR BbpRegIdx, BbpValue;
-	
+
 		if ((pAd->EEPROMDefaultValue[i] != 0xFFFF) && (pAd->EEPROMDefaultValue[i] != 0))
 		{
 			BbpRegIdx = (UCHAR)(pAd->EEPROMDefaultValue[i] >> 8);
@@ -1598,7 +1598,7 @@ VOID	NICInitAsicFromEEPROM(
 			}
 		}
 		else
-			pAd->StaCfg.bHardwareRadio = FALSE;		
+			pAd->StaCfg.bHardwareRadio = FALSE;
 
 		if (pAd->StaCfg.bRadio == FALSE)
 		{
@@ -1607,12 +1607,12 @@ VOID	NICInitAsicFromEEPROM(
 		else
 		{
 			RTMPSetLED(pAd, LED_RADIO_ON);
-#ifdef RT2860        
+#ifdef RT2860
 			AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x02);
 			AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x00);
 			// 2-1. wait command ok.
 			AsicCheckCommanOk(pAd, PowerWakeCID);
-#endif // RT2860 //        
+#endif // RT2860 //
 		}
 	}
 #endif // CONFIG_STA_SUPPORT //
@@ -1627,11 +1627,11 @@ VOID	NICInitAsicFromEEPROM(
 	else
 		pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = FALSE;
 	//
-	// Since BBP has been progamed, to make sure BBP setting will be 
+	// Since BBP has been progamed, to make sure BBP setting will be
 	// upate inside of AsicAntennaSelect, so reset to UNKNOWN_BAND!!
 	//
 	pAd->CommonCfg.BandState = UNKNOWN_BAND;
-	
+
 	RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3);
 	BBPR3 &= (~0x18);
 	if(pAd->Antenna.field.RxPath == 3)
@@ -1658,7 +1658,7 @@ VOID	NICInitAsicFromEEPROM(
 		BBPR1 &= (~0x18);
 		}
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BBPR1);
-    
+
 		DBGPRINT(RT_DEBUG_TRACE, ("Use Hw Radio Control Pin=%d; if used Pin=%d;\n", pAd->CommonCfg.bHardwareRadio, pAd->CommonCfg.bHardwareRadio));
 	}
 #endif // CONFIG_STA_SUPPORT //
@@ -1668,7 +1668,7 @@ VOID	NICInitAsicFromEEPROM(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Initialize NIC hardware
 
@@ -1681,7 +1681,7 @@ VOID	NICInitAsicFromEEPROM(
 	IRQL = PASSIVE_LEVEL
 
 	Note:
-		
+
 	========================================================================
 */
 NDIS_STATUS	NICInitializeAdapter(
@@ -1707,15 +1707,15 @@ retry:
 		RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
 		if ((GloCfg.field.TxDMABusy == 0)  && (GloCfg.field.RxDMABusy == 0))
 			break;
-		
+
 		RTMPusecDelay(1000);
 		i++;
 	}while ( i<100);
-	DBGPRINT(RT_DEBUG_TRACE, ("<== DMA offset 0x208 = 0x%x\n", GloCfg.word));	
+	DBGPRINT(RT_DEBUG_TRACE, ("<== DMA offset 0x208 = 0x%x\n", GloCfg.word));
 	GloCfg.word &= 0xff0;
 	GloCfg.field.EnTXWriteBackDDONE =1;
 	RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-	
+
 	// Record HW Beacon offset
 	pAd->BeaconOffset[0] = HW_BEACON_BASE0;
 	pAd->BeaconOffset[1] = HW_BEACON_BASE1;
@@ -1725,7 +1725,7 @@ retry:
 	pAd->BeaconOffset[5] = HW_BEACON_BASE5;
 	pAd->BeaconOffset[6] = HW_BEACON_BASE6;
 	pAd->BeaconOffset[7] = HW_BEACON_BASE7;
-	
+
 	//
 	// write all shared Ring's base address into ASIC
 	//
@@ -1767,7 +1767,7 @@ retry:
 	DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR2 : 0x%x\n", Value));
 
 	// Write AC_VO base address register
-	Value = RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_VO].Cell[0].AllocPa);	
+	Value = RTMP_GetPhysicalAddressLow(pAd->TxRing[QID_AC_VO].Cell[0].AllocPa);
 	RTMP_IO_WRITE32(pAd, TX_BASE_PTR3, Value);
 	DBGPRINT(RT_DEBUG_TRACE, ("--> TX_BASE_PTR3 : 0x%x\n", Value));
 
@@ -1790,7 +1790,7 @@ retry:
 	pAd->RxRing.RxSwReadIdx = 0;
 	pAd->RxRing.RxCpuIdx = RX_RING_SIZE-1;
 	RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx);
-	
+
 	// Init TX rings index pointer
 	{
 		for (i=0; i<NUM_OF_TX_RING; i++)
@@ -1850,7 +1850,7 @@ retry:
 		RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);
 		if ((GloCfg.field.TxDMABusy == 0)  && (GloCfg.field.RxDMABusy == 0))
 			break;
-		
+
 		RTMPusecDelay(1000);
 		i++;
 	}while ( i < 100);
@@ -1858,7 +1858,7 @@ retry:
 	GloCfg.word &= 0xff0;
 	GloCfg.field.EnTXWriteBackDDONE =1;
 	RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word);
-	
+
 	IntCfg.word = 0;
 	RTMP_IO_WRITE32(pAd, DELAY_INT_CFG, IntCfg.word);
 #endif // RT2860 //
@@ -1874,7 +1874,7 @@ retry:
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Initialize ASIC
 
@@ -1887,7 +1887,7 @@ retry:
 	IRQL = PASSIVE_LEVEL
 
 	Note:
-		
+
 	========================================================================
 */
 NDIS_STATUS	NICInitializeAsic(
@@ -1940,7 +1940,7 @@ NDIS_STATUS	NICInitializeAsic(
 
 		if ((MacCsr12 & 0x03) == 0)	// if BB.RF is stable
 			break;
-		
+
 		DBGPRINT(RT_DEBUG_TRACE, ("Check MAC_STATUS_CFG  = Busy = %x\n", MacCsr12));
 		RTMPusecDelay(1000);
 	} while (Index++ < 100);
@@ -1953,7 +1953,7 @@ NDIS_STATUS	NICInitializeAsic(
 
 	// Read BBP register, make sure BBP is up and running before write new data
 	Index = 0;
-	do 
+	do
 	{
 		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R0, &R0);
 		DBGPRINT(RT_DEBUG_TRACE, ("BBP version = %x\n", R0));
@@ -1968,7 +1968,7 @@ NDIS_STATUS	NICInitializeAsic(
 	{
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBPRegTable[Index].Register, BBPRegTable[Index].Value);
 	}
-	
+
 	// for rt2860E and after, init BBP_R84 with 0x19. This is for extension channel overlapping IOT.
 	if ((pAd->MACVersion&0xffff) != 0x0101)
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R84, 0x19);
@@ -1979,7 +1979,7 @@ NDIS_STATUS	NICInitializeAsic(
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x12);
     }
-	
+
 	if (pAd->MACVersion >= RALINK_2880E_VERSION && pAd->MACVersion < RALINK_3070_VERSION) // 3*3
 	{
 		// enlarge MAX_LEN_CFG
@@ -2002,7 +2002,7 @@ NDIS_STATUS	NICInitializeAsic(
 			DBGPRINT(RT_DEBUG_TRACE, ("Set Radio Off\n"));
 		}
 	}
-#endif // CONFIG_STA_SUPPORT //	
+#endif // CONFIG_STA_SUPPORT //
 
 	// Clear raw counters
 	RTMP_IO_READ32(pAd, RX_STA_CNT0, &Counter);
@@ -2011,10 +2011,10 @@ NDIS_STATUS	NICInitializeAsic(
 	RTMP_IO_READ32(pAd, TX_STA_CNT0, &Counter);
 	RTMP_IO_READ32(pAd, TX_STA_CNT1, &Counter);
 	RTMP_IO_READ32(pAd, TX_STA_CNT2, &Counter);
-	
+
 	// ASIC will keep garbage value after boot
 	// Clear all seared key table when initial
-	// This routine can be ignored in radio-ON/OFF operation. 
+	// This routine can be ignored in radio-ON/OFF operation.
 	if (bHardReset)
 	{
 		for (KeyIdx = 0; KeyIdx < 4; KeyIdx++)
@@ -2028,16 +2028,16 @@ NDIS_STATUS	NICInitializeAsic(
 			RTMP_IO_WRITE32(pAd, MAC_WCID_ATTRIBUTE_BASE + (KeyIdx * HW_WCID_ATTRI_SIZE), 1);
 		}
 	}
-	
 
-	// It isn't necessary to clear this space when not hard reset. 	
+
+	// It isn't necessary to clear this space when not hard reset.
 	if (bHardReset == TRUE)
 	{
-		// clear all on-chip BEACON frame space			
+		// clear all on-chip BEACON frame space
 		for (apidx = 0; apidx < HW_BEACON_MAX_COUNT; apidx++)
 		{
 			for (i = 0; i < HW_BEACON_OFFSET>>2; i+=4)
-				RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[apidx] + i, 0x00); 
+				RTMP_IO_WRITE32(pAd, pAd->BeaconOffset[apidx] + i, 0x00);
 		}
 	}
 
@@ -2056,7 +2056,7 @@ NDIS_STATUS	NICInitializeAsic(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Reset NIC Asics
 
@@ -2070,7 +2070,7 @@ NDIS_STATUS	NICInitializeAsic(
 
 	Note:
 		Reset NIC to initial state AS IS system boot up time.
-		
+
 	========================================================================
 */
 VOID	NICIssueReset(
@@ -2093,7 +2093,7 @@ VOID	NICIssueReset(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Check ASIC registers and find any reason the system might hang
 
@@ -2104,7 +2104,7 @@ VOID	NICIssueReset(
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	========================================================================
 */
 BOOLEAN	NICCheckForHang(
@@ -2123,7 +2123,7 @@ VOID NICUpdateFifoStaCounters(
 	CHAR				reTry;
 	UCHAR				succMCS;
 
-#ifdef RALINK_ATE		
+#ifdef RALINK_ATE
 	/* Nothing to do in ATE mode */
 	if (ATE_ON(pAd))
 		return;
@@ -2161,14 +2161,14 @@ VOID NICUpdateFifoStaCounters(
 #ifdef UAPSD_AP_SUPPORT
 			UAPSD_SP_AUE_Handle(pAd, pEntry, StaFifo.field.TxSuccess);
 #endif // UAPSD_AP_SUPPORT //
- 
+
 			if (!StaFifo.field.TxSuccess)
 			{
 				pEntry->FIFOCount++;
 				pEntry->OneSecTxFailCount++;
-									
+
 				if (pEntry->FIFOCount >= 1)
-				{			
+				{
 					DBGPRINT(RT_DEBUG_TRACE, ("#"));
 #if 0
 					SendRefreshBAR(pAd, pEntry);
@@ -2180,7 +2180,7 @@ VOID NICUpdateFifoStaCounters(
 
 					if(pEntry->PsMode == PWR_ACTIVE)
 					{
-#ifdef DOT11_N_SUPPORT					
+#ifdef DOT11_N_SUPPORT
 						int tid;
 						for (tid=0; tid<NUM_OF_TID; tid++)
 						{
@@ -2192,8 +2192,8 @@ VOID NICUpdateFifoStaCounters(
 						pEntry->ContinueTxFailCnt++;
 					}
 					else
-					{    
-						// Clear the FIFOCount when sta in Power Save mode. Basically we assume 
+					{
+						// Clear the FIFOCount when sta in Power Save mode. Basically we assume
 						//     this tx error happened due to sta just go to sleep.
 						pEntry->FIFOCount = 0;
 						pEntry->ContinueTxFailCnt = 0;
@@ -2233,7 +2233,7 @@ VOID NICUpdateFifoStaCounters(
 				{
 					pEntry->TXMCSSuccessful[pid]++;
 				}
-				else 
+				else
 				{
 					pEntry->TXMCSAutoFallBack[pid][succMCS]++;
 				}
@@ -2248,10 +2248,10 @@ VOID NICUpdateFifoStaCounters(
 				if ((pid >= 12) && succMCS <=7)
 				{
 					reTry -= 4;
-				} 
+				}
 				pEntry->OneSecTxRetryOkCount += reTry;
 			}
-			
+
 			i++;
 			// ASIC store 16 stack
 		} while ( i < (2*TX_RING_SIZE) );
@@ -2260,7 +2260,7 @@ VOID NICUpdateFifoStaCounters(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Read statistical counters from hardware registers and record them
 		in software variables for later on query
@@ -2272,7 +2272,7 @@ VOID NICUpdateFifoStaCounters(
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	========================================================================
 */
 VOID NICUpdateRawCounters(
@@ -2324,7 +2324,7 @@ VOID NICUpdateRawCounters(
 	pAd->WlanCounters.FrameDuplicateCount.u.LowPart += RxStaCnt2.field.RxDupliCount;
 	// Update RX Overflow counter
 	pAd->Counters8023.RxNoBuffer += (RxStaCnt2.field.RxFifoOverflowCount);
-	
+
 	if (!pAd->bUpdateBcnCntDone)
 	{
 	// Update BEACON sent count
@@ -2354,12 +2354,12 @@ VOID NICUpdateRawCounters(
 		pAd->RalinkCounters.TxNonAggCount += TxAggCnt.field.NonAggTxCount;
 		pAd->RalinkCounters.TxAgg1MPDUCount += TxAggCnt0.field.AggSize1Count;
 		pAd->RalinkCounters.TxAgg2MPDUCount += TxAggCnt0.field.AggSize2Count;
-		
+
 		pAd->RalinkCounters.TxAgg3MPDUCount += TxAggCnt1.field.AggSize3Count;
 		pAd->RalinkCounters.TxAgg4MPDUCount += TxAggCnt1.field.AggSize4Count;
 		pAd->RalinkCounters.TxAgg5MPDUCount += TxAggCnt2.field.AggSize5Count;
 		pAd->RalinkCounters.TxAgg6MPDUCount += TxAggCnt2.field.AggSize6Count;
-	
+
 		pAd->RalinkCounters.TxAgg7MPDUCount += TxAggCnt3.field.AggSize7Count;
 		pAd->RalinkCounters.TxAgg8MPDUCount += TxAggCnt3.field.AggSize8Count;
 		pAd->RalinkCounters.TxAgg9MPDUCount += TxAggCnt4.field.AggSize9Count;
@@ -2396,7 +2396,7 @@ VOID NICUpdateRawCounters(
 		pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt6.field.AggSize14Count / 14);
 
 		pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt7.field.AggSize15Count / 15);
-		pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt7.field.AggSize16Count / 16);				
+		pAd->RalinkCounters.TransmittedAMPDUCount.u.LowPart += (TxAggCnt7.field.AggSize16Count / 16);
 	}
 
 #ifdef DBG_DIAGNOSE
@@ -2404,11 +2404,11 @@ VOID NICUpdateRawCounters(
 		RtmpDiagStruct	*pDiag;
 		COUNTER_RALINK	*pRalinkCounters;
 		UCHAR			ArrayCurIdx, i;
-		
+
 		pDiag = &pAd->DiagStruct;
 		pRalinkCounters = &pAd->RalinkCounters;
 		ArrayCurIdx = pDiag->ArrayCurIdx;
-		
+
 		if (pDiag->inited == 0)
 		{
 			NdisZeroMemory(pDiag, sizeof(struct _RtmpDiagStrcut_));
@@ -2439,7 +2439,7 @@ VOID NICUpdateRawCounters(
 			pDiag->TxAMPDUCnt[ArrayCurIdx][15] = TxAggCnt7.field.AggSize16Count;
 
 			pDiag->RxCrcErrCnt[ArrayCurIdx] = RxStaCnt0.field.CrcErr;
-			
+
 			INC_RING_INDEX(pDiag->ArrayCurIdx,  DIAGNOSE_TIME);
 			ArrayCurIdx = pDiag->ArrayCurIdx;
 			for (i =0; i < 9; i++)
@@ -2463,7 +2463,7 @@ VOID NICUpdateRawCounters(
 			if (pDiag->ArrayCurIdx == pDiag->ArrayStartIdx)
 				INC_RING_INDEX(pDiag->ArrayStartIdx,  DIAGNOSE_TIME);
 		}
-		
+
 	}
 #endif // DBG_DIAGNOSE //
 
@@ -2473,7 +2473,7 @@ VOID NICUpdateRawCounters(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Reset NIC from error
 
@@ -2487,7 +2487,7 @@ VOID NICUpdateRawCounters(
 
 	Note:
 		Reset NIC from error state
-		
+
 	========================================================================
 */
 VOID	NICResetFromError(
@@ -2496,22 +2496,22 @@ VOID	NICResetFromError(
 	// Reset BBP (according to alex, reset ASIC will force reset BBP
 	// Therefore, skip the reset BBP
 	// RTMP_IO_WRITE32(pAd, MAC_CSR1, 0x2);
-		
+
 	RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x1);
 	// Remove ASIC from reset state
 	RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0x0);
 
-	NICInitializeAdapter(pAd, FALSE);	
+	NICInitializeAdapter(pAd, FALSE);
 	NICInitAsicFromEEPROM(pAd);
 
-	// Switch to current channel, since during reset process, the connection should remains on.	
+	// Switch to current channel, since during reset process, the connection should remains on.
 	AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
 	AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		erase 8051 firmware image in MAC ASIC
 
@@ -2519,7 +2519,7 @@ VOID	NICResetFromError(
 		Adapter						Pointer to our adapter
 
 	IRQL = PASSIVE_LEVEL
-		
+
 	========================================================================
 */
 VOID NICEraseFirmware(
@@ -2534,7 +2534,7 @@ VOID NICEraseFirmware(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Load 8051 firmware RT2561.BIN file into MAC ASIC
 
@@ -2546,7 +2546,7 @@ VOID NICEraseFirmware(
 		NDIS_STATUS_FAILURE         image not found
 
 	IRQL = PASSIVE_LEVEL
-		
+
 	========================================================================
 */
 NDIS_STATUS NICLoadFirmware(
@@ -2611,7 +2611,7 @@ NDIS_STATUS NICLoadFirmware(
 			/* open the bin file */
 			srcf = filp_open(src, O_RDONLY, 0);
 
-			if (IS_ERR(srcf)) 
+			if (IS_ERR(srcf))
 			{
 				printk("%s - Error %ld opening %s\n",
 					   __FUNCTION__, -PTR_ERR(srcf), src);
@@ -2697,7 +2697,7 @@ NDIS_STATUS NICLoadFirmware(
 			;
 		else
 		{
-			retval = filp_close(srcf, NULL);			
+			retval = filp_close(srcf, NULL);
 			if (retval)
 			{
 				DBGPRINT(RT_DEBUG_ERROR,
@@ -2721,7 +2721,7 @@ NDIS_STATUS NICLoadFirmware(
 	} /* End of if */
 
 	/* enable Host program ram write selection */
-	RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x10000); 
+	RTMP_IO_WRITE32(pAd, PBF_SYS_CTRL, 0x10000);
 
 	for(i=0; i<FileLength; i+=4)
 	{
@@ -2772,7 +2772,7 @@ NDIS_STATUS NICLoadFirmware(
 
 		if (MacReg & 0x80)
 			break;
-		
+
 		RTMPusecDelay(1000);
 	} while (Index++ < 1000);
 
@@ -2790,7 +2790,7 @@ NDIS_STATUS NICLoadFirmware(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Load Tx rate switching parameters
 
@@ -2806,7 +2806,7 @@ NDIS_STATUS NICLoadFirmware(
 	Rate Table Format:
 		1. (B0: Valid Item number) (B1:Initial item from zero)
 		2. Item Number(Dec)      Mode(Hex)     Current MCS(Dec)    TrainUp(Dec)    TrainDown(Dec)
-		
+
 	========================================================================
 */
 NDIS_STATUS NICLoadRateSwitchingParams(
@@ -2817,22 +2817,22 @@ NDIS_STATUS NICLoadRateSwitchingParams(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		if  pSrc1 all zero with length Length, return 0.
 		If not all zero, return 1
 
 	Arguments:
-		pSrc1						 
+		pSrc1
 
 	Return Value:
 		1:			not all zero
 		0:			all zero
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-		
+
 	========================================================================
 */
 ULONG	RTMPNotAllZero(
@@ -2864,23 +2864,23 @@ ULONG	RTMPNotAllZero(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Compare two memory block
 
 	Arguments:
 		pSrc1		Pointer to first memory address
 		pSrc2		Pointer to second memory address
-		
+
 	Return Value:
 		0:			memory is equal
 		1:			pSrc1 memory is larger
 		2:			pSrc2 memory is larger
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-		
+
 	========================================================================
 */
 ULONG	RTMPCompareMemory(
@@ -2909,7 +2909,7 @@ ULONG	RTMPCompareMemory(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Zero out memory block
 
@@ -2919,12 +2919,12 @@ ULONG	RTMPCompareMemory(
 
 	Return Value:
 		None
-		
+
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	RTMPZeroMemory(
@@ -2960,7 +2960,7 @@ VOID	RTMPFillMemory(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Copy data from memory block 1 to memory block 2
 
@@ -2968,15 +2968,15 @@ VOID	RTMPFillMemory(
 		pDest		Pointer to destination memory address
 		pSrc		Pointer to source memory address
 		Length		Copy size
-		
+
 	Return Value:
 		None
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	RTMPMoveMemory(
@@ -3001,7 +3001,7 @@ VOID	RTMPMoveMemory(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Initialize port configuration structure
 
@@ -3014,7 +3014,7 @@ VOID	RTMPMoveMemory(
 	IRQL = PASSIVE_LEVEL
 
 	Note:
-		
+
 	========================================================================
 */
 VOID	UserCfgInit(
@@ -3022,8 +3022,8 @@ VOID	UserCfgInit(
 {
     UINT key_index, bss_index;
 
-	DBGPRINT(RT_DEBUG_TRACE, ("--> UserCfgInit\n"));    
-	 
+	DBGPRINT(RT_DEBUG_TRACE, ("--> UserCfgInit\n"));
+
 	//
 	//  part I. intialize common configuration
 	//
@@ -3037,7 +3037,7 @@ VOID	UserCfgInit(
 		}
 	}
 
-	pAd->Antenna.word = 0; 
+	pAd->Antenna.word = 0;
 	pAd->CommonCfg.BBPCurrentBW = BW_20;
 
 	pAd->LedCntl.word = 0;
@@ -3059,7 +3059,7 @@ VOID	UserCfgInit(
 	pAd->bProtectionTest = FALSE;
 	pAd->bHCCATest = FALSE;
 	pAd->bGenOneHCCA = FALSE;
-	pAd->CommonCfg.Dsifs = 10;      // in units of usec 
+	pAd->CommonCfg.Dsifs = 10;      // in units of usec
 	pAd->CommonCfg.TxPower = 100; //mW
 	pAd->CommonCfg.TxPowerPercentage = 0xffffffff; // AUTO
 	pAd->CommonCfg.TxPowerDefault = 0xffffffff; // AUTO
@@ -3068,7 +3068,7 @@ VOID	UserCfgInit(
 	pAd->CommonCfg.RtsThreshold = 2347;
 	pAd->CommonCfg.FragmentThreshold = 2346;
 	pAd->CommonCfg.UseBGProtection = 0;    // 0: AUTO
-	pAd->CommonCfg.bEnableTxBurst = TRUE; //0;    	
+	pAd->CommonCfg.bEnableTxBurst = TRUE; //0;
 	pAd->CommonCfg.PhyMode = 0xff;     // unknown
 	pAd->CommonCfg.BandState = UNKNOWN_BAND;
 	pAd->CommonCfg.RadarDetect.CSPeriod = 10;
@@ -3091,11 +3091,11 @@ VOID	UserCfgInit(
 	pAd->HTCEnable = FALSE;
 	pAd->bBroadComHT = FALSE;
 	pAd->CommonCfg.bRdg = FALSE;
-	
+
 #ifdef DOT11N_DRAFT3
 	pAd->CommonCfg.Dot11OBssScanPassiveDwell = dot11OBSSScanPassiveDwell;	// Unit : TU. 5~1000
 	pAd->CommonCfg.Dot11OBssScanActiveDwell = dot11OBSSScanActiveDwell;	// Unit : TU. 10~1000
-	pAd->CommonCfg.Dot11BssWidthTriggerScanInt = dot11BSSWidthTriggerScanInterval;	// Unit : Second	
+	pAd->CommonCfg.Dot11BssWidthTriggerScanInt = dot11BSSWidthTriggerScanInterval;	// Unit : Second
 	pAd->CommonCfg.Dot11OBssScanPassiveTotalPerChannel = dot11OBSSScanPassiveTotalPerChannel;	// Unit : TU. 200~10000
 	pAd->CommonCfg.Dot11OBssScanActiveTotalPerChannel = dot11OBSSScanActiveTotalPerChannel;	// Unit : TU. 20~10000
 	pAd->CommonCfg.Dot11BssWidthChanTranDelayFactor = dot11BSSWidthChannelTransactionDelayFactor;
@@ -3109,9 +3109,9 @@ VOID	UserCfgInit(
 	pAd->CommonCfg.BACapability.field.Policy = IMMED_BA;
 	pAd->CommonCfg.BACapability.field.RxBAWinLimit = 64; //32;
 	pAd->CommonCfg.BACapability.field.TxBAWinLimit = 64; //32;
-	DBGPRINT(RT_DEBUG_TRACE, ("--> UserCfgInit. BACapability = 0x%x\n", pAd->CommonCfg.BACapability.word));    
+	DBGPRINT(RT_DEBUG_TRACE, ("--> UserCfgInit. BACapability = 0x%x\n", pAd->CommonCfg.BACapability.word));
 
-	pAd->CommonCfg.BACapability.field.AutoBA = FALSE;	
+	pAd->CommonCfg.BACapability.field.AutoBA = FALSE;
 	BATableInit(pAd, &pAd->BATable);
 
 	pAd->CommonCfg.bExtChannelSwitchAnnouncement = 1;
@@ -3130,7 +3130,7 @@ VOID	UserCfgInit(
 	//pAd->CommonCfg.HTPhyMode.field.ShortGI = GI_800;
 	//pAd->CommonCfg.HTPhyMode.field.STBC = STBC_NONE;
 	pAd->CommonCfg.TxRate = RATE_6;
-	
+
 	pAd->CommonCfg.MlmeTransmit.field.MCS = MCS_RATE_6;
 	pAd->CommonCfg.MlmeTransmit.field.BW = BW_20;
 	pAd->CommonCfg.MlmeTransmit.field.MODE = MODE_OFDM;
@@ -3153,7 +3153,7 @@ VOID	UserCfgInit(
 		pAd->StaCfg.OrigWepStatus = Ndis802_11EncryptionDisabled;
 		pAd->StaCfg.PairCipher = Ndis802_11EncryptionDisabled;
 		pAd->StaCfg.GroupCipher = Ndis802_11EncryptionDisabled;
-		pAd->StaCfg.bMixCipher = FALSE;	
+		pAd->StaCfg.bMixCipher = FALSE;
 		pAd->StaCfg.DefaultKeyId = 0;
 
 		// 802.1x port control
@@ -3250,11 +3250,11 @@ VOID	UserCfgInit(
 
 	// Default for extra information is not valid
 	pAd->ExtraInfo = EXTRA_INFO_CLEAR;
-	
+
 	// Default Config change flag
 	pAd->bConfigChanged = FALSE;
 
-	// 
+	//
 	// part III. AP configurations
 	//
 
@@ -3263,12 +3263,12 @@ VOID	UserCfgInit(
 	// part IV. others
 	//
 	// dynamic BBP R66:sensibity tuning to overcome background noise
-	pAd->BbpTuning.bEnable                = TRUE;  
+	pAd->BbpTuning.bEnable                = TRUE;
 	pAd->BbpTuning.FalseCcaLowerThreshold = 100;
 	pAd->BbpTuning.FalseCcaUpperThreshold = 512;
 	pAd->BbpTuning.R66Delta               = 4;
 	pAd->Mlme.bEnableAutoAntennaCheck = TRUE;
-	
+
 	//
 	// Also initial R66CurrentValue, RTUSBResumeMsduTransmission might use this value.
 	// if not initial this value, the default value will be 0.
@@ -3277,7 +3277,7 @@ VOID	UserCfgInit(
 
 	pAd->Bbp94 = BBPR94_DEFAULT;
 	pAd->BbpForCCK = FALSE;
-	
+
 	// initialize MAC table and allocate spin lock
 	NdisZeroMemory(&pAd->MacTab, sizeof(MAC_TABLE));
 	InitializeQueueHeader(&pAd->MacTab.McastPsQueue);
@@ -3305,7 +3305,7 @@ VOID	UserCfgInit(
 	pAd->ate.bRxFer = 0;
 	pAd->ate.bQATxStart = FALSE;
 	pAd->ate.bQARxStart = FALSE;
-#ifdef RT2860 
+#ifdef RT2860
 	pAd->ate.bFWLoading = FALSE;
 #endif // RT2860 //
 #ifdef RALINK_28xx_QA
@@ -3356,8 +3356,8 @@ void AtoH(char * src, UCHAR * dest, int destlen)
 	char * srcptr;
 	PUCHAR destTemp;
 
-	srcptr = src;	
-	destTemp = (PUCHAR) dest; 
+	srcptr = src;
+	destTemp = (PUCHAR) dest;
 
 	while(destlen--)
 	{
@@ -3377,7 +3377,7 @@ VOID	RTMPPatchMacBbpBug(
 	{
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBPRegTable[Index].Register, (UCHAR)BBPRegTable[Index].Value);
 	}
-	
+
 	// Initialize RF register to default value
 	AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
 	AsicLockChannel(pAd, pAd->CommonCfg.Channel);
@@ -3388,7 +3388,7 @@ VOID	RTMPPatchMacBbpBug(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Init timer objects
 
@@ -3402,7 +3402,7 @@ VOID	RTMPPatchMacBbpBug(
 		None
 
 	Note:
-		
+
 	========================================================================
 */
 VOID	RTMPInitTimer(
@@ -3414,11 +3414,11 @@ VOID	RTMPInitTimer(
 {
 	//
 	// Set Valid to TRUE for later used.
-	// It will crash if we cancel a timer or set a timer 
+	// It will crash if we cancel a timer or set a timer
 	// that we haven't initialize before.
-	// 
+	//
 	pTimer->Valid      = TRUE;
-	
+
 	pTimer->PeriodicType = Repeat;
 	pTimer->State      = FALSE;
 	pTimer->cookie = (ULONG) pData;
@@ -3429,7 +3429,7 @@ VOID	RTMPInitTimer(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Init timer objects
 
@@ -3442,7 +3442,7 @@ VOID	RTMPInitTimer(
 
 	Note:
 		To use this routine, must call RTMPInitTimer before.
-		
+
 	========================================================================
 */
 VOID	RTMPSetTimer(
@@ -3473,7 +3473,7 @@ VOID	RTMPSetTimer(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Init timer objects
 
@@ -3486,7 +3486,7 @@ VOID	RTMPSetTimer(
 
 	Note:
 		To use this routine, must call RTMPInitTimer before.
-		
+
 	========================================================================
 */
 VOID	RTMPModTimer(
@@ -3517,7 +3517,7 @@ VOID	RTMPModTimer(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Cancel timer objects
 
@@ -3529,11 +3529,11 @@ VOID	RTMPModTimer(
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
 		1.) To use this routine, must call RTMPInitTimer before.
 		2.) Reset NIC to initial state AS IS system boot up time.
-		
+
 	========================================================================
 */
 VOID	RTMPCancelTimer(
@@ -3545,7 +3545,7 @@ VOID	RTMPCancelTimer(
 		if (pTimer->State == FALSE)
 			pTimer->Repeat = FALSE;
 			RTMP_OS_Del_Timer(&pTimer->TimerObj, pCancelled);
-			
+
 		if (*pCancelled == TRUE)
 			pTimer->State = TRUE;
 
@@ -3554,7 +3554,7 @@ VOID	RTMPCancelTimer(
 	{
 		//
 		// NdisMCancelTimer just canced the timer and not mean release the timer.
-		// And don't set the "Valid" to False. So that we can use this timer again.	
+		// And don't set the "Valid" to False. So that we can use this timer again.
 		//
 		DBGPRINT_ERR(("RTMPCancelTimer failed, Timer hasn't been initialize!\n"));
 	}
@@ -3562,7 +3562,7 @@ VOID	RTMPCancelTimer(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Set LED Status
 
@@ -3575,13 +3575,13 @@ VOID	RTMPCancelTimer(
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-		
+
 	========================================================================
 */
 VOID RTMPSetLED(
-	IN PRTMP_ADAPTER 	pAd, 
+	IN PRTMP_ADAPTER 	pAd,
 	IN UCHAR			Status)
 {
 	//ULONG			data;
@@ -3601,7 +3601,7 @@ VOID RTMPSetLED(
 		case LED_LINK_DOWN:
 			HighByte = 0x20;
 			AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
-			pAd->LedIndicatorStregth = 0; 
+			pAd->LedIndicatorStregth = 0;
 			break;
 		case LED_LINK_UP:
 			if (pAd->CommonCfg.Channel > 14)
@@ -3614,7 +3614,7 @@ VOID RTMPSetLED(
 			HighByte = 0x20;
 			AsicSendCommandToMcu(pAd, 0x50, 0xff, LowByte, HighByte);
 			break;
-		case LED_HALT: 
+		case LED_HALT:
 			LowByte = 0; // Driver sets MAC register and MAC controls LED
 		case LED_RADIO_OFF:
 			HighByte = 0;
@@ -3643,15 +3643,15 @@ VOID RTMPSetLED(
 	//
 	if ((Status != LED_ON_SITE_SURVEY) && (Status != LED_POWER_UP))
 		pAd->LedStatus = Status;
-    
+
 	DBGPRINT(RT_DEBUG_TRACE, ("RTMPSetLED::Mode=%d,HighByte=0x%02x,LowByte=0x%02x\n", pAd->LedCntl.field.LedMode, HighByte, LowByte));
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
-		Set LED Signal Stregth 
+		Set LED Signal Stregth
 
 	Arguments:
 		pAd						Pointer to our adapter
@@ -3661,9 +3661,9 @@ VOID RTMPSetLED(
 		None
 
 	IRQL = PASSIVE_LEVEL
-	
+
 	Note:
-		Can be run on any IRQL level. 
+		Can be run on any IRQL level.
 
 		According to Microsoft Zero Config Wireless Signal Stregth definition as belows.
 		<= -90  No Signal
@@ -3671,11 +3671,11 @@ VOID RTMPSetLED(
 		<= -71  Low
 		<= -67  Good
 		<= -57  Very Good
-		 > -57  Excellent		
+		 > -57  Excellent
 	========================================================================
 */
 VOID RTMPSetSignalLED(
-	IN PRTMP_ADAPTER 	pAd, 
+	IN PRTMP_ADAPTER 	pAd,
 	IN NDIS_802_11_RSSI Dbm)
 {
 	UCHAR		nLed = 0;
@@ -3698,7 +3698,7 @@ VOID RTMPSetSignalLED(
 		nLed = 7;
 	else if (Dbm <= -57)
 		nLed = 15;
-	else 
+	else
 		nLed = 31;
 
 	//
@@ -3713,9 +3713,9 @@ VOID RTMPSetSignalLED(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
-		Enable RX 
+		Enable RX
 
 	Arguments:
 		pAd						Pointer to our adapter
@@ -3724,7 +3724,7 @@ VOID RTMPSetSignalLED(
 		None
 
 	IRQL <= DISPATCH_LEVEL
-	
+
 	Note:
 		Before Enable RX, make sure you have enabled Interrupt.
 	========================================================================
@@ -3742,16 +3742,16 @@ VOID RTMPEnableRxTx(
 	{
 		UINT32 rx_filter_flag = APNORMAL;
 
-				
+
 		RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, rx_filter_flag);     // enable RX of DMA block
 	}
 	else
 	{
 		RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL);     // Staion not drop control frame will fail WiFi Certification.
 	}
-	
+
 	RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, 0xc);
-	DBGPRINT(RT_DEBUG_TRACE, ("<== RTMPEnableRxTx\n"));	
+	DBGPRINT(RT_DEBUG_TRACE, ("<== RTMPEnableRxTx\n"));
 }
 
 
diff --git a/common/rtmp_tkip.c b/common/rtmp_tkip.c
index 42d15d6..a87ea3a 100644
--- a/common/rtmp_tkip.c
+++ b/common/rtmp_tkip.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -35,84 +35,84 @@
 	Paul Wu		02-25-02		Initial
 */
 
-#include	"rt_config.h"
+#include "../rt_config.h"
 
-// Rotation functions on 32 bit values 
+// Rotation functions on 32 bit values
 #define ROL32( A, n ) \
-	( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) ) 
-#define ROR32( A, n ) ROL32( (A), 32-(n) ) 
-
-UINT Tkip_Sbox_Lower[256] = 
-{ 
-	0xA5,0x84,0x99,0x8D,0x0D,0xBD,0xB1,0x54, 
-	0x50,0x03,0xA9,0x7D,0x19,0x62,0xE6,0x9A, 
-	0x45,0x9D,0x40,0x87,0x15,0xEB,0xC9,0x0B, 
-	0xEC,0x67,0xFD,0xEA,0xBF,0xF7,0x96,0x5B, 
-	0xC2,0x1C,0xAE,0x6A,0x5A,0x41,0x02,0x4F, 
-	0x5C,0xF4,0x34,0x08,0x93,0x73,0x53,0x3F, 
-	0x0C,0x52,0x65,0x5E,0x28,0xA1,0x0F,0xB5, 
-	0x09,0x36,0x9B,0x3D,0x26,0x69,0xCD,0x9F, 
-	0x1B,0x9E,0x74,0x2E,0x2D,0xB2,0xEE,0xFB, 
-	0xF6,0x4D,0x61,0xCE,0x7B,0x3E,0x71,0x97, 
-	0xF5,0x68,0x00,0x2C,0x60,0x1F,0xC8,0xED, 
-	0xBE,0x46,0xD9,0x4B,0xDE,0xD4,0xE8,0x4A, 
-	0x6B,0x2A,0xE5,0x16,0xC5,0xD7,0x55,0x94, 
-	0xCF,0x10,0x06,0x81,0xF0,0x44,0xBA,0xE3, 
-	0xF3,0xFE,0xC0,0x8A,0xAD,0xBC,0x48,0x04, 
-	0xDF,0xC1,0x75,0x63,0x30,0x1A,0x0E,0x6D, 
-	0x4C,0x14,0x35,0x2F,0xE1,0xA2,0xCC,0x39, 
-	0x57,0xF2,0x82,0x47,0xAC,0xE7,0x2B,0x95, 
-	0xA0,0x98,0xD1,0x7F,0x66,0x7E,0xAB,0x83, 
-	0xCA,0x29,0xD3,0x3C,0x79,0xE2,0x1D,0x76, 
-	0x3B,0x56,0x4E,0x1E,0xDB,0x0A,0x6C,0xE4, 
-	0x5D,0x6E,0xEF,0xA6,0xA8,0xA4,0x37,0x8B, 
-	0x32,0x43,0x59,0xB7,0x8C,0x64,0xD2,0xE0, 
-	0xB4,0xFA,0x07,0x25,0xAF,0x8E,0xE9,0x18, 
-	0xD5,0x88,0x6F,0x72,0x24,0xF1,0xC7,0x51, 
-	0x23,0x7C,0x9C,0x21,0xDD,0xDC,0x86,0x85, 
-	0x90,0x42,0xC4,0xAA,0xD8,0x05,0x01,0x12, 
-	0xA3,0x5F,0xF9,0xD0,0x91,0x58,0x27,0xB9, 
-	0x38,0x13,0xB3,0x33,0xBB,0x70,0x89,0xA7, 
-	0xB6,0x22,0x92,0x20,0x49,0xFF,0x78,0x7A, 
-	0x8F,0xF8,0x80,0x17,0xDA,0x31,0xC6,0xB8, 
-	0xC3,0xB0,0x77,0x11,0xCB,0xFC,0xD6,0x3A 
+	( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) )
+#define ROR32( A, n ) ROL32( (A), 32-(n) )
+
+UINT Tkip_Sbox_Lower[256] =
+{
+	0xA5,0x84,0x99,0x8D,0x0D,0xBD,0xB1,0x54,
+	0x50,0x03,0xA9,0x7D,0x19,0x62,0xE6,0x9A,
+	0x45,0x9D,0x40,0x87,0x15,0xEB,0xC9,0x0B,
+	0xEC,0x67,0xFD,0xEA,0xBF,0xF7,0x96,0x5B,
+	0xC2,0x1C,0xAE,0x6A,0x5A,0x41,0x02,0x4F,
+	0x5C,0xF4,0x34,0x08,0x93,0x73,0x53,0x3F,
+	0x0C,0x52,0x65,0x5E,0x28,0xA1,0x0F,0xB5,
+	0x09,0x36,0x9B,0x3D,0x26,0x69,0xCD,0x9F,
+	0x1B,0x9E,0x74,0x2E,0x2D,0xB2,0xEE,0xFB,
+	0xF6,0x4D,0x61,0xCE,0x7B,0x3E,0x71,0x97,
+	0xF5,0x68,0x00,0x2C,0x60,0x1F,0xC8,0xED,
+	0xBE,0x46,0xD9,0x4B,0xDE,0xD4,0xE8,0x4A,
+	0x6B,0x2A,0xE5,0x16,0xC5,0xD7,0x55,0x94,
+	0xCF,0x10,0x06,0x81,0xF0,0x44,0xBA,0xE3,
+	0xF3,0xFE,0xC0,0x8A,0xAD,0xBC,0x48,0x04,
+	0xDF,0xC1,0x75,0x63,0x30,0x1A,0x0E,0x6D,
+	0x4C,0x14,0x35,0x2F,0xE1,0xA2,0xCC,0x39,
+	0x57,0xF2,0x82,0x47,0xAC,0xE7,0x2B,0x95,
+	0xA0,0x98,0xD1,0x7F,0x66,0x7E,0xAB,0x83,
+	0xCA,0x29,0xD3,0x3C,0x79,0xE2,0x1D,0x76,
+	0x3B,0x56,0x4E,0x1E,0xDB,0x0A,0x6C,0xE4,
+	0x5D,0x6E,0xEF,0xA6,0xA8,0xA4,0x37,0x8B,
+	0x32,0x43,0x59,0xB7,0x8C,0x64,0xD2,0xE0,
+	0xB4,0xFA,0x07,0x25,0xAF,0x8E,0xE9,0x18,
+	0xD5,0x88,0x6F,0x72,0x24,0xF1,0xC7,0x51,
+	0x23,0x7C,0x9C,0x21,0xDD,0xDC,0x86,0x85,
+	0x90,0x42,0xC4,0xAA,0xD8,0x05,0x01,0x12,
+	0xA3,0x5F,0xF9,0xD0,0x91,0x58,0x27,0xB9,
+	0x38,0x13,0xB3,0x33,0xBB,0x70,0x89,0xA7,
+	0xB6,0x22,0x92,0x20,0x49,0xFF,0x78,0x7A,
+	0x8F,0xF8,0x80,0x17,0xDA,0x31,0xC6,0xB8,
+	0xC3,0xB0,0x77,0x11,0xCB,0xFC,0xD6,0x3A
 };
 
-UINT Tkip_Sbox_Upper[256] = 
-{ 
-	0xC6,0xF8,0xEE,0xF6,0xFF,0xD6,0xDE,0x91, 
-	0x60,0x02,0xCE,0x56,0xE7,0xB5,0x4D,0xEC, 
-	0x8F,0x1F,0x89,0xFA,0xEF,0xB2,0x8E,0xFB, 
-	0x41,0xB3,0x5F,0x45,0x23,0x53,0xE4,0x9B, 
-	0x75,0xE1,0x3D,0x4C,0x6C,0x7E,0xF5,0x83, 
-	0x68,0x51,0xD1,0xF9,0xE2,0xAB,0x62,0x2A, 
-	0x08,0x95,0x46,0x9D,0x30,0x37,0x0A,0x2F, 
-	0x0E,0x24,0x1B,0xDF,0xCD,0x4E,0x7F,0xEA, 
-	0x12,0x1D,0x58,0x34,0x36,0xDC,0xB4,0x5B, 
-	0xA4,0x76,0xB7,0x7D,0x52,0xDD,0x5E,0x13, 
-	0xA6,0xB9,0x00,0xC1,0x40,0xE3,0x79,0xB6, 
-	0xD4,0x8D,0x67,0x72,0x94,0x98,0xB0,0x85, 
-	0xBB,0xC5,0x4F,0xED,0x86,0x9A,0x66,0x11, 
-	0x8A,0xE9,0x04,0xFE,0xA0,0x78,0x25,0x4B, 
-	0xA2,0x5D,0x80,0x05,0x3F,0x21,0x70,0xF1, 
-	0x63,0x77,0xAF,0x42,0x20,0xE5,0xFD,0xBF, 
-	0x81,0x18,0x26,0xC3,0xBE,0x35,0x88,0x2E, 
-	0x93,0x55,0xFC,0x7A,0xC8,0xBA,0x32,0xE6, 
-	0xC0,0x19,0x9E,0xA3,0x44,0x54,0x3B,0x0B, 
-	0x8C,0xC7,0x6B,0x28,0xA7,0xBC,0x16,0xAD, 
-	0xDB,0x64,0x74,0x14,0x92,0x0C,0x48,0xB8, 
-	0x9F,0xBD,0x43,0xC4,0x39,0x31,0xD3,0xF2, 
-	0xD5,0x8B,0x6E,0xDA,0x01,0xB1,0x9C,0x49, 
-	0xD8,0xAC,0xF3,0xCF,0xCA,0xF4,0x47,0x10, 
-	0x6F,0xF0,0x4A,0x5C,0x38,0x57,0x73,0x97, 
-	0xCB,0xA1,0xE8,0x3E,0x96,0x61,0x0D,0x0F, 
-	0xE0,0x7C,0x71,0xCC,0x90,0x06,0xF7,0x1C, 
-	0xC2,0x6A,0xAE,0x69,0x17,0x99,0x3A,0x27, 
-	0xD9,0xEB,0x2B,0x22,0xD2,0xA9,0x07,0x33, 
-	0x2D,0x3C,0x15,0xC9,0x87,0xAA,0x50,0xA5, 
-	0x03,0x59,0x09,0x1A,0x65,0xD7,0x84,0xD0, 
-	0x82,0x29,0x5A,0x1E,0x7B,0xA8,0x6D,0x2C 
-}; 
+UINT Tkip_Sbox_Upper[256] =
+{
+	0xC6,0xF8,0xEE,0xF6,0xFF,0xD6,0xDE,0x91,
+	0x60,0x02,0xCE,0x56,0xE7,0xB5,0x4D,0xEC,
+	0x8F,0x1F,0x89,0xFA,0xEF,0xB2,0x8E,0xFB,
+	0x41,0xB3,0x5F,0x45,0x23,0x53,0xE4,0x9B,
+	0x75,0xE1,0x3D,0x4C,0x6C,0x7E,0xF5,0x83,
+	0x68,0x51,0xD1,0xF9,0xE2,0xAB,0x62,0x2A,
+	0x08,0x95,0x46,0x9D,0x30,0x37,0x0A,0x2F,
+	0x0E,0x24,0x1B,0xDF,0xCD,0x4E,0x7F,0xEA,
+	0x12,0x1D,0x58,0x34,0x36,0xDC,0xB4,0x5B,
+	0xA4,0x76,0xB7,0x7D,0x52,0xDD,0x5E,0x13,
+	0xA6,0xB9,0x00,0xC1,0x40,0xE3,0x79,0xB6,
+	0xD4,0x8D,0x67,0x72,0x94,0x98,0xB0,0x85,
+	0xBB,0xC5,0x4F,0xED,0x86,0x9A,0x66,0x11,
+	0x8A,0xE9,0x04,0xFE,0xA0,0x78,0x25,0x4B,
+	0xA2,0x5D,0x80,0x05,0x3F,0x21,0x70,0xF1,
+	0x63,0x77,0xAF,0x42,0x20,0xE5,0xFD,0xBF,
+	0x81,0x18,0x26,0xC3,0xBE,0x35,0x88,0x2E,
+	0x93,0x55,0xFC,0x7A,0xC8,0xBA,0x32,0xE6,
+	0xC0,0x19,0x9E,0xA3,0x44,0x54,0x3B,0x0B,
+	0x8C,0xC7,0x6B,0x28,0xA7,0xBC,0x16,0xAD,
+	0xDB,0x64,0x74,0x14,0x92,0x0C,0x48,0xB8,
+	0x9F,0xBD,0x43,0xC4,0x39,0x31,0xD3,0xF2,
+	0xD5,0x8B,0x6E,0xDA,0x01,0xB1,0x9C,0x49,
+	0xD8,0xAC,0xF3,0xCF,0xCA,0xF4,0x47,0x10,
+	0x6F,0xF0,0x4A,0x5C,0x38,0x57,0x73,0x97,
+	0xCB,0xA1,0xE8,0x3E,0x96,0x61,0x0D,0x0F,
+	0xE0,0x7C,0x71,0xCC,0x90,0x06,0xF7,0x1C,
+	0xC2,0x6A,0xAE,0x69,0x17,0x99,0x3A,0x27,
+	0xD9,0xEB,0x2B,0x22,0xD2,0xA9,0x07,0x33,
+	0x2D,0x3C,0x15,0xC9,0x87,0xAA,0x50,0xA5,
+	0x03,0x59,0x09,0x1A,0x65,0xD7,0x84,0xD0,
+	0x82,0x29,0x5A,0x1E,0x7B,0xA8,0x6D,0x2C
+};
 
 /*****************************/
 /******** SBOX Table *********/
@@ -163,7 +163,7 @@ VOID xor_128(
 	IN  PUCHAR              a,
 	IN  PUCHAR              b,
 	OUT PUCHAR              out);
-	
+
 VOID next_key(
 	IN  PUCHAR              key,
 	IN  INT                 round);
@@ -178,7 +178,7 @@ VOID shift_row(
 
 VOID mix_column(
 	IN  PUCHAR              in,
-	OUT PUCHAR              out);		
+	OUT PUCHAR              out);
 
 UCHAR RTMPCkipSbox(
 	IN  UCHAR               a);
@@ -212,10 +212,10 @@ typedef	struct	PACKED _IV_CONTROL_
 				UCHAR		Byte;
 			}	CONTROL;
 		}	field;
-		
+
 		ULONG	word;
 	}	IV16;
-	
+
 	ULONG	IV32;
 }	TKIP_IV, *PTKIP_IV;
 
@@ -224,235 +224,235 @@ typedef	struct	PACKED _IV_CONTROL_
 	========================================================================
 
 	Routine	Description:
-		Convert from UCHAR[] to ULONG in a portable way 
-		
+		Convert from UCHAR[] to ULONG in a portable way
+
 	Arguments:
       pMICKey		pointer to MIC Key
-		
+
 	Return Value:
 		None
 
 	Note:
-		
+
 	========================================================================
 */
-ULONG	RTMPTkipGetUInt32( 	
+ULONG	RTMPTkipGetUInt32(
 	IN	PUCHAR	pMICKey)
-{  	
-	ULONG	res = 0; 
+{
+	ULONG	res = 0;
 	INT		i;
-	
-	for (i = 0; i < 4; i++) 
-	{ 
-		res |= (*pMICKey++) << (8 * i); 
+
+	for (i = 0; i < 4; i++)
+	{
+		res |= (*pMICKey++) << (8 * i);
 	}
 
-	return res; 
-} 
+	return res;
+}
 
 /*
 	========================================================================
 
 	Routine	Description:
-		Convert from ULONG to UCHAR[] in a portable way 
-		
+		Convert from ULONG to UCHAR[] in a portable way
+
 	Arguments:
       pDst			pointer to destination for convert ULONG to UCHAR[]
       val			the value for convert
-		
+
 	Return Value:
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	RTMPTkipPutUInt32(
 	IN OUT	PUCHAR		pDst,
-	IN		ULONG		val)					  
-{ 	
+	IN		ULONG		val)
+{
 	INT i;
-	
-	for(i = 0; i < 4; i++) 
-	{ 
-		*pDst++ = (UCHAR) (val & 0xff); 
-		val >>= 8; 
-	} 
-} 
+
+	for(i = 0; i < 4; i++)
+	{
+		*pDst++ = (UCHAR) (val & 0xff);
+		val >>= 8;
+	}
+}
 
 /*
 	========================================================================
 
 	Routine	Description:
 		Set the MIC Key.
-		
+
 	Arguments:
       pAd		Pointer to our adapter
       pMICKey		pointer to MIC Key
-		
+
 	Return Value:
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-		
+
 	========================================================================
 */
-VOID RTMPTkipSetMICKey(  
-	IN	PTKIP_KEY_INFO	pTkip,	
+VOID RTMPTkipSetMICKey(
+	IN	PTKIP_KEY_INFO	pTkip,
 	IN	PUCHAR			pMICKey)
-{ 
-	// Set the key 
-	pTkip->K0 = RTMPTkipGetUInt32(pMICKey); 
-	pTkip->K1 = RTMPTkipGetUInt32(pMICKey + 4); 
-	// and reset the message 
+{
+	// Set the key
+	pTkip->K0 = RTMPTkipGetUInt32(pMICKey);
+	pTkip->K1 = RTMPTkipGetUInt32(pMICKey + 4);
+	// and reset the message
 	pTkip->L = pTkip->K0;
 	pTkip->R = pTkip->K1;
 	pTkip->nBytesInM = 0;
 	pTkip->M = 0;
-} 
+}
 
 /*
 	========================================================================
 
 	Routine	Description:
 		Calculate the MIC Value.
-		
+
 	Arguments:
       pAd		Pointer to our adapter
       uChar			Append this uChar
-		
+
 	Return Value:
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-		
+
 	========================================================================
 */
-VOID	RTMPTkipAppendByte( 
-	IN	PTKIP_KEY_INFO	pTkip,	
+VOID	RTMPTkipAppendByte(
+	IN	PTKIP_KEY_INFO	pTkip,
 	IN	UCHAR 			uChar)
-{ 
-	// Append the byte to our word-sized buffer 
-	pTkip->M |= (uChar << (8* pTkip->nBytesInM)); 
-	pTkip->nBytesInM++; 
-	// Process the word if it is full. 
-	if( pTkip->nBytesInM >= 4 ) 
-	{ 
-		pTkip->L ^= pTkip->M; 
-		pTkip->R ^= ROL32( pTkip->L, 17 ); 
-		pTkip->L += pTkip->R; 
-		pTkip->R ^= ((pTkip->L & 0xff00ff00) >> 8) | ((pTkip->L & 0x00ff00ff) << 8); 
-		pTkip->L += pTkip->R; 
-		pTkip->R ^= ROL32( pTkip->L, 3 ); 
-		pTkip->L += pTkip->R; 
-		pTkip->R ^= ROR32( pTkip->L, 2 ); 
-		pTkip->L += pTkip->R; 
-		// Clear the buffer 
-		pTkip->M = 0; 
-		pTkip->nBytesInM = 0; 
-	} 
-} 
+{
+	// Append the byte to our word-sized buffer
+	pTkip->M |= (uChar << (8* pTkip->nBytesInM));
+	pTkip->nBytesInM++;
+	// Process the word if it is full.
+	if( pTkip->nBytesInM >= 4 )
+	{
+		pTkip->L ^= pTkip->M;
+		pTkip->R ^= ROL32( pTkip->L, 17 );
+		pTkip->L += pTkip->R;
+		pTkip->R ^= ((pTkip->L & 0xff00ff00) >> 8) | ((pTkip->L & 0x00ff00ff) << 8);
+		pTkip->L += pTkip->R;
+		pTkip->R ^= ROL32( pTkip->L, 3 );
+		pTkip->L += pTkip->R;
+		pTkip->R ^= ROR32( pTkip->L, 2 );
+		pTkip->L += pTkip->R;
+		// Clear the buffer
+		pTkip->M = 0;
+		pTkip->nBytesInM = 0;
+	}
+}
 
 /*
 	========================================================================
 
 	Routine	Description:
 		Calculate the MIC Value.
-		
+
 	Arguments:
       pAd		Pointer to our adapter
       pSrc			Pointer to source data for Calculate MIC Value
       Len			Indicate the length of the source data
-		
+
 	Return Value:
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-		
+
 	========================================================================
 */
-VOID	RTMPTkipAppend( 
-	IN	PTKIP_KEY_INFO	pTkip,	
+VOID	RTMPTkipAppend(
+	IN	PTKIP_KEY_INFO	pTkip,
 	IN	PUCHAR			pSrc,
-	IN	UINT			nBytes)						  
-{ 
-	// This is simple 
-	while(nBytes > 0) 
-	{ 
-		RTMPTkipAppendByte(pTkip, *pSrc++); 
-		nBytes--; 
-	} 
-} 
+	IN	UINT			nBytes)
+{
+	// This is simple
+	while(nBytes > 0)
+	{
+		RTMPTkipAppendByte(pTkip, *pSrc++);
+		nBytes--;
+	}
+}
 
 /*
 	========================================================================
 
 	Routine	Description:
 		Get the MIC Value.
-		
+
 	Arguments:
       pAd		Pointer to our adapter
-		
+
 	Return Value:
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
 		the MIC Value is store in pAd->PrivateInfo.MIC
 	========================================================================
 */
-VOID	RTMPTkipGetMIC( 
+VOID	RTMPTkipGetMIC(
 	IN	PTKIP_KEY_INFO	pTkip)
-{ 
+{
 	// Append the minimum padding
-	RTMPTkipAppendByte(pTkip, 0x5a );	
-	RTMPTkipAppendByte(pTkip, 0 ); 
-	RTMPTkipAppendByte(pTkip, 0 ); 
-	RTMPTkipAppendByte(pTkip, 0 ); 
-	RTMPTkipAppendByte(pTkip, 0 ); 
-	// and then zeroes until the length is a multiple of 4 
-	while( pTkip->nBytesInM != 0 ) 
-	{ 
-		RTMPTkipAppendByte(pTkip, 0 ); 
-	} 
-	// The appendByte function has already computed the result. 
+	RTMPTkipAppendByte(pTkip, 0x5a );
+	RTMPTkipAppendByte(pTkip, 0 );
+	RTMPTkipAppendByte(pTkip, 0 );
+	RTMPTkipAppendByte(pTkip, 0 );
+	RTMPTkipAppendByte(pTkip, 0 );
+	// and then zeroes until the length is a multiple of 4
+	while( pTkip->nBytesInM != 0 )
+	{
+		RTMPTkipAppendByte(pTkip, 0 );
+	}
+	// The appendByte function has already computed the result.
 	RTMPTkipPutUInt32(pTkip->MIC, pTkip->L);
 	RTMPTkipPutUInt32(pTkip->MIC + 4, pTkip->R);
-} 
+}
 
 /*
 	========================================================================
 
 	Routine	Description:
-		Init Tkip function.	
-		
+		Init Tkip function.
+
 	Arguments:
       pAd		Pointer to our adapter
 		pTKey       Pointer to the Temporal Key (TK), TK shall be 128bits.
 		KeyId		TK Key ID
 		pTA			Pointer to transmitter address
 		pMICKey		pointer to MIC Key
-		
+
 	Return Value:
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 VOID	RTMPInitTkipEngine(
-	IN	PRTMP_ADAPTER	pAd,	
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			pKey,
 	IN	UCHAR			KeyId,
 	IN	PUCHAR			pTA,
@@ -464,10 +464,10 @@ VOID	RTMPInitTkipEngine(
 	TKIP_IV	tkipIv;
 
 	// Prepare 8 bytes TKIP encapsulation for MPDU
-	NdisZeroMemory(&tkipIv, sizeof(TKIP_IV));	
-	tkipIv.IV16.field.rc0 = *(pTSC + 1);	
-	tkipIv.IV16.field.rc1 = (tkipIv.IV16.field.rc0 | 0x20) & 0x7f;	
-	tkipIv.IV16.field.rc2 = *pTSC;	
+	NdisZeroMemory(&tkipIv, sizeof(TKIP_IV));
+	tkipIv.IV16.field.rc0 = *(pTSC + 1);
+	tkipIv.IV16.field.rc1 = (tkipIv.IV16.field.rc0 | 0x20) & 0x7f;
+	tkipIv.IV16.field.rc2 = *pTSC;
 	tkipIv.IV16.field.CONTROL.field.ExtIV = 1;  // 0: non-extended IV, 1: an extended IV
 	tkipIv.IV16.field.CONTROL.field.KeyID = KeyId;
 	NdisMoveMemory(&tkipIv.IV32, (pTSC + 2), 4);   // Copy IV
@@ -480,25 +480,25 @@ VOID	RTMPInitTkipEngine(
 	========================================================================
 
 	Routine	Description:
-		Init MIC Value calculation function which include set MIC key & 
+		Init MIC Value calculation function which include set MIC key &
 		calculate first 16 bytes (DA + SA + priority +  0)
-		
+
 	Arguments:
       pAd		Pointer to our adapter
 		pTKey       Pointer to the Temporal Key (TK), TK shall be 128bits.
 		pDA			Pointer to DA address
 		pSA			Pointer to SA address
 		pMICKey		pointer to MIC Key
-		
+
 	Return Value:
 		None
 
 	Note:
-	
+
 	========================================================================
 */
 VOID	RTMPInitMICEngine(
-	IN	PRTMP_ADAPTER	pAd,	
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			pKey,
 	IN	PUCHAR			pDA,
 	IN	PUCHAR			pSA,
@@ -522,7 +522,7 @@ VOID	RTMPInitMICEngine(
 
 	Routine	Description:
 		Compare MIC value of received MSDU
-		
+
 	Arguments:
 		pAd	Pointer to our adapter
 		pSrc        Pointer to the received Plain text data
@@ -530,15 +530,15 @@ VOID	RTMPInitMICEngine(
 		pSA			Pointer to SA address
 		pMICKey		pointer to MIC Key
 		Len         the length of the received plain text data exclude MIC value
-		
+
 	Return Value:
 		TRUE        MIC value matched
 		FALSE       MIC value mismatched
-		
+
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 BOOLEAN	RTMPTkipCompareMICValue(
@@ -561,23 +561,23 @@ BOOLEAN	RTMPTkipCompareMICValue(
 	RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSA, MAC_ADDR_LEN);
 	// Priority + 3 bytes of 0
 	RTMPTkipAppend(&pAd->PrivateInfo.Rx, (PUCHAR)&Priority, 4);
-	
+
 	// Calculate MIC value from plain text data
 	RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSrc, Len);
 
 	// Get MIC valude from received frame
 	NdisMoveMemory(OldMic, pSrc + Len, 8);
-	
+
 	// Get MIC value from decrypted plain data
 	RTMPTkipGetMIC(&pAd->PrivateInfo.Rx);
-		
+
 	// Move MIC value from MSDU, this steps should move to data path.
 	// Since the MIC value might cross MPDUs.
 	if(!NdisEqualMemory(pAd->PrivateInfo.Rx.MIC, OldMic, 8))
 	{
 		DBGPRINT_RAW(RT_DEBUG_ERROR, ("RTMPTkipCompareMICValue(): TKIP MIC Error !\n"));  //MIC error.
 
-		
+
 		return (FALSE);
 	}
 	return (TRUE);
@@ -588,7 +588,7 @@ BOOLEAN	RTMPTkipCompareMICValue(
 
 	Routine	Description:
 		Compare MIC value of received MSDU
-		
+
 	Arguments:
 		pAd	Pointer to our adapter
 		pLLC		LLC header
@@ -597,15 +597,15 @@ BOOLEAN	RTMPTkipCompareMICValue(
 		pSA			Pointer to SA address
 		pMICKey		pointer to MIC Key
 		Len         the length of the received plain text data exclude MIC value
-		
+
 	Return Value:
 		TRUE        MIC value matched
 		FALSE       MIC value mismatched
-		
+
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 BOOLEAN	RTMPTkipCompareMICValueWithLLC(
@@ -628,7 +628,7 @@ BOOLEAN	RTMPTkipCompareMICValueWithLLC(
 	RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSA, MAC_ADDR_LEN);
 	// Priority + 3 bytes of 0
 	RTMPTkipAppend(&pAd->PrivateInfo.Rx, (PUCHAR)&Priority, 4);
-	
+
 	// Start with LLC header
 	RTMPTkipAppend(&pAd->PrivateInfo.Rx, pLLC, 8);
 
@@ -637,17 +637,17 @@ BOOLEAN	RTMPTkipCompareMICValueWithLLC(
 
 	// Get MIC valude from received frame
 	NdisMoveMemory(OldMic, pSrc + Len, 8);
-	
+
 	// Get MIC value from decrypted plain data
 	RTMPTkipGetMIC(&pAd->PrivateInfo.Rx);
-		
+
 	// Move MIC value from MSDU, this steps should move to data path.
 	// Since the MIC value might cross MPDUs.
 	if(!NdisEqualMemory(pAd->PrivateInfo.Rx.MIC, OldMic, 8))
 	{
 		DBGPRINT_RAW(RT_DEBUG_ERROR, ("RTMPTkipCompareMICValueWithLLC(): TKIP MIC Error !\n"));  //MIC error.
-	
-		
+
+
 		return (FALSE);
 	}
 	return (TRUE);
@@ -656,22 +656,22 @@ BOOLEAN	RTMPTkipCompareMICValueWithLLC(
 	========================================================================
 
 	Routine	Description:
-		Copy frame from waiting queue into relative ring buffer and set 
+		Copy frame from waiting queue into relative ring buffer and set
 	appropriate ASIC register to kick hardware transmit function
-		
+
 	Arguments:
 		pAd		Pointer	to our adapter
 		PNDIS_PACKET	Pointer to Ndis Packet for MIC calculation
 		pEncap			Pointer to LLC encap data
 		LenEncap		Total encap length, might be 0 which indicates no encap
-		
+
 	Return Value:
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 VOID	RTMPCalculateMICValue(
@@ -692,11 +692,11 @@ VOID	RTMPCalculateMICValue(
 
 	UserPriority = RTMP_GET_PACKET_UP(pPacket);
 	pSrc = pSrcBufVA;
-    
-	// determine if this is a vlan packet 
+
+	// determine if this is a vlan packet
 	if (((*(pSrc + 12) << 8) + *(pSrc + 13)) == 0x8100)
 		vlan_offset = 4;
-	
+
 	{
 		RTMPInitMICEngine(
 			pAd,
@@ -706,14 +706,14 @@ VOID	RTMPCalculateMICValue(
 			UserPriority,
 			pKey->TxMic);
 	}
-	
+
 
 	if (pEncap != NULL)
 	{
 		// LLC encapsulation
 		RTMPTkipAppend(&pAd->PrivateInfo.Tx, pEncap, 6);
 		// Protocol Type
-		RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc + 12 + vlan_offset, 2);		
+		RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc + 12 + vlan_offset, 2);
 	}
 	SrcBufLen -= (14 + vlan_offset);
 	pSrc += (14 + vlan_offset);
@@ -723,8 +723,8 @@ VOID	RTMPCalculateMICValue(
 		{
 			RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc, SrcBufLen);
 		}
-		
-		break;	// No need handle next packet	
+
+		break;	// No need handle next packet
 
 	}	while (TRUE);		// End of copying payload
 
@@ -733,141 +733,141 @@ VOID	RTMPCalculateMICValue(
 }
 
 
-/************************************************************/ 
-/* tkip_sbox()																*/ 
-/* Returns a 16 bit value from a 64K entry table. The Table */ 
-/* is synthesized from two 256 entry byte wide tables.		*/ 
-/************************************************************/ 
+/************************************************************/
+/* tkip_sbox()																*/
+/* Returns a 16 bit value from a 64K entry table. The Table */
+/* is synthesized from two 256 entry byte wide tables.		*/
+/************************************************************/
 
-UINT tkip_sbox(UINT index) 
-{ 
-	UINT index_low; 
-	UINT index_high; 
-	UINT left, right; 
+UINT tkip_sbox(UINT index)
+{
+	UINT index_low;
+	UINT index_high;
+	UINT left, right;
 
-	index_low = (index % 256); 
-	index_high = ((index >> 8) % 256); 
+	index_low = (index % 256);
+	index_high = ((index >> 8) % 256);
 
-	left = Tkip_Sbox_Lower[index_low] + (Tkip_Sbox_Upper[index_low] * 256); 
-	right = Tkip_Sbox_Upper[index_high] + (Tkip_Sbox_Lower[index_high] * 256); 
+	left = Tkip_Sbox_Lower[index_low] + (Tkip_Sbox_Upper[index_low] * 256);
+	right = Tkip_Sbox_Upper[index_high] + (Tkip_Sbox_Lower[index_high] * 256);
 
-	return (left ^ right); 
+	return (left ^ right);
 }
 
-UINT rotr1(UINT a) 
-{ 
-	unsigned int b; 
-
-	if ((a & 0x01) == 0x01) 
-	{ 
-		b = (a >> 1) | 0x8000; 
-	} 
-	else 
-	{ 
-		b = (a >> 1) & 0x7fff; 
-	} 
-	b = b % 65536; 
-	return b; 
-} 
+UINT rotr1(UINT a)
+{
+	unsigned int b;
+
+	if ((a & 0x01) == 0x01)
+	{
+		b = (a >> 1) | 0x8000;
+	}
+	else
+	{
+		b = (a >> 1) & 0x7fff;
+	}
+	b = b % 65536;
+	return b;
+}
 
 VOID RTMPTkipMixKey(
-	UCHAR *key, 
-	UCHAR *ta, 
+	UCHAR *key,
+	UCHAR *ta,
 	ULONG pnl, /* Least significant 16 bits of PN */
-	ULONG pnh, /* Most significant 32 bits of PN */ 
-	UCHAR *rc4key, 
+	ULONG pnh, /* Most significant 32 bits of PN */
+	UCHAR *rc4key,
 	UINT *p1k)
 {
 
-	UINT tsc0; 
+	UINT tsc0;
 	UINT tsc1;
-	UINT tsc2; 
-
-	UINT ppk0; 
-	UINT ppk1; 
-	UINT ppk2; 
-	UINT ppk3; 
-	UINT ppk4; 
-	UINT ppk5; 
-
-	INT i; 
-	INT j; 
-
-	tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */ 
-	tsc1 = (unsigned int)(pnh % 65536); 
-	tsc2 = (unsigned int)(pnl % 65536); /* lsb */ 
-
-	/* Phase 1, step 1 */ 
-	p1k[0] = tsc1; 
-	p1k[1] = tsc0; 
-	p1k[2] = (UINT)(ta[0] + (ta[1]*256)); 
-	p1k[3] = (UINT)(ta[2] + (ta[3]*256)); 
-	p1k[4] = (UINT)(ta[4] + (ta[5]*256)); 
-
-	/* Phase 1, step 2 */ 
-	for (i=0; i<8; i++) 
-	{ 
-		j = 2*(i & 1); 
-		p1k[0] = (p1k[0] + tkip_sbox( (p1k[4] ^ ((256*key[1+j]) + key[j])) % 65536 )) % 65536; 
-		p1k[1] = (p1k[1] + tkip_sbox( (p1k[0] ^ ((256*key[5+j]) + key[4+j])) % 65536 )) % 65536; 
-		p1k[2] = (p1k[2] + tkip_sbox( (p1k[1] ^ ((256*key[9+j]) + key[8+j])) % 65536 )) % 65536; 
-		p1k[3] = (p1k[3] + tkip_sbox( (p1k[2] ^ ((256*key[13+j]) + key[12+j])) % 65536 )) % 65536; 
-		p1k[4] = (p1k[4] + tkip_sbox( (p1k[3] ^ (((256*key[1+j]) + key[j]))) % 65536 )) % 65536; 
-		p1k[4] = (p1k[4] + i) % 65536; 
-	} 
-
-	/* Phase 2, Step 1 */ 
-	ppk0 = p1k[0]; 
-	ppk1 = p1k[1]; 
-	ppk2 = p1k[2]; 
-	ppk3 = p1k[3]; 
-	ppk4 = p1k[4]; 
-	ppk5 = (p1k[4] + tsc2) % 65536; 
-
-	/* Phase2, Step 2 */ 
-	ppk0 = ppk0 + tkip_sbox( (ppk5 ^ ((256*key[1]) + key[0])) % 65536); 
-	ppk1 = ppk1 + tkip_sbox( (ppk0 ^ ((256*key[3]) + key[2])) % 65536); 
-	ppk2 = ppk2 + tkip_sbox( (ppk1 ^ ((256*key[5]) + key[4])) % 65536); 
-	ppk3 = ppk3 + tkip_sbox( (ppk2 ^ ((256*key[7]) + key[6])) % 65536); 
-	ppk4 = ppk4 + tkip_sbox( (ppk3 ^ ((256*key[9]) + key[8])) % 65536); 
-	ppk5 = ppk5 + tkip_sbox( (ppk4 ^ ((256*key[11]) + key[10])) % 65536); 
-
-	ppk0 = ppk0 + rotr1(ppk5 ^ ((256*key[13]) + key[12])); 
-	ppk1 = ppk1 + rotr1(ppk0 ^ ((256*key[15]) + key[14])); 
-	ppk2 = ppk2 + rotr1(ppk1); 
-	ppk3 = ppk3 + rotr1(ppk2); 
-	ppk4 = ppk4 + rotr1(ppk3); 
-	ppk5 = ppk5 + rotr1(ppk4); 
-
-	/* Phase 2, Step 3 */ 
+	UINT tsc2;
+
+	UINT ppk0;
+	UINT ppk1;
+	UINT ppk2;
+	UINT ppk3;
+	UINT ppk4;
+	UINT ppk5;
+
+	INT i;
+	INT j;
+
+	tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
+	tsc1 = (unsigned int)(pnh % 65536);
+	tsc2 = (unsigned int)(pnl % 65536); /* lsb */
+
+	/* Phase 1, step 1 */
+	p1k[0] = tsc1;
+	p1k[1] = tsc0;
+	p1k[2] = (UINT)(ta[0] + (ta[1]*256));
+	p1k[3] = (UINT)(ta[2] + (ta[3]*256));
+	p1k[4] = (UINT)(ta[4] + (ta[5]*256));
+
+	/* Phase 1, step 2 */
+	for (i=0; i<8; i++)
+	{
+		j = 2*(i & 1);
+		p1k[0] = (p1k[0] + tkip_sbox( (p1k[4] ^ ((256*key[1+j]) + key[j])) % 65536 )) % 65536;
+		p1k[1] = (p1k[1] + tkip_sbox( (p1k[0] ^ ((256*key[5+j]) + key[4+j])) % 65536 )) % 65536;
+		p1k[2] = (p1k[2] + tkip_sbox( (p1k[1] ^ ((256*key[9+j]) + key[8+j])) % 65536 )) % 65536;
+		p1k[3] = (p1k[3] + tkip_sbox( (p1k[2] ^ ((256*key[13+j]) + key[12+j])) % 65536 )) % 65536;
+		p1k[4] = (p1k[4] + tkip_sbox( (p1k[3] ^ (((256*key[1+j]) + key[j]))) % 65536 )) % 65536;
+		p1k[4] = (p1k[4] + i) % 65536;
+	}
+
+	/* Phase 2, Step 1 */
+	ppk0 = p1k[0];
+	ppk1 = p1k[1];
+	ppk2 = p1k[2];
+	ppk3 = p1k[3];
+	ppk4 = p1k[4];
+	ppk5 = (p1k[4] + tsc2) % 65536;
+
+	/* Phase2, Step 2 */
+	ppk0 = ppk0 + tkip_sbox( (ppk5 ^ ((256*key[1]) + key[0])) % 65536);
+	ppk1 = ppk1 + tkip_sbox( (ppk0 ^ ((256*key[3]) + key[2])) % 65536);
+	ppk2 = ppk2 + tkip_sbox( (ppk1 ^ ((256*key[5]) + key[4])) % 65536);
+	ppk3 = ppk3 + tkip_sbox( (ppk2 ^ ((256*key[7]) + key[6])) % 65536);
+	ppk4 = ppk4 + tkip_sbox( (ppk3 ^ ((256*key[9]) + key[8])) % 65536);
+	ppk5 = ppk5 + tkip_sbox( (ppk4 ^ ((256*key[11]) + key[10])) % 65536);
+
+	ppk0 = ppk0 + rotr1(ppk5 ^ ((256*key[13]) + key[12]));
+	ppk1 = ppk1 + rotr1(ppk0 ^ ((256*key[15]) + key[14]));
+	ppk2 = ppk2 + rotr1(ppk1);
+	ppk3 = ppk3 + rotr1(ppk2);
+	ppk4 = ppk4 + rotr1(ppk3);
+	ppk5 = ppk5 + rotr1(ppk4);
+
+	/* Phase 2, Step 3 */
     /* Phase 2, Step 3 */
 
-	tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */ 
-	tsc1 = (unsigned int)(pnh % 65536); 
-	tsc2 = (unsigned int)(pnl % 65536); /* lsb */ 
+	tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
+	tsc1 = (unsigned int)(pnh % 65536);
+	tsc2 = (unsigned int)(pnl % 65536); /* lsb */
 
-	rc4key[0] = (tsc2 >> 8) % 256; 
-	rc4key[1] = (((tsc2 >> 8) % 256) | 0x20) & 0x7f; 
-	rc4key[2] = tsc2 % 256; 
-	rc4key[3] = ((ppk5 ^ ((256*key[1]) + key[0])) >> 1) % 256; 
+	rc4key[0] = (tsc2 >> 8) % 256;
+	rc4key[1] = (((tsc2 >> 8) % 256) | 0x20) & 0x7f;
+	rc4key[2] = tsc2 % 256;
+	rc4key[3] = ((ppk5 ^ ((256*key[1]) + key[0])) >> 1) % 256;
 
-	rc4key[4] = ppk0 % 256; 
-	rc4key[5] = (ppk0 >> 8) % 256; 
+	rc4key[4] = ppk0 % 256;
+	rc4key[5] = (ppk0 >> 8) % 256;
 
-	rc4key[6] = ppk1 % 256; 
-	rc4key[7] = (ppk1 >> 8) % 256; 
+	rc4key[6] = ppk1 % 256;
+	rc4key[7] = (ppk1 >> 8) % 256;
 
-	rc4key[8] = ppk2 % 256; 
-	rc4key[9] = (ppk2 >> 8) % 256; 
+	rc4key[8] = ppk2 % 256;
+	rc4key[9] = (ppk2 >> 8) % 256;
 
-	rc4key[10] = ppk3 % 256; 
-	rc4key[11] = (ppk3 >> 8) % 256; 
+	rc4key[10] = ppk3 % 256;
+	rc4key[11] = (ppk3 >> 8) % 256;
 
-	rc4key[12] = ppk4 % 256; 
-	rc4key[13] = (ppk4 >> 8) % 256; 
+	rc4key[12] = ppk4 % 256;
+	rc4key[13] = (ppk4 >> 8) % 256;
 
-	rc4key[14] = ppk5 % 256; 
-	rc4key[15] = (ppk5 >> 8) % 256; 
+	rc4key[14] = ppk5 % 256;
+	rc4key[15] = (ppk5 >> 8) % 256;
 }
 
 
@@ -923,7 +923,7 @@ void construct_mic_header2(
 	mic_header2[4] = mpdu[20];
 	mic_header2[5] = mpdu[21];
 
-	// In Sequence Control field, mute sequence numer bits (12-bit) 
+	// In Sequence Control field, mute sequence numer bits (12-bit)
 	mic_header2[6] = mpdu[22] & 0x0f;   /* SC */
 	mic_header2[7] = 0x00; /* mpdu[23]; */
 
@@ -965,11 +965,11 @@ void construct_mic_iv(
 	int i;
 
 	mic_iv[0] = 0x59;
-	if (qc_exists && a4_exists) 
+	if (qc_exists && a4_exists)
 		mic_iv[1] = mpdu[30] & 0x0f;    /* QoS_TC           */
-	if (qc_exists && !a4_exists) 
+	if (qc_exists && !a4_exists)
 		mic_iv[1] = mpdu[24] & 0x0f;   /* mute bits 7-4    */
-	if (!qc_exists) 
+	if (!qc_exists)
 		mic_iv[1] = 0x00;
 	for (i = 2; i < 8; i++)
 		mic_iv[i] = mpdu[i + 8];                    /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */
@@ -1019,7 +1019,7 @@ void aes128k128d(unsigned char *key, unsigned char *data, unsigned char *ciphert
 		if (round == 0)
 		{
 			xor_128(round_key, data, ciphertext);
-			next_key(round_key, round);         
+			next_key(round_key, round);
 		}
 		else if (round == 10)
 		{
@@ -1068,7 +1068,7 @@ void construct_ctr_preload(
 	  for (i = 8; i < 14; i++)
 			ctr_preload[i] =    pn_vector[13 - i];          /* ctr_preload[8:13] = PN[5:0] */
 #endif
-	ctr_preload[14] =  (unsigned char) (c / 256); // Ctr 
+	ctr_preload[14] =  (unsigned char) (c / 256); // Ctr
 	ctr_preload[15] =  (unsigned char) (c % 256);
 
 }
@@ -1081,7 +1081,7 @@ void construct_ctr_preload(
 BOOLEAN RTMPSoftDecryptTKIP(
 	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR	pData,
-	IN ULONG	DataByteCnt, 
+	IN ULONG	DataByteCnt,
 	IN UCHAR    UserPriority,
 	IN PCIPHER_KEY	pWpaKey)
 {
@@ -1105,7 +1105,7 @@ BOOLEAN RTMPSoftDecryptTKIP(
 	UCHAR			RC4Key[16];
 	UINT			p1k[5]; //for mix_key;
 	ULONG			pnl;/* Least significant 16 bits of PN */
-	ULONG			pnh;/* Most significant 32 bits of PN */ 
+	ULONG			pnh;/* Most significant 32 bits of PN */
 	UINT			num_blocks;
 	UINT			payload_remainder;
 	ARCFOURCONTEXT 	ArcFourContext;
@@ -1121,10 +1121,10 @@ BOOLEAN RTMPSoftDecryptTKIP(
 	fc0 = *pData;
 	fc1 = *(pData + 1);
 
-	fc = *((PUSHORT)pData);	
-	
+	fc = *((PUSHORT)pData);
+
 	frame_type = ((fc0 >> 2) & 0x03);
-	frame_subtype = ((fc0 >> 4) & 0x0f);	
+	frame_subtype = ((fc0 >> 4) & 0x0f);
 
     from_ds = (fc1 & 0x2) >> 1;
     to_ds = (fc1 & 0x1);
@@ -1132,7 +1132,7 @@ BOOLEAN RTMPSoftDecryptTKIP(
     a4_exists = (from_ds & to_ds);
     qc_exists = ((frame_subtype == 0x08) ||    /* Assumed QoS subtypes */
                   (frame_subtype == 0x09) ||   /* Likely to change.    */
-                  (frame_subtype == 0x0a) || 
+                  (frame_subtype == 0x0a) ||
                   (frame_subtype == 0x0b)
                  );
 
@@ -1140,7 +1140,7 @@ BOOLEAN RTMPSoftDecryptTKIP(
 	if (a4_exists)
 		HeaderLen += 6;
 
-	KeyID = *((PUCHAR)(pData+ HeaderLen + 3));	
+	KeyID = *((PUCHAR)(pData+ HeaderLen + 3));
 	KeyID = KeyID >> 6;
 
 	if (pWpaKey[KeyID].KeyLen == 0)
@@ -1149,10 +1149,10 @@ BOOLEAN RTMPSoftDecryptTKIP(
 		return FALSE;
 	}
 
-	duration = *((PUSHORT)(pData+2));	
+	duration = *((PUSHORT)(pData+2));
 
 	seq_control = *((PUSHORT)(pData+22));
-	
+
 	if (qc_exists)
 	{
 		if (a4_exists)
@@ -1164,13 +1164,13 @@ BOOLEAN RTMPSoftDecryptTKIP(
 			qos_control = *((PUSHORT)(pData+24));
 		}
 	}
-	
+
 	if (to_ds == 0 && from_ds == 1)
 	{
 		NdisMoveMemory(DA, pData+4, MAC_ADDR_LEN);
 		NdisMoveMemory(SA, pData+16, MAC_ADDR_LEN);
 		NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN);  //BSSID
-	}	
+	}
 	else if (to_ds == 0 && from_ds == 0 )
 	{
 		NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN);
@@ -1193,12 +1193,12 @@ BOOLEAN RTMPSoftDecryptTKIP(
 	num_blocks = (DataByteCnt - 16) / 16;
 	payload_remainder = (DataByteCnt - 16) % 16;
 
-	pnl = (*(pData + HeaderLen)) * 256 + *(pData + HeaderLen + 2);	
+	pnl = (*(pData + HeaderLen)) * 256 + *(pData + HeaderLen + 2);
 	pnh = *((PULONG)(pData + HeaderLen + 4));
-	pnh = cpu2le32(pnh);	
+	pnh = cpu2le32(pnh);
 	RTMPTkipMixKey(pWpaKey[KeyID].Key, TA, pnl, pnh, RC4Key, p1k);
 
-	ARCFOUR_INIT(&ArcFourContext, RC4Key, 16); 
+	ARCFOUR_INIT(&ArcFourContext, RC4Key, 16);
 
 	ARCFOUR_DECRYPT(&ArcFourContext, pData + HeaderLen, pData + HeaderLen + 8, DataByteCnt - HeaderLen - 8);
 	NdisMoveMemory(&trailfcs, pData + DataByteCnt - 8 - 4, 4);
@@ -1221,7 +1221,7 @@ BOOLEAN RTMPSoftDecryptTKIP(
 	if (!NdisEqualMemory(MIC, TrailMIC, 8))
 	{
 		DBGPRINT(RT_DEBUG_ERROR, ("RTMPSoftDecryptTKIP, WEP Data MIC Error !\n"));	 //MIC error.
-		return (FALSE);		
+		return (FALSE);
 	}
 
 #ifdef RT_BIG_ENDIAN
@@ -1236,18 +1236,18 @@ BOOLEAN RTMPSoftDecryptTKIP(
 BOOLEAN RTMPSoftDecryptAES(
 	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR	pData,
-	IN ULONG	DataByteCnt, 
+	IN ULONG	DataByteCnt,
 	IN PCIPHER_KEY	pWpaKey)
 {
 	UCHAR			KeyID;
 	UINT			HeaderLen;
 	UCHAR			PN[6];
-	UINT			payload_len;	
+	UINT			payload_len;
 	UINT			num_blocks;
 	UINT			payload_remainder;
 	USHORT			fc;
 	UCHAR			fc0;
-	UCHAR			fc1;	
+	UCHAR			fc1;
 	UINT			frame_type;
 	UINT			frame_subtype;
 	UINT			from_ds;
@@ -1262,7 +1262,7 @@ BOOLEAN RTMPSoftDecryptAES(
 	UCHAR 			padded_buffer[16];
 	UCHAR 			mic_iv[16];
 	UCHAR 			mic_header1[16];
-	UCHAR 			mic_header2[16];	
+	UCHAR 			mic_header2[16];
 	UCHAR			MIC[8];
 	UCHAR			TrailMIC[8];
 
@@ -1273,10 +1273,10 @@ BOOLEAN RTMPSoftDecryptAES(
 	fc0 = *pData;
 	fc1 = *(pData + 1);
 
-	fc = *((PUSHORT)pData);	
+	fc = *((PUSHORT)pData);
 
 	frame_type = ((fc0 >> 2) & 0x03);
-	frame_subtype = ((fc0 >> 4) & 0x0f);	
+	frame_subtype = ((fc0 >> 4) & 0x0f);
 
 	from_ds = (fc1 & 0x2) >> 1;
 	to_ds = (fc1 & 0x1);
@@ -1284,7 +1284,7 @@ BOOLEAN RTMPSoftDecryptAES(
 	a4_exists = (from_ds & to_ds);
 	qc_exists = ((frame_subtype == 0x08) ||    /* Assumed QoS subtypes */
 				  (frame_subtype == 0x09) ||   /* Likely to change.    */
-				  (frame_subtype == 0x0a) || 
+				  (frame_subtype == 0x0a) ||
 				  (frame_subtype == 0x0b)
 				 );
 
@@ -1292,7 +1292,7 @@ BOOLEAN RTMPSoftDecryptAES(
 	if (a4_exists)
 		HeaderLen += 6;
 
-	KeyID = *((PUCHAR)(pData+ HeaderLen + 3));	
+	KeyID = *((PUCHAR)(pData+ HeaderLen + 3));
 	KeyID = KeyID >> 6;
 
 	if (pWpaKey[KeyID].KeyLen == 0)
@@ -1310,14 +1310,14 @@ BOOLEAN RTMPSoftDecryptAES(
 
 	payload_len = DataByteCnt - HeaderLen - 8 - 8;	// 8 bytes for CCMP header , 8 bytes for MIC
 	payload_remainder = (payload_len) % 16;
-	num_blocks = (payload_len) / 16; 
-	
-	
+	num_blocks = (payload_len) / 16;
+
+
 
 	// Find start of payload
 	payload_index = HeaderLen + 8; //IV+EIV
 
-	for (i=0; i< num_blocks; i++)	
+	for (i=0; i< num_blocks; i++)
 	{
 		construct_ctr_preload(ctr_preload,
 								a4_exists,
@@ -1335,7 +1335,7 @@ BOOLEAN RTMPSoftDecryptAES(
 
 	//
 	// If there is a short final block, then pad it
-	// encrypt it and copy the unpadded part back 
+	// encrypt it and copy the unpadded part back
 	//
 	if (payload_remainder > 0)
 	{
@@ -1358,7 +1358,7 @@ BOOLEAN RTMPSoftDecryptAES(
 
 	//
 	// Descrypt the MIC
-	// 
+	//
 	construct_ctr_preload(ctr_preload,
 							a4_exists,
 							qc_exists,
@@ -1366,14 +1366,14 @@ BOOLEAN RTMPSoftDecryptAES(
 							PN,
 							0);
 	NdisZeroMemory(padded_buffer, 16);
-	NdisMoveMemory(padded_buffer, pData + payload_index, 8); 
-	
+	NdisMoveMemory(padded_buffer, pData + payload_index, 8);
+
 	aes128k128d(pWpaKey[KeyID].Key, ctr_preload, aes_out);
 
-	bitwise_xor(aes_out, padded_buffer, chain_buffer);	
+	bitwise_xor(aes_out, padded_buffer, chain_buffer);
 
 	NdisMoveMemory(TrailMIC, chain_buffer, 8);
-	
+
 	//
 	// Calculate MIC
 	//
@@ -1411,7 +1411,7 @@ BOOLEAN RTMPSoftDecryptAES(
 	aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
 
 	// iterate through each 16 byte payload block
-	for (i = 0; i < num_blocks; i++)     
+	for (i = 0; i < num_blocks; i++)
 	{
 		bitwise_xor(aes_out, pData + payload_index, chain_buffer);
 		payload_index += 16;
@@ -1425,7 +1425,7 @@ BOOLEAN RTMPSoftDecryptAES(
 		NdisMoveMemory(padded_buffer, pData + payload_index, payload_remainder);
 
 		bitwise_xor(aes_out, padded_buffer, chain_buffer);
-		aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);		
+		aes128k128d(pWpaKey[KeyID].Key, chain_buffer, aes_out);
 	}
 	// aes_out contains padded mic, discard most significant
 	// 8 bytes to generate 64 bit MIC
@@ -1433,7 +1433,7 @@ BOOLEAN RTMPSoftDecryptAES(
 
 	if (!NdisEqualMemory(MIC, TrailMIC, 8))
 	{
-		DBGPRINT(RT_DEBUG_ERROR, ("RTMPSoftDecryptAES, MIC Error !\n"));	 //MIC error.	
+		DBGPRINT(RT_DEBUG_ERROR, ("RTMPSoftDecryptAES, MIC Error !\n"));	 //MIC error.
 		return FALSE;
 	}
 
diff --git a/common/rtmp_wep.c b/common/rtmp_wep.c
index 2b3cd30..ffe26c2 100644
--- a/common/rtmp_wep.c
+++ b/common/rtmp_wep.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -35,9 +35,9 @@
 	Paul Wu		10-28-02		Initial
 */
 
-#include	"rt_config.h"
+#include "../rt_config.h"
 
-UINT FCSTAB_32[256] = 
+UINT FCSTAB_32[256] =
 {
 	0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
 	0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
@@ -59,87 +59,87 @@ UINT FCSTAB_32[256] =
 	0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
 	0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
 	0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
-	0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 
-	0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 
-	0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 
-	0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 
-	0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 
-	0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 
-	0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 
-	0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 
-	0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 
-	0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 
-	0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 
-	0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 
-	0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 
-	0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 
-	0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 
-	0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 
-	0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 
-	0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 
-	0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 
-	0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 
-	0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 
-	0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 
-	0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 
-	0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 
-	0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 
-	0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 
-	0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 
-	0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 
-	0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 
-	0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 
-	0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 
-	0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 
-	0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 
-	0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 
-	0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 
-	0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 
-	0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 
-	0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 
-	0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 
-	0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 
-	0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 
-	0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 
-	0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 
-	0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 
-}; 
+	0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+	0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
+	0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
+	0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+	0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
+	0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
+	0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+	0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
+	0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
+	0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+	0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
+	0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
+	0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+	0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
+	0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
+	0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+	0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
+	0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
+	0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+	0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
+	0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
+	0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+	0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
+	0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
+	0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+	0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
+	0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
+	0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+	0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
+	0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
+	0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+	0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
+	0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
+	0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+	0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
+	0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
+	0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+	0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
+	0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
+	0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+	0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
+	0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
+	0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+	0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
+};
 
 /*
 	========================================================================
 
 	Routine	Description:
-		Init WEP function.	
-		
+		Init WEP function.
+
 	Arguments:
       pAd		Pointer to our adapter
 		pKey        Pointer to the WEP KEY
 		KeyId		   WEP Key ID
 		KeyLen      the length of WEP KEY
 		pDest       Pointer to the destination which Encryption data will store in.
-		
+
 	Return Value:
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 VOID	RTMPInitWepEngine(
-	IN	PRTMP_ADAPTER	pAd,	
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			pKey,
 	IN	UCHAR			KeyId,
-	IN	UCHAR			KeyLen, 
+	IN	UCHAR			KeyLen,
 	IN OUT	PUCHAR		pDest)
 {
 	UINT i;
 	UCHAR   WEPKEY[] = {
 		//IV
-		0x00, 0x11, 0x22, 
+		0x00, 0x11, 0x22,
 		//WEP KEY
-		0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC 
+		0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
 	};
 
 	pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32;   //Init crc32.
@@ -159,35 +159,35 @@ VOID	RTMPInitWepEngine(
 			WEPKEY[i] = RandomByte(pAd);   //Call mlme RandomByte() function.
 		ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY, KeyLen + 3);  //INIT SBOX, KEYLEN+3(IV)
 
-		NdisMoveMemory(pDest, WEPKEY, 3);  //Append Init Vector 
+		NdisMoveMemory(pDest, WEPKEY, 3);  //Append Init Vector
     }
-	*(pDest+3) = (KeyId << 6);       //Append KEYID 
-	
+	*(pDest+3) = (KeyId << 6);       //Append KEYID
+
 }
 
 /*
 	========================================================================
 
 	Routine	Description:
-		Encrypt transimitted data		
-		
+		Encrypt transimitted data
+
 	Arguments:
       pAd		Pointer to our adapter
       pSrc        Pointer to the transimitted source data that will be encrypt
       pDest       Pointer to the destination where entryption data will be store in.
       Len			Indicate the length of the source data
-		
+
 	Return Value:
       None
-		        
+
 	IRQL = DISPATCH_LEVEL
 
 	Note:
-	
+
 	========================================================================
 */
 VOID	RTMPEncryptData(
-	IN	PRTMP_ADAPTER	pAd,	
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			pSrc,
 	IN	PUCHAR			pDest,
 	IN	UINT			Len)
@@ -201,19 +201,19 @@ VOID	RTMPEncryptData(
 	========================================================================
 
 	Routine	Description:
-		Decrypt received WEP data	
-		
+		Decrypt received WEP data
+
 	Arguments:
 		pAdapter		Pointer to our adapter
 		pSrc        Pointer to the received data
 		Len         the length of the received data
-		
+
 	Return Value:
 		TRUE        Decrypt WEP data success
 		FALSE       Decrypt WEP data failed
-		
+
 	Note:
-	
+
 	========================================================================
 */
 BOOLEAN	RTMPSoftDecryptWEP(
@@ -227,20 +227,20 @@ BOOLEAN	RTMPSoftDecryptWEP(
 	UCHAR	KeyIdx;
 	UCHAR   WEPKEY[] = {
 		//IV
-		0x00, 0x11, 0x22, 
+		0x00, 0x11, 0x22,
 		//WEP KEY
-		0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC 
+		0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
 	};
 	UCHAR 	*pPayload = (UCHAR *)pData + LENGTH_802_11;
 	ULONG	payload_len = DataByteCnt - LENGTH_802_11;
 
 	NdisMoveMemory(WEPKEY, pPayload, 3);    //Get WEP IV
-	
+
 	KeyIdx = (*(pPayload + 3) & 0xc0) >> 6;
 	if (pGroupKey[KeyIdx].KeyLen == 0)
 		return (FALSE);
 
-	NdisMoveMemory(WEPKEY + 3, pGroupKey[KeyIdx].Key, pGroupKey[KeyIdx].KeyLen);	
+	NdisMoveMemory(WEPKEY + 3, pGroupKey[KeyIdx].Key, pGroupKey[KeyIdx].KeyLen);
 	ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY, pGroupKey[KeyIdx].KeyLen + 3);
 	ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, pPayload, pPayload + 4, payload_len - 4);
 	NdisMoveMemory(&trailfcs, pPayload + payload_len - 8, 4);
@@ -259,20 +259,20 @@ BOOLEAN	RTMPSoftDecryptWEP(
 	========================================================================
 
 	Routine	Description:
-		The Stream Cipher Encryption Algorithm "ARCFOUR" initialize		
-		
+		The Stream Cipher Encryption Algorithm "ARCFOUR" initialize
+
 	Arguments:
 	   Ctx         Pointer to ARCFOUR CONTEXT (SBOX)
 		pKey        Pointer to the WEP KEY
 		KeyLen      Indicate the length fo the WEP KEY
-		
+
 	Return Value:
 	   None
-		
+
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 VOID	ARCFOUR_INIT(
@@ -285,7 +285,7 @@ VOID	ARCFOUR_INIT(
 	UINT	stateindex;
 	PUCHAR	state;
 	UINT	counter;
-	
+
 	state = Ctx->STATE;
 	Ctx->X = 0;
 	Ctx->Y = 0;
@@ -309,16 +309,16 @@ VOID	ARCFOUR_INIT(
 	========================================================================
 
 	Routine	Description:
-		Get bytes from ARCFOUR CONTEXT (S-BOX)				
-		
+		Get bytes from ARCFOUR CONTEXT (S-BOX)
+
 	Arguments:
 	   Ctx         Pointer to ARCFOUR CONTEXT (SBOX)
-		
+
 	Return Value:
-	   UCHAR  - the value of the ARCFOUR CONTEXT (S-BOX)		
-		
+	   UCHAR  - the value of the ARCFOUR CONTEXT (S-BOX)
+
 	Note:
-	
+
 	========================================================================
 */
 UCHAR	ARCFOUR_BYTE(
@@ -328,7 +328,7 @@ UCHAR	ARCFOUR_BYTE(
   UINT y;
   UCHAR sx, sy;
   PUCHAR state;
-  
+
   state = Ctx->STATE;
   x = (Ctx->X + 1) & 0xff;
   sx = state[x];
@@ -340,31 +340,31 @@ UCHAR	ARCFOUR_BYTE(
   state[x] = sy;
 
   return(state[(sx + sy) & 0xff]);
-  
+
 }
 
 /*
 	========================================================================
 
 	Routine	Description:
-		The Stream Cipher Decryption Algorithm 		
-		
+		The Stream Cipher Decryption Algorithm
+
 	Arguments:
 		Ctx         Pointer to ARCFOUR CONTEXT (SBOX)
-		pDest			Pointer to the Destination 
+		pDest			Pointer to the Destination
 		pSrc        Pointer to the Source data
 		Len         Indicate the length of the Source data
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-	
+
 	========================================================================
 */
 VOID	ARCFOUR_DECRYPT(
 	IN	PARCFOURCONTEXT	Ctx,
-	IN	PUCHAR			pDest, 
+	IN	PUCHAR			pDest,
 	IN	PUCHAR			pSrc,
 	IN	UINT			Len)
 {
@@ -378,21 +378,21 @@ VOID	ARCFOUR_DECRYPT(
 	========================================================================
 
 	Routine	Description:
-		The Stream Cipher Encryption Algorithm 		
-		
+		The Stream Cipher Encryption Algorithm
+
 	Arguments:
 		Ctx         Pointer to ARCFOUR CONTEXT (SBOX)
-		pDest			Pointer to the Destination 
+		pDest			Pointer to the Destination
 		pSrc        Pointer to the Source data
 		Len         Indicate the length of the Source dta
-		
+
 	Return Value:
 		None
-		        
+
 	IRQL = DISPATCH_LEVEL
 
 	Note:
-	
+
 	========================================================================
 */
 VOID	ARCFOUR_ENCRYPT(
@@ -412,14 +412,14 @@ VOID	ARCFOUR_ENCRYPT(
 
 	Routine	Description:
 		The Stream Cipher Encryption Algorithm which conform to the special requirement to encrypt  GTK.
-		
+
 	Arguments:
 		Ctx         Pointer to ARCFOUR CONTEXT (SBOX)
-		pDest			Pointer to the Destination 
+		pDest			Pointer to the Destination
 		pSrc        Pointer to the Source data
 		Len         Indicate the length of the Source dta
-		
-		
+
+
 	========================================================================
 */
 
@@ -433,7 +433,7 @@ VOID	WPAARCFOUR_ENCRYPT(
         //discard first 256 bytes
 	for (i = 0; i < 256; i++)
             ARCFOUR_BYTE(Ctx);
-    
+
 	for (i = 0; i < Len; i++)
 		pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
 }
@@ -444,19 +444,19 @@ VOID	WPAARCFOUR_ENCRYPT(
 
 	Routine	Description:
 		Calculate a new FCS given the current FCS and the new data.
-		
+
 	Arguments:
 		Fcs	      the original FCS value
 		Cp          pointer to the data which will be calculate the FCS
 		Len         the length of the data
-		
+
 	Return Value:
 		UINT - FCS 32 bits
-		        
+
 	IRQL = DISPATCH_LEVEL
 
 	Note:
-	
+
 	========================================================================
 */
 UINT	RTMP_CALC_FCS32(
@@ -467,24 +467,24 @@ UINT	RTMP_CALC_FCS32(
 	while (Len--)
 	   Fcs = (((Fcs) >> 8) ^ FCSTAB_32[((Fcs) ^ (*Cp++)) & 0xff]);
 
-	return (Fcs); 
-} 
+	return (Fcs);
+}
 
 
 /*
 	========================================================================
 
 	Routine	Description:
-		Get last FCS and encrypt it to the destination				
-		
+		Get last FCS and encrypt it to the destination
+
 	Arguments:
-		pDest			Pointer to the Destination 
-		
+		pDest			Pointer to the Destination
+
 	Return Value:
 		None
-		
+
 	Note:
-	
+
 	========================================================================
 */
 VOID	RTMPSetICV(
@@ -493,7 +493,7 @@ VOID	RTMPSetICV(
 {
 	pAd->PrivateInfo.FCSCRC32 ^= 0xffffffff;             /* complement */
 	pAd->PrivateInfo.FCSCRC32 = cpu2le32(pAd->PrivateInfo.FCSCRC32);
-	
+
 	ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest, (PUCHAR) &pAd->PrivateInfo.FCSCRC32, 4);
 }
 
diff --git a/common/spectrum.c b/common/spectrum.c
index fba1191..85e636a 100644
--- a/common/spectrum.c
+++ b/common/spectrum.c
@@ -7,37 +7,37 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 
     Module Name:
 	action.c
- 
+
     Abstract:
     Handle association related requests either from WSTA or from local MLME
- 
+
     Revision History:
     Who          When          What
     ---------    ----------    ----------------------------------------------
 	Fonchi Wu    2008	  	   created for 802.11h
  */
 
-#include "rt_config.h"
+#include "../rt_config.h"
 #include "action.h"
 
 VOID MeasureReqTabInit(
@@ -88,7 +88,7 @@ static PMEASURE_REQ_ENTRY MeasureReqLookUp(
 
 	while (pEntry)
 	{
-		if (pEntry->DialogToken == DialogToken) 
+		if (pEntry->DialogToken == DialogToken)
 			break;
 		else
 		{
@@ -98,7 +98,7 @@ static PMEASURE_REQ_ENTRY MeasureReqLookUp(
 	}
 
 	RTMP_SEM_UNLOCK(&pAd->CommonCfg.MeasureReqTabLock);
-	
+
 	return pEntry;
 }
 
@@ -126,7 +126,7 @@ static PMEASURE_REQ_ENTRY MeasureReqInsert(
 		{
 			NdisGetSystemUpTime(&Now);
 			pEntry = &pTab->Content[i];
- 
+
 			if ((pEntry->Valid == TRUE)
 				&& RTMP_TIME_AFTER((unsigned long)Now, (unsigned long)(pEntry->lastTime + MQ_REQ_AGE_OUT)))
 			{
@@ -159,7 +159,7 @@ static PMEASURE_REQ_ENTRY MeasureReqInsert(
 
 				break;
 			}
- 
+
 			if (pEntry->Valid == FALSE)
 				break;
 		}
@@ -196,7 +196,7 @@ static PMEASURE_REQ_ENTRY MeasureReqInsert(
 		}
 
 		RTMP_SEM_UNLOCK(&pAd->CommonCfg.MeasureReqTabLock);
-	} 
+	}
 
 	return pEntry;
 }
@@ -215,7 +215,7 @@ static VOID MeasureReqDelete(
 	}
 
 	// if empty, return
-	if (pTab->Size == 0) 
+	if (pTab->Size == 0)
 	{
 		DBGPRINT(RT_DEBUG_ERROR, ("pMeasureReqTab empty.\n"));
 		return;
@@ -306,7 +306,7 @@ static PTPC_REQ_ENTRY TpcReqLookUp(
 
 	while (pEntry)
 	{
-		if (pEntry->DialogToken == DialogToken) 
+		if (pEntry->DialogToken == DialogToken)
 			break;
 		else
 		{
@@ -316,7 +316,7 @@ static PTPC_REQ_ENTRY TpcReqLookUp(
 	}
 
 	RTMP_SEM_UNLOCK(&pAd->CommonCfg.TpcReqTabLock);
-	
+
 	return pEntry;
 }
 
@@ -345,7 +345,7 @@ static PTPC_REQ_ENTRY TpcReqInsert(
 		{
 			NdisGetSystemUpTime(&Now);
 			pEntry = &pTab->Content[i];
- 
+
 			if ((pEntry->Valid == TRUE)
 				&& RTMP_TIME_AFTER((unsigned long)Now, (unsigned long)(pEntry->lastTime + TPC_REQ_AGE_OUT)))
 			{
@@ -378,7 +378,7 @@ static PTPC_REQ_ENTRY TpcReqInsert(
 
 				break;
 			}
- 
+
 			if (pEntry->Valid == FALSE)
 				break;
 		}
@@ -415,7 +415,7 @@ static PTPC_REQ_ENTRY TpcReqInsert(
 		}
 
 		RTMP_SEM_UNLOCK(&pAd->CommonCfg.TpcReqTabLock);
-	} 
+	}
 
 	return pEntry;
 }
@@ -434,7 +434,7 @@ static VOID TpcReqDelete(
 	}
 
 	// if empty, return
-	if (pTab->Size == 0) 
+	if (pTab->Size == 0)
 	{
 		DBGPRINT(RT_DEBUG_ERROR, ("pTpcReqTab empty.\n"));
 		return;
@@ -481,9 +481,9 @@ static VOID TpcReqDelete(
 	==========================================================================
 	Description:
 		Get Current TimeS tamp.
-		
+
 	Parametrs:
-	
+
 	Return	: Current Time Stamp.
 	==========================================================================
  */
@@ -498,9 +498,9 @@ static UINT64 GetCurrentTimeStamp(
 	==========================================================================
 	Description:
 		Get Current Transmit Power.
-		
+
 	Parametrs:
-	
+
 	Return	: Current Time Stamp.
 	==========================================================================
  */
@@ -515,12 +515,12 @@ static UINT8 GetCurTxPwr(
 	==========================================================================
 	Description:
 		Insert Dialog Token into frame.
-		
+
 	Parametrs:
 		1. frame buffer pointer.
 		2. frame length.
 		3. Dialog token.
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -544,11 +544,11 @@ static VOID InsertDialogToken(
 	==========================================================================
 	Description:
 		Insert TPC Request IE into frame.
-		
+
 	Parametrs:
 		1. frame buffer pointer.
 		2. frame length.
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -575,13 +575,13 @@ static VOID InsertDialogToken(
 	==========================================================================
 	Description:
 		Insert TPC Report IE into frame.
-		
+
 	Parametrs:
 		1. frame buffer pointer.
 		2. frame length.
 		3. Transmit Power.
 		4. Link Margin.
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -616,14 +616,14 @@ static VOID InsertDialogToken(
 	==========================================================================
 	Description:
 		Insert Channel Switch Announcement IE into frame.
-		
+
 	Parametrs:
 		1. frame buffer pointer.
 		2. frame length.
 		3. channel switch announcement mode.
 		4. new selected channel.
 		5. channel switch announcement count.
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -660,7 +660,7 @@ static VOID InsertChSwAnnIE(
 	==========================================================================
 	Description:
 		Insert Measure Request IE into frame.
-		
+
 	Parametrs:
 		1. frame buffer pointer.
 		2. frame length.
@@ -671,7 +671,7 @@ static VOID InsertChSwAnnIE(
 		7. Measure Start time.
 		8. Measure Duration.
 
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -700,16 +700,16 @@ static VOID InsertMeasureReqIE(
 	==========================================================================
 	Description:
 		Insert Measure Report IE into frame.
-		
+
 	Parametrs:
 		1. frame buffer pointer.
 		2. frame length.
 		3. Measure Token.
 		4. Measure Request Mode.
 		5. Measure Request Type.
-		6. Length of Report Infomation 
+		6. Length of Report Infomation
 		7. Pointer of Report Infomation Buffer.
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -726,7 +726,7 @@ static VOID InsertMeasureReportIE(
 	UINT8 ElementID = IE_MEASUREMENT_REPORT;
 
 	Len = sizeof(MEASURE_REPORT_INFO) + ReportLnfoLen;
-		
+
 	MakeOutgoingFrame(pFrameBuf,					&TempLen,
 						1,							&ElementID,
 						1,							&Len,
@@ -751,17 +751,17 @@ static VOID InsertMeasureReportIE(
 	Description:
 		Prepare Measurement request action frame and enqueue it into
 		management queue waiting for transmition.
-		
+
 	Parametrs:
 		1. the destination mac address of the frame.
-	
+
 	Return	: None.
 	==========================================================================
  */
 VOID EnqueueMeasurementReq(
 	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR pDA,
-	IN UINT8 MeasureToken, 
+	IN UINT8 MeasureToken,
 	IN UINT8 MeasureReqMode,
 	IN UINT8 MeasureReqType,
 	IN UINT8 MeasureCh,
@@ -814,10 +814,10 @@ VOID EnqueueMeasurementReq(
 	Description:
 		Prepare Measurement report action frame and enqueue it into
 		management queue waiting for transmition.
-		
+
 	Parametrs:
 		1. the destination mac address of the frame.
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -825,7 +825,7 @@ VOID EnqueueMeasurementRep(
 	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR pDA,
 	IN UINT8 DialogToken,
-	IN UINT8 MeasureToken, 
+	IN UINT8 MeasureToken,
 	IN UINT8 MeasureReqMode,
 	IN UINT8 MeasureReqType,
 	IN UINT8 ReportInfoLen,
@@ -865,7 +865,7 @@ VOID EnqueueMeasurementRep(
 	MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
 	MlmeFreeMemory(pAd, pOutBuffer);
 
-	return;	
+	return;
 }
 
 /*
@@ -873,10 +873,10 @@ VOID EnqueueMeasurementRep(
 	Description:
 		Prepare TPC Request action frame and enqueue it into
 		management queue waiting for transmition.
-		
+
 	Parametrs:
 		1. the destination mac address of the frame.
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -923,10 +923,10 @@ VOID EnqueueTPCReq(
 	Description:
 		Prepare TPC Report action frame and enqueue it into
 		management queue waiting for transmition.
-		
+
 	Parametrs:
 		1. the destination mac address of the frame.
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -975,18 +975,18 @@ VOID EnqueueTPCRep(
 	Description:
 		Prepare Channel Switch Announcement action frame and enqueue it into
 		management queue waiting for transmition.
-		
+
 	Parametrs:
 		1. the destination mac address of the frame.
 		2. Channel switch announcement mode.
 		2. a New selected channel.
-	
+
 	Return	: None.
 	==========================================================================
  */
 VOID EnqueueChSwAnn(
 	IN PRTMP_ADAPTER pAd,
-	IN PUCHAR pDA, 
+	IN PUCHAR pDA,
 	IN UINT8 ChSwMode,
 	IN UINT8 NewCh)
 {
@@ -1101,13 +1101,13 @@ static VOID StartDFSProcedure(
 	==========================================================================
 	Description:
 		Channel Switch Announcement action frame sanity check.
-		
+
 	Parametrs:
 		1. MLME message containing the received frame
 		2. message length.
 		3. Channel switch announcement infomation buffer.
-		
-	
+
+
 	Return	: None.
 	==========================================================================
  */
@@ -1117,7 +1117,7 @@ static VOID StartDFSProcedure(
   +----+-----+-----------+------------+-----------+
   | ID | Len |Ch Sw Mode | New Ch Num | Ch Sw Cnt |
   +----+-----+-----------+------------+-----------+
-    1    1        1           1            1      
+    1    1        1           1            1
 */
 static BOOLEAN PeerChSwAnnSanity(
 	IN PRTMP_ADAPTER pAd,
@@ -1149,14 +1149,14 @@ static BOOLEAN PeerChSwAnnSanity(
 				NdisMoveMemory(&pChSwAnnInfo->ChSwMode, eid_ptr->Octet, 1);
 				NdisMoveMemory(&pChSwAnnInfo->Channel, eid_ptr->Octet + 1, 1);
 				NdisMoveMemory(&pChSwAnnInfo->ChSwCnt, eid_ptr->Octet + 2, 1);
-				
+
 				result = TRUE;
                 break;
-            
+
 			default:
 				break;
 		}
-		eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);        
+		eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
 	}
 
 	return result;
@@ -1166,12 +1166,12 @@ static BOOLEAN PeerChSwAnnSanity(
 	==========================================================================
 	Description:
 		Measurement request action frame sanity check.
-		
+
 	Parametrs:
 		1. MLME message containing the received frame
 		2. message length.
 		3. Measurement request infomation buffer.
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -1219,7 +1219,7 @@ static BOOLEAN PeerMeasureReqSanity(
 				pMeasureReqInfo->MeasureReq.MeasureStartTime = SWAP64(MeasureStartTime);
 				NdisMoveMemory(&MeasureDuration, ptr + 9, 2);
 				pMeasureReqInfo->MeasureReq.MeasureDuration = SWAP16(MeasureDuration);
-				
+
 				result = TRUE;
 				break;
 
@@ -1236,13 +1236,13 @@ static BOOLEAN PeerMeasureReqSanity(
 	==========================================================================
 	Description:
 		Measurement report action frame sanity check.
-		
+
 	Parametrs:
 		1. MLME message containing the received frame
 		2. message length.
 		3. Measurement report infomation buffer.
 		4. basic report infomation buffer.
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -1311,7 +1311,7 @@ static BOOLEAN PeerMeasureReportSanity(
 					NdisMoveMemory(&pReport->MeasureStartTime, ptr + 1, 8);
 					NdisMoveMemory(&pReport->MeasureDuration, ptr + 9, 2);
 					NdisMoveMemory(&pReport->Map, ptr + 11, 1);
-					
+
 				}
 				else if (pMeasureReportInfo->ReportType == RM_CCA)
 				{
@@ -1321,7 +1321,7 @@ static BOOLEAN PeerMeasureReportSanity(
 					NdisMoveMemory(&pReport->MeasureStartTime, ptr + 1, 8);
 					NdisMoveMemory(&pReport->MeasureDuration, ptr + 9, 2);
 					NdisMoveMemory(&pReport->CCA_Busy_Fraction, ptr + 11, 1);
-					
+
 				}
 				else if (pMeasureReportInfo->ReportType == RM_RPI_HISTOGRAM)
 				{
@@ -1348,12 +1348,12 @@ static BOOLEAN PeerMeasureReportSanity(
 	==========================================================================
 	Description:
 		TPC Request action frame sanity check.
-		
+
 	Parametrs:
 		1. MLME message containing the received frame
 		2. message length.
 		3. Dialog Token.
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -1396,20 +1396,20 @@ static BOOLEAN PeerTpcReqSanity(
 		eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
 	}
 
-	return result;	
+	return result;
 }
 
 /*
 	==========================================================================
 	Description:
 		TPC Report action frame sanity check.
-		
+
 	Parametrs:
 		1. MLME message containing the received frame
 		2. message length.
 		3. Dialog Token.
 		4. TPC Report IE.
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -1455,23 +1455,23 @@ static BOOLEAN PeerTpcRepSanity(
 		eid_ptr = (PEID_STRUCT)((UCHAR*)eid_ptr + 2 + eid_ptr->Len);
 	}
 
-	return result;	
+	return result;
 }
 
 /*
 	==========================================================================
 	Description:
 		Channel Switch Announcement action frame handler.
-		
+
 	Parametrs:
 		Elme - MLME message containing the received frame
-	
+
 	Return	: None.
 	==========================================================================
  */
 static VOID PeerChSwAnnAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	CH_SW_ANN_INFO ChSwAnnInfo;
 	PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
@@ -1495,7 +1495,7 @@ static VOID PeerChSwAnnAction(
 		if (Bssidx == BSS_NOT_FOUND)
 		{
 			DBGPRINT(RT_DEBUG_TRACE, ("PeerChSwAnnAction - Bssidx is not found\n"));
-			return;  
+			return;
 		}
 
 		DBGPRINT(RT_DEBUG_TRACE, ("\n****Bssidx is %d, Channel = %d\n", index, pAd->ScanTab.BssEntry[Bssidx].Channel));
@@ -1514,7 +1514,7 @@ static VOID PeerChSwAnnAction(
 			MlmeQueueInit(&pAd->Mlme.Queue);
 			BssTableInit(&pAd->ScanTab);
 		    RTMPusecDelay(1000000);		// use delay to prevent STA do reassoc
-					
+
 			// channel sanity check
 			for (index = 0 ; index < pAd->ChannelListNum; index++)
 			{
@@ -1545,10 +1545,10 @@ static VOID PeerChSwAnnAction(
 	==========================================================================
 	Description:
 		Measurement Request action frame handler.
-		
+
 	Parametrs:
 		Elme - MLME message containing the received frame
-	
+
 	Return	: None.
 	==========================================================================
  */
@@ -1575,16 +1575,16 @@ static VOID PeerMeasureReqAction(
 	==========================================================================
 	Description:
 		Measurement Report action frame handler.
-		
+
 	Parametrs:
 		Elme - MLME message containing the received frame
-	
+
 	Return	: None.
 	==========================================================================
  */
 static VOID PeerMeasureReportAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	MEASURE_REPORT_INFO MeasureReportInfo;
 	PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
@@ -1640,16 +1640,16 @@ static VOID PeerMeasureReportAction(
 	==========================================================================
 	Description:
 		TPC Request action frame handler.
-		
+
 	Parametrs:
 		Elme - MLME message containing the received frame
-	
+
 	Return	: None.
 	==========================================================================
  */
 static VOID PeerTpcReqAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	PFRAME_802_11 pFr = (PFRAME_802_11)Elem->Msg;
 	PUCHAR pFramePtr = pFr->Octet;
@@ -1683,16 +1683,16 @@ static VOID PeerTpcReqAction(
 	==========================================================================
 	Description:
 		TPC Report action frame handler.
-		
+
 	Parametrs:
 		Elme - MLME message containing the received frame
-	
+
 	Return	: None.
 	==========================================================================
  */
 static VOID PeerTpcRepAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UINT8 DialogToken;
 	TPC_REPORT_INFO TpcRepInfo;
@@ -1717,16 +1717,16 @@ static VOID PeerTpcRepAction(
 	Description:
 		Spectrun action frames Handler such as channel switch annoucement,
 		measurement report, measurement request actions frames.
-		
+
 	Parametrs:
 		Elme - MLME message containing the received frame
-	
+
 	Return	: None.
 	==========================================================================
  */
 VOID PeerSpectrumAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 
 	UCHAR	Action = Elem->Msg[LENGTH_802_11+1];
@@ -1760,9 +1760,9 @@ VOID PeerSpectrumAction(
 				SEC_CHA_OFFSET_IE	Secondary;
 				CHA_SWITCH_ANNOUNCE_IE	ChannelSwitch;
 
-				// 802.11h only has Channel Switch Announcement IE. 
+				// 802.11h only has Channel Switch Announcement IE.
 				RTMPMoveMemory(&ChannelSwitch, &Elem->Msg[LENGTH_802_11+4], sizeof (CHA_SWITCH_ANNOUNCE_IE));
-					
+
 				// 802.11n D3.03 adds secondary channel offset element in the end.
 				if (Elem->MsgLen ==  (LENGTH_802_11 + 2 + sizeof (CHA_SWITCH_ANNOUNCE_IE) + sizeof (SEC_CHA_OFFSET_IE)))
 				{
@@ -1789,14 +1789,14 @@ VOID PeerSpectrumAction(
 /*
 	==========================================================================
 	Description:
-		
+
 	Parametrs:
-	
+
 	Return	: None.
 	==========================================================================
  */
 INT Set_MeasureReq_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UINT Aid = 1;
@@ -1831,7 +1831,7 @@ INT Set_MeasureReq_Proc(
 				break;
 		}
 		ArgIdx++;
-	}	
+	}
 
 	DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d, MeasureReqType=%d MeasureCh=%d\n", __FUNCTION__, Aid, MeasureReqType, MeasureCh));
 	if (!VALID_WCID(Aid))
@@ -1852,7 +1852,7 @@ INT Set_MeasureReq_Proc(
 }
 
 INT Set_TpcReq_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UINT Aid;
diff --git a/os/linux/config.mk b/config.mk
similarity index 97%
rename from os/linux/config.mk
rename to config.mk
index 5f4c5d1..f57d7bb 100644
--- a/os/linux/config.mk
+++ b/config.mk
@@ -33,7 +33,7 @@ HAS_EXT_BUILD_CHANNEL_LIST=n
 #Support for Net-SNMP
 HAS_SNMP_SUPPORT=n
 
-#Support features of Single SKU. 
+#Support features of Single SKU.
 HAS_SINGLE_SKU_SUPPORT=n
 
 #Support features of 802.11n
@@ -45,7 +45,7 @@ HAS_DOT11_N_SUPPORT=y
 CC := $(CROSS_COMPILE)gcc
 LD := $(CROSS_COMPILE)ld
 
-WFLAGS := -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT  -DLINUX -Wall -Wstrict-prototypes -Wno-trigraphs 
+WFLAGS := -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT  -DLINUX -Wall -Wstrict-prototypes -Wno-trigraphs
 
 
 #################################################
@@ -54,7 +54,7 @@ WFLAGS := -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT  -DLINUX -Wall
 # config for STA mode
 
 ifeq ($(RT28xx_MODE),STA)
-WFLAGS += -DCONFIG_STA_SUPPORT -DDBG 
+WFLAGS += -DCONFIG_STA_SUPPORT -DDBG
 
 ifeq ($(HAS_WPA_SUPPLICANT),y)
 WFLAGS += -DWPA_SUPPLICANT_SUPPORT
@@ -181,7 +181,7 @@ export CFLAGS
 endif
 
 ifeq ($(PLATFORM),SIGMA)
-CFLAGS := -D__KERNEL__ -I$(RT28xx_DIR)/include -I$(LINUX_SRC)/include -I$(LINUX_SRC)/include/asm/gcc -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -DEM86XX_CHIP=EM86XX_CHIPID_TANGO2 -DEM86XX_REVISION=6 -I$(LINUX_SRC)/include/asm-mips/mach-generic -I$(RT2860_DIR)/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2     -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe  -mabi=32 -march=mips32r2 -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap -DMODULE $(WFLAGS) 
+CFLAGS := -D__KERNEL__ -I$(RT28xx_DIR)/include -I$(LINUX_SRC)/include -I$(LINUX_SRC)/include/asm/gcc -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -I$(LINUX_SRC)/include/asm-mips/mach-tango2 -DEM86XX_CHIP=EM86XX_CHIPID_TANGO2 -DEM86XX_REVISION=6 -I$(LINUX_SRC)/include/asm-mips/mach-generic -I$(RT2860_DIR)/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2     -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe  -mabi=32 -march=mips32r2 -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap -DMODULE $(WFLAGS)
 
 export CFLAGS
 endif
@@ -192,7 +192,7 @@ export CFLAGS
 endif
 
 ifeq ($(PLATFORM),5VT)
-CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -O3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mabi=apcs-gnu -mno-thumb-interwork -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm926ej-s --param max-inline-insns-single=40000  -Uarm -Wdeclaration-after-statement -Wno-pointer-sign -DMODULE $(WFLAGS) 
+CFLAGS := -D__KERNEL__ -I$(LINUX_SRC)/include -I$(RT28xx_DIR)/include -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -O3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mabi=apcs-gnu -mno-thumb-interwork -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm926ej-s --param max-inline-insns-single=40000  -Uarm -Wdeclaration-after-statement -Wno-pointer-sign -DMODULE $(WFLAGS)
 
 export CFLAGS
 endif
diff --git a/include/dfs.h b/dfs.h
similarity index 91%
rename from include/dfs.h
rename to dfs.h
index 8a2a60d..752a635 100644
--- a/include/dfs.h
+++ b/dfs.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
     Module Name:
@@ -59,7 +59,7 @@ VOID RadarDetectionStop(
 
 VOID RadarDetectPeriodic(
 	IN PRTMP_ADAPTER	pAd);
-	
+
 
 BOOLEAN RadarChannelCheck(
 	IN PRTMP_ADAPTER	pAd,
@@ -90,11 +90,11 @@ VOID RTMPPrepareRadarDetectParams(
 
 
 INT Set_ChMovingTime_Proc(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR arg);
 
 INT Set_LongPulseRadarTh_Proc(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR arg);
 
 
diff --git a/include/leap.h b/leap.h
similarity index 90%
rename from include/leap.h
rename to leap.h
index 0a9fb87..6818c1f 100644
--- a/include/leap.h
+++ b/leap.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -112,15 +112,15 @@ VOID LeapMacHeaderInit(
     IN  PUCHAR              pAddr3);
 
 VOID LeapStartAction(
-    IN PRTMP_ADAPTER    pAd, 
+    IN PRTMP_ADAPTER    pAd,
     IN MLME_QUEUE_ELEM  *Elem);
 
 VOID LeapIdentityAction(
-    IN PRTMP_ADAPTER    pAd, 
+    IN PRTMP_ADAPTER    pAd,
     IN MLME_QUEUE_ELEM  *Elem);
 
 VOID LeapPeerChallengeAction(
-    IN PRTMP_ADAPTER    pAd, 
+    IN PRTMP_ADAPTER    pAd,
     IN MLME_QUEUE_ELEM  *Elem);
 
 VOID HashPwd(
@@ -152,11 +152,11 @@ VOID DesEncrypt(
     OUT PUCHAR  szOut);
 
 VOID LeapNetworkChallengeAction(
-    IN PRTMP_ADAPTER    pAd, 
+    IN PRTMP_ADAPTER    pAd,
     IN MLME_QUEUE_ELEM  *Elem);
 
 VOID LeapNetworkChallengeResponse(
-    IN PRTMP_ADAPTER    pAd, 
+    IN PRTMP_ADAPTER    pAd,
     IN MLME_QUEUE_ELEM  *Elem);
 
 VOID HashpwdHash(
@@ -165,14 +165,14 @@ VOID HashpwdHash(
 
 VOID ProcessSessionKey(
     OUT PUCHAR  SessionKey,
-    IN  PUCHAR  hash2, 
-    IN  PUCHAR  ChallengeToRadius, 
+    IN  PUCHAR  hash2,
+    IN  PUCHAR  ChallengeToRadius,
     IN  PUCHAR  ChallengeResponseFromRadius,
-    IN  PUCHAR  ChallengeFromRadius, 
+    IN  PUCHAR  ChallengeFromRadius,
     IN  PUCHAR  ChallengeResponseToRadius);
 
 VOID LeapEapolKeyAction(
-    IN PRTMP_ADAPTER    pAd, 
+    IN PRTMP_ADAPTER    pAd,
     IN MLME_QUEUE_ELEM  *Elem);
 
 VOID RogueApTableInit(
@@ -183,9 +183,9 @@ ULONG RogueApTableSearch(
     IN PUCHAR           pAddr);
 
 VOID RogueApEntrySet(
-    IN  PRTMP_ADAPTER   pAd, 
-    OUT ROGUEAP_ENTRY   *pRogueAp, 
-    IN PUCHAR           pAddr, 
+    IN  PRTMP_ADAPTER   pAd,
+    OUT ROGUEAP_ENTRY   *pRogueAp,
+    IN PUCHAR           pAddr,
     IN UCHAR            FaileCode);
 
 ULONG RogueApTableSetEntry(
@@ -195,7 +195,7 @@ ULONG RogueApTableSetEntry(
     IN UCHAR            FaileCode);
 
 VOID RogueApTableDeleteEntry(
-    IN OUT ROGUEAP_TABLE *Tab, 
+    IN OUT ROGUEAP_TABLE *Tab,
     IN PUCHAR          pAddr);
 
 VOID LeapAuthTimeout(
diff --git a/include/link_list.h b/link_list.h
similarity index 90%
rename from include/link_list.h
rename to link_list.h
index ff2f64a..f652113 100644
--- a/include/link_list.h
+++ b/link_list.h
@@ -1,134 +1,134 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
- *************************************************************************
- */
-
-#ifndef __LINK_LIST_H__
-#define __LINK_LIST_H__
-
-typedef struct _LIST_ENTRY
-{
-	struct _LIST_ENTRY *pNext;
-} LIST_ENTRY, *PLIST_ENTRY;
-
-typedef struct _LIST_HEADR
-{
-	PLIST_ENTRY pHead;
-	PLIST_ENTRY pTail;
-	UCHAR size;
-} LIST_HEADER, *PLIST_HEADER;
-
-static inline VOID initList(
-	IN PLIST_HEADER pList)
-{
-	pList->pHead = pList->pTail = NULL;
-	pList->size = 0;
-	return;
-}
-
-static inline VOID insertTailList(
-	IN PLIST_HEADER pList,
-	IN PLIST_ENTRY pEntry)
-{
-	pEntry->pNext = NULL;
-	if (pList->pTail)
-		pList->pTail->pNext = pEntry;
-	else
-		pList->pHead = pEntry;
-	pList->pTail = pEntry;
-	pList->size++;
-
-	return;
-}
-
-static inline PLIST_ENTRY removeHeadList(
-	IN PLIST_HEADER pList)
-{
-	PLIST_ENTRY pNext;
-	PLIST_ENTRY pEntry;
-
-	pEntry = pList->pHead;
-	if (pList->pHead != NULL)
-	{
-		pNext = pList->pHead->pNext;
-		pList->pHead = pNext;
-		if (pNext == NULL)
-			pList->pTail = NULL;
-		pList->size--;
-	}
-	return pEntry;
-}
-
-static inline int getListSize(
-	IN PLIST_HEADER pList)
-{
-	return pList->size;
-}
-
-static inline PLIST_ENTRY delEntryList(
-	IN PLIST_HEADER pList,
-	IN PLIST_ENTRY pEntry)
-{
-	PLIST_ENTRY pCurEntry;
-	PLIST_ENTRY pPrvEntry;
-
-	if(pList->pHead == NULL)
-		return NULL;
-
-	if(pEntry == pList->pHead)
-	{
-		pCurEntry = pList->pHead;
-		pList->pHead = pCurEntry->pNext;
-
-		if(pList->pHead == NULL)
-			pList->pTail = NULL;
-
-		pList->size--;
-		return pCurEntry;
-	}
-
-	pPrvEntry = pList->pHead;
-	pCurEntry = pPrvEntry->pNext;
-	while(pCurEntry != NULL)
-	{
-		if (pEntry == pCurEntry)
-		{
-			pPrvEntry->pNext = pCurEntry->pNext;
-
-			if(pEntry == pList->pTail)
-				pList->pTail = pPrvEntry;
-
-			pList->size--;
-			break;
-		}
-		pPrvEntry = pCurEntry;
-		pCurEntry = pPrvEntry->pNext;
-	}
-
-	return pCurEntry;
-}
-
-#endif // ___LINK_LIST_H__ //
-
+/*
+ *************************************************************************
+ * Ralink Tech Inc.
+ * 5F., No.36, Taiyuan St., Jhubei City,
+ * Hsinchu County 302,
+ * Taiwan, R.O.C.
+ *
+ * (c) Copyright 2002-2007, Ralink Technology, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
+ *************************************************************************
+ */
+
+#ifndef __LINK_LIST_H__
+#define __LINK_LIST_H__
+
+typedef struct _LIST_ENTRY
+{
+	struct _LIST_ENTRY *pNext;
+} LIST_ENTRY, *PLIST_ENTRY;
+
+typedef struct _LIST_HEADR
+{
+	PLIST_ENTRY pHead;
+	PLIST_ENTRY pTail;
+	UCHAR size;
+} LIST_HEADER, *PLIST_HEADER;
+
+static inline VOID initList(
+	IN PLIST_HEADER pList)
+{
+	pList->pHead = pList->pTail = NULL;
+	pList->size = 0;
+	return;
+}
+
+static inline VOID insertTailList(
+	IN PLIST_HEADER pList,
+	IN PLIST_ENTRY pEntry)
+{
+	pEntry->pNext = NULL;
+	if (pList->pTail)
+		pList->pTail->pNext = pEntry;
+	else
+		pList->pHead = pEntry;
+	pList->pTail = pEntry;
+	pList->size++;
+
+	return;
+}
+
+static inline PLIST_ENTRY removeHeadList(
+	IN PLIST_HEADER pList)
+{
+	PLIST_ENTRY pNext;
+	PLIST_ENTRY pEntry;
+
+	pEntry = pList->pHead;
+	if (pList->pHead != NULL)
+	{
+		pNext = pList->pHead->pNext;
+		pList->pHead = pNext;
+		if (pNext == NULL)
+			pList->pTail = NULL;
+		pList->size--;
+	}
+	return pEntry;
+}
+
+static inline int getListSize(
+	IN PLIST_HEADER pList)
+{
+	return pList->size;
+}
+
+static inline PLIST_ENTRY delEntryList(
+	IN PLIST_HEADER pList,
+	IN PLIST_ENTRY pEntry)
+{
+	PLIST_ENTRY pCurEntry;
+	PLIST_ENTRY pPrvEntry;
+
+	if(pList->pHead == NULL)
+		return NULL;
+
+	if(pEntry == pList->pHead)
+	{
+		pCurEntry = pList->pHead;
+		pList->pHead = pCurEntry->pNext;
+
+		if(pList->pHead == NULL)
+			pList->pTail = NULL;
+
+		pList->size--;
+		return pCurEntry;
+	}
+
+	pPrvEntry = pList->pHead;
+	pCurEntry = pPrvEntry->pNext;
+	while(pCurEntry != NULL)
+	{
+		if (pEntry == pCurEntry)
+		{
+			pPrvEntry->pNext = pCurEntry->pNext;
+
+			if(pEntry == pList->pTail)
+				pList->pTail = pPrvEntry;
+
+			pList->size--;
+			break;
+		}
+		pPrvEntry = pCurEntry;
+		pCurEntry = pPrvEntry->pNext;
+	}
+
+	return pCurEntry;
+}
+
+#endif // ___LINK_LIST_H__ //
+
diff --git a/include/md4.h b/md4.h
similarity index 88%
rename from include/md4.h
rename to md4.h
index 1e114d5..f1e5b52 100644
--- a/include/md4.h
+++ b/md4.h
@@ -7,23 +7,23 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
- */ 
+ */
 
 #ifndef __MD4_H__
 #define __MD4_H__
diff --git a/include/md5.h b/md5.h
similarity index 93%
rename from include/md5.h
rename to md5.h
index df60360..d85db12 100644
--- a/include/md5.h
+++ b/md5.h
@@ -7,23 +7,23 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
- 
+
 	Module Name:
 	md5.h
 
@@ -54,7 +54,7 @@
 typedef struct _MD5_CTX {
     UINT32   Buf[4];             // buffers of four states
 	UCHAR   Input[64];          // input message
-	UINT32   LenInBitCount[2];   // length counter for input message, 0 up to 64 bits	                            
+	UINT32   LenInBitCount[2];   // length counter for input message, 0 up to 64 bits
 }   MD5_CTX;
 
 VOID MD5Init(MD5_CTX *pCtx);
@@ -73,7 +73,7 @@ typedef	struct _SHA_CTX
 	UINT32   Buf[5];             // buffers of five states
 	UCHAR   Input[80];          // input message
 	UINT32   LenInBitCount[2];   // length counter for input message, 0 up to 64 bits
-	
+
 }	SHA_CTX;
 
 VOID SHAInit(SHA_CTX *pCtx);
diff --git a/include/mlme.h b/mlme.h
similarity index 95%
rename from include/mlme.h
rename to mlme.h
index 3f37ad7..5cb6165 100644
--- a/include/mlme.h
+++ b/mlme.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -34,18 +34,18 @@
 	--------	----------		----------------------------------------------
 	John Chang	2003-08-28		Created
 	John Chang  2004-09-06      modified for RT2600
-	
+
 */
 #ifndef __MLME_H__
 #define __MLME_H__
 
-// maximum supported capability information - 
+// maximum supported capability information -
 // ESS, IBSS, Privacy, Short Preamble, Spectrum mgmt, Short Slot
 #define SUPPORTED_CAPABILITY_INFO   0x0533
 
 #define END_OF_ARGS                 -1
 #define LFSR_MASK                   0x80000057
-#define MLME_TASK_EXEC_INTV         100/*200*/       //  
+#define MLME_TASK_EXEC_INTV         100/*200*/       //
 #define LEAD_TIME                   5
 #define MLME_TASK_EXEC_MULTIPLE       10  /*5*/       // MLME_TASK_EXEC_MULTIPLE * MLME_TASK_EXEC_INTV = 1 sec
 #define REORDER_EXEC_INTV         	100       // 0.1 sec
@@ -89,7 +89,7 @@ extern UINT32 CW_MAX_IN_BITS;
 // SHould not refer to this constant anymore
 //#define RSSI_TO_DBM_OFFSET          120 // for RT2530 RSSI-115 = dBm
 #define RSSI_FOR_MID_TX_POWER       -55  // -55 db is considered mid-distance
-#define RSSI_FOR_LOW_TX_POWER       -45  // -45 db is considered very short distance and 
+#define RSSI_FOR_LOW_TX_POWER       -45  // -45 db is considered very short distance and
                                         // eligible to use a lower TX power
 #define RSSI_FOR_LOWEST_TX_POWER    -30
 //#define MID_TX_POWER_DELTA          0   // 0 db from full TX power upon mid-distance to AP
@@ -202,7 +202,7 @@ if (((__pEntry)) != NULL) \
 //
 // 802.11 frame formats
 //
-//  HT Capability INFO field in HT Cap IE .   
+//  HT Capability INFO field in HT Cap IE .
 typedef struct PACKED {
 #ifdef RT_BIG_ENDIAN
 	USHORT	LSIGTxopProSup:1;
@@ -237,7 +237,7 @@ typedef struct PACKED {
 #endif	/* !RT_BIG_ENDIAN */
 } HT_CAP_INFO, *PHT_CAP_INFO;
 
-//  HT Capability INFO field in HT Cap IE .   
+//  HT Capability INFO field in HT Cap IE .
 typedef struct PACKED {
 #ifdef RT_BIG_ENDIAN
 	UCHAR	rsv:3;//momi power safe
@@ -250,7 +250,7 @@ typedef struct PACKED {
 #endif /* !RT_BIG_ENDIAN */
 } HT_CAP_PARM, *PHT_CAP_PARM;
 
-//  HT Capability INFO field in HT Cap IE .   
+//  HT Capability INFO field in HT Cap IE .
 typedef struct PACKED {
 	UCHAR	MCSSet[10];
 	UCHAR	SupRate[2];  // unit : 1Mbps
@@ -259,20 +259,20 @@ typedef struct PACKED {
 	UCHAR	MpduDensity:1;
 	UCHAR	TxStream:2;
 	UCHAR	TxRxNotEqual:1;
-	UCHAR	TxMCSSetDefined:1; 
+	UCHAR	TxMCSSetDefined:1;
 #else
-	UCHAR	TxMCSSetDefined:1; 
+	UCHAR	TxMCSSetDefined:1;
 	UCHAR	TxRxNotEqual:1;
 	UCHAR	TxStream:2;
 	UCHAR	MpduDensity:1;
 	UCHAR	rsv:3;
 #endif // RT_BIG_ENDIAN //
-	UCHAR	rsv3[3];  
+	UCHAR	rsv3[3];
 } HT_MCS_SET, *PHT_MCS_SET;
 
-//  HT Capability INFO field in HT Cap IE .  
+//  HT Capability INFO field in HT Cap IE .
 typedef struct PACKED {
-#ifdef RT_BIG_ENDIAN 
+#ifdef RT_BIG_ENDIAN
 	USHORT	rsv2:4;
 	USHORT	RDGSupport:1;	//reverse Direction Grant  support
 	USHORT	PlusHTC:1;	//+HTC control field support
@@ -291,7 +291,7 @@ typedef struct PACKED {
 #endif /* RT_BIG_ENDIAN */
 } EXT_HT_CAP_INFO, *PEXT_HT_CAP_INFO;
 
-//  HT Beamforming field in HT Cap IE .   
+//  HT Beamforming field in HT Cap IE .
 typedef struct PACKED _HT_BF_CAP{
 #ifdef RT_BIG_ENDIAN
 	ULONG	rsv:3;
@@ -301,7 +301,7 @@ typedef struct PACKED _HT_BF_CAP{
 	ULONG	NoComSteerBFAntSup:2;
 	ULONG	CSIBFAntSup:2;
 	ULONG	MinGrouping:2;
-	ULONG	ExpComBF:2;	
+	ULONG	ExpComBF:2;
 	ULONG	ExpNoComBF:2;
 	ULONG	ExpCSIFbk:2;
 	ULONG	ExpComSteerCapable:1;
@@ -309,8 +309,8 @@ typedef struct PACKED _HT_BF_CAP{
 	ULONG	ExpCSICapable:1;
 	ULONG	Calibration:2;
 	ULONG	ImpTxBFCapable:1;
-	ULONG	TxNDPCapable:1;	
-	ULONG	RxNDPCapable:1;	
+	ULONG	TxNDPCapable:1;
+	ULONG	RxNDPCapable:1;
 	ULONG	TxSoundCapable:1;
 	ULONG	RxSoundCapable:1;
 	ULONG	TxBFRecCapable:1;
@@ -318,16 +318,16 @@ typedef struct PACKED _HT_BF_CAP{
 	ULONG	TxBFRecCapable:1;
 	ULONG	RxSoundCapable:1;
 	ULONG	TxSoundCapable:1;
-	ULONG	RxNDPCapable:1;	
-	ULONG	TxNDPCapable:1;	
-	ULONG	ImpTxBFCapable:1;	
+	ULONG	RxNDPCapable:1;
+	ULONG	TxNDPCapable:1;
+	ULONG	ImpTxBFCapable:1;
 	ULONG	Calibration:2;
 	ULONG	ExpCSICapable:1;
 	ULONG	ExpNoComSteerCapable:1;
 	ULONG	ExpComSteerCapable:1;
-	ULONG	ExpCSIFbk:2;	
-	ULONG	ExpNoComBF:2;	
-	ULONG	ExpComBF:2;	
+	ULONG	ExpCSIFbk:2;
+	ULONG	ExpNoComBF:2;
+	ULONG	ExpComBF:2;
 	ULONG	MinGrouping:2;
 	ULONG	CSIBFAntSup:2;
 	ULONG	NoComSteerBFAntSup:2;
@@ -338,7 +338,7 @@ typedef struct PACKED _HT_BF_CAP{
 #endif // RT_BIG_ENDIAN //
 } HT_BF_CAP, *PHT_BF_CAP;
 
-//  HT antenna selection field in HT Cap IE .   
+//  HT antenna selection field in HT Cap IE .
 typedef struct PACKED _HT_AS_CAP{
 #ifdef RT_BIG_ENDIAN
 	UCHAR	rsv:1;
@@ -348,9 +348,9 @@ typedef struct PACKED _HT_AS_CAP{
 	UCHAR	ExpCSIFbk:1;
 	UCHAR	AntIndFbkTxASEL:1;
 	UCHAR	ExpCSIFbkTxASEL:1;
-	UCHAR	AntSelect:1; 
+	UCHAR	AntSelect:1;
 #else
-	UCHAR	AntSelect:1; 
+	UCHAR	AntSelect:1;
 	UCHAR	ExpCSIFbkTxASEL:1;
 	UCHAR	AntIndFbkTxASEL:1;
 	UCHAR	ExpCSIFbk:1;
@@ -384,7 +384,7 @@ typedef struct PACKED _HT_CAPABILITY_IE{
 #define dot11OBSSScanActiveTotalPerChannel					20	//in TU. min total amount of time that the STA scans each channel when performing a active OBSS scan
 #define dot11BSSWidthChannelTransactionDelayFactor			5	// min ratio between the delay time in performing a switch from 20MHz BSS to 20/40 BSS operation and the maxima
 																//	interval between overlapping BSS scan operations.
-#define dot11BSSScanActivityThreshold						25	// in %%, max total time that a STA may be active on the medium during a period of 
+#define dot11BSSScanActivityThreshold						25	// in %%, max total time that a STA may be active on the medium during a period of
 																//	(dot11BSSWidthChannelTransactionDelayFactor * dot11BSSWidthTriggerScanInterval) seconds without
 																//	being obligated to perform OBSS Scan operations. default is 25(== 0.25%)
 
@@ -405,8 +405,8 @@ typedef union PACKED _BSS_2040_COEXIST_IE{
  #ifdef RT_BIG_ENDIAN
 	UCHAR	rsv:5;
 	UCHAR	BSS20WidthReq:1;
-	UCHAR	Intolerant40:1;	
-	UCHAR	InfoReq:1; 
+	UCHAR	Intolerant40:1;
+	UCHAR	InfoReq:1;
  #else
 	UCHAR	InfoReq:1;
 	UCHAR	Intolerant40:1;			// Inter-BSS. set 1 when prohibits a receiving BSS from operating as a 20/40 Mhz BSS.
@@ -419,8 +419,8 @@ typedef union PACKED _BSS_2040_COEXIST_IE{
 
 
 typedef struct  _TRIGGER_EVENTA{
-	BOOLEAN			bValid;	 
-	UCHAR	BSSID[6];	
+	BOOLEAN			bValid;
+	UCHAR	BSSID[6];
 	UCHAR	RegClass;	// Regulatory Class
 	USHORT	Channel;
 	ULONG	CDCounter;   // Maintain a seperate count down counter for each Event A.
@@ -430,12 +430,12 @@ typedef struct  _TRIGGER_EVENTA{
 // If one Event A delete or created, or if Event B is detected or not detected, STA should send 2040BSSCoexistence to AP.
 #define MAX_TRIGGER_EVENT		64
 typedef struct  _TRIGGER_EVENT_TAB{
-	UCHAR	EventANo;	
-	TRIGGER_EVENTA	EventA[MAX_TRIGGER_EVENT];	
-	ULONG			EventBCountDown;	// Count down counter for Event B. 
+	UCHAR	EventANo;
+	TRIGGER_EVENTA	EventA[MAX_TRIGGER_EVENT];
+	ULONG			EventBCountDown;	// Count down counter for Event B.
 } TRIGGER_EVENT_TAB, *PTRIGGER_EVENT_TAB;
 
-// 7.3.27 20/40 Bss Coexistence Mgmt capability used in extended capabilities information IE( ID = 127 = IE_EXT_CAPABILITY). 
+// 7.3.27 20/40 Bss Coexistence Mgmt capability used in extended capabilities information IE( ID = 127 = IE_EXT_CAPABILITY).
 //	This is the first octet and was defined in 802.11n D3.03 and 802.11yD9.0
 typedef struct PACKED _EXT_CAP_INFO_ELEMENT{
 #ifdef RT_BIG_ENDIAN
@@ -463,7 +463,7 @@ typedef struct PACKED _BSS_2040_COEXIST_ELEMENT{
 //802.11n 7.3.2.59
 typedef struct PACKED _BSS_2040_INTOLERANT_CH_REPORT{
 	UCHAR				ElementID;		// ID = IE_2040_BSS_INTOLERANT_REPORT = 73
-	UCHAR				Len;	
+	UCHAR				Len;
 	UCHAR				RegulatoryClass;
 	UCHAR				ChList[0];
 }BSS_2040_INTOLERANT_CH_REPORT, *PBSS_2040_INTOLERANT_CH_REPORT;
@@ -472,14 +472,14 @@ typedef struct PACKED _BSS_2040_INTOLERANT_CH_REPORT{
 // The structure for channel switch annoucement IE. This is in 802.11n D3.03
 typedef struct PACKED _CHA_SWITCH_ANNOUNCE_IE{
 	UCHAR			SwitchMode;	//channel switch mode
-	UCHAR			NewChannel;	// 
-	UCHAR			SwitchCount;	// 
+	UCHAR			NewChannel;	//
+	UCHAR			SwitchCount;	//
 } CHA_SWITCH_ANNOUNCE_IE, *PCHA_SWITCH_ANNOUNCE_IE;
 
 
 // The structure for channel switch annoucement IE. This is in 802.11n D3.03
 typedef struct PACKED _SEC_CHA_OFFSET_IE{
-	UCHAR			SecondaryChannelOffset;	 // 1: Secondary above, 3: Secondary below, 0: no Secondary 
+	UCHAR			SecondaryChannelOffset;	 // 1: Secondary above, 3: Secondary below, 0: no Secondary
 } SEC_CHA_OFFSET_IE, *PSEC_CHA_OFFSET_IE;
 
 
@@ -488,7 +488,7 @@ typedef struct {
 	BOOLEAN			bHtEnable;	 // If we should use ht rate.
 	BOOLEAN			bPreNHt;	 // If we should use ht rate.
 	//Substract from HT Capability IE
-	UCHAR			MCSSet[16];	//only supoort MCS=0-15,32 , 
+	UCHAR			MCSSet[16];	//only supoort MCS=0-15,32 ,
 } RT_HT_PHY_INFO, *PRT_HT_PHY_INFO;
 
 //This structure substracts ralink supports from all 802.11n-related features.
@@ -503,7 +503,7 @@ typedef struct {
 	USHORT	ShortGIfor40:1;	//for40MHz
 	USHORT	ShortGIfor20:1;
 	USHORT	GF:1;	//green field
-	USHORT	MimoPs:2;//mimo power safe MMPS_	
+	USHORT	MimoPs:2;//mimo power safe MMPS_
 	USHORT	ChannelWidth:1;
 #else
 	USHORT	ChannelWidth:1;
@@ -521,13 +521,13 @@ typedef struct {
 	//Substract from Addiont HT INFO IE
 #ifdef RT_BIG_ENDIAN
 	UCHAR	RecomWidth:1;
-	UCHAR	ExtChanOffset:2;	// Please not the difference with following 	UCHAR	NewExtChannelOffset; from 802.11n 
-	UCHAR	MpduDensity:3;	
+	UCHAR	ExtChanOffset:2;	// Please not the difference with following 	UCHAR	NewExtChannelOffset; from 802.11n
+	UCHAR	MpduDensity:3;
 	UCHAR	MaxRAmpduFactor:2;
 #else
 	UCHAR	MaxRAmpduFactor:2;
 	UCHAR	MpduDensity:3;
-	UCHAR	ExtChanOffset:2;	// Please not the difference with following 	UCHAR	NewExtChannelOffset; from 802.11n 
+	UCHAR	ExtChanOffset:2;	// Please not the difference with following 	UCHAR	NewExtChannelOffset; from 802.11n
 	UCHAR	RecomWidth:1;
 #endif
 
@@ -544,25 +544,25 @@ typedef struct {
 	USHORT	OBSS_NonHTExist:1;
 	USHORT	rsv2:11;
 #endif
-	
+
 	// New Extension Channel Offset IE
-	UCHAR	NewExtChannelOffset;	
+	UCHAR	NewExtChannelOffset;
 	// Extension Capability IE = 127
-	UCHAR	BSSCoexist2040;	
+	UCHAR	BSSCoexist2040;
 } RT_HT_CAPABILITY, *PRT_HT_CAPABILITY;
 
-//   field in Addtional HT Information IE .   
+//   field in Addtional HT Information IE .
 typedef struct PACKED {
 #ifdef RT_BIG_ENDIAN
 	UCHAR	SerInterGranu:3;
 	UCHAR	S_PSMPSup:1;
-	UCHAR	RifsMode:1; 
-	UCHAR	RecomWidth:1;	
+	UCHAR	RifsMode:1;
+	UCHAR	RecomWidth:1;
 	UCHAR	ExtChanOffset:2;
 #else
 	UCHAR	ExtChanOffset:2;
 	UCHAR	RecomWidth:1;
-	UCHAR	RifsMode:1; 
+	UCHAR	RifsMode:1;
 	UCHAR	S_PSMPSup:1;	 //Indicate support for scheduled PSMP
 	UCHAR	SerInterGranu:3;	 //service interval granularity
 #endif
@@ -570,17 +570,17 @@ typedef struct PACKED {
 
 typedef struct PACKED{
 #ifdef RT_BIG_ENDIAN
-	USHORT	rsv2:11; 
+	USHORT	rsv2:11;
 	USHORT	OBSS_NonHTExist:1;
 	USHORT	rsv:1;
 	USHORT	NonGfPresent:1;
-	USHORT	OperaionMode:2;	
+	USHORT	OperaionMode:2;
 #else
 	USHORT	OperaionMode:2;
 	USHORT	NonGfPresent:1;
-	USHORT	rsv:1; 
+	USHORT	rsv:1;
 	USHORT	OBSS_NonHTExist:1;
-	USHORT	rsv2:11; 
+	USHORT	rsv2:11;
 #endif
 } ADD_HTINFO2, *PADD_HTINFO2;
 
@@ -599,12 +599,12 @@ typedef struct PACKED{
 #else
 	USHORT	StbcMcs:6;
 	USHORT	DualBeacon:1;
-	USHORT	DualCTSProtect:1; 
+	USHORT	DualCTSProtect:1;
 	USHORT	STBCBeacon:1;
-	USHORT	LsigTxopProt:1;	// L-SIG TXOP protection full support 
-	USHORT	PcoActive:1; 
-	USHORT	PcoPhase:1; 
-	USHORT	rsv:4; 
+	USHORT	LsigTxopProt:1;	// L-SIG TXOP protection full support
+	USHORT	PcoActive:1;
+	USHORT	PcoPhase:1;
+	USHORT	rsv:4;
 #endif // RT_BIG_ENDIAN //
 } ADD_HTINFO3, *PADD_HTINFO3;
 
@@ -612,8 +612,8 @@ typedef struct PACKED{
 typedef struct  PACKED{
 	UCHAR				ControlChan;
 	ADD_HTINFO			AddHtInfo;
-	ADD_HTINFO2			AddHtInfo2;	 
-	ADD_HTINFO3			AddHtInfo3;	 
+	ADD_HTINFO2			AddHtInfo2;
+	ADD_HTINFO3			AddHtInfo3;
 	UCHAR				MCSSet[16];		// Basic MCS set
 } ADD_HT_INFO_IE, *PADD_HT_INFO_IE;
 
@@ -672,7 +672,7 @@ typedef struct PACKED {
     USHORT      AMsduPresent:1;
     USHORT      Txop_QueueSize:8;
 #endif /* !RT_BIG_ENDIAN */
-} QOS_CONTROL, *PQOS_CONTROL;	
+} QOS_CONTROL, *PQOS_CONTROL;
 
 // 2-byte Frame control field
 typedef	struct	PACKED {
@@ -820,11 +820,11 @@ typedef struct PACKED {
     USHORT      NumTID:4;
     USHORT      Rsv1:9;
     USHORT      Compressed:1;
-    USHORT      MTID:1;		
+    USHORT      MTID:1;
     USHORT      ACKPolicy:1;
 #else
     USHORT      ACKPolicy:1;
-    USHORT      MTID:1;		
+    USHORT      MTID:1;
     USHORT      Compressed:1;
     USHORT      Rsv1:9;
     USHORT      NumTID:4;
@@ -937,7 +937,7 @@ typedef struct PACKED _FRAME_ADDBA_REQ {
 	UCHAR	Action;
 	UCHAR	Token;	// 1
 	BA_PARM		BaParm;	      //  2 - 10
-	USHORT		TimeOutValue;	// 0 - 0 
+	USHORT		TimeOutValue;	// 0 - 0
 	BASEQ_CONTROL	BaStartSeq; // 0-0
 }   FRAME_ADDBA_REQ, *PFRAME_ADDBA_REQ;
 
@@ -1005,7 +1005,7 @@ typedef struct PACKED {
 //
 // _Limit must be the 2**n - 1
 // _SEQ1 , _SEQ2 must be within 0 ~ _Limit
-// 
+//
 #define SEQ_STEPONE(_SEQ1, _SEQ2, _Limit)	((_SEQ1 == ((_SEQ2+1) & _Limit)))
 #define SEQ_SMALLER(_SEQ1, _SEQ2, _Limit)	(((_SEQ1-_SEQ2) & ((_Limit+1)>>1)))
 #define SEQ_LARGER(_SEQ1, _SEQ2, _Limit)	((_SEQ1 != _SEQ2) && !(((_SEQ1-_SEQ2) & ((_Limit+1)>>1))))
@@ -1030,7 +1030,7 @@ typedef	struct	_CIPHER_SUITE	{
 	USHORT							RsnCapability;	// RSN capability from beacon
 	BOOLEAN							bMixMode;		// Indicate Pair & Group cipher might be different
 }	CIPHER_SUITE, *PCIPHER_SUITE;
-	
+
 // EDCA configuration from AP's BEACON/ProbeRsp
 typedef struct {
     BOOLEAN     bValid;         // 1: variable contains valid value
@@ -1123,7 +1123,7 @@ typedef struct {
     UCHAR   ExtRateLen;
 	HT_CAPABILITY_IE HtCapability;
 	UCHAR			HtCapabilityLen;
-	ADD_HT_INFO_IE AddHtInfo;	// AP might use this additional ht info IE 
+	ADD_HT_INFO_IE AddHtInfo;	// AP might use this additional ht info IE
 	UCHAR			AddHtInfoLen;
 	UCHAR			NewExtChanOffset;
 	CHAR    Rssi;
@@ -1139,7 +1139,7 @@ typedef struct {
     USHORT  CfpDurRemaining;
     UCHAR   SsidLen;
     CHAR    Ssid[MAX_LEN_OF_SSID];
-    
+
     ULONG   LastBeaconRxTime; // OS's timestamp
 
 	BOOLEAN	bSES;
@@ -1151,7 +1151,7 @@ typedef struct {
 	// New for microsoft WPA support
 	NDIS_802_11_FIXED_IEs	FixIEs;
 	NDIS_802_11_AUTHENTICATION_MODE	AuthModeAux;	// Addition mode for WPA2 / WPA capable AP
-	NDIS_802_11_AUTHENTICATION_MODE	AuthMode;	
+	NDIS_802_11_AUTHENTICATION_MODE	AuthMode;
 	NDIS_802_11_WEP_STATUS	WepStatus;				// Unicast Encryption Algorithm extract from VAR_IE
 	USHORT					VarIELen;				// Length of next VIE include EID & Length
 	UCHAR					VarIEs[MAX_VIE_LEN];
@@ -1241,7 +1241,7 @@ typedef struct _MLME_AUX {
     USHORT              CfpMaxDuration;
     USHORT              CfpPeriod;
     USHORT              AtimWin;
-    
+
 	// Copy supported rate from desired AP's beacon. We are trying to match
 	// AP's supported and extended rate settings.
 	UCHAR		        SupRate[MAX_LEN_OF_SUPPORTED_RATES];
@@ -1250,7 +1250,7 @@ typedef struct _MLME_AUX {
 	UCHAR		        ExtRateLen;
 	HT_CAPABILITY_IE		HtCapability;
 	UCHAR		        	HtCapabilityLen;
-	ADD_HT_INFO_IE		AddHtInfo;	// AP might use this additional ht info IE 
+	ADD_HT_INFO_IE		AddHtInfo;	// AP might use this additional ht info IE
 	UCHAR			NewExtChannelOffset;
 	//RT_HT_CAPABILITY	SupportedHtPhy;
 
@@ -1261,7 +1261,7 @@ typedef struct _MLME_AUX {
 
     // new to keep Ralink specific feature
     ULONG               APRalinkIe;
-    
+
     BSS_TABLE           SsidBssTab;     // AP list for the same SSID
     BSS_TABLE           RoamTab;        // AP list eligible for roaming
     ULONG               BssIdx;
@@ -1275,7 +1275,7 @@ typedef struct _MLME_AUX {
 } MLME_AUX, *PMLME_AUX;
 
 typedef struct _MLME_ADDBA_REQ_STRUCT{
-	UCHAR   Wcid;	// 
+	UCHAR   Wcid;	//
 	UCHAR   pAddr[MAC_ADDR_LEN];
 	UCHAR   BaBufSize;
 	USHORT	TimeOutValue;
@@ -1286,7 +1286,7 @@ typedef struct _MLME_ADDBA_REQ_STRUCT{
 
 
 typedef struct _MLME_DELBA_REQ_STRUCT{
-	UCHAR   Wcid;	// 
+	UCHAR   Wcid;	//
 	UCHAR     Addr[MAC_ADDR_LEN];
 	UCHAR   TID;
 	UCHAR	Initiator;
@@ -1368,7 +1368,7 @@ typedef struct PACKED _RTMP_TX_RATE_SWITCH
 #ifdef RT_BIG_ENDIAN
 	UCHAR	Rsv2:2;
 	UCHAR	Mode:2;
-	UCHAR	Rsv1:1;	
+	UCHAR	Rsv1:1;
 	UCHAR	BW:1;
 	UCHAR	ShortGI:1;
 	UCHAR	STBC:1;
@@ -1379,7 +1379,7 @@ typedef struct PACKED _RTMP_TX_RATE_SWITCH
 	UCHAR	Rsv1:1;
 	UCHAR	Mode:2;
 	UCHAR	Rsv2:2;
-#endif	
+#endif
 	UCHAR   CurrMCS;
 	UCHAR   TrainUp;
 	UCHAR   TrainDown;
diff --git a/include/oid.h b/oid.h
similarity index 96%
rename from include/oid.h
rename to oid.h
index 563ac43..f2f91b6 100644
--- a/include/oid.h
+++ b/oid.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -63,7 +63,7 @@
 #define BAND_WIDTH_10		3	// 802.11j has 10MHz. This definition is for internal usage. doesn't fill in the IE or other field.
 // SHORTGI
 #define GAP_INTERVAL_400	1	// only support in HT mode
-#define GAP_INTERVAL_800	0	
+#define GAP_INTERVAL_800	0
 #define GAP_INTERVAL_BOTH	2
 
 #define NdisMediaStateConnected			1
@@ -200,7 +200,7 @@
 #define RT_OID_QUERY_MULTIPLE_CARD_SUPPORT          0x0647
 
 // Ralink defined OIDs
-// Dennis Lee move to platform specific	
+// Dennis Lee move to platform specific
 
 #define	RT_OID_802_11_BSSID					  (OID_GET_SET_TOGGLE |	OID_802_11_BSSID)
 #define	RT_OID_802_11_SSID					  (OID_GET_SET_TOGGLE |	OID_802_11_SSID)
@@ -231,7 +231,7 @@ typedef enum _NDIS_802_11_STATUS_TYPE
 {
     Ndis802_11StatusType_Authentication,
     Ndis802_11StatusType_MediaStreamMode,
-    Ndis802_11StatusType_PMKID_CandidateList,		
+    Ndis802_11StatusType_PMKID_CandidateList,
     Ndis802_11StatusTypeMax    // not a real type, defined as an upper bound
 } NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
 
@@ -276,8 +276,8 @@ typedef struct _NDIS_802_11_PMKID_CANDIDATE_LIST
 // Added new types for OFDM 5G and 2.4G
 typedef enum _NDIS_802_11_NETWORK_TYPE
 {
-   Ndis802_11FH, 
-   Ndis802_11DS, 
+   Ndis802_11FH,
+   Ndis802_11DS,
     Ndis802_11OFDM5,
     Ndis802_11OFDM5_N,
     Ndis802_11OFDM24,
@@ -311,7 +311,7 @@ typedef LONG    NDIS_802_11_RSSI;           // in dBm
 typedef struct _NDIS_802_11_CONFIGURATION_FH
 {
    ULONG           Length;            // Length of structure
-   ULONG           HopPattern;        // As defined by 802.11, MSB set 
+   ULONG           HopPattern;        // As defined by 802.11, MSB set
    ULONG           HopSet;            // to one if non-802.11
    ULONG           DwellTime;         // units are Kusec
 } NDIS_802_11_CONFIGURATION_FH, *PNDIS_802_11_CONFIGURATION_FH;
@@ -348,7 +348,7 @@ typedef struct _NDIS_802_11_STATISTICS
    LARGE_INTEGER   CCMPFormatErrors;
    LARGE_INTEGER   CCMPReplays;
    LARGE_INTEGER   CCMPDecryptErrors;
-   LARGE_INTEGER   FourWayHandshakeFailures;   
+   LARGE_INTEGER   FourWayHandshakeFailures;
 } NDIS_802_11_STATISTICS, *PNDIS_802_11_STATISTICS;
 
 typedef  ULONG  NDIS_802_11_KEY_INDEX;
@@ -365,20 +365,20 @@ typedef struct PACKED _RADIUS_SRV_INFO {
 
 typedef struct PACKED _RADIUS_KEY_INFO
 {
-	UCHAR			radius_srv_num;			
+	UCHAR			radius_srv_num;
 	RADIUS_SRV_INFO	radius_srv_info[MAX_RADIUS_SRV_NUM];
 	UCHAR			ieee8021xWEP;		 // dynamic WEP
-    UCHAR           key_index;           
+    UCHAR           key_index;
     UCHAR           key_length;          // length of key in bytes
-    UCHAR           key_material[13];    
+    UCHAR           key_material[13];
 } RADIUS_KEY_INFO, *PRADIUS_KEY_INFO;
 
 // It's used by 802.1x daemon to require relative configuration
 typedef struct PACKED _RADIUS_CONF
 {
-    UINT32          Length;             // Length of this structure    
-    UCHAR			mbss_num;			// indicate multiple BSS number 
-	UINT32			own_ip_addr;	
+    UINT32          Length;             // Length of this structure
+    UCHAR			mbss_num;			// indicate multiple BSS number
+	UINT32			own_ip_addr;
 	UINT32			retry_interval;
 	UINT32			session_timeout_interval;
 	UCHAR			EAPifname[IFNAMSIZ];
@@ -395,7 +395,7 @@ typedef struct PACKED _RADIUS_CONF
 typedef struct _NDIS_802_11_KEY
 {
     UINT           Length;             // Length of this structure
-    UINT           KeyIndex;           
+    UINT           KeyIndex;
     UINT           KeyLength;          // length of key in bytes
     NDIS_802_11_MAC_ADDRESS BSSID;
     NDIS_802_11_KEY_RSC KeyRSC;
@@ -406,8 +406,8 @@ typedef struct _NDIS_802_11_KEY
 typedef struct _NDIS_802_11_REMOVE_KEY
 {
     UINT           Length;             // Length of this structure
-    UINT           KeyIndex;           
-    NDIS_802_11_MAC_ADDRESS BSSID;      
+    UINT           KeyIndex;
+    NDIS_802_11_MAC_ADDRESS BSSID;
 } NDIS_802_11_REMOVE_KEY, *PNDIS_802_11_REMOVE_KEY;
 
 typedef struct _NDIS_802_11_WEP
@@ -439,7 +439,7 @@ typedef enum _NDIS_802_11_AUTHENTICATION_MODE
     Ndis802_11AuthModeWPAPSK,
     Ndis802_11AuthModeWPANone,
    Ndis802_11AuthModeWPA2,
-   Ndis802_11AuthModeWPA2PSK,    
+   Ndis802_11AuthModeWPA2PSK,
    	Ndis802_11AuthModeWPA1WPA2,
 	Ndis802_11AuthModeWPA1PSKWPA2PSK,
    Ndis802_11AuthModeMax           // Not a real mode, defined as upper bound
@@ -500,14 +500,14 @@ typedef struct PACKED _NDIS_802_11_BSSID_LIST_EX
     NDIS_WLAN_BSSID_EX      Bssid[1];
 } NDIS_802_11_BSSID_LIST_EX, *PNDIS_802_11_BSSID_LIST_EX;
 
-typedef struct PACKED _NDIS_802_11_FIXED_IEs 
+typedef struct PACKED _NDIS_802_11_FIXED_IEs
 {
     UCHAR Timestamp[8];
     USHORT BeaconInterval;
     USHORT Capabilities;
 } NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
 
-typedef struct _NDIS_802_11_VARIABLE_IEs 
+typedef struct _NDIS_802_11_VARIABLE_IEs
 {
     UCHAR ElementID;
     UCHAR Length;    // Number of bytes in data field
@@ -592,7 +592,7 @@ typedef struct _NDIS_802_11_AUTHENTICATION_EVENT
     NDIS_802_11_STATUS_INDICATION       Status;
     NDIS_802_11_AUTHENTICATION_REQUEST  Request[1];
 } NDIS_802_11_AUTHENTICATION_EVENT, *PNDIS_802_11_AUTHENTICATION_EVENT;
-        
+
 // 802.11 Media stream constraints, associated with OID_802_11_MEDIA_STREAM_MODE
 typedef enum _NDIS_802_11_MEDIA_STREAM_MODE
 {
@@ -667,7 +667,7 @@ typedef struct _NDIS_802_11_CAPABILITY
 #define RTPRIV_IOCTL_GET_MAC_TABLE					(SIOCIWFIRSTPRIV + 0x0F)
 
 #define RTPRIV_IOCTL_SHOW							(SIOCIWFIRSTPRIV + 0x11)
-enum {    
+enum {
     SHOW_CONN_STATUS = 4,
     SHOW_DRVIER_VERION = 5,
     SHOW_BA_INFO = 6,
@@ -724,10 +724,10 @@ enum {
 typedef union  _HTTRANSMIT_SETTING {
 #ifdef RT_BIG_ENDIAN
 	struct	{
-	USHORT		MODE:2;	// Use definition MODE_xxx.  
+	USHORT		MODE:2;	// Use definition MODE_xxx.
 	USHORT		TxBF:1;
 	USHORT		rsv:2;
-	USHORT		STBC:2;	//SPACE 
+	USHORT		STBC:2;	//SPACE
 	USHORT		ShortGI:1;
 	USHORT		BW:1;	//channel bandwidth 20MHz or 40 MHz
 	USHORT   	MCS:7;                 // MCS
@@ -737,10 +737,10 @@ typedef union  _HTTRANSMIT_SETTING {
 	USHORT   	MCS:7;                 // MCS
 	USHORT		BW:1;	//channel bandwidth 20MHz or 40 MHz
 	USHORT		ShortGI:1;
-	USHORT		STBC:2;	//SPACE 
+	USHORT		STBC:2;	//SPACE
 	USHORT		rsv:2;
 	USHORT		TxBF:1;
-	USHORT		MODE:2;	// Use definition MODE_xxx.  
+	USHORT		MODE:2;	// Use definition MODE_xxx.
 	}	field;
 #endif
 	USHORT		word;
@@ -753,7 +753,7 @@ typedef enum _RT_802_11_PREAMBLE {
 } RT_802_11_PREAMBLE, *PRT_802_11_PREAMBLE;
 
 // Only for STA, need to sync with AP
-// 2005-03-08 match current RaConfig. 
+// 2005-03-08 match current RaConfig.
 typedef enum _RT_802_11_PHY_MODE {
 	PHY_11BG_MIXED = 0,
 	PHY_11B,
@@ -798,9 +798,9 @@ typedef union  _MACHTTRANSMIT_SETTING {
 	USHORT   	MCS:7;                 // MCS
 	USHORT		BW:1;	//channel bandwidth 20MHz or 40 MHz
 	USHORT		ShortGI:1;
-	USHORT		STBC:2;	//SPACE 
-	USHORT		rsv:3;	 
-	USHORT		MODE:2;	// Use definition MODE_xxx.  
+	USHORT		STBC:2;	//SPACE
+	USHORT		rsv:3;
+	USHORT		MODE:2;	// Use definition MODE_xxx.
 	}	field;
 	USHORT		word;
  } MACHTTRANSMIT_SETTING, *PMACHTTRANSMIT_SETTING;
@@ -863,7 +863,7 @@ typedef	struct	_OID_BACAP_STRUC	{
 		UCHAR       	AmsduEnable;	//Enable AMSDU transmisstion
 		UCHAR       	AmsduSize;	// 0:3839, 1:7935 bytes. UINT  MSDUSizeToBytes[]	= { 3839, 7935};
 		UCHAR       	MMPSmode;	// MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
-		BOOLEAN		AutoBA;	// Auto BA will automatically	
+		BOOLEAN		AutoBA;	// Auto BA will automatically
 } OID_BACAP_STRUC, *POID_BACAP_STRUC;
 
 typedef struct _RT_802_11_ACL_ENTRY {
@@ -885,9 +885,9 @@ typedef struct _RT_802_11_WDS {
 } RT_802_11_WDS, *PRT_802_11_WDS;
 
 typedef struct _RT_802_11_TX_RATES_ {
-    UCHAR       SupRateLen;	
+    UCHAR       SupRateLen;
     UCHAR       SupRate[MAX_LENGTH_OF_SUPPORT_RATES];
-    UCHAR       ExtRateLen;	
+    UCHAR       ExtRateLen;
     UCHAR       ExtRate[MAX_LENGTH_OF_SUPPORT_RATES];
 } RT_802_11_TX_RATES, *PRT_802_11_TX_RATES;
 
@@ -911,7 +911,7 @@ typedef struct _RT_802_11_TX_RATES_ {
 
 // This is OID setting structure. So only GF or MM as Mode. This is valid when our wirelss mode has 802.11n in use.
 typedef struct {
-	RT_802_11_PHY_MODE		PhyMode; 	// 
+	RT_802_11_PHY_MODE		PhyMode; 	//
 	UCHAR		TransmitNo;
 	UCHAR		HtMode; 	//HTMODE_GF or HTMODE_MM
 	UCHAR		ExtOffset;	//extension channel above or below
@@ -973,7 +973,7 @@ typedef enum _RT_802_11_DLS_MODE {
 #endif // WPA_SUPPLICANT_SUPPORT //
 #endif // CONFIG_STA_SUPPORT //
 
-#define MAX_CUSTOM_LEN 128 
+#define MAX_CUSTOM_LEN 128
 
 #ifdef CONFIG_STA_SUPPORT
 typedef enum _RT_802_11_D_CLIENT_MODE
diff --git a/os/linux/Makefile.4 b/os/linux/Makefile.4
deleted file mode 100644
index 93a9a93..0000000
--- a/os/linux/Makefile.4
+++ /dev/null
@@ -1,84 +0,0 @@
-include $(RT28xx_DIR)/os/linux/config.mk 
-
-MOD_NAME = rt$(CHIPSET)sta
-DAT_PATH = /etc/Wireless/RT$(CHIPSET)STA
-DAT_FILE_NAME = RT$(CHIPSET)STA.dat
-
-OBJ := $(MOD_NAME).o
-
-RT28XX_STA_OBJ := \
-	$(RT28xx_DIR)/common/md5.o\
-	$(RT28xx_DIR)/common/mlme.o\
-	$(RT28xx_DIR)/common/rtmp_wep.o\
-	$(RT28xx_DIR)/common/action.o\
-	$(RT28xx_DIR)/common/ba_action.o\
-	$(RT28xx_DIR)/common/cmm_data.o\
-	$(RT28xx_DIR)/common/rtmp_init.o\
-	$(RT28xx_DIR)/common/rtmp_tkip.o\
-	$(RT28xx_DIR)/common/cmm_sync.o\
-	$(RT28xx_DIR)/common/eeprom.o\
-	$(RT28xx_DIR)/common/cmm_sanity.o\
-	$(RT28xx_DIR)/common/cmm_info.o\
-	$(RT28xx_DIR)/common/cmm_wpa.o\
-	$(RT28xx_DIR)/common/dfs.o\
-	$(RT28xx_DIR)/common/spectrum.o\
-	$(RT28xx_DIR)/sta/assoc.o\
-	$(RT28xx_DIR)/sta/aironet.o\
-	$(RT28xx_DIR)/sta/auth.o\
-	$(RT28xx_DIR)/sta/auth_rsp.o\
-	$(RT28xx_DIR)/sta/sync.o\
-	$(RT28xx_DIR)/sta/sanity.o\
-	$(RT28xx_DIR)/sta/rtmp_data.o\
-	$(RT28xx_DIR)/sta/connect.o\
-	$(RT28xx_DIR)/sta/wpa.o\
-	$(RT28xx_DIR)/os/linux/rt_linux.o\
-    $(RT28xx_DIR)/os/linux/rt_profile.o\
-	$(RT28xx_DIR)/os/linux/rt_main_dev.o\
-	$(RT28xx_DIR)/os/linux/sta_ioctl.o
-
-ifeq ($(HAS_BLOCK_NET_IF),y)
-RT28XX_STA_OBJ += $(RT28xx_DIR)/common/netif_block.o
-endif
-
-ifeq ($(CHIPSET),2860)
-RT28XX_STA_OBJ += \
-	$(RT28xx_DIR)/common/2860_rtmp_init.o\
-	$(RT28xx_DIR)/os/linux/2860_main_dev.o\
-	$(RT28xx_DIR)/common/cmm_data_2860.o
-endif
-
-ifeq ($(HAS_ATE),y)
-RT28XX_STA_OBJ += $(RT28xx_DIR)/os/linux/rt_ate.o
-endif
-
-ifeq ($(HAS_QOS_DLS_SUPPORT),y)
-RT28XX_STA_OBJ += $(RT28xx_DIR)/sta/dls.o
-endif
-
-all:$(OBJ)
-
-rt$(CHIPSET)sta.o: $(RT28XX_STA_OBJ)
-	$(LD) -r $^ -o $@
-
-clean:
-	rm -f $(RT28xx_DIR)/common/*.o
-	rm -f $(RT28xx_DIR)/common/.*.{cmd,flags,d}
-	rm -f $(RT28xx_DIR)/os/linux/*.{o,ko,mod.{o,c}}
-	rm -f $(RT28xx_DIR)/os/linux/.*.{cmd,flags,d}
-	rm -fr $(RT28xx_DIR)/os/linux/.tmp_versions
-	rm -f $(RT28xx_DIR)/sta/*.o
-	rm -f $(RT28xx_DIR)/sta/.*.{cmd,flags,d}
-
-install:
-	rm -rf $(DAT_PATH)
-	$(shell [ ! -f /etc/Wireless ] && mkdir /etc/Wireless)
-	mkdir $(DAT_PATH)
-	cp $(RT28xx_DIR)/$(DAT_FILE_NAME) $(DAT_PATH)/.
-	install -d $(LINUX_SRC_MODULE)
-	install -m 644 -c $(addsuffix .o,$(MOD_NAME)) $(LINUX_SRC_MODULE)
-	/sbin/depmod -a ${shell uname -r}
-
-uninstall:
-#	rm -rf $(DAT_PATH)
-	rm -rf $(addprefix $(LINUX_SRC_MODULE),$(addsuffix .o,$(MOD_NAME)))
-	/sbin/depmod -a ${shell uname -r}
diff --git a/os/linux/Makefile.6 b/os/linux/Makefile.6
deleted file mode 100644
index 5dd36e3..0000000
--- a/os/linux/Makefile.6
+++ /dev/null
@@ -1,86 +0,0 @@
-include $(RT28xx_DIR)/os/linux/config.mk
-
-MOD_NAME = rt$(CHIPSET)sta
-DAT_PATH = /etc/Wireless/RT$(CHIPSET)STA
-DAT_FILE_NAME = RT$(CHIPSET)STA.dat
-
-obj-m := $(MOD_NAME).o
-
-rt$(CHIPSET)sta-objs := \
-	../../common/md5.o\
-	../../common/mlme.o\
-	../../common/rtmp_wep.o\
-	../../common/action.o\
-	../../common/cmm_data.o\
-	../../common/rtmp_init.o\
-	../../common/rtmp_tkip.o\
-	../../common/cmm_sync.o\
-	../../common/eeprom.o\
-	../../common/cmm_sanity.o\
-	../../common/cmm_info.o\
-	../../common/cmm_wpa.o\
-	../../common/dfs.o\
-	../../common/spectrum.o\
-	../../sta/assoc.o\
-	../../sta/aironet.o\
-	../../sta/auth.o\
-	../../sta/auth_rsp.o\
-	../../sta/sync.o\
-	../../sta/sanity.o\
-	../../sta/rtmp_data.o\
-	../../sta/connect.o\
-	../../sta/wpa.o\
-	../../os/linux/rt_linux.o\
-    ../../os/linux/rt_profile.o\
-	../../os/linux/rt_main_dev.o\
-	../../os/linux/sta_ioctl.o
-
-ifeq ($(HAS_DOT11_N_SUPPORT),y)
-rt$(CHIPSET)sta-objs += \
-	../../common/ba_action.o
-endif
-
-ifeq ($(HAS_BLOCK_NET_IF),y)
-rt$(CHIPSET)sta-objs += ../../common/netif_block.o
-endif
-
-ifeq ($(HAS_QOS_DLS_SUPPORT),y)
-rt$(CHIPSET)sta-objs += ../../sta/dls.o
-endif
-
-ifeq ($(CHIPSET),2860)
-rt$(CHIPSET)sta-objs += \
-	../../common/2860_rtmp_init.o\
-	../../os/linux/2860_main_dev.o\
-	../../common/cmm_data_2860.o
-endif
-
-ifeq ($(HAS_ATE),y)
-rt$(CHIPSET)sta-objs += ../../os/linux/rt_ate.o
-endif
-
-#endif // CONFIG_STA_SUPPORT //
-
-
-clean:
-	rm -f ../../common/*.o
-	rm -f ../../common/.*.{cmd,flags,d}
-	rm -f ../../os/linux/*.{o,ko,mod.{o,c}}
-	rm -f ../../os/linux/.*.{cmd,flags,d}
-	rm -fr ../../os/linux/.tmp_versions
-	rm -f ../../sta/*.o
-	rm -f ../../sta/.*.{cmd,flags,d}
-
-install:
-	rm -rf $(DAT_PATH)
-	$(shell [ ! -f /etc/Wireless ] && mkdir /etc/Wireless)
-	mkdir $(DAT_PATH)
-	cp $(RT28xx_DIR)/$(DAT_FILE_NAME) $(DAT_PATH)/.
-	install -d $(LINUX_SRC_MODULE)
-	install -m 644 -c $(addsuffix .ko,$(MOD_NAME)) $(LINUX_SRC_MODULE)
-	/sbin/depmod -a ${shell uname -r}
-
-uninstall:
-#	rm -rf $(DAT_PATH)
-	rm -rf $(addprefix $(LINUX_SRC_MODULE),$(addsuffix .ko,$(MOD_NAME)))
-	/sbin/depmod -a ${shell uname -r}
diff --git a/os/linux/Makefile.kbuild b/os/linux/Makefile.kbuild
deleted file mode 100644
index 8ea0c12..0000000
--- a/os/linux/Makefile.kbuild
+++ /dev/null
@@ -1,79 +0,0 @@
-include $(RT28xx_DIR)/os/linux/config.mk
-
-MOD_NAME = rt$(CHIPSET)sta
-DAT_PATH = /etc/Wireless/RT$(CHIPSET)STA
-DAT_FILE_NAME = RT$(CHIPSET)STA.dat
-
-obj-m := $(MOD_NAME).o
-
-rt$(CHIPSET)sta-objs := \
-	common/md5.o\
-	common/mlme.o\
-	common/rtmp_wep.o\
-	common/action.o\
-	common/cmm_data.o\
-	common/rtmp_init.o\
-	common/rtmp_tkip.o\
-	common/cmm_sync.o\
-	common/eeprom.o\
-	common/cmm_sanity.o\
-	common/cmm_info.o\
-	common/cmm_wpa.o\
-	common/dfs.o\
-	common/spectrum.o\
-	sta/assoc.o\
-	sta/aironet.o\
-	sta/auth.o\
-	sta/auth_rsp.o\
-	sta/sync.o\
-	sta/sanity.o\
-	sta/rtmp_data.o\
-	sta/connect.o\
-	sta/wpa.o\
-	os/linux/rt_linux.o\
-	os/linux/rt_profile.o\
-	os/linux/rt_main_dev.o\
-	os/linux/sta_ioctl.o
-
-ifeq ($(HAS_DOT11_N_SUPPORT),y)
-rt$(CHIPSET)sta-objs += \
-	common/ba_action.o
-endif
-
-ifeq ($(HAS_BLOCK_NET_IF),y)
-rt$(CHIPSET)sta-objs += common/netif_block.o
-endif
-
-ifeq ($(HAS_QOS_DLS_SUPPORT),y)
-rt$(CHIPSET)sta-objs += sta/dls.o
-endif
-
-ifeq ($(CHIPSET),2860)
-rt$(CHIPSET)sta-objs += \
-	common/2860_rtmp_init.o\
-	os/linux/2860_main_dev.o\
-	common/cmm_data_2860.o
-endif
-
-ifeq ($(HAS_ATE),y)
-rt$(CHIPSET)sta-objs += os/linux/rt_ate.o
-endif
-
-clean:
-	rm -f common/*.o
-	rm -f common/.*.{cmd,flags,d}
-	rm -f os/linux/*.{o,ko,mod.{o,c}}
-	rm -f os/linux/.*.{cmd,flags,d}
-	rm -fr os/linux/.tmp_versions
-	rm -f sta/*.o
-	rm -f sta/.*.{cmd,flags,d}
-
-install:
-	install -d $(LINUX_SRC_MODULE)
-	install -m 644 -c $(addsuffix .ko,$(MOD_NAME)) $(LINUX_SRC_MODULE)
-	/sbin/depmod -a ${shell uname -r}
-
-uninstall:
-	rm -rf $(addprefix $(LINUX_SRC_MODULE),$(addsuffix .ko,$(MOD_NAME)))
-
-
diff --git a/os/linux/Module.symvers b/os/linux/Module.symvers
deleted file mode 100644
index e69de29..0000000
diff --git a/os/linux/modules.order b/os/linux/modules.order
deleted file mode 100644
index a6cc50c..0000000
--- a/os/linux/modules.order
+++ /dev/null
@@ -1 +0,0 @@
-kernel//home/snowpin/temp/2860/V1.8.0.0/RT2860_V1.8.0.0/DPO/os/linux/rt2860sta.ko
diff --git a/os/linux/sta_ioctl.c.patch b/os/linux/sta_ioctl.c.patch
deleted file mode 100644
index 4bf50e5..0000000
--- a/os/linux/sta_ioctl.c.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- sta_ioctl.c	2008-09-18 10:14:57.000000000 +0800
-+++ sta_ioctl.c.fc9	2008-09-18 10:45:57.000000000 +0800
-@@ -49,15 +49,9 @@
- 
- #define GROUP_KEY_NO                4
- 
--#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
- #define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E)		iwe_stream_add_event(_A, _B, _C, _D, _E)
- #define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E)		iwe_stream_add_point(_A, _B, _C, _D, _E)
- #define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F)	iwe_stream_add_value(_A, _B, _C, _D, _E, _F)
--#else
--#define IWE_STREAM_ADD_EVENT(_A, _B, _C, _D, _E)		iwe_stream_add_event(_B, _C, _D, _E)
--#define IWE_STREAM_ADD_POINT(_A, _B, _C, _D, _E)		iwe_stream_add_point(_B, _C, _D, _E)
--#define IWE_STREAM_ADD_VALUE(_A, _B, _C, _D, _E, _F)	iwe_stream_add_value(_B, _C, _D, _E, _F)
--#endif
- 
- extern UCHAR    CipherWpa2Template[];
- extern UCHAR    CipherWpaPskTkip[];
diff --git a/include/rt2860.h b/rt2860.h
similarity index 98%
rename from include/rt2860.h
rename to rt2860.h
index fd7dafb..c8977d5 100644
--- a/include/rt2860.h
+++ b/rt2860.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
  */
 
@@ -94,7 +94,7 @@ rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 #define NEED_QUEUE_BACK_FOR_AGG(pAd, QueIdx, freeNum, _TxFrameType) \
 		(((freeNum != (TX_RING_SIZE-1)) && (pAd->TxSwQueue[QueIdx].Number == 0)) || (freeNum<3))
 		//(((freeNum) != (TX_RING_SIZE-1)) && (pAd->TxSwQueue[QueIdx].Number == 1 /*0*/))
-		
+
 
 #define HAL_KickOutMgmtTx(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen)	\
 			RtmpPCIMgmtKickOut(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen)
@@ -111,16 +111,16 @@ rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 
 #define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \
 			RtmpPCI_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber)
-			
+
 #define HAL_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber)	\
 			RtmpPCI_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber)
-	
+
 #define HAL_FinalWriteTxResource(_pAd, _pTxBlk, _TotalMPDUSize, _FirstTxIdx)	\
 			RtmpPCI_FinalWriteTxResource(_pAd, _pTxBlk, _TotalMPDUSize, _FirstTxIdx)
 
 #define HAL_LastTxIdx(_pAd, _QueIdx,_LastTxIdx) \
 			/*RtmpPCIDataLastTxIdx(_pAd, _QueIdx,_LastTxIdx)*/
-	
+
 #define HAL_KickOutTx(_pAd, _pTxBlk, _QueIdx)	\
 			RTMP_IO_WRITE32((_pAd), TX_CTX_IDX0+((_QueIdx)*0x10), (_pAd)->TxRing[(_QueIdx)].TxCpuIdx)
 /*			RtmpPCIDataKickOut(_pAd, _pTxBlk, _QueIdx)*/
@@ -293,7 +293,7 @@ rt2860_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
 
 #define RT28XX_HANDLE_COUNTER_MEASURE(_pAd, _pEntry)		\
 		HandleCounterMeasure(_pAd, _pEntry)
-		
+
 /* ----------------- Power Save Related MACRO ----------------- */
 #define RT28XX_PS_POLL_ENQUEUE(pAd)				EnqueuePsPoll(pAd)
 
diff --git a/include/rt28xx.h b/rt28xx.h
similarity index 95%
rename from include/rt28xx.h
rename to rt28xx.h
index 250321f..ff23043 100644
--- a/include/rt28xx.h
+++ b/rt28xx.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -85,7 +85,7 @@ typedef	union	_INT_SOURCE_CSR_STRUC	{
 		UINT32		RxDelayINT:1;
 		UINT32		TxDelayINT:1;
 		UINT32		RxDone:1;
-		UINT32		Ac0DmaDone:1;//4      
+		UINT32		Ac0DmaDone:1;//4
 		UINT32       	Ac1DmaDone:1;
 		UINT32       	Ac2DmaDone:1;
 		UINT32       	Ac3DmaDone:1;
@@ -404,12 +404,12 @@ typedef	union	_USB_DMA_CFG_STRUC	{
 	    UINT32  TxBusy:1;   	//USB DMA TX FSM busy . debug only
 	    UINT32  RxBusy:1;        //USB DMA RX FSM busy . debug only
 	    UINT32  EpoutValid:6;        //OUT endpoint data valid. debug only
-	    UINT32  TxBulkEn:1;        //Enable USB DMA Tx  
-	    UINT32  RxBulkEn:1;        //Enable USB DMA Rx  
-	    UINT32  RxBulkAggEn:1;        //Enable Rx Bulk Aggregation  
+	    UINT32  TxBulkEn:1;        //Enable USB DMA Tx
+	    UINT32  RxBulkEn:1;        //Enable USB DMA Rx
+	    UINT32  RxBulkAggEn:1;        //Enable Rx Bulk Aggregation
 	    UINT32  TxopHalt:1;        //Halt TXOP count down when TX buffer is full.
 	    UINT32  TxClear:1;        //Clear USB DMA TX path
-	    UINT32  rsv:2;        
+	    UINT32  rsv:2;
 	    UINT32  phyclear:1;        		//phy watch dog enable. write 1
 	    UINT32  RxBulkAggLmt:8;        //Rx Bulk Aggregation Limit  in unit of 1024 bytes
 	    UINT32  RxBulkAggTOut:8;        //Rx Bulk Aggregation TimeOut  in unit of 33ns
@@ -422,22 +422,22 @@ typedef	union	_USB_DMA_CFG_STRUC	{
 	    UINT32  RxBulkAggTOut:8;        //Rx Bulk Aggregation TimeOut  in unit of 33ns
 	    UINT32  RxBulkAggLmt:8;        //Rx Bulk Aggregation Limit  in unit of 256 bytes
 	    UINT32  phyclear:1;        		//phy watch dog enable. write 1
-	    UINT32  rsv:2;        
+	    UINT32  rsv:2;
 	    UINT32  TxClear:1;        //Clear USB DMA TX path
 	    UINT32  TxopHalt:1;        //Halt TXOP count down when TX buffer is full.
-	    UINT32  RxBulkAggEn:1;        //Enable Rx Bulk Aggregation  
-	    UINT32  RxBulkEn:1;        //Enable USB DMA Rx  
-	    UINT32  TxBulkEn:1;        //Enable USB DMA Tx  
+	    UINT32  RxBulkAggEn:1;        //Enable Rx Bulk Aggregation
+	    UINT32  RxBulkEn:1;        //Enable USB DMA Rx
+	    UINT32  TxBulkEn:1;        //Enable USB DMA Tx
 	    UINT32  EpoutValid:6;        //OUT endpoint data valid
-	    UINT32  RxBusy:1;        //USB DMA RX FSM busy 
-	    UINT32  TxBusy:1;   	//USB DMA TX FSM busy 
+	    UINT32  RxBusy:1;        //USB DMA RX FSM busy
+	    UINT32  TxBusy:1;   	//USB DMA TX FSM busy
 	}	field;
 	UINT32			word;
 }	USB_DMA_CFG_STRUC, *PUSB_DMA_CFG_STRUC;
 #endif
 
 //
-//  3  PBF  registers  
+//  3  PBF  registers
 //
 //
 // Most are for debug. Driver doesn't touch PBF register.
@@ -452,7 +452,7 @@ typedef	union	_USB_DMA_CFG_STRUC	{
 #define     PBF_CAP_CTRL     0x0440
 
 //
-//  4  MAC  registers  
+//  4  MAC  registers
 //
 //
 //  4.1 MAC SYSTEM  configuration registers (offset:0x1000)
@@ -559,17 +559,17 @@ typedef	union	_MAC_CSR5_STRUC	{
 #endif
 
 #define MAX_LEN_CFG              0x1018		// rt2860b max 16k bytes. bit12:13 Maximum PSDU length (power factor) 0:2^13, 1:2^14, 2:2^15, 3:2^16
-#define BBP_CSR_CFG            		0x101c		//  
+#define BBP_CSR_CFG            		0x101c		//
 //
 // BBP_CSR_CFG: BBP serial control register
 //
 #ifdef RT_BIG_ENDIAN
 typedef	union	_BBP_CSR_CFG_STRUC	{
 	struct	{
-		UINT32		:12;		
+		UINT32		:12;
 		UINT32		BBP_RW_MODE:1;		// 0: use serial mode  1:parallel
 		UINT32		BBP_PAR_DUR:1;		    // 0: 4 MAC clock cycles  1: 8 MAC clock cycles
-		UINT32		Busy:1;				// 1: ASIC is busy execute BBP programming.	
+		UINT32		Busy:1;				// 1: ASIC is busy execute BBP programming.
 		UINT32		fRead:1;		    // 0: Write	BBP, 1:	Read BBP
 		UINT32		RegNum:8;			// Selected	BBP	register
 		UINT32		Value:8;			// Register	value to program into BBP
@@ -582,7 +582,7 @@ typedef	union	_BBP_CSR_CFG_STRUC	{
 		UINT32		Value:8;			// Register	value to program into BBP
 		UINT32		RegNum:8;			// Selected	BBP	register
 		UINT32		fRead:1;		    // 0: Write	BBP, 1:	Read BBP
-		UINT32		Busy:1;				// 1: ASIC is busy execute BBP programming.	
+		UINT32		Busy:1;				// 1: ASIC is busy execute BBP programming.
 		UINT32		BBP_PAR_DUR:1;		     // 0: 4 MAC clock cycles  1: 8 MAC clock cycles
 		UINT32		BBP_RW_MODE:1;		// 0: use serial mode  1:parallel
 		UINT32		:12;
@@ -590,7 +590,7 @@ typedef	union	_BBP_CSR_CFG_STRUC	{
 	UINT32			word;
 }	BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC;
 #endif
-#define RF_CSR_CFG0            		0x1020		 
+#define RF_CSR_CFG0            		0x1020
 //
 // RF_CSR_CFG: RF control register
 //
@@ -598,7 +598,7 @@ typedef	union	_BBP_CSR_CFG_STRUC	{
 typedef	union	_RF_CSR_CFG0_STRUC	{
 	struct	{
 		UINT32		Busy:1;		    // 0: idle 1: 8busy
-		UINT32		Sel:1;				// 0:RF_LE0 activate  1:RF_LE1 activate	
+		UINT32		Sel:1;				// 0:RF_LE0 activate  1:RF_LE1 activate
 		UINT32		StandbyMode:1;		    // 0: high when stand by 1:	low when standby
 		UINT32		bitwidth:5;			// Selected	BBP	register
 		UINT32		RegIdAndContent:24;			// Register	value to program into BBP
@@ -611,13 +611,13 @@ typedef	union	_RF_CSR_CFG0_STRUC	{
 		UINT32		RegIdAndContent:24;			// Register	value to program into BBP
 		UINT32		bitwidth:5;			// Selected	BBP	register
 		UINT32		StandbyMode:1;		    // 0: high when stand by 1:	low when standby
-		UINT32		Sel:1;				// 0:RF_LE0 activate  1:RF_LE1 activate	
+		UINT32		Sel:1;				// 0:RF_LE0 activate  1:RF_LE1 activate
 		UINT32		Busy:1;		    // 0: idle 1: 8busy
 	}	field;
 	UINT32			word;
 }	RF_CSR_CFG0_STRUC, *PRF_CSR_CFG0_STRUC;
 #endif
-#define RF_CSR_CFG1           		0x1024		 
+#define RF_CSR_CFG1           		0x1024
 #ifdef RT_BIG_ENDIAN
 typedef	union	_RF_CSR_CFG1_STRUC	{
 	struct	{
@@ -637,7 +637,7 @@ typedef	union	_RF_CSR_CFG1_STRUC	{
 	UINT32			word;
 }	RF_CSR_CFG1_STRUC, *PRF_CSR_CFG1_STRUC;
 #endif
-#define RF_CSR_CFG2           		0x1028		//  
+#define RF_CSR_CFG2           		0x1028		//
 #ifdef RT_BIG_ENDIAN
 typedef	union	_RF_CSR_CFG2_STRUC	{
 	struct	{
@@ -659,12 +659,12 @@ typedef	union	_RF_CSR_CFG2_STRUC	{
 #ifdef RT_BIG_ENDIAN
 typedef	union	_LED_CFG_STRUC	{
 	struct	{
-		UINT32		:1;			 
+		UINT32		:1;
 		UINT32		LedPolar:1;			// Led Polarity.  0: active low1: active high
 		UINT32		YLedMode:2;			// yellow Led Mode
 		UINT32		GLedMode:2;			// green Led Mode
 		UINT32		RLedMode:2;			// red Led Mode    0: off1: blinking upon TX2: periodic slow blinking3: always on
-		UINT32		rsv:2;		    
+		UINT32		rsv:2;
 		UINT32		SlowBlinkPeriod:6;			// slow blinking period. unit:1ms
 		UINT32		OffPeriod:8;			// blinking off period unit 1ms
 		UINT32		OnPeriod:8;			// blinking on period unit 1ms
@@ -677,12 +677,12 @@ typedef	union	_LED_CFG_STRUC	{
 		UINT32		OnPeriod:8;			// blinking on period unit 1ms
 		UINT32		OffPeriod:8;			// blinking off period unit 1ms
 		UINT32		SlowBlinkPeriod:6;			// slow blinking period. unit:1ms
-		UINT32		rsv:2;		    
+		UINT32		rsv:2;
 		UINT32		RLedMode:2;			// red Led Mode    0: off1: blinking upon TX2: periodic slow blinking3: always on
 		UINT32		GLedMode:2;			// green Led Mode
 		UINT32		YLedMode:2;			// yellow Led Mode
 		UINT32		LedPolar:1;			// Led Polarity.  0: active low1: active high
-		UINT32		:1;			 
+		UINT32		:1;
 	}	field;
 	UINT32			word;
 }	LED_CFG_STRUC, *PLED_CFG_STRUC;
@@ -690,11 +690,11 @@ typedef	union	_LED_CFG_STRUC	{
 //
 //  4.2 MAC TIMING  configuration registers (offset:0x1100)
 //
-#define XIFS_TIME_CFG             0x1100		 // MAC_CSR8  MAC_CSR9   
+#define XIFS_TIME_CFG             0x1100		 // MAC_CSR8  MAC_CSR9
 #ifdef RT_BIG_ENDIAN
 typedef	union	_IFS_SLOT_CFG_STRUC	{
 	struct	{
-	    UINT32  rsv:2;         
+	    UINT32  rsv:2;
 	    UINT32  BBRxendEnable:1;        //  reference RXEND signal to begin XIFS defer
 	    UINT32  EIFS:9;        //  unit 1us
 	    UINT32  OfdmXifsTime:4;        //OFDM SIFS. unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND
@@ -711,7 +711,7 @@ typedef	union	_IFS_SLOT_CFG_STRUC	{
 	    UINT32  OfdmXifsTime:4;        //OFDM SIFS. unit 1us. Applied after OFDM RX when MAC doesn't reference BBP signal BBRXEND
 	    UINT32  EIFS:9;        //  unit 1us
 	    UINT32  BBRxendEnable:1;        //  reference RXEND signal to begin XIFS defer
-	    UINT32  rsv:2;         
+	    UINT32  rsv:2;
 	}	field;
 	UINT32			word;
 }	IFS_SLOT_CFG_STRUC, *PIFS_SLOT_CFG_STRUC;
@@ -719,8 +719,8 @@ typedef	union	_IFS_SLOT_CFG_STRUC	{
 
 #define BKOFF_SLOT_CFG             0x1104		 //  mac_csr9 last 8 bits
 #define NAV_TIME_CFG             0x1108		 // NAV  (MAC_CSR15)
-#define CH_TIME_CFG             0x110C		 	// Count as channel busy 
-#define PBF_LIFE_TIMER             0x1110		 //TX/RX MPDU timestamp timer (free run)Unit: 1us  
+#define CH_TIME_CFG             0x110C		 	// Count as channel busy
+#define PBF_LIFE_TIMER             0x1110		 //TX/RX MPDU timestamp timer (free run)Unit: 1us
 #define BCN_TIME_CFG             0x1114		 // TXRX_CSR9
 
 #define BCN_OFFSET0				0x042C
@@ -760,7 +760,7 @@ typedef	union	_BCN_TIME_CFG_STRUC	{
 #define TSF_TIMER_DW0             0x111C  		// Local TSF timer lsb 32 bits. Read-only
 #define TSF_TIMER_DW1             0x1120  		// msb 32 bits. Read-only.
 #define TBTT_TIMER             	0x1124  		// TImer remains till next TBTT. Read-only.  TXRX_CSR14
-#define INT_TIMER_CFG              	0x1128  		//  
+#define INT_TIMER_CFG              	0x1128  		//
 #define INT_TIMER_EN             	0x112c  		//  GP-timer and pre-tbtt Int enable
 #define CH_IDLE_STA              	0x1130  		//  channel idle time
 #define CH_BUSY_STA              	0x1134  		//  channle busy time
@@ -771,7 +771,7 @@ typedef	union	_BCN_TIME_CFG_STRUC	{
 #define PWR_PIN_CFG             0x1204		 // old MAC_CSR12
 #define AUTO_WAKEUP_CFG             0x1208		 // old MAC_CSR10
 //
-// AUTO_WAKEUP_CFG: Manual power control / status register 
+// AUTO_WAKEUP_CFG: Manual power control / status register
 //
 #ifdef RT_BIG_ENDIAN
 typedef	union	_AUTO_WAKEUP_STRUC	{
@@ -796,7 +796,7 @@ typedef	union	_AUTO_WAKEUP_STRUC	{
 #endif
 //
 //  4.3 MAC TX  configuration registers (offset:0x1300)
-//       
+//
 
 #define EDCA_AC0_CFG	0x1300		//AC_TXOP_CSR0 0x3474
 #define EDCA_AC1_CFG	0x1304
@@ -805,9 +805,9 @@ typedef	union	_AUTO_WAKEUP_STRUC	{
 #ifdef RT_BIG_ENDIAN
 typedef	union	_EDCA_AC_CFG_STRUC	{
 	struct	{
-	    UINT32  :12;        // 
+	    UINT32  :12;        //
 	    UINT32  Cwmax:4;        //unit power of 2
-	    UINT32  Cwmin:4;        // 
+	    UINT32  Cwmin:4;        //
 	    UINT32  Aifsn:4;        // # of slot time
 	    UINT32  AcTxop:8;        //  in unit of 32us
 	}	field;
@@ -818,9 +818,9 @@ typedef	union	_EDCA_AC_CFG_STRUC	{
 	struct	{
 	    UINT32  AcTxop:8;        //  in unit of 32us
 	    UINT32  Aifsn:4;        // # of slot time
-	    UINT32  Cwmin:4;        // 
+	    UINT32  Cwmin:4;        //
 	    UINT32  Cwmax:4;        //unit power of 2
-	    UINT32  :12;       // 
+	    UINT32  :12;       //
 	}	field;
 	UINT32			word;
 }	EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC;
@@ -832,7 +832,7 @@ typedef	union	_EDCA_AC_CFG_STRUC	{
 #define TX_PWR_CFG_2	0x131C
 #define TX_PWR_CFG_3	0x1320
 #define TX_PWR_CFG_4	0x1324
-#define TX_PIN_CFG		0x1328		 
+#define TX_PIN_CFG		0x1328
 #define TX_BAND_CFG	0x132c		// 0x1 use upper 20MHz. 0 juse lower 20MHz
 #define TX_SW_CFG0		0x1330
 #define TX_SW_CFG1		0x1334
@@ -844,7 +844,7 @@ typedef	union	_EDCA_AC_CFG_STRUC	{
 #ifdef RT_BIG_ENDIAN
 typedef	union	_TX_RTS_CFG_STRUC	{
 	struct	{
-	    UINT32       rsv:7;     
+	    UINT32       rsv:7;
 	    UINT32       RtsFbkEn:1;    // enable rts rate fallback
 	    UINT32       RtsThres:16;    // unit:byte
 	    UINT32       AutoRtsRetryLimit:8;
@@ -866,18 +866,18 @@ typedef	union	_TX_RTS_CFG_STRUC	{
 #ifdef RT_BIG_ENDIAN
 typedef	union	_TX_TIMEOUT_CFG_STRUC	{
 	struct	{
-	    UINT32       rsv2:8;     
+	    UINT32       rsv2:8;
 	    UINT32       TxopTimeout:8;	//TXOP timeout value for TXOP truncation.  It is recommended that (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
 	    UINT32       RxAckTimeout:8;	// unit:slot. Used for TX precedure
 	    UINT32       MpduLifeTime:4;    //  expiration time = 2^(9+MPDU LIFE TIME)  us
-	    UINT32       rsv:4;     
+	    UINT32       rsv:4;
 	}	field;
 	UINT32			word;
 }	TX_TIMEOUT_CFG_STRUC, *PTX_TIMEOUT_CFG_STRUC;
 #else
 typedef	union	_TX_TIMEOUT_CFG_STRUC	{
 	struct	{
-	    UINT32       rsv:4;     
+	    UINT32       rsv:4;
 	    UINT32       MpduLifeTime:4;    //  expiration time = 2^(9+MPDU LIFE TIME)  us
 	    UINT32       RxAckTimeout:8;	// unit:slot. Used for TX precedure
 	    UINT32       TxopTimeout:8;	//TXOP timeout value for TXOP truncation.  It is recommended that (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
@@ -890,14 +890,14 @@ typedef	union	_TX_TIMEOUT_CFG_STRUC	{
 #ifdef RT_BIG_ENDIAN
 typedef	union PACKED _TX_RTY_CFG_STRUC	{
 	struct	{
-	    UINT32       rsv:1;     
+	    UINT32       rsv:1;
 	    UINT32       TxautoFBEnable:1;    // Tx retry PHY rate auto fallback enable
 	    UINT32       AggRtyMode:1;	// Aggregate MPDU retry mode.  0:expired by retry limit, 1: expired by mpdu life timer
 	    UINT32       NonAggRtyMode:1;	// Non-Aggregate MPDU retry mode.  0:expired by retry limit, 1: expired by mpdu life timer
 	    UINT32       LongRtyThre:12;	// Long retry threshoold
 	    UINT32       LongRtyLimit:8;	//long retry limit
 	    UINT32       ShortRtyLimit:8;	//  short retry limit
-	    
+
 	}	field;
 	UINT32			word;
 }	TX_RTY_CFG_STRUC, *PTX_RTY_CFG_STRUC;
@@ -919,11 +919,11 @@ typedef	union PACKED _TX_RTY_CFG_STRUC	{
 #ifdef RT_BIG_ENDIAN
 typedef	union	PACKED _TX_LINK_CFG_STRUC	{
 	struct PACKED {
-	    UINT32       RemotMFS:8;	//remote MCS feedback sequence number     
+	    UINT32       RemotMFS:8;	//remote MCS feedback sequence number
 	    UINT32       RemotMFB:8;    //  remote MCS feedback
-	    UINT32       rsv:3;	//  
+	    UINT32       rsv:3;	//
 	    UINT32       TxCFAckEn:1;	//   Piggyback CF-ACK enable
-	    UINT32       TxRDGEn:1;	// RDG TX enable 
+	    UINT32       TxRDGEn:1;	// RDG TX enable
 	    UINT32       TxMRQEn:1;	//  MCS request TX enable
 	    UINT32       RemoteUMFSEnable:1;	//  remote unsolicit  MFB enable.  0: not apply remote remote unsolicit (MFS=7)
 	    UINT32       MFBEnable:1;	//  TX apply remote MFB 1:enable
@@ -938,11 +938,11 @@ typedef	union	PACKED _TX_LINK_CFG_STRUC	{
 	    UINT32       MFBEnable:1;	//  TX apply remote MFB 1:enable
 	    UINT32       RemoteUMFSEnable:1;	//  remote unsolicit  MFB enable.  0: not apply remote remote unsolicit (MFS=7)
 	    UINT32       TxMRQEn:1;	//  MCS request TX enable
-	    UINT32       TxRDGEn:1;	// RDG TX enable 
+	    UINT32       TxRDGEn:1;	// RDG TX enable
 	    UINT32       TxCFAckEn:1;	//   Piggyback CF-ACK enable
-	    UINT32       rsv:3;	//  
+	    UINT32       rsv:3;	//
 	    UINT32       RemotMFB:8;    //  remote MCS feedback
-	    UINT32       RemotMFS:8;	//remote MCS feedback sequence number     
+	    UINT32       RemotMFS:8;	//remote MCS feedback sequence number
 	}	field;
 	UINT32			word;
 }	TX_LINK_CFG_STRUC, *PTX_LINK_CFG_STRUC;
@@ -1041,7 +1041,7 @@ typedef	union	_LG_FBK_CFG0_STRUC	{
 #ifdef RT_BIG_ENDIAN
 typedef	union	_LG_FBK_CFG1_STRUC	{
 	struct	{
-	    UINT32       rsv:16;	 
+	    UINT32       rsv:16;
 	    UINT32       CCKMCS3FBK:4;	//initial value is 2
 	    UINT32       CCKMCS2FBK:4;	//initial value is 1
 	    UINT32       CCKMCS1FBK:4;	//initial value is 0
@@ -1056,7 +1056,7 @@ typedef	union	_LG_FBK_CFG1_STRUC	{
 	    UINT32       CCKMCS1FBK:4;	//initial value is 0
 	    UINT32       CCKMCS2FBK:4;	//initial value is 1
 	    UINT32       CCKMCS3FBK:4;	//initial value is 2
-	    UINT32       rsv:16;	 
+	    UINT32       rsv:16;
 	}	field;
 	UINT32			word;
 }	LG_FBK_CFG1_STRUC, *PLG_FBK_CFG1_STRUC;
@@ -1073,7 +1073,7 @@ typedef	union	_LG_FBK_CFG1_STRUC	{
 #ifdef RT_BIG_ENDIAN
 typedef	union	_PROT_CFG_STRUC	{
 	struct	{
-	    UINT32       rsv:5;	 
+	    UINT32       rsv:5;
 	    UINT32       RTSThEn:1;	//RTS threshold enable on CCK TX
 	    UINT32       TxopAllowGF40:1;	//CCK TXOP allowance.0:disallow.
 	    UINT32       TxopAllowGF20:1;	//CCK TXOP allowance.0:disallow.
@@ -1083,14 +1083,14 @@ typedef	union	_PROT_CFG_STRUC	{
 	    UINT32       TxopAllowCck:1;	//CCK TXOP allowance.0:disallow.
 	    UINT32       ProtectNav:2;	//TXOP protection type for CCK TX. 0:None, 1:ShortNAVprotect,  2:LongNAVProtect, 3:rsv
 	    UINT32       ProtectCtrl:2;	//Protection control frame type for CCK TX. 1:RTS/CTS, 2:CTS-to-self, 0:None, 3:rsv
-	    UINT32       ProtectRate:16;	//Protection control frame rate for CCK TX(RTS/CTS/CFEnd). 
+	    UINT32       ProtectRate:16;	//Protection control frame rate for CCK TX(RTS/CTS/CFEnd).
 	}	field;
 	UINT32			word;
 }	PROT_CFG_STRUC, *PPROT_CFG_STRUC;
 #else
 typedef	union	_PROT_CFG_STRUC	{
 	struct	{
-	    UINT32       ProtectRate:16;	//Protection control frame rate for CCK TX(RTS/CTS/CFEnd). 
+	    UINT32       ProtectRate:16;	//Protection control frame rate for CCK TX(RTS/CTS/CFEnd).
 	    UINT32       ProtectCtrl:2;	//Protection control frame type for CCK TX. 1:RTS/CTS, 2:CTS-to-self, 0:None, 3:rsv
 	    UINT32       ProtectNav:2;	//TXOP protection type for CCK TX. 0:None, 1:ShortNAVprotect,  2:LongNAVProtect, 3:rsv
 	    UINT32       TxopAllowCck:1;	//CCK TXOP allowance.0:disallow.
@@ -1100,7 +1100,7 @@ typedef	union	_PROT_CFG_STRUC	{
 	    UINT32       TxopAllowGF20:1;	//CCK TXOP allowance.0:disallow.
 	    UINT32       TxopAllowGF40:1;	//CCK TXOP allowance.0:disallow.
 	    UINT32       RTSThEn:1;	//RTS threshold enable on CCK TX
-	    UINT32       rsv:5;	 
+	    UINT32       rsv:5;
 	}	field;
 	UINT32			word;
 }	PROT_CFG_STRUC, *PPROT_CFG_STRUC;
@@ -1111,8 +1111,8 @@ typedef	union	_PROT_CFG_STRUC	{
 #define MM40_PROT_CFG	0x1370		//MM40 Protection
 #define GF20_PROT_CFG	0x1374		//GF20 Protection
 #define GF40_PROT_CFG	0x1378		//GR40 Protection
-#define EXP_CTS_TIME	0x137C		// 
-#define EXP_ACK_TIME	0x1380		// 
+#define EXP_CTS_TIME	0x137C		//
+#define EXP_ACK_TIME	0x1380		//
 
 //
 //  4.4 MAC RX configuration registers (offset:0x1400)
@@ -1125,7 +1125,7 @@ typedef	union	_PROT_CFG_STRUC	{
 #ifdef RT_BIG_ENDIAN
 typedef union _AUTO_RSP_CFG_STRUC {
  struct {
-     UINT32        :24;    
+     UINT32        :24;
      UINT32       AckCtsPsmBit:1;   // Power bit value in conrtrol frame
      UINT32       DualCTSEn:1;   // Power bit value in conrtrol frame
      UINT32       rsv:1;   // Power bit value in conrtrol frame
@@ -1148,7 +1148,7 @@ typedef union _AUTO_RSP_CFG_STRUC {
      UINT32       rsv:1;   // Power bit value in conrtrol frame
      UINT32       DualCTSEn:1;   // Power bit value in conrtrol frame
      UINT32       AckCtsPsmBit:1;   // Power bit value in conrtrol frame
-     UINT32        :24;    
+     UINT32        :24;
  } field;
  UINT32   word;
 } AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC;
@@ -1169,9 +1169,9 @@ typedef union _AUTO_RSP_CFG_STRUC {
 //
 //  4.6 HCCA/PSMP (offset:0x1600)
 //
-#define TXOP_HLDR_ADDR0		0x1600		 
-#define TXOP_HLDR_ADDR1		0x1604		 
-#define TXOP_HLDR_ET		0x1608		 
+#define TXOP_HLDR_ADDR0		0x1600
+#define TXOP_HLDR_ADDR1		0x1604
+#define TXOP_HLDR_ET		0x1608
 #define QOS_CFPOLL_RA_DW0		0x160c
 #define QOS_CFPOLL_A1_DW1		0x1610
 #define QOS_CFPOLL_QC		0x1614
@@ -1225,7 +1225,7 @@ typedef	union	_RX_STA_CNT1_STRUC	{
 #endif
 
 //
-// RX_STA_CNT2_STRUC: 
+// RX_STA_CNT2_STRUC:
 //
 #ifdef RT_BIG_ENDIAN
 typedef	union	_RX_STA_CNT2_STRUC	{
@@ -1316,8 +1316,8 @@ typedef	union PACKED _TX_STA_FIFO_STRUC	{
 	struct	{
 		UINT32		Reserve:2;
 		UINT32		TxBF:1; // 3*3
-		UINT32		SuccessRate:13;	//include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16. 
-//		UINT32		SuccessRate:16;	//include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16. 
+		UINT32		SuccessRate:13;	//include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
+//		UINT32		SuccessRate:16;	//include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
 		UINT32		wcid:8;		//wireless client index
 		UINT32       	TxAckRequired:1;    // ack required
 		UINT32       	TxAggre:1;    // Tx is aggregated
@@ -1336,8 +1336,8 @@ typedef	union PACKED _TX_STA_FIFO_STRUC	{
 		UINT32       	TxAggre:1;    // Tx Retry Success
 		UINT32       	TxAckRequired:1;    // Tx fail
 		UINT32		wcid:8;		//wireless client index
-//		UINT32		SuccessRate:16;	//include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16. 
-		UINT32		SuccessRate:13;	//include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16. 
+//		UINT32		SuccessRate:16;	//include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
+		UINT32		SuccessRate:13;	//include MCS, mode ,shortGI, BW settingSame format as TXWI Word 0 Bit 31-16.
 		UINT32		TxBF:1;
 		UINT32		Reserve:2;
 	}	field;
@@ -1538,7 +1538,7 @@ typedef	union	_MPDU_DEN_CNT_STRUC	{
 //
 // Security key table memory, base address = 0x1000
 //
-#define MAC_WCID_BASE		0x1800 //8-bytes(use only 6-bytes) * 256 entry = 
+#define MAC_WCID_BASE		0x1800 //8-bytes(use only 6-bytes) * 256 entry =
 #define HW_WCID_ENTRY_SIZE   8
 #define PAIRWISE_KEY_TABLE_BASE     0x4000      // 32-byte * 256-entry =  -byte
 #define HW_KEY_ENTRY_SIZE           0x20
@@ -1547,7 +1547,7 @@ typedef	union	_MPDU_DEN_CNT_STRUC	{
 #define HW_IVEIV_ENTRY_SIZE   8
 #define MAC_WCID_ATTRIBUTE_BASE     0x6800      // 4-byte * 256-entry =  -byte
 #define HW_WCID_ATTRI_SIZE   4
-#define WCID_RESERVED          		0x6bfc 
+#define WCID_RESERVED          		0x6bfc
 #define SHARED_KEY_TABLE_BASE       0x6c00      // 32-byte * 16-entry = 512-byte
 #define SHARED_KEY_MODE_BASE       0x7000      // 32-byte * 16-entry = 512-byte
 #define HW_SHARED_KEY_MODE_SIZE   4
@@ -1631,8 +1631,8 @@ typedef struct _HW_WCID_ENTRY {  // 8-byte per entry
 // 1. The original region for BCN 0~3
 // 2. Extract memory from FCE table for BCN 4~5
 // 3. Extract memory from Pair-wise key table for BCN 6~7
-//	  It occupied those memory of wcid 238~253 for BCN 6 
-//						      and wcid 222~237 for BCN 7  	
+//	  It occupied those memory of wcid 238~253 for BCN 6
+//						      and wcid 222~237 for BCN 7
 #define HW_BEACON_MAX_SIZE      0x1000 /* unit: byte */
 #define HW_BEACON_BASE0         0x7800
 #define HW_BEACON_BASE1         0x7A00
@@ -1643,8 +1643,8 @@ typedef struct _HW_WCID_ENTRY {  // 8-byte per entry
 #define HW_BEACON_BASE6         0x5DC0
 #define HW_BEACON_BASE7         0x5BC0
 
-#define HW_BEACON_MAX_COUNT     8 
-#define HW_BEACON_OFFSET		0x0200 
+#define HW_BEACON_MAX_COUNT     8
+#define HW_BEACON_OFFSET		0x0200
 #define HW_BEACON_CONTENT_LEN	(HW_BEACON_OFFSET - TXWI_SIZE)
 
 // HOST-MCU shared memory - base address = 0x2100
@@ -1839,7 +1839,7 @@ typedef struct _HW_WCID_ENTRY {  // 8-byte per entry
 #define EEPROM_A_TX2_PWR_OFFSET      0xa6
 #define EEPROM_VERSION_OFFSET       0x02
 #define	EEPROM_FREQ_OFFSET			0x3a
-#define EEPROM_TXPOWER_BYRATE 	0xde	// 20MHZ power. 
+#define EEPROM_TXPOWER_BYRATE 	0xde	// 20MHZ power.
 #define EEPROM_TXPOWER_DELTA		0x50	// 20MHZ AND 40 MHZ use different power. This is delta in 40MHZ.
 #define VALID_EEPROM_VERSION        1
 
@@ -1869,7 +1869,7 @@ typedef struct _HW_KEY_ENTRY {          // 32-byte per entry
     UCHAR   Key[16];
     UCHAR   TxMic[8];
     UCHAR   RxMic[8];
-} HW_KEY_ENTRY, *PHW_KEY_ENTRY; 
+} HW_KEY_ENTRY, *PHW_KEY_ENTRY;
 
 //8.1.2	IV/EIV  format  : 2DW
 
@@ -1920,9 +1920,9 @@ typedef	struct	PACKED _TXD_STRUC {
 	// Word 2
 	UINT32		SDPtr1;
 	// Word 3
-	UINT32		ICO:1;	
-	UINT32		UCO:1;	
-	UINT32		TCO:1;	
+	UINT32		ICO:1;
+	UINT32		UCO:1;
+	UINT32		TCO:1;
 	UINT32		rsv:2;
 	UINT32		QSEL:2;	// select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
 	UINT32		WIV:1;	// Wireless Info Valid. 1 if Driver already fill WI,  o if DMA needs to copy WI to correctposition
@@ -1946,8 +1946,8 @@ typedef	struct	PACKED _TXD_STRUC {
 	UINT32		WIV:1;	// Wireless Info Valid. 1 if Driver already fill WI,  o if DMA needs to copy WI to correctposition
 	UINT32		QSEL:2;	// select on-chip FIFO ID for 2nd-stage output scheduler.0:MGMT, 1:HCCA 2:EDCA
 	UINT32		rsv:2;
-	UINT32		TCO:1;	//  
-	UINT32		UCO:1;	//  
+	UINT32		TCO:1;	//
+	UINT32		UCO:1;	//
 	UINT32		ICO:1;	//
 }	TXD_STRUC, *PTXD_STRUC;
 #endif
@@ -1965,17 +1965,17 @@ typedef	struct	PACKED _TXWI_STRUC {
 	UINT32		PHYMODE:2;
 	UINT32		TxBF:1;	// 3*3
 	UINT32		rsv2:1;
-	UINT32		Ifs:1;	// 
+	UINT32		Ifs:1;	//
 	UINT32		STBC:2;	//channel bandwidth 20MHz or 40 MHz
 	UINT32		ShortGI:1;
 	UINT32		BW:1;	//channel bandwidth 20MHz or 40 MHz
 	UINT32		MCS:7;
-	
+
 	UINT32		rsv:6;
 	UINT32		txop:2;	//tx back off mode 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs only when previous frame exchange is successful.
 	UINT32		MpduDensity:3;
 	UINT32		AMPDU:1;
-	
+
 	UINT32		TS:1;
 	UINT32		CFACK:1;
 	UINT32		MIMOps:1;	// the remote peer is in dynamic MIMO-PS mode
@@ -1999,20 +1999,20 @@ typedef	struct	PACKED _TXWI_STRUC {
 	UINT32		MIMOps:1;	// the remote peer is in dynamic MIMO-PS mode
 	UINT32		CFACK:1;
 	UINT32		TS:1;
-		
+
 	UINT32		AMPDU:1;
 	UINT32		MpduDensity:3;
 	UINT32		txop:2;	//FOR "THIS" frame. 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs only when previous frame exchange is successful.
 	UINT32		rsv:6;
-	
+
 	UINT32		MCS:7;
 	UINT32		BW:1;	//channel bandwidth 20MHz or 40 MHz
 	UINT32		ShortGI:1;
 	UINT32		STBC:2;	// 1: STBC support MCS =0-7,   2,3 : RESERVE
-	UINT32		Ifs:1;	// 
+	UINT32		Ifs:1;	//
 	UINT32		rsv2:1;
 	UINT32		TxBF:1;	// 3*3
-	UINT32		PHYMODE:2;  
+	UINT32		PHYMODE:2;
 	// Word	1
 	UINT32		ACK:1;
 	UINT32		NSEQ:1;
@@ -2052,17 +2052,17 @@ typedef	struct	PACKED _RXD_STRUC	{
 	UINT32		RSSI:1;
 	UINT32		HTC:1;
 	UINT32		AMSDU:1;		// rx with 802.3 header, not 802.11 header. obsolete.
-	UINT32		CipherErr:2;        // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid	
+	UINT32		CipherErr:2;        // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid
 	UINT32		Crc:1;              // 1: CRC error
 	UINT32		MyBss:1;  	// 1: this frame belongs to the same BSSID
-	UINT32		Bcast:1;            // 1: this is a broadcast frame	
+	UINT32		Bcast:1;            // 1: this is a broadcast frame
 	UINT32		Mcast:1;            // 1: this is a multicast frame
 	UINT32		U2M:1;              // 1: this RX frame is unicast to me
 	UINT32		FRAG:1;
 	UINT32		NULLDATA:1;
 	UINT32		DATA:1;
 	UINT32		BA:1;
-	
+
 }	RXD_STRUC, *PRXD_STRUC, RT28XX_RXD_STRUC, *PRT28XX_RXD_STRUC;
 #else
 typedef	struct	PACKED _RXD_STRUC	{
@@ -2083,15 +2083,15 @@ typedef	struct	PACKED _RXD_STRUC	{
 	UINT32		FRAG:1;
 	UINT32		U2M:1;              // 1: this RX frame is unicast to me
 	UINT32		Mcast:1;            // 1: this is a multicast frame
-	UINT32		Bcast:1;            // 1: this is a broadcast frame	
-	UINT32		MyBss:1;  	// 1: this frame belongs to the same BSSID	
+	UINT32		Bcast:1;            // 1: this is a broadcast frame
+	UINT32		MyBss:1;  	// 1: this frame belongs to the same BSSID
 	UINT32		Crc:1;              // 1: CRC error
 	UINT32		CipherErr:2;        // 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid
 	UINT32		AMSDU:1;		// rx with 802.3 header, not 802.11 header.
 	UINT32		HTC:1;
 	UINT32		RSSI:1;
 	UINT32		L2PAD:1;
-	UINT32		AMPDU:1;	
+	UINT32		AMPDU:1;
 	UINT32		Decrypted:1;	// this frame is being decrypted.
 	UINT32		PlcpSignal:1;		// To be moved
 	UINT32		PlcpRssil:1;// To be moved
@@ -2100,7 +2100,7 @@ typedef	struct	PACKED _RXD_STRUC	{
 #endif
 #endif // RT2860 //
 //
-// RXWI wireless information format, in PBF. invisible in driver. 
+// RXWI wireless information format, in PBF. invisible in driver.
 //
 #ifdef RT_BIG_ENDIAN
 typedef	struct	PACKED _RXWI_STRUC {
@@ -2224,14 +2224,14 @@ typedef union _M2H_CMD_DONE_STRUC {
 typedef union  _MCU_LEDCS_STRUC {
 	struct	{
 		UCHAR		Polarity:1;
-		UCHAR		LedMode:7;		
+		UCHAR		LedMode:7;
 	} field;
 	UCHAR				word;
 } MCU_LEDCS_STRUC, *PMCU_LEDCS_STRUC;
 #else
 typedef union  _MCU_LEDCS_STRUC {
 	struct	{
-		UCHAR		LedMode:7;		
+		UCHAR		LedMode:7;
 		UCHAR		Polarity:1;
 	} field;
 	UCHAR			word;
@@ -2247,7 +2247,7 @@ typedef union  _MCU_LEDCS_STRUC {
 #ifdef RT_BIG_ENDIAN
 typedef	union	_NAV_TIME_CFG_STRUC	{
 	struct	{
-		USHORT		rsv:6;   
+		USHORT		rsv:6;
 		USHORT		ZeroSifs:1;               // Applied zero SIFS timer after OFDM RX 0: disable
 		USHORT		Eifs:9;               // in unit of 1-us
 		UCHAR       SlotTime;    // in unit of 1-us
@@ -2262,7 +2262,7 @@ typedef	union	_NAV_TIME_CFG_STRUC	{
 		UCHAR       SlotTime;    // in unit of 1-us
 		USHORT		Eifs:9;               // in unit of 1-us
 		USHORT		ZeroSifs:1;               // Applied zero SIFS timer after OFDM RX 0: disable
-		USHORT		rsv:6;             
+		USHORT		rsv:6;
 	}	field;
 	UINT32			word;
 }	NAV_TIME_CFG_STRUC, *PNAV_TIME_CFG_STRUC;
@@ -2278,11 +2278,11 @@ typedef	union	_NAV_TIME_CFG_STRUC	{
 #ifdef RT_BIG_ENDIAN
 typedef	union	RX_FILTR_CFG_STRUC	{
 	struct	{
-		UINT32		:15;		
+		UINT32		:15;
 		UINT32       DropRsvCntlType:1;
 
-        	UINT32       	DropBAR:1;       //  
-		UINT32		DropBA:1;		//  
+        	UINT32       	DropBAR:1;       //
+		UINT32		DropBA:1;		//
 		UINT32		DropPsPoll:1;		// Drop Ps-Poll
 		UINT32		DropRts:1;		// Drop Ps-Poll
 
@@ -2323,8 +2323,8 @@ typedef	union	_RX_FILTR_CFG_STRUC	{
 
 		UINT32		DropRts:1;		// Drop Ps-Poll
 		UINT32		DropPsPoll:1;		// Drop Ps-Poll
-		UINT32		DropBA:1;		//  
-        	UINT32       	DropBAR:1;       //  
+		UINT32		DropBA:1;		//
+        	UINT32       	DropBAR:1;       //
 
 		UINT32       	DropRsvCntlType:1;
 		UINT32		:15;
@@ -2342,7 +2342,7 @@ typedef	union	_RX_FILTR_CFG_STRUC	{
 #ifdef RT_BIG_ENDIAN
 typedef	union	_PHY_CSR4_STRUC	{
 	struct	{
-		UINT32		Busy:1;				// 1: ASIC is busy execute RF programming.		
+		UINT32		Busy:1;				// 1: ASIC is busy execute RF programming.
 		UINT32		PLL_LD:1;			// RF PLL_LD status
 		UINT32		IFSelect:1;			// 1: select IF	to program,	0: select RF to	program
 		UINT32		NumberOfBits:5;		// Number of bits used in RFRegValue (I:20,	RFMD:22)
@@ -2486,8 +2486,8 @@ typedef	union	_E2PROM_CSR_STRUC	{
 #ifdef RT_BIG_ENDIAN
 typedef	union	_EEPROM_ANTENNA_STRUC	{
 	struct	{
-		USHORT      Rsv:4;              
-		USHORT      RfIcType:4;             // see E2PROM document		
+		USHORT      Rsv:4;
+		USHORT      RfIcType:4;             // see E2PROM document
 		USHORT		TxPath:4;	// 1: 1T, 2: 2T
 		USHORT		RxPath:4;	// 1: 1R, 2: 2R, 3: 3R
 	}	field;
@@ -2498,8 +2498,8 @@ typedef	union	_EEPROM_ANTENNA_STRUC	{
 	struct	{
 		USHORT		RxPath:4;	// 1: 1R, 2: 2R, 3: 3R
 		USHORT		TxPath:4;	// 1: 1T, 2: 2T
-		USHORT      RfIcType:4;             // see E2PROM document		
-		USHORT      Rsv:4;              
+		USHORT      RfIcType:4;             // see E2PROM document
+		USHORT      Rsv:4;
 	}	field;
 	USHORT			word;
 }	EEPROM_ANTENNA_STRUC, *PEEPROM_ANTENNA_STRUC;
@@ -2514,8 +2514,8 @@ typedef	union _EEPROM_NIC_CINFIG2_STRUC	{
 		USHORT		EnableWPSPBC:1;                 // WPS PBC Control bit
 		USHORT		BW40MSidebandForA:1;
 		USHORT		BW40MSidebandForG:1;
-		USHORT		CardbusAcceleration:1;	// !!! NOTE: 0 - enable, 1 - disable		
-		USHORT		ExternalLNAForA:1;			// external LNA enable for 5G		
+		USHORT		CardbusAcceleration:1;	// !!! NOTE: 0 - enable, 1 - disable
+		USHORT		ExternalLNAForA:1;			// external LNA enable for 5G
 		USHORT		ExternalLNAForG:1;			// external LNA enable for 2.4G
 		USHORT		DynamicTxAgcControl:1;			//
 		USHORT		HardwareRadioControl:1;	// Whether RF is controlled by driver or HW. 1:enable hw control, 0:disable
@@ -2529,7 +2529,7 @@ typedef	union _EEPROM_NIC_CINFIG2_STRUC	{
 		USHORT		DynamicTxAgcControl:1;			//
 		USHORT		ExternalLNAForG:1;				//
 		USHORT		ExternalLNAForA:1;			// external LNA enable for 2.4G
-		USHORT		CardbusAcceleration:1;	// !!! NOTE: 0 - enable, 1 - disable		
+		USHORT		CardbusAcceleration:1;	// !!! NOTE: 0 - enable, 1 - disable
 		USHORT		BW40MSidebandForG:1;
 		USHORT		BW40MSidebandForA:1;
 		USHORT		EnableWPSPBC:1;                 // WPS PBC Control bit
@@ -2608,7 +2608,7 @@ typedef	union	_EEPROM_LED_STRUC	{
 		USHORT	PolarityGPIO_3:1;	// Polarity GPIO#3 setting.
 		USHORT	PolarityGPIO_4:1;	// Polarity GPIO#4 setting.
 		USHORT	LedMode:5;			// Led mode.
-		USHORT	Rsvd:3;				// Reserved		
+		USHORT	Rsvd:3;				// Reserved
 	}	field;
 	USHORT	word;
 }	EEPROM_LED_STRUC, *PEEPROM_LED_STRUC;
@@ -2700,7 +2700,7 @@ typedef	union	_RF_CSR_CFG_STRUC	{
 #else
 typedef	union	_RF_CSR_CFG_STRUC	{
 	struct	{
-		UINT	RF_CSR_DATA:8;			// DATA 
+		UINT	RF_CSR_DATA:8;			// DATA
 		UINT	TESTCSR_RFACC_REGNUM:5;	// RF register ID
 		UINT	Rsvd2:3;				// Reserved
 		UINT	RF_CSR_WR:1;			// 0: read  1: write
diff --git a/os/linux/rt_ate.c b/rt_ate.c
similarity index 94%
rename from os/linux/rt_ate.c
rename to rt_ate.c
index 5255815..2f07db5 100644
--- a/os/linux/rt_ate.c
+++ b/rt_ate.c
@@ -7,28 +7,28 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
  */
 
 #include "rt_config.h"
 
 #ifdef RALINK_ATE
-UCHAR TemplateFrame[24] = {0x08/* Data type */,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xAA,0xBB,0x12,0x34,0x56,0x00,0x11,0x22,0xAA,0xBB,0xCC,0x00,0x00};	// 802.11 MAC Header, Type:Data, Length:24bytes 
+UCHAR TemplateFrame[24] = {0x08/* Data type */,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0xAA,0xBB,0x12,0x34,0x56,0x00,0x11,0x22,0xAA,0xBB,0xCC,0x00,0x00};	// 802.11 MAC Header, Type:Data, Length:24bytes
 extern RTMP_RF_REGS RF2850RegTable[];
 extern UCHAR NUM_OF_2850_CHNL;
 
@@ -61,7 +61,7 @@ static INT ATETxPwrHandler(
 	IN char index);
 
 static INT ATECmdHandler(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 static int CheckMCSValid(
@@ -71,8 +71,8 @@ static int CheckMCSValid(
 #ifdef RT2860
 static VOID ATEWriteTxWI(
 	IN	PRTMP_ADAPTER	pAd,
-	IN	PTXWI_STRUC 	pOutTxWI,	
-	IN	BOOLEAN			FRAG,	
+	IN	PTXWI_STRUC 	pOutTxWI,
+	IN	BOOLEAN			FRAG,
 	IN	BOOLEAN			CFACK,
 	IN	BOOLEAN			InsTimestamp,
 	IN	BOOLEAN 		AMPDU,
@@ -84,8 +84,8 @@ static VOID ATEWriteTxWI(
 	IN	UCHAR 			PID,
 	IN	UCHAR			TID,
 	IN	UCHAR			TxRate,
-	IN	UCHAR			Txopmode,	
-	IN	BOOLEAN			CfAck,	
+	IN	UCHAR			Txopmode,
+	IN	BOOLEAN			CfAck,
 	IN	HTTRANSMIT_SETTING	*pTransmit);
 #endif // RT2860 //
 
@@ -133,7 +133,7 @@ static VOID RtmpDmaEnable(
 	BOOLEAN value;
 	ULONG WaitCnt;
 	WPDMA_GLO_CFG_STRUC GloCfg;
-	
+
 	value = Enable > 0 ? 1 : 0;
 
 	// check DMA is in busy mode.
@@ -144,7 +144,7 @@ static VOID RtmpDmaEnable(
 		if (WaitCnt++ > 100)
 			break;
 	}
-	
+
 	RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word);	// disable DMA
 	GloCfg.field.EnableTxDMA = value;
 	GloCfg.field.EnableRxDMA = value;
@@ -220,7 +220,7 @@ static int CheckMCSValid(
 		case 3:
 			pRateTab = HTMIXRateTable;
 			break;
-		default: 
+		default:
 			ATEDBGPRINT(RT_DEBUG_ERROR, ("unrecognizable Tx Mode %d\n", Mode));
 			return -1;
 			break;
@@ -246,7 +246,7 @@ static INT ATETxPwrHandler(
 	CHAR TxPower;
 	UCHAR Bbp94 = 0;
 	BOOLEAN bPowerReduce = FALSE;
-	
+
 #ifdef RALINK_28xx_QA
 	if ((pAd->ate.bQATxStart == TRUE) || (pAd->ate.bQARxStart == TRUE))
 	{
@@ -273,19 +273,19 @@ static INT ATETxPwrHandler(
 				//
 				R = 31;
 				if (TxPower <= 36)
-					Bbp94 = BBPR94_DEFAULT + (UCHAR)(TxPower - 31);		
+					Bbp94 = BBPR94_DEFAULT + (UCHAR)(TxPower - 31);
 			}
 			else if (TxPower < 0)
 			{
 				//
 				// R3, R4 can't less than 0, -1 ~ -6 used by BBP 94
-				//	
+				//
 				R = 0;
 				if (TxPower >= -6)
 					Bbp94 = BBPR94_DEFAULT + TxPower;
 			}
 			else
-			{  
+			{
 				// 0 ~ 31
 				R = (ULONG) TxPower;
 				Bbp94 = BBPR94_DEFAULT;
@@ -306,14 +306,14 @@ static INT ATETxPwrHandler(
 			{
 				//
 				// R3, R4 can't less than 0
-				//	
+				//
 				// -1 ~ -7
 				ASSERT((TxPower >= -7));
 				R = (ULONG)(TxPower + 7);
 				bPowerReduce = TRUE;
 			}
 			else
-			{  
+			{
 				// 0 ~ 15
 				R = (ULONG) TxPower;
 			}
@@ -360,7 +360,7 @@ static INT ATETxPwrHandler(
 					R = (R << 10);		// shift TX power control to correct RF(R3) register bit position
 					R |= (pAd->LatchRfRegs.R3 & 0xffffc1ff);
 
-					/* Clear bit 9 of R3 to reduce 7dB. */ 
+					/* Clear bit 9 of R3 to reduce 7dB. */
 					pAd->LatchRfRegs.R3 = (R & (~(1 << 9)));
 				}
 				else
@@ -368,7 +368,7 @@ static INT ATETxPwrHandler(
 					R = (R << 7);		// shift TX power control to correct RF(R4) register bit position
 					R |= (pAd->LatchRfRegs.R4 & 0xfffff83f);
 
-					/* Clear bit 6 of R4 to reduce 7dB. */ 
+					/* Clear bit 6 of R4 to reduce 7dB. */
 					pAd->LatchRfRegs.R4 = (R & (~(1 << 6)));
 				}
 			}
@@ -387,7 +387,7 @@ static INT ATETxPwrHandler(
 	ULONG R;
 	CHAR TxPower;
 	UCHAR Bbp94 = 0;
-	
+
 #ifdef RALINK_28xx_QA
 	if ((pAd->ate.bQATxStart == TRUE) || (pAd->ate.bQARxStart == TRUE))
 	{
@@ -413,19 +413,19 @@ static INT ATETxPwrHandler(
 		//
 		R = 31;
 		if (TxPower <= 36)
-			Bbp94 = BBPR94_DEFAULT + (UCHAR)(TxPower - 31);		
+			Bbp94 = BBPR94_DEFAULT + (UCHAR)(TxPower - 31);
 	}
 	else if (TxPower < 0)
 	{
 		//
 		// R3, R4 can't less than 0, -1 ~ -6 used by BBP 94
-		//	
+		//
 		R = 0;
 		if (TxPower >= -6)
 			Bbp94 = BBPR94_DEFAULT + TxPower;
 	}
 	else
-	{  
+	{
 		// 0 ~ 31
 		R = (ULONG) TxPower;
 		Bbp94 = BBPR94_DEFAULT;
@@ -482,7 +482,7 @@ static INT ATETxPwrHandler(
         5. RXFRAME   = Receive Frames
 #ifdef RALINK_28xx_QA
         6. TXSTOP    = Stop Any Type of Transmition
-        7. RXSTOP    = Stop Receiving Frames        
+        7. RXSTOP    = Stop Receiving Frames
 #endif // RALINK_28xx_QA //
     Return:
         TRUE if all parameters are OK, FALSE otherwise
@@ -490,7 +490,7 @@ static INT ATETxPwrHandler(
 */
 #ifdef RT2860
 static INT	ATECmdHandler(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UINT32			Value = 0;
@@ -522,7 +522,7 @@ static INT	ATECmdHandler(
 	BbpData = 0;
 
 	// clean bit4 to stop continuous Tx production test.
-	MacData &= 0xFFFFFFEF; 
+	MacData &= 0xFFFFFFEF;
 
 	if (!strcmp(arg, "ATESTART")) 		//Enter ATE mode and set Tx/Rx Idle
 	{
@@ -544,7 +544,7 @@ static INT	ATECmdHandler(
 		{
 			// No Carrier Test set BBP R22 bit7=0, bit6=0, bit[5~0]=0x0
 			ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
-			BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]	
+			BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
 		    ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
 		}
 		else if (atemode & ATE_TXCARRSUPP)
@@ -556,9 +556,9 @@ static INT	ATECmdHandler(
 
 			// No Carrier Suppression set BBP R24 bit0=0
 			ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R24, &BbpData);
-			BbpData &= 0xFFFFFFFE; //clear bit0	
+			BbpData &= 0xFFFFFFFE; //clear bit0
 		    ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, BbpData);
-		}		
+		}
 		// We should free some resource which was allocated when ATE_TXFRAME , ATE_STOP, and ATE_TXCONT.
 		else if ((atemode & ATE_TXFRAME) || (atemode == ATE_STOP))
 		{
@@ -629,7 +629,7 @@ static INT	ATECmdHandler(
 		// Tx frame
 		pAd->ate.bQATxStart = FALSE;
 		pAd->ate.bQARxStart = FALSE;
-		pAd->ate.seq = 0; 
+		pAd->ate.seq = 0;
 
 		// counters
 		pAd->ate.U2M = 0;
@@ -657,7 +657,7 @@ static INT	ATECmdHandler(
 		BbpSoftReset(pAd);
 
 
-#ifdef CONFIG_STA_SUPPORT 
+#ifdef CONFIG_STA_SUPPORT
 		//
 		// LinkDown() has "AsicDisableSync();" and "RTMP_BBP_IO_R/W8_BY_REG_ID();" inside.
 		//
@@ -684,18 +684,18 @@ static INT	ATECmdHandler(
 		Value &= ~(1 << 3);
 		RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
 	}
-	else if (!strcmp(arg, "ATESTOP")) 
-	{						
+	else if (!strcmp(arg, "ATESTOP"))
+	{
 		ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: ATESTOP\n"));
-		
+
 		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
 		RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData); // recover the MAC_SYS_CTRL register back.
-		
+
 		// Disable Tx, Rx
 		RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
 		Value &= (0xfffffff3);
 		RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
-		
+
 		// Abort Tx, RX DMA.
 		RtmpDmaEnable(pAd, 0);
 
@@ -711,20 +711,20 @@ static INT	ATECmdHandler(
 		pAd->ate.Mode = ATE_STOP;
 
 
-#ifdef CONFIG_STA_SUPPORT 
+#ifdef CONFIG_STA_SUPPORT
 		//
-		// Even the firmware has been loaded, 
-		// we still could use ATE_BBP_IO_READ8_BY_REG_ID(). 
+		// Even the firmware has been loaded,
+		// we still could use ATE_BBP_IO_READ8_BY_REG_ID().
 		// But this is not suggested.
 		//
 		BbpSoftReset(pAd);
 #endif // CONFIG_STA_SUPPORT //
 
 		NICDisableInterrupt(pAd);
-		
+
 		NICInitializeAdapter(pAd, TRUE);
 
-		
+
 		// Reinitialize Rx Ring before Rx DMA is enabled.
 		// The nightmare of >>>RxCoherent<<< was gone !
 		for (index = 0; index < RX_RING_SIZE; index++)
@@ -733,12 +733,12 @@ static INT	ATECmdHandler(
 			pRxD->DDONE = 0;
 		}
 
-		// We should read EEPROM for all cases.  
+		// We should read EEPROM for all cases.
 		NICReadEEPROMParameters(pAd, NULL);
-		NICInitAsicFromEEPROM(pAd); 
+		NICInitAsicFromEEPROM(pAd);
 
 		AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
-		AsicLockChannel(pAd, pAd->CommonCfg.Channel);		
+		AsicLockChannel(pAd, pAd->CommonCfg.Channel);
 
 		//
 		// Enable Interrupt
@@ -752,14 +752,14 @@ static INT	ATECmdHandler(
 		pAd->int_enable_reg = ((DELAYINTMASK)  | (RxINT|TxDataInt|TxMgmtInt)) & ~(0x03);
 		pAd->int_disable_mask = 0;
 		pAd->int_pending = 0;
-#endif			
+#endif
 		RTMP_IO_WRITE32(pAd, INT_SOURCE_CSR, 0xffffffff);  // clear garbage interrupts
 		NICEnableInterrupt(pAd);
 
 
 /*=========================================================================*/
 		/* restore RX_FILTR_CFG */
-#ifdef CONFIG_STA_SUPPORT 
+#ifdef CONFIG_STA_SUPPORT
 		/* restore RX_FILTR_CFG due to that QA maybe set it to 0x3 */
 		RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL);
 #endif // CONFIG_STA_SUPPORT //
@@ -779,7 +779,7 @@ static INT	ATECmdHandler(
 		RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
 
 
-#ifdef CONFIG_STA_SUPPORT 
+#ifdef CONFIG_STA_SUPPORT
 		RTMPStationStart(pAd);
 #endif // CONFIG_STA_SUPPORT //
 #ifndef UCOS
@@ -792,7 +792,7 @@ static INT	ATECmdHandler(
 		pAd->ate.Mode |= ATE_TXCARR;
 
 		// QA has done the following steps if it is used.
-		if (pAd->ate.bQATxStart == FALSE) 
+		if (pAd->ate.bQATxStart == FALSE)
 		{
 			// Soft reset BBP.
 			BbpSoftReset(pAd);
@@ -814,7 +814,7 @@ static INT	ATECmdHandler(
 		if (pAd->ate.bQATxStart == TRUE)
 		{
 			/* set MAC_SYS_CTRL(0x1004) bit4(Continuous Tx Production Test)
-			   and bit2(MAC TX enable) back to zero. */ 
+			   and bit2(MAC TX enable) back to zero. */
 			RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
 			MacData &= 0xFFFFFFEB;
 			RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
@@ -851,10 +851,10 @@ static INT	ATECmdHandler(
 		}
 
 		pAd->ate.TxDoneCount = 0;
-		
+
 		/* Only needed if we have to send some normal frames. */
 		SetJapanFilter(pAd);
-		
+
 		for (i = 0; (i < TX_RING_SIZE-1) && (i < pAd->ate.TxCount); i++)
 		{
 			PNDIS_PACKET pPacket;
@@ -944,7 +944,7 @@ static INT	ATECmdHandler(
 			RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QID_AC_BE * 0x10,  &pTxRing->TxDmaIdx);
 			pTxRing->TxSwFreeIdx = pTxRing->TxDmaIdx;
 			pTxRing->TxCpuIdx = pTxRing->TxDmaIdx;
-			RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QID_AC_BE * 0x10, pTxRing->TxCpuIdx);					
+			RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QID_AC_BE * 0x10, pTxRing->TxCpuIdx);
 		}
 
 		pAd->ate.TxDoneCount = 0;
@@ -1024,7 +1024,7 @@ static INT	ATECmdHandler(
 
 		RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &MacData);
 		MacData |= 0x00000010;
-		RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);							
+		RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, MacData);
 	}
 	else if (!strcmp(arg, "TXFRAME")) // Tx Frames
 	{
@@ -1044,13 +1044,13 @@ static INT	ATECmdHandler(
 			RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QID_AC_BE * 0x10,  &pTxRing->TxDmaIdx);
 			pTxRing->TxSwFreeIdx = pTxRing->TxDmaIdx;
 			pTxRing->TxCpuIdx = pTxRing->TxDmaIdx;
-			RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QID_AC_BE * 0x10, pTxRing->TxCpuIdx);					
+			RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QID_AC_BE * 0x10, pTxRing->TxCpuIdx);
 		}
 
 		pAd->ate.TxDoneCount = 0;
 
 		SetJapanFilter(pAd);
-		
+
 		for (i = 0; (i < TX_RING_SIZE-1) && (i < pAd->ate.TxCount); i++)
 		{
 			PNDIS_PACKET pPacket;
@@ -1106,7 +1106,7 @@ static INT	ATECmdHandler(
 		RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
 #ifdef RALINK_28xx_QA
 		// add this for LoopBack mode
-		if (pAd->ate.bQARxStart == FALSE)  
+		if (pAd->ate.bQARxStart == FALSE)
 		{
 			// Disable Rx
 			RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &Value);
@@ -1114,7 +1114,7 @@ static INT	ATECmdHandler(
 			RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
 		}
 
-		if (pAd->ate.bQATxStart == TRUE)  
+		if (pAd->ate.bQATxStart == TRUE)
 		{
 			pAd->ate.TxStatus = 1;
 			//pAd->ate.Repeat = 0;
@@ -1145,7 +1145,7 @@ static INT	ATECmdHandler(
 		{
 			// No Carrier Test set BBP R22 bit7=0, bit6=0, bit[5~0]=0x0
 			ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R22, &BbpData);
-			BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]	
+			BbpData &= 0xFFFFFF00; //clear bit7, bit6, bit[5~0]
 		    ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R22, BbpData);
 		}
 		else if (atemode & ATE_TXCARRSUPP)
@@ -1157,9 +1157,9 @@ static INT	ATECmdHandler(
 
 			// No Carrier Suppression set BBP R24 bit0=0
 			ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R24, &BbpData);
-			BbpData &= 0xFFFFFFFE; //clear bit0	
+			BbpData &= 0xFFFFFFFE; //clear bit0
 		    ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R24, BbpData);
-		}		
+		}
 		// We should free some resource which allocate when ATE_TXFRAME , ATE_STOP, and ATE_TXCONT.
 		else if ((atemode & ATE_TXFRAME) || (atemode == ATE_STOP))
 		{
@@ -1243,7 +1243,7 @@ static INT	ATECmdHandler(
 		else if (atemode & ATE_TXCARRSUPP)
 		{
 			;
-		}		
+		}
 
 		// We should free some resource which was allocated when ATE_TXFRAME , ATE_STOP, and ATE_TXCONT.
 		else if ((atemode & ATE_TXFRAME) || (atemode == ATE_STOP))
@@ -1287,7 +1287,7 @@ static INT	ATECmdHandler(
 		RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, Value);
 	}
 	else
-	{	
+	{
 		ATEDBGPRINT(RT_DEBUG_TRACE, ("ATE: Invalid arg!\n"));
 		return FALSE;
 	}
@@ -1309,7 +1309,7 @@ static INT	ATECmdHandler(
 
 
 INT	Set_ATE_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	if (ATECmdHandler(pAd, arg))
@@ -1326,30 +1326,30 @@ INT	Set_ATE_Proc(
 	}
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE ADDR1=DA for TxFrame(AP  : To DS = 0 ; From DS = 1)
         or
-        Set ATE ADDR3=DA for TxFrame(STA : To DS = 1 ; From DS = 0)        
-        
+        Set ATE ADDR3=DA for TxFrame(STA : To DS = 1 ; From DS = 0)
+
     Return:
         TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
 */
 INT	Set_ATE_DA_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	CHAR				*value;
 	INT					i;
-	
+
 	if(strlen(arg) != 17)  //Mac address acceptable format 01:02:03:04:05:06 length 17
 		return FALSE;
 
-    for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":")) 
+    for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
 	{
-		if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) ) 
+		if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
 			return FALSE;  //Invalid
 
 
@@ -1368,34 +1368,34 @@ INT	Set_ATE_DA_Proc(
 #endif // CONFIG_STA_SUPPORT //
 
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_DA_Proc Success\n"));
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE ADDR3=SA for TxFrame(AP  : To DS = 0 ; From DS = 1)
         or
         Set ATE ADDR2=SA for TxFrame(STA : To DS = 1 ; From DS = 0)
-        
+
     Return:
         TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
 */
 INT	Set_ATE_SA_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	CHAR				*value;
 	INT					i;
-	
+
 	if(strlen(arg) != 17)  //Mac address acceptable format 01:02:03:04:05:06 length 17
 		return FALSE;
 
-    for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":")) 
+    for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
 	{
-		if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) ) 
+		if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
 			return FALSE;  //Invalid
 
 
@@ -1418,7 +1418,7 @@ INT	Set_ATE_SA_Proc(
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE ADDR2=BSSID for TxFrame(AP  : To DS = 0 ; From DS = 1)
@@ -1430,18 +1430,18 @@ INT	Set_ATE_SA_Proc(
     ==========================================================================
 */
 INT	Set_ATE_BSSID_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	CHAR				*value;
 	INT					i;
-	
+
 	if(strlen(arg) != 17)  //Mac address acceptable format 01:02:03:04:05:06 length 17
 		return FALSE;
 
-    for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":")) 
+    for (i=0, value = rstrtok(arg, ":"); value; value = rstrtok(NULL, ":"))
 	{
-		if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) ) 
+		if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
 			return FALSE;  //Invalid
 
 
@@ -1464,7 +1464,7 @@ INT	Set_ATE_BSSID_Proc(
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE Tx Channel
@@ -1474,7 +1474,7 @@ INT	Set_ATE_BSSID_Proc(
     ==========================================================================
 */
 INT	Set_ATE_CHANNEL_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UCHAR channel;
@@ -1491,15 +1491,15 @@ INT	Set_ATE_CHANNEL_Proc(
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_CHANNEL_Proc (ATE Channel = %d)\n", pAd->ate.Channel));
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_CHANNEL_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE Tx Power0
-        
+
     Return:
         TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
@@ -1509,7 +1509,7 @@ INT	Set_ATE_TX_POWER0_Proc(
 	IN	PUCHAR			arg)
 {
 	CHAR TxPower;
-	
+
 	TxPower = simple_strtol(arg, 0, 10);
 
 	if (pAd->ate.Channel <= 14)
@@ -1533,15 +1533,15 @@ INT	Set_ATE_TX_POWER0_Proc(
 	ATETxPwrHandler(pAd, 0);
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_POWER0_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE Tx Power1
-        
+
     Return:
         TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
@@ -1551,7 +1551,7 @@ INT	Set_ATE_TX_POWER1_Proc(
 	IN	PUCHAR			arg)
 {
 	CHAR TxPower;
-	
+
 	TxPower = simple_strtol(arg, 0, 10);
 
 	if (pAd->ate.Channel <= 14)
@@ -1575,15 +1575,15 @@ INT	Set_ATE_TX_POWER1_Proc(
 	ATETxPwrHandler(pAd, 1);
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_POWER1_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE Tx Antenna
-        
+
     Return:
         TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
@@ -1593,7 +1593,7 @@ INT	Set_ATE_TX_Antenna_Proc(
 	IN	PUCHAR			arg)
 {
 	CHAR value;
-	
+
 	value = simple_strtol(arg, 0, 10);
 
 	if ((value > 2) || (value < 0))
@@ -1607,15 +1607,15 @@ INT	Set_ATE_TX_Antenna_Proc(
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_Antenna_Proc (Antenna = %d)\n", pAd->ate.TxAntennaSel));
 	ATEDBGPRINT(RT_DEBUG_TRACE,("Ralink: Set_ATE_TX_Antenna_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE Rx Antenna
-        
+
     Return:
         TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
@@ -1625,7 +1625,7 @@ INT	Set_ATE_RX_Antenna_Proc(
 	IN	PUCHAR			arg)
 {
 	CHAR value;
-	
+
 	value = simple_strtol(arg, 0, 10);
 
 	if ((value > 3) || (value < 0))
@@ -1639,26 +1639,26 @@ INT	Set_ATE_RX_Antenna_Proc(
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_RX_Antenna_Proc (Antenna = %d)\n", pAd->ate.RxAntennaSel));
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_RX_Antenna_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE RF frequence offset
-        
+
     Return:
         TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
 */
 INT	Set_ATE_TX_FREQOFFSET_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UCHAR RFFreqOffset;
 	ULONG R4;
-	
+
 	RFFreqOffset = simple_strtol(arg, 0, 10);
 
 	if(RFFreqOffset >= 64)
@@ -1671,40 +1671,40 @@ INT	Set_ATE_TX_FREQOFFSET_Proc(
 	R4 = pAd->ate.RFFreqOffset << 15;		// shift TX power control to correct RF register bit position
 	R4 |= (pAd->LatchRfRegs.R4 & ((~0x001f8000)));
 	pAd->LatchRfRegs.R4 = R4;
-	
+
 	RtmpRfIoWrite(pAd);
 
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_FREQOFFSET_Proc (RFFreqOffset = %d)\n", pAd->ate.RFFreqOffset));
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_FREQOFFSET_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE RF BW
-        
+
     Return:
         TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
 */
 INT	Set_ATE_TX_BW_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	int i;
 	UCHAR value = 0;
 	UCHAR BBPCurrentBW;
-	
+
 	BBPCurrentBW = simple_strtol(arg, 0, 10);
 
 	if(BBPCurrentBW == 0)
 		pAd->ate.TxWI.BW = BW_20;
 	else
 		pAd->ate.TxWI.BW = BW_40;
- 
+
 	if(pAd->ate.TxWI.BW == BW_20)
 	{
 		if(pAd->ate.Channel <= 14)
@@ -1713,8 +1713,8 @@ INT	Set_ATE_TX_BW_Proc(
  		{
 				if (pAd->Tx20MPwrCfgGBand[i] != 0xffffffff)
 				{
-					RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx20MPwrCfgGBand[i]);	
-					RTMPusecDelay(5000);				
+					RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx20MPwrCfgGBand[i]);
+					RTMPusecDelay(5000);
 				}
 			}
 		}
@@ -1724,17 +1724,17 @@ INT	Set_ATE_TX_BW_Proc(
 			{
 				if (pAd->Tx20MPwrCfgABand[i] != 0xffffffff)
  			{
-					RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx20MPwrCfgABand[i]);	
- 				RTMPusecDelay(5000);				
+					RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx20MPwrCfgABand[i]);
+ 				RTMPusecDelay(5000);
  			}
  		}
 		}
- 
+
 		//Set BBP R4 bit[4:3]=0:0
  		ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &value);
  		value &= (~0x18);
  		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, value);
- 
+
   		//Set BBP R66=0x3C
  		value = 0x3C;
  		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, value);
@@ -1765,7 +1765,7 @@ INT	Set_ATE_TX_BW_Proc(
 				// when Channel==14 && Mode==CCK && BandWidth==20M, BBP R4 bit5=1
  				ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &value);
 				value |= 0x20; //set bit5=1
- 				ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, value);				
+ 				ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, value);
 			}
 		}
 
@@ -1782,8 +1782,8 @@ INT	Set_ATE_TX_BW_Proc(
 			{
 				if (pAd->Tx40MPwrCfgGBand[i] != 0xffffffff)
 				{
-					RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx40MPwrCfgGBand[i]);	
-					RTMPusecDelay(5000);				
+					RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx40MPwrCfgGBand[i]);
+					RTMPusecDelay(5000);
 				}
 			}
 		}
@@ -1793,10 +1793,10 @@ INT	Set_ATE_TX_BW_Proc(
 			{
 				if (pAd->Tx40MPwrCfgABand[i] != 0xffffffff)
 				{
-					RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx40MPwrCfgABand[i]);	
-					RTMPusecDelay(5000);				
+					RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, pAd->Tx40MPwrCfgABand[i]);
+					RTMPusecDelay(5000);
 				}
-			}		
+			}
 #ifdef DOT11_N_SUPPORT
 			if ((pAd->ate.TxWI.PHYMODE >= MODE_HTMIX) && (pAd->ate.TxWI.MCS == 7))
 			{
@@ -1837,21 +1837,21 @@ INT	Set_ATE_TX_BW_Proc(
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_BW_Proc (BBPCurrentBW = %d)\n", pAd->ate.TxWI.BW));
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_BW_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE Tx frame length
-        
+
     Return:
         TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
 */
 INT	Set_ATE_TX_LENGTH_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	pAd->ate.TxLength = simple_strtol(arg, 0, 10);
@@ -1866,21 +1866,21 @@ INT	Set_ATE_TX_LENGTH_Proc(
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_LENGTH_Proc (TxLength = %d)\n", pAd->ate.TxLength));
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_LENGTH_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE Tx frame count
-        
+
     Return:
         TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
 */
 INT	Set_ATE_TX_COUNT_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	pAd->ate.TxCount = simple_strtol(arg, 0, 10);
@@ -1888,15 +1888,15 @@ INT	Set_ATE_TX_COUNT_Proc(
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_COUNT_Proc (TxCount = %d)\n", pAd->ate.TxCount));
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_COUNT_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE Tx frame MCS
-        
+
         Return:
         	TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
@@ -1924,11 +1924,11 @@ INT	Set_ATE_TX_MCS_Proc(
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_MCS_Proc (MCS = %d)\n", pAd->ate.TxWI.MCS));
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_MCS_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE Tx frame Mode
@@ -1936,7 +1936,7 @@ INT	Set_ATE_TX_MCS_Proc(
         1: MODE_OFDM
         2: MODE_HTMIX
         3: MODE_HTGREENFIELD
-        
+
         Return:
         	TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
@@ -1958,15 +1958,15 @@ INT	Set_ATE_TX_MODE_Proc(
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_MODE_Proc (TxMode = %d)\n", pAd->ate.TxWI.PHYMODE));
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_MODE_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set ATE Tx frame GI
-        
+
         Return:
         	TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
@@ -1987,7 +1987,7 @@ INT	Set_ATE_TX_GI_Proc(
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_TX_GI_Proc (GI = %d)\n", pAd->ate.TxWI.ShortGI));
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_TX_GI_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
@@ -1997,7 +1997,7 @@ INT	Set_ATE_TX_GI_Proc(
     ==========================================================================
  */
 INT	Set_ATE_RX_FER_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	pAd->ate.bRxFer = simple_strtol(arg, 0, 10);
@@ -2011,12 +2011,12 @@ INT	Set_ATE_RX_FER_Proc(
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Set_ATE_RX_FER_Proc (bRxFer = %d)\n", pAd->ate.bRxFer));
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("Ralink: Set_ATE_RX_FER_Proc Success\n"));
 
-	
+
 	return TRUE;
 }
 
 INT Set_ATE_Read_RF_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ate_print(KERN_EMERG "R1 = %lx\n", pAd->LatchRfRegs.R1);
@@ -2028,7 +2028,7 @@ INT Set_ATE_Read_RF_Proc(
 }
 
 INT Set_ATE_Write_RF1_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UINT32 value = simple_strtol(arg, 0, 16);
@@ -2040,7 +2040,7 @@ INT Set_ATE_Write_RF1_Proc(
 }
 
 INT Set_ATE_Write_RF2_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UINT32 value = simple_strtol(arg, 0, 16);
@@ -2052,7 +2052,7 @@ INT Set_ATE_Write_RF2_Proc(
 }
 
 INT Set_ATE_Write_RF3_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UINT32 value = simple_strtol(arg, 0, 16);
@@ -2064,7 +2064,7 @@ INT Set_ATE_Write_RF3_Proc(
 }
 
 INT Set_ATE_Write_RF4_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UINT32 value = simple_strtol(arg, 0, 16);
@@ -2075,18 +2075,18 @@ INT Set_ATE_Write_RF4_Proc(
 	return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Load and Write EEPROM from a binary file prepared in advance.
-        
+
         Return:
         	TRUE if all parameters are OK, FALSE otherwise
     ==========================================================================
 */
 #ifndef UCOS
 INT Set_ATE_Load_E2P_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	BOOLEAN		    ret = FALSE;
@@ -2097,7 +2097,7 @@ INT Set_ATE_Load_E2P_Proc(
 	USHORT 			WriteEEPROM[(EEPROM_SIZE/2)];
 	UINT32			FileLength = 0;
 	UINT32 			value = simple_strtol(arg, 0, 10);
-	
+
 	ATEDBGPRINT(RT_DEBUG_ERROR, ("===> %s (value=%d)\n\n", __FUNCTION__, value));
 
 	if (value > 0)
@@ -2120,12 +2120,12 @@ INT Set_ATE_Load_E2P_Proc(
 			/* open the bin file */
 			srcf = filp_open(src, O_RDONLY, 0);
 
-			if (IS_ERR(srcf)) 
+			if (IS_ERR(srcf))
 			{
 				ate_print("%s - Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(srcf), src);
 				break;
 			}
-			
+
 			/* the object must have a read method */
 			if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
 			{
@@ -2161,32 +2161,32 @@ INT Set_ATE_Load_E2P_Proc(
 		}
 		else
 		{
-			retval = filp_close(srcf, NULL);			
+			retval = filp_close(srcf, NULL);
 			if (retval)
 			{
 				ATEDBGPRINT(RT_DEBUG_ERROR, ("--> Error %d closing %s\n", -retval, src));
-				
-			} 
+
+			}
 		}
 
 		/* restore */
 		set_fs(orgfs);
 		current->fsuid = orgfsuid;
-		current->fsgid = orgfsgid;		
+		current->fsgid = orgfsgid;
 	}
     ATEDBGPRINT(RT_DEBUG_ERROR, ("<=== %s (ret=%d)\n", __FUNCTION__, ret));
 
     return ret;
-	
+
 }
 #else
 INT Set_ATE_Load_E2P_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	USHORT 			WriteEEPROM[(EEPROM_SIZE/2)];
 	struct iwreq	*wrq = (struct iwreq *)arg;
-	
+
 	ATEDBGPRINT(RT_DEBUG_TRACE, ("===> %s (wrq->u.data.length = %d)\n\n", __FUNCTION__, wrq->u.data.length));
 
 	if (wrq->u.data.length != EEPROM_SIZE)
@@ -2207,25 +2207,25 @@ INT Set_ATE_Load_E2P_Proc(
 		{
 				/* write the content of .bin file to EEPROM */
 				rt_ee_write_all(pAd, WriteEEPROM);
-				
+
 		} while(FALSE);
 		}
 
     ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== %s\n", __FUNCTION__));
 
     return TRUE;
-	
+
 }
 #endif // !UCOS //
 
 INT Set_ATE_Read_E2P_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	USHORT buffer[EEPROM_SIZE/2];
 	USHORT *p;
 	int i;
-	
+
 	rt_ee_read_all(pAd, (USHORT *)buffer);
 	p = buffer;
 	for (i = 0; i < (EEPROM_SIZE/2); i++)
@@ -2239,7 +2239,7 @@ INT Set_ATE_Read_E2P_Proc(
 }
 
 INT	Set_ATE_Show_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ate_print("Mode=%d\n", pAd->ate.Mode);
@@ -2266,7 +2266,7 @@ INT	Set_ATE_Show_Proc(
 }
 
 INT	Set_ATE_Help_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ate_print("ATE=ATESTART, ATESTOP, TXCONT, TXCARR, TXFRAME, RXFRAME\n");
@@ -2304,11 +2304,11 @@ INT	Set_ATE_Help_Proc(
     Description:
 
 	AsicSwitchChannel() dedicated for ATE.
-    
+
     ==========================================================================
 */
 VOID ATEAsicSwitchChannel(
-    IN PRTMP_ADAPTER pAd) 
+    IN PRTMP_ADAPTER pAd)
 {
 	UINT32 R2 = 0, R3 = DEFAULT_RF_TX_POWER, R4 = 0, Value = 0;
 	CHAR TxPwer = 0, TxPwer2 = 0;
@@ -2319,7 +2319,7 @@ VOID ATEAsicSwitchChannel(
 #ifdef RALINK_28xx_QA
 	if ((pAd->ate.bQATxStart == TRUE) || (pAd->ate.bQARxStart == TRUE))
 	{
-		if (pAd->ate.Channel != pAd->LatchRfRegs.Channel)			
+		if (pAd->ate.Channel != pAd->LatchRfRegs.Channel)
 		{
 			pAd->ate.Channel = pAd->LatchRfRegs.Channel;
 		}
@@ -2345,7 +2345,7 @@ VOID ATEAsicSwitchChannel(
 		case RFIC_2850:
 		case RFIC_2720:
 		case RFIC_2750:
-			
+
 			for (index = 0; index < NUM_OF_2850_CHNL; index++)
 			{
 				if (Channel == RFRegTable[index].Channel)
@@ -2365,22 +2365,22 @@ VOID ATEAsicSwitchChannel(
 								ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
 								BbpValue &= 0xE4;
 								BbpValue |= 0x00;
-								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);								
+								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
 								break;
 							case 2:
 								R2 |= 0x10040;
 								ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
 								BbpValue &= 0xE4;
 								BbpValue |= 0x01;
-								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);									
+								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
 								break;
-							default:	
+							default:
 								R2 |= 0x40;
 								ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
 								BbpValue &= 0xE4;
 								/* Only enable two Antenna to receive. */
 								BbpValue |= 0x08;
-								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);								
+								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
 								break;
 						}
 					}
@@ -2402,7 +2402,7 @@ VOID ATEAsicSwitchChannel(
 						{
 							R2 |= 0x8000;	// If TX Antenna select is 2 , bit 15 = 1; Disable Ant 1
 							ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue);
-							BbpValue &= 0xE7;	
+							BbpValue &= 0xE7;
 							BbpValue |= 0x08;
 							ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue);
 						}
@@ -2423,31 +2423,31 @@ VOID ATEAsicSwitchChannel(
 								ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
 								BbpValue &= 0xE4;
 								BbpValue |= 0x00;
-								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);								
+								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
 								break;
 							case 2:
 								R2 |= 0x10040;
 								ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
 								BbpValue &= 0xE4;
 								BbpValue |= 0x01;
-								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);									
+								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
 								break;
-							case 3:	
+							case 3:
 								R2 |= 0x30000;
 								ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
 								BbpValue &= 0xE4;
 								BbpValue |= 0x02;
 								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
-								break;								
-							default:	
+								break;
+							default:
 								ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue);
 								BbpValue &= 0xE4;
 								BbpValue |= 0x10;
-								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);								
+								ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue);
 								break;
 						}
 					}
-					
+
 					if (Channel > 14)
 					{
 						// initialize R3, R4
@@ -2495,7 +2495,7 @@ VOID ATEAsicSwitchChannel(
 					{
 						R4 |=0x200000;
 					}
-					
+
 					// Update variables
 					pAd->LatchRfRegs.Channel = Channel;
 					pAd->LatchRfRegs.R1 = RFRegTable[index].R1;
@@ -2504,7 +2504,7 @@ VOID ATEAsicSwitchChannel(
 					pAd->LatchRfRegs.R4 = R4;
 
 					RtmpRfIoWrite(pAd);
-					
+
 					break;
 				}
 			}
@@ -2518,7 +2518,7 @@ VOID ATEAsicSwitchChannel(
 	if (Channel <= 14)
 	{
 	    ULONG	TxPinCfg = 0x00050F0A;// 2007.10.09 by Brian : 0x0005050A ==> 0x00050F0A
-		
+
 		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
 		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
 		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
@@ -2562,7 +2562,7 @@ VOID ATEAsicSwitchChannel(
 	else
 	{
 	    ULONG	TxPinCfg = 0x00050F05;//2007.10.09 by Brian : 0x00050505 ==> 0x00050F05
-		
+
 		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - GET_LNA_GAIN(pAd)));
 		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - GET_LNA_GAIN(pAd)));
 		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - GET_LNA_GAIN(pAd)));
@@ -2580,7 +2580,7 @@ VOID ATEAsicSwitchChannel(
 
 		ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R92, &BbpValue);
 		ASSERT((BbpValue == 0x00));
-		
+
 		// 5.5GHz band selection PIN, bit1 and bit2 are complement
 		RTMP_IO_READ32(pAd, TX_BAND_CFG, &Value);
 		Value &= (~0x6);
@@ -2602,13 +2602,13 @@ VOID ATEAsicSwitchChannel(
 
     // R66 should be set according to Channel and use 20MHz when scanning
 	if (Channel <= 14)
-	{	
+	{
 		// BG band
 		R66 = 0x2E + GET_LNA_GAIN(pAd);
 		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, R66);
 	}
 	else
-	{	
+	{
 		// 5.5 GHz band
 		if (pAd->ate.TxWI.BW == BW_20)
 		{
@@ -2624,34 +2624,34 @@ VOID ATEAsicSwitchChannel(
 
 	//
 	// On 11A, We should delay and wait RF/BBP to be stable
-	// and the appropriate time should be 1000 micro seconds 
+	// and the appropriate time should be 1000 micro seconds
 	// 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL.
 	//
-	RTMPusecDelay(1000);  
+	RTMPusecDelay(1000);
 
 	if (Channel > 14)
 	{
 		// When 5.5GHz band the LSB of TxPwr will be used to reduced 7dB or not.
 		ATEDBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
-								  Channel, 
-								  pAd->RfIcType, 
+								  Channel,
+								  pAd->RfIcType,
 								  pAd->Antenna.field.TxPath,
-								  pAd->LatchRfRegs.R1, 
-								  pAd->LatchRfRegs.R2, 
-								  pAd->LatchRfRegs.R3, 
+								  pAd->LatchRfRegs.R1,
+								  pAd->LatchRfRegs.R2,
+								  pAd->LatchRfRegs.R3,
 								  pAd->LatchRfRegs.R4));
 	}
 	else
 	{
 		ATEDBGPRINT(RT_DEBUG_TRACE, ("SwitchChannel#%d(RF=%d, Pwr0=%u, Pwr1=%u, %dT) to , R1=0x%08lx, R2=0x%08lx, R3=0x%08lx, R4=0x%08lx\n",
-								  Channel, 
-								  pAd->RfIcType, 
+								  Channel,
+								  pAd->RfIcType,
 								  (R3 & 0x00003e00) >> 9,
 								  (R4 & 0x000007c0) >> 6,
 								  pAd->Antenna.field.TxPath,
-								  pAd->LatchRfRegs.R1, 
-								  pAd->LatchRfRegs.R2, 
-								  pAd->LatchRfRegs.R3, 
+								  pAd->LatchRfRegs.R1,
+								  pAd->LatchRfRegs.R2,
+								  pAd->LatchRfRegs.R3,
 								  pAd->LatchRfRegs.R4));
     }
 }
@@ -2677,7 +2677,7 @@ VOID ATEAsicSwitchChannel(
 	==========================================================================
  */
 VOID ATEAsicAdjustTxPower(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	INT			i, j;
 	CHAR		DeltaPwr = 0;
@@ -2785,10 +2785,10 @@ VOID ATEAsicAdjustTxPower(
 					*pTxAgcCompensate = -(TxAgcStep * (idx-1));
 //				else
 //					*pTxAgcCompensate = -((UCHAR)R3);
-				
+
 				DeltaPwr += (*pTxAgcCompensate);
 				ATEDBGPRINT(RT_DEBUG_TRACE, ("-- Tx Power, BBP R1=%x, TssiRef=%x, TxAgcStep=%x, step = -%d\n",
-					BbpR49, TssiRef, TxAgcStep, idx-1));                    
+					BbpR49, TssiRef, TxAgcStep, idx-1));
 			}
 			else if (BbpR49 < pTssiPlusBoundary[1])
 			{
@@ -2892,7 +2892,7 @@ VOID ATEAsicAdjustTxPower(
 			/* TX_PWR_CFG_1 ~ TX_PWR_CFG_4 */
 			RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, TxPwr[i]);
 
-			
+
 		}
 	}
 
@@ -2902,7 +2902,7 @@ VOID ATEAsicAdjustTxPower(
 	========================================================================
 	Routine Description:
 		Write TxWI for ATE mode.
-		
+
 	Return Value:
 		None
 	========================================================================
@@ -2910,8 +2910,8 @@ VOID ATEAsicAdjustTxPower(
 #ifdef RT2860
 static VOID ATEWriteTxWI(
 	IN	PRTMP_ADAPTER	pAd,
-	IN	PTXWI_STRUC 	pOutTxWI,	
-	IN	BOOLEAN			FRAG,	
+	IN	PTXWI_STRUC 	pOutTxWI,
+	IN	BOOLEAN			FRAG,
 	IN	BOOLEAN			CFACK,
 	IN	BOOLEAN			InsTimestamp,
 	IN	BOOLEAN 		AMPDU,
@@ -2923,8 +2923,8 @@ static VOID ATEWriteTxWI(
 	IN	UCHAR 			PID,
 	IN	UCHAR			TID,
 	IN	UCHAR			TxRate,
-	IN	UCHAR			Txopmode,	
-	IN	BOOLEAN			CfAck,	
+	IN	UCHAR			Txopmode,
+	IN	BOOLEAN			CfAck,
 	IN	HTTRANSMIT_SETTING	*pTransmit)
 {
 	TXWI_STRUC 		TxWI;
@@ -2945,22 +2945,22 @@ static VOID ATEWriteTxWI(
 	pTxWI->AMPDU = AMPDU;
 	pTxWI->ACK = Ack;
 	pTxWI->txop= Txopmode;
-	
+
 	pTxWI->NSEQ = NSeq;
 	// John tune the performace with Intel Client in 20 MHz performance
 	if( BASize >7 )
 		BASize =7;
-		
-	pTxWI->BAWinSize = BASize;	
+
+	pTxWI->BAWinSize = BASize;
 	pTxWI->WirelessCliID = WCID;
-	pTxWI->MPDUtotalByteCount = Length; 
-	pTxWI->PacketId = PID; 
-	
+	pTxWI->MPDUtotalByteCount = Length;
+	pTxWI->PacketId = PID;
+
 	// If CCK or OFDM, BW must be 20
 	pTxWI->BW = (pTransmit->field.MODE <= MODE_OFDM) ? (BW_20) : (pTransmit->field.BW);
 	pTxWI->ShortGI = pTransmit->field.ShortGI;
 	pTxWI->STBC = pTransmit->field.STBC;
-	
+
 	pTxWI->MCS = pTransmit->field.MCS;
 	pTxWI->PHYMODE = pTransmit->field.MODE;
 	pTxWI->CFACK = CfAck;
@@ -3015,7 +3015,7 @@ VOID ATEDisableAsicProtect(
 	Protect[0] = ProtCfg.word;
 	Protect[1] = ProtCfg.word;
 
-	// NO PROTECT 
+	// NO PROTECT
 	// 1.All STAs in the BSS are 20/40 MHz HT
 	// 2. in ai 20/40MHz BSS
 	// 3. all STAs are 20MHz in a 20MHz BSS
@@ -3027,13 +3027,13 @@ VOID ATEDisableAsicProtect(
 	//	PROT_NAV(19:18)  -- 01 (Short NAV protection)
 	//  PROT_CTRL(17:16) -- 00 (None)
 	// 	PROT_RATE(15:0)  -- 0x4004 (OFDM 24M)
-	Protect[2] = 0x01744004;	
+	Protect[2] = 0x01744004;
 
 	// MM40_PROT_CFG
 	//	Reserved (31:27)
 	// 	PROT_TXOP(25:20) -- 111111
 	//	PROT_NAV(19:18)  -- 01 (Short NAV protection)
-	//  PROT_CTRL(17:16) -- 00 (None) 
+	//  PROT_CTRL(17:16) -- 00 (None)
 	// 	PROT_RATE(15:0)  -- 0x4084 (duplicate OFDM 24M)
 	Protect[3] = 0x03f44084;
 
@@ -3054,7 +3054,7 @@ VOID ATEDisableAsicProtect(
 	Protect[5] = 0x03f44084;
 
 	pAd->CommonCfg.IOTestParm.bRTSLongProtOn = FALSE;
-	
+
 	offset = CCK_PROT_CFG;
 	for (i = 0;i < 6;i++)
 		RTMP_IO_WRITE32(pAd, offset + i*4, Protect[i]);
@@ -3077,7 +3077,7 @@ CHAR ATEConvertToRssi(
 	// Rssi equals to zero should be an invalid value
 	if (Rssi == 0)
 		return -99;
-	
+
 	LNAGain = GET_LNA_GAIN(pAd);
 	if (pAd->LatchRfRegs.Channel > 14)
 	{
@@ -3101,9 +3101,9 @@ CHAR ATEConvertToRssi(
 	return (-12 - RssiOffset - LNAGain - Rssi);
 }
 #else
-// 
+//
 // The way originally used in ATE of rt2860ap.
-// 
+//
 CHAR ATEConvertToRssi(
 	IN PRTMP_ADAPTER pAd,
 	IN	CHAR			Rssi,
@@ -3135,7 +3135,7 @@ CHAR ATEConvertToRssi(
 		else
 			RssiOffset = pAd->BGRssiOffset2;
     }
-	
+
     return (-32 - RssiOffset + LNAGain - Rssi);
 }
 #endif /* end of #if 1 */
@@ -3148,14 +3148,14 @@ CHAR ATEConvertToRssi(
 	Note:
 		This routine should only be called when
 		entering TXFRAME mode or TXCONT mode.
-				
+
 	========================================================================
 */
 static VOID SetJapanFilter(
 	IN		PRTMP_ADAPTER	pAd)
 {
 	UCHAR			BbpData = 0;
-	
+
 	//
 	// If Channel=14 and Bandwidth=20M and Mode=CCK, set BBP R4 bit5=1
 	// (Japan Tx filter coefficients)when (TXFRAME or TXCONT).
@@ -3210,7 +3210,7 @@ VOID ATESampleRssi(
 	pAd->ate.LastSNR0 = (CHAR)(pRxWI->SNR0);
 	pAd->ate.LastSNR1 = (CHAR)(pRxWI->SNR1);
 	pAd->ate.RxCntPerSec++;
-	pAd->ate.LastRssi0 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI0, RSSI_0);				
+	pAd->ate.LastRssi0 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI0, RSSI_0);
 	pAd->ate.LastRssi1 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI1, RSSI_1);
 	pAd->ate.LastRssi2 = ATEConvertToRssi(pAd, (CHAR) pRxWI->RSSI2, RSSI_2);
 	pAd->ate.AvgRssi0X8 = (pAd->ate.AvgRssi0X8 - pAd->ate.AvgRssi0) + pAd->ate.LastRssi0;
@@ -3228,7 +3228,7 @@ VOID RTMPStationStop(
     IN  PRTMP_ADAPTER   pAd)
 {
 //	BOOLEAN       Cancelled;
-	
+
     ATEDBGPRINT(RT_DEBUG_TRACE, ("==> RTMPStationStop\n"));
 
 #if 0
@@ -3260,7 +3260,7 @@ VOID RTMPStationStart(
 }
 #endif // CONFIG_STA_SUPPORT //
 
-/* 
+/*
 	==========================================================================
 	Description:
 		Setup Frame format.
@@ -3293,7 +3293,7 @@ static INT ATESetUpFrame(
 	PHEADER_802_11	pHeader80211;
 #endif // RALINK_28xx_QA //
 
-	if (pAd->ate.bQATxStart == TRUE) 
+	if (pAd->ate.bQATxStart == TRUE)
 	{
 		// always use QID_AC_BE and FIFO_EDCA
 
@@ -3303,7 +3303,7 @@ static INT ATESetUpFrame(
 		TxHTPhyMode.field.STBC = 0;
 		TxHTPhyMode.field.MCS = pAd->ate.TxWI.MCS;
 		TxHTPhyMode.field.MODE = pAd->ate.TxWI.PHYMODE;
-		ATEWriteTxWI(pAd, pTxWI, pAd->ate.TxWI.FRAG, pAd->ate.TxWI.CFACK, pAd->ate.TxWI.TS,  pAd->ate.TxWI.AMPDU, pAd->ate.TxWI.ACK, pAd->ate.TxWI.NSEQ, 
+		ATEWriteTxWI(pAd, pTxWI, pAd->ate.TxWI.FRAG, pAd->ate.TxWI.CFACK, pAd->ate.TxWI.TS,  pAd->ate.TxWI.AMPDU, pAd->ate.TxWI.ACK, pAd->ate.TxWI.NSEQ,
 			pAd->ate.TxWI.BAWinSize, 0, pAd->ate.TxWI.MPDUtotalByteCount, pAd->ate.TxWI.PacketId, 0, 0, pAd->ate.TxWI.txop/*IFS_HTTXOP*/, pAd->ate.TxWI.CFACK/*FALSE*/, &TxHTPhyMode);
 	}
 	else
@@ -3313,13 +3313,13 @@ static INT ATESetUpFrame(
 		TxHTPhyMode.field.STBC = 0;
 		TxHTPhyMode.field.MCS = pAd->ate.TxWI.MCS;
 		TxHTPhyMode.field.MODE = pAd->ate.TxWI.PHYMODE;
-		ATEWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE,  FALSE, FALSE, FALSE, 
+		ATEWriteTxWI(pAd, pTxWI, FALSE, FALSE, FALSE,  FALSE, FALSE, FALSE,
 			4, 0, pAd->ate.TxLength, 0, 0, 0, IFS_HTTXOP, FALSE, &TxHTPhyMode);
 	}
-	
+
 	// fill 802.11 header.
 #ifdef RALINK_28xx_QA
-	if (pAd->ate.bQATxStart == TRUE) 
+	if (pAd->ate.bQATxStart == TRUE)
 	{
 		NdisMoveMemory(pDMAHeaderBufVA+TXWI_SIZE, pAd->ate.Header, pAd->ate.HLen);
 	}
@@ -3338,7 +3338,7 @@ static INT ATESetUpFrame(
 
 	/* alloc buffer for payload */
 #ifdef RALINK_28xx_QA
-	if (pAd->ate.bQATxStart == TRUE) 
+	if (pAd->ate.bQATxStart == TRUE)
 	{
 		/* Why not use RTMP_AllocateTxPacketBuffer() instead of RTMP_AllocateRxPacketBuffer()? */
 		pPacket = RTMP_AllocateRxPacketBuffer(pAd, pAd->ate.DLen + 0x100, FALSE, &AllocVa, &AllocPa);
@@ -3361,7 +3361,7 @@ static INT ATESetUpFrame(
 	pDest = (PUCHAR) AllocVa;
 
 #ifdef RALINK_28xx_QA
-	if (pAd->ate.bQATxStart == TRUE) 
+	if (pAd->ate.bQATxStart == TRUE)
 	{
 		RTPKT_TO_OSPKT(pPacket)->len = pAd->ate.DLen;
 	}
@@ -3373,13 +3373,13 @@ static INT ATESetUpFrame(
 
 	// Prepare frame payload
 #ifdef RALINK_28xx_QA
-	if (pAd->ate.bQATxStart == TRUE) 
+	if (pAd->ate.bQATxStart == TRUE)
 	{
 		// copy pattern
 		if ((pAd->ate.PLen != 0))
 		{
 			int j;
-			
+
 			for (j = 0; j < pAd->ate.DLen; j+=pAd->ate.PLen)
 			{
 				memcpy(RTPKT_TO_OSPKT(pPacket)->data + j, pAd->ate.Pattern, pAd->ate.PLen);
@@ -3395,7 +3395,7 @@ static INT ATESetUpFrame(
 
 	//
 	// build Tx Descriptor
-	// 
+	//
 #ifndef RT_BIG_ENDIAN
 	pTxD = (PTXD_STRUC) pTxRing->Cell[TxIdx].AllocVa;
 #else
@@ -3421,7 +3421,7 @@ static INT ATESetUpFrame(
 		pDest = (PUCHAR)pTxWI;
 		pDest += TXWI_SIZE;
 		pHeader80211 = (PHEADER_802_11)pDest;
-		
+
 		// modify sequence number....
 		if (pAd->ate.TxDoneCount == 0)
 		{
@@ -3462,7 +3462,7 @@ VOID rt_ee_read_all(PRTMP_ADAPTER pAd, USHORT *Data)
 {
 	USHORT i;
 	USHORT value;
-	
+
 	for (i = 0 ; i < EEPROM_SIZE/2 ; )
 	{
 		/* "value" is expecially for some compilers... */
@@ -3514,9 +3514,9 @@ VOID ATE_QA_Statistics(
 			pAd->ate.OtherCount++;
 		}
 	}
-	pAd->ate.RSSI0 = pRxWI->RSSI0; 
-	pAd->ate.RSSI1 = pRxWI->RSSI1; 
-	pAd->ate.RSSI2 = pRxWI->RSSI2; 
+	pAd->ate.RSSI0 = pRxWI->RSSI0;
+	pAd->ate.RSSI1 = pRxWI->RSSI1;
+	pAd->ate.RSSI2 = pRxWI->RSSI2;
 	pAd->ate.SNR0 = pRxWI->SNR0;
 	pAd->ate.SNR1 = pRxWI->SNR1;
 }
@@ -3605,7 +3605,7 @@ static VOID RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, UINT32
 #ifdef UCOS
 int ate_copy_to_user(
 	IN PUCHAR payload,
-	IN PUCHAR msg, 
+	IN PUCHAR msg,
 	IN INT    len)
 {
 	memmove(payload, msg, len);
@@ -3619,21 +3619,21 @@ int ate_copy_to_user(
 #define	LEN_OF_ARG 16
 
 VOID RtmpDoAte(
-	IN	PRTMP_ADAPTER	pAdapter, 
+	IN	PRTMP_ADAPTER	pAdapter,
 	IN	struct iwreq	*wrq)
 {
 	unsigned short Command_Id;
 	struct ate_racfghdr *pRaCfg;
 	INT	Status = NDIS_STATUS_SUCCESS;
 
-	
+
 
 	if((pRaCfg = kmalloc(sizeof(struct ate_racfghdr), GFP_KERNEL)) == NULL)
 	{
 		Status = -EINVAL;
 		return;
 	}
-				
+
 	NdisZeroMemory(pRaCfg, sizeof(struct ate_racfghdr));
 
     if (copy_from_user((PUCHAR)pRaCfg, wrq->u.data.pointer, wrq->u.data.length))
@@ -3642,13 +3642,13 @@ VOID RtmpDoAte(
 		kfree(pRaCfg);
 		return;
 	}
-    
+
 
 	Command_Id = ntohs(pRaCfg->command_id);
-	
+
 	ATEDBGPRINT(RT_DEBUG_TRACE,("\n%s: Command_Id = 0x%04x !\n", __FUNCTION__, Command_Id));
-	
-	switch (Command_Id) 
+
+	switch (Command_Id)
 	{
  		// We will get this command when QA starts.
 		case RACFG_CMD_ATE_START:
@@ -3660,7 +3660,7 @@ VOID RtmpDoAte(
 				pRaCfg->status = htons(0);
 
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
 				ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
@@ -3698,14 +3698,14 @@ VOID RtmpDoAte(
 					// Get the pid of ATE daemon.
 					memcpy((UCHAR *)&pAdapter->ate.AtePid,
 						(&pRaCfg->data[0]) - 2/* == &(pRaCfg->status) */,
-						sizeof(pAdapter->ate.AtePid));					
+						sizeof(pAdapter->ate.AtePid));
 
 					// prepare feedback as soon as we can to avoid QA timeout.
 					pRaCfg->length = htons(2);
 					pRaCfg->status = htons(0);
 
 					wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-										+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+										+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 										+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
 					ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
@@ -3719,7 +3719,7 @@ VOID RtmpDoAte(
 					//
 					// kill ATE daemon when leaving ATE mode.
 					// We must kill ATE daemon first before setting ATESTOP,
-					// or Microsoft will report sth. wrong. 
+					// or Microsoft will report sth. wrong.
 #ifndef UCOS
 					ret = KILL_THREAD_PID(pAdapter->ate.AtePid, SIGTERM, 1);
 					if (ret)
@@ -3743,13 +3743,13 @@ VOID RtmpDoAte(
 			{
 				UINT32 R1, R2, R3, R4;
 				USHORT channel;
-				
+
 				memcpy(&R1, pRaCfg->data-2, 4);
 				memcpy(&R2, pRaCfg->data+2, 4);
 				memcpy(&R3, pRaCfg->data+6, 4);
 				memcpy(&R4, pRaCfg->data+10, 4);
-				memcpy(&channel, pRaCfg->data+14, 2);		
-				
+				memcpy(&channel, pRaCfg->data+14, 2);
+
 				pAdapter->LatchRfRegs.R1 = ntohl(R1);
 				pAdapter->LatchRfRegs.R2 = ntohl(R2);
 				pAdapter->LatchRfRegs.R3 = ntohl(R3);
@@ -3766,7 +3766,7 @@ VOID RtmpDoAte(
 				pRaCfg->status = htons(0);
 
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
 				ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
@@ -3780,12 +3780,12 @@ VOID RtmpDoAte(
                 	ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_RF_WRITE_ALL is done !\n"));
 				}
 			}
-            break;				
-			
+            break;
+
 		case RACFG_CMD_E2PROM_READ16:
 			{
 				USHORT	offset, value, tmp;
-				
+
 				offset = ntohs(pRaCfg->status);
 				/* "tmp" is expecially for some compilers... */
 				RT28xx_EEPROM_READ16(pAdapter, offset, tmp);
@@ -3800,7 +3800,7 @@ VOID RtmpDoAte(
 				memcpy(pRaCfg->data, &value, 2);
 
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
 				ATEDBGPRINT(RT_DEBUG_TRACE, ("sizeof(struct ate_racfghdr) = %d\n", sizeof(struct ate_racfghdr)));
@@ -3821,7 +3821,7 @@ VOID RtmpDoAte(
 		case RACFG_CMD_E2PROM_WRITE16:
 			{
 				USHORT	offset, value;
-				
+
 				offset = ntohs(pRaCfg->status);
 				memcpy(&value, pRaCfg->data, 2);
 				value = ntohs(value);
@@ -3831,7 +3831,7 @@ VOID RtmpDoAte(
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -3857,7 +3857,7 @@ VOID RtmpDoAte(
 				pRaCfg->length = htons(2+EEPROM_SIZE);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -3884,7 +3884,7 @@ VOID RtmpDoAte(
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -3904,7 +3904,7 @@ VOID RtmpDoAte(
 			{
 				UINT32	offset;
 				UINT32	value;
-				
+
 				memcpy(&offset, &pRaCfg->status, 4);
 				offset = ntohl(offset);
 
@@ -3920,7 +3920,7 @@ VOID RtmpDoAte(
 				memcpy(pRaCfg->data, &value, 4);
 
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -3938,10 +3938,10 @@ VOID RtmpDoAte(
 		case RACFG_CMD_IO_WRITE:
 			{
 				UINT32	offset, value;
-								
+
 				memcpy(&offset, pRaCfg->data-2, 4);
 				memcpy(&value, pRaCfg->data+2, 4);
-			
+
 				offset = ntohl(offset);
 
 				// We do not need the base address.
@@ -3950,12 +3950,12 @@ VOID RtmpDoAte(
 				value = ntohl(value);
 				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_IO_WRITE: offset = %x, value = %x\n", offset, value));
 				RTMP_IO_WRITE32(pAdapter, offset, value);
-				
+
 				// prepare feedback
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -3969,12 +3969,12 @@ VOID RtmpDoAte(
 				}
 			}
 			break;
-			
+
 		case RACFG_CMD_IO_READ_BULK:
 			{
 				UINT32	offset;
 				USHORT	len;
-				
+
 				memcpy(&offset, &pRaCfg->status, 4);
 				offset = ntohl(offset);
 
@@ -3998,7 +3998,7 @@ VOID RtmpDoAte(
 				pRaCfg->length = htons(2+len*4);// unit in four bytes
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4017,7 +4017,7 @@ VOID RtmpDoAte(
 			{
 				USHORT	offset;
 				UCHAR	value;
-				
+
 				value = 0;
 				offset = ntohs(pRaCfg->status);
 
@@ -4027,7 +4027,7 @@ VOID RtmpDoAte(
 				}
 				else
 				{
-					RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, offset,  &value);	
+					RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, offset,  &value);
 				}
 				// prepare feedback
 				pRaCfg->length = htons(3);
@@ -4037,7 +4037,7 @@ VOID RtmpDoAte(
 				ATEDBGPRINT(RT_DEBUG_TRACE,("BBP value = %x\n", value));
 
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4055,7 +4055,7 @@ VOID RtmpDoAte(
 			{
 				USHORT	offset;
 				UCHAR	value;
-				
+
 				offset = ntohs(pRaCfg->status);
 				memcpy(&value, pRaCfg->data, 1);
 
@@ -4072,12 +4072,12 @@ VOID RtmpDoAte(
 				{
 					SyncTxRxConfig(pAdapter, offset, value);
 				}
-				
+
 				// prepare feedback
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4095,11 +4095,11 @@ VOID RtmpDoAte(
 		case RACFG_CMD_BBP_READ_ALL:
 			{
 				USHORT j;
-				
+
 				for (j = 0; j < 137; j++)
 				{
 					pRaCfg->data[j] = 0;
-					
+
 					if (ATE_ON(pAdapter))
 					{
 						ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, j,  &pRaCfg->data[j]);
@@ -4109,13 +4109,13 @@ VOID RtmpDoAte(
 						RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, j,  &pRaCfg->data[j]);
 					}
 				}
-				
+
 				// prepare feedback
 				pRaCfg->length = htons(2+137);
 				pRaCfg->status = htons(0);
 
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4136,11 +4136,11 @@ VOID RtmpDoAte(
 			USHORT offset;
 			USHORT len;
 			USHORT buffer[EEPROM_SIZE/2];
-			
+
 			offset = ntohs(pRaCfg->status);
 			memcpy(&len, pRaCfg->data, 2);
 			len = ntohs(len);
-			
+
 			rt_ee_read_all(pAdapter,(USHORT *)buffer);
 			if (offset + len <= EEPROM_SIZE)
 				memcpy_exs(pAdapter, pRaCfg->data, (UCHAR *)buffer+offset, len);
@@ -4151,7 +4151,7 @@ VOID RtmpDoAte(
 			pRaCfg->length = htons(2+len);
 			pRaCfg->status = htons(0);
 			wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4172,7 +4172,7 @@ VOID RtmpDoAte(
 			USHORT offset;
 			USHORT len;
 			USHORT buffer[EEPROM_SIZE/2];
-			
+
 			offset = ntohs(pRaCfg->status);
 			memcpy(&len, pRaCfg->data, 2);
 			len = ntohs(len);
@@ -4185,7 +4185,7 @@ VOID RtmpDoAte(
 			pRaCfg->length = htons(2);
 			pRaCfg->status = htons(0);
 			wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-								+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+								+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 								+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
             if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
             {
@@ -4204,12 +4204,12 @@ VOID RtmpDoAte(
 		{
 			UINT32 offset, i, value;
 			USHORT len;
-			
+
 			memcpy(&offset, &pRaCfg->status, 4);
 			offset = ntohl(offset);
 			memcpy(&len, pRaCfg->data+2, 2);
 			len = ntohs(len);
-			
+
 			for (i = 0; i < len; i += 4)
 			{
 				memcpy_exl(pAdapter, (UCHAR *)&value, pRaCfg->data+4+i, 4);
@@ -4221,7 +4221,7 @@ VOID RtmpDoAte(
 			pRaCfg->length = htons(2);
 			pRaCfg->status = htons(0);
 			wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-								+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+								+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 								+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
             if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
             {
@@ -4241,16 +4241,16 @@ VOID RtmpDoAte(
 			USHORT offset;
 			USHORT len;
 			USHORT j;
-			
+
 			offset = ntohs(pRaCfg->status);
 			memcpy(&len, pRaCfg->data, 2);
 			len = ntohs(len);
-			
-				
+
+
 			for (j = offset; j < (offset+len); j++)
 			{
 				pRaCfg->data[j - offset] = 0;
-				
+
 				if (pAdapter->ate.Mode == ATE_STOP)
 				{
 					RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, j,  &pRaCfg->data[j - offset]);
@@ -4265,7 +4265,7 @@ VOID RtmpDoAte(
 			pRaCfg->length = htons(2+len);
 			pRaCfg->status = htons(0);
 			wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-								+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+								+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 								+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4287,11 +4287,11 @@ VOID RtmpDoAte(
 			USHORT len;
 			USHORT j;
 			UCHAR *value;
-			
+
 			offset = ntohs(pRaCfg->status);
 			memcpy(&len, pRaCfg->data, 2);
 			len = ntohs(len);
-							
+
 			for (j = offset; j < (offset+len); j++)
 			{
 				value = pRaCfg->data + 2 + (j - offset);
@@ -4309,7 +4309,7 @@ VOID RtmpDoAte(
 			pRaCfg->length = htons(2);
 			pRaCfg->status = htons(0);
 			wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-								+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+								+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 								+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4330,7 +4330,7 @@ VOID RtmpDoAte(
 			USHORT offset;
 			USHORT len;
 			USHORT j;
-			
+
 			offset = ntohs(pRaCfg->status);
 			memcpy(&len, pRaCfg->data, 2);
 			len = ntohs(len);
@@ -4345,7 +4345,7 @@ VOID RtmpDoAte(
 			pRaCfg->length = htons(2+len);
 			pRaCfg->status = htons(0);
 			wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-								+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+								+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 								+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4367,7 +4367,7 @@ VOID RtmpDoAte(
 			USHORT len;
 			USHORT j;
 			UCHAR *value;
-			
+
 			offset = ntohs(pRaCfg->status);
 			memcpy(&len, pRaCfg->data, 2);
 			len = ntohs(len);
@@ -4382,7 +4382,7 @@ VOID RtmpDoAte(
 			pRaCfg->length = htons(2);
 			pRaCfg->status = htons(0);
 			wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-								+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+								+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 								+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4404,7 +4404,7 @@ VOID RtmpDoAte(
 			{
 				UCHAR	channel;
 				INT32   buffer[3][10];/* 3 : RxPath ; 10 : no. of per rssi samples */
-				
+
 				channel = (ntohs(pRaCfg->status) & 0x00FF);
 				CalNoiseLevel(pAdapter, channel, buffer);
 				memcpy_exl(pAdapter, (UCHAR *)pRaCfg->data, (UCHAR *)&(buffer[0][0]), (sizeof(INT32)*3*10));
@@ -4413,7 +4413,7 @@ VOID RtmpDoAte(
 				pRaCfg->length = htons(2 + (sizeof(INT32)*3*10));
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4445,11 +4445,11 @@ VOID RtmpDoAte(
 				memcpy_exl(pAdapter, &pRaCfg->data[48], (UCHAR *)&pAdapter->ate.RSSI2, 4);
 				memcpy_exl(pAdapter, &pRaCfg->data[52], (UCHAR *)&pAdapter->ate.SNR0, 4);
 				memcpy_exl(pAdapter, &pRaCfg->data[56], (UCHAR *)&pAdapter->ate.SNR1, 4);
-				
+
 				pRaCfg->length = htons(2+60);
-				pRaCfg->status = htons(0);			
+				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4477,12 +4477,12 @@ VOID RtmpDoAte(
 				pAdapter->ate.TxHCCA = 0;
 				pAdapter->ate.TxMgmt = 0;
 				pAdapter->ate.TxDoneCount = 0;
-				
+
 				pRaCfg->length = htons(2);
-				pRaCfg->status = htons(0);			
+				pRaCfg->status = htons(0);
 
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4495,7 +4495,7 @@ VOID RtmpDoAte(
                 	ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_CLEAR_COUNTER is done !\n"));
 				}
 			}
-			
+
 			break;
 
 		case RACFG_CMD_TX_START:
@@ -4507,7 +4507,7 @@ VOID RtmpDoAte(
 				if ((pAdapter->ate.TxStatus != 0) && (pAdapter->ate.Mode & ATE_TXFRAME))
 				{
 					ATEDBGPRINT(RT_DEBUG_TRACE,("Ate Tx is already running, to run next Tx, you must stop it first\n"));
-					err = 2; 
+					err = 2;
 					goto TX_START_ERROR;
 				}
 				else if ((pAdapter->ate.TxStatus != 0) && !(pAdapter->ate.Mode & ATE_TXFRAME))
@@ -4531,7 +4531,7 @@ VOID RtmpDoAte(
 				{
 					// Get frame info
 
-					NdisMoveMemory(&pAdapter->ate.TxWI, pRaCfg->data + 2, 16);						
+					NdisMoveMemory(&pAdapter->ate.TxWI, pRaCfg->data + 2, 16);
 #ifdef RT_BIG_ENDIAN
 					RTMPWIEndianChange((PUCHAR)&pAdapter->ate.TxWI, TYPE_TXWI);
 #endif // RT_BIG_ENDIAN //
@@ -4618,7 +4618,7 @@ VOID RtmpDoAte(
 									break;
 							}
 						}
-						break;	
+						break;
 
 					case BBP22_TXCARR:
 						{
@@ -4626,7 +4626,7 @@ VOID RtmpDoAte(
 							pAdapter->ate.bQATxStart = TRUE;
 							Set_ATE_Proc(pAdapter, "TXCARR");
 						}
-						break;							
+						break;
 
 					default:
 						{
@@ -4640,9 +4640,9 @@ VOID RtmpDoAte(
 					// prepare feedback
 					pRaCfg->length = htons(2);
 					pRaCfg->status = htons(0);
-					
+
 					wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-										+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+										+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 										+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
 	            	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4661,9 +4661,9 @@ TX_START_ERROR:
 				// prepare feedback
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(err);
-				
+
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
             	{
@@ -4680,14 +4680,14 @@ TX_START_ERROR:
 		case RACFG_CMD_GET_TX_STATUS:
 			{
 				UINT32 count;
-				
+
 				// prepare feedback
 				pRaCfg->length = htons(6);
 				pRaCfg->status = htons(0);
 				count = htonl(pAdapter->ate.TxDoneCount);
 				NdisMoveMemory(pRaCfg->data, &count, 4);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4712,7 +4712,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4738,7 +4738,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4763,7 +4763,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4790,7 +4790,7 @@ TX_START_ERROR:
 				pRaCfg->status = htons(0);
 
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
 				ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
@@ -4817,7 +4817,7 @@ TX_START_ERROR:
 				pRaCfg->status = htons(0);
 
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
 				ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
@@ -4844,7 +4844,7 @@ TX_START_ERROR:
 				pRaCfg->status = htons(0);
 
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
 				ATEDBGPRINT(RT_DEBUG_TRACE, ("wrq->u.data.length = %d\n", wrq->u.data.length));
@@ -4859,7 +4859,7 @@ TX_START_ERROR:
                 	ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_START_TX_FRAME is done !\n"));
 				}
 			}
-			break;	
+			break;
 
 		case RACFG_CMD_ATE_SET_BW:
 			{
@@ -4867,20 +4867,20 @@ TX_START_ERROR:
 				UCHAR    str[LEN_OF_ARG];
 
 				NdisZeroMemory(str, LEN_OF_ARG);
-				
-				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_BW\n"));				
+
+				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_BW\n"));
 
 				memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
 				value = ntohs(value);
 				sprintf((PCHAR)str, "%d", value);
 
 				Set_ATE_TX_BW_Proc(pAdapter, str);
-				
+
 				// prepare feedback
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4902,7 +4902,7 @@ TX_START_ERROR:
 
 				NdisZeroMemory(str, LEN_OF_ARG);
 
-				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_POWER0\n"));				
+				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_POWER0\n"));
 
 				memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
 				value = ntohs(value);
@@ -4913,7 +4913,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4934,8 +4934,8 @@ TX_START_ERROR:
 				UCHAR    str[LEN_OF_ARG];
 
 				NdisZeroMemory(str, LEN_OF_ARG);
-				
-				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_POWER1\n"));				
+
+				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_POWER1\n"));
 
 				memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
 				value = ntohs(value);
@@ -4946,7 +4946,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -4968,7 +4968,7 @@ TX_START_ERROR:
 
 				NdisZeroMemory(str, LEN_OF_ARG);
 
-				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_FREQ_OFFSET\n"));				
+				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_FREQ_OFFSET\n"));
 
 				memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
 				value = ntohs(value);
@@ -4979,7 +4979,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5008,7 +5008,7 @@ TX_START_ERROR:
 				memcpy_exl(pAdapter, &pRaCfg->data[28], (UCHAR *)&pAdapter->Counters8023.RxNoBuffer, 4);
 				memcpy_exl(pAdapter, &pRaCfg->data[32], (UCHAR *)&pAdapter->WlanCounters.FrameDuplicateCount.u.LowPart, 4);
 				memcpy_exl(pAdapter, &pRaCfg->data[36], (UCHAR *)&pAdapter->RalinkCounters.OneSecFalseCCACnt, 4);
-				
+
 				if (pAdapter->ate.RxAntennaSel == 0)
 				{
 					INT32 RSSI0 = 0;
@@ -5026,14 +5026,14 @@ TX_START_ERROR:
 				else
 				{
 					INT32 RSSI0 = 0;
-				
+
 					RSSI0 = (INT32)(pAdapter->ate.LastRssi0 - pAdapter->BbpRssiToDbmDelta);
 					memcpy_exl(pAdapter, &pRaCfg->data[40], (UCHAR *)&RSSI0, 4);
 					pRaCfg->length = htons(2+44);
 				}
-				pRaCfg->status = htons(0);			
+				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5055,18 +5055,18 @@ TX_START_ERROR:
 
 				NdisZeroMemory(str, LEN_OF_ARG);
 
-				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_RESET_COUNTER\n"));				
+				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_RESET_COUNTER\n"));
 
 				sprintf((PCHAR)str, "%d", value);
 				Set_ResetStatCounter_Proc(pAdapter, str);
 
 				pAdapter->ate.TxDoneCount = 0;
-			
+
 				pRaCfg->length = htons(2);
-				pRaCfg->status = htons(0);			
+				pRaCfg->status = htons(0);
 
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5079,7 +5079,7 @@ TX_START_ERROR:
                 	ATEDBGPRINT(RT_DEBUG_TRACE, ("RACFG_CMD_ATE_RESET_COUNTER is done !\n"));
 				}
 			}
-			
+
 			break;
 
 		case RACFG_CMD_ATE_SEL_TX_ANTENNA:
@@ -5088,8 +5088,8 @@ TX_START_ERROR:
 				UCHAR    str[LEN_OF_ARG];
 
 				NdisZeroMemory(str, LEN_OF_ARG);
-				
-				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SEL_TX_ANTENNA\n"));				
+
+				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SEL_TX_ANTENNA\n"));
 
 				memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
 				value = ntohs(value);
@@ -5100,7 +5100,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5114,15 +5114,15 @@ TX_START_ERROR:
 				}
 			}
 			break;
-			
+
 		case RACFG_CMD_ATE_SEL_RX_ANTENNA:
 			{
 				SHORT    value = 0;
 				UCHAR    str[LEN_OF_ARG];
 
 				NdisZeroMemory(str, LEN_OF_ARG);
-				
-				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SEL_RX_ANTENNA\n"));				
+
+				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SEL_RX_ANTENNA\n"));
 
 				memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
 				value = ntohs(value);
@@ -5133,7 +5133,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5154,8 +5154,8 @@ TX_START_ERROR:
 				UCHAR    str[LEN_OF_ARG];
 
 				NdisZeroMemory(str, LEN_OF_ARG);
-				
-				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_PREAMBLE\n"));				
+
+				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_PREAMBLE\n"));
 
 				memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
 				value = ntohs(value);
@@ -5166,7 +5166,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5187,8 +5187,8 @@ TX_START_ERROR:
 				UCHAR    str[LEN_OF_ARG];
 
 				NdisZeroMemory(str, LEN_OF_ARG);
-				
-				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_CHANNEL\n"));				
+
+				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_CHANNEL\n"));
 
 				memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
 				value = ntohs(value);
@@ -5199,7 +5199,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5226,7 +5226,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5254,7 +5254,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5282,7 +5282,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5304,8 +5304,8 @@ TX_START_ERROR:
 				UCHAR    str[LEN_OF_ARG];
 
 				NdisZeroMemory(str, LEN_OF_ARG);
-				
-				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_RATE\n"));				
+
+				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_RATE\n"));
 
 				memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
 				value = ntohs(value);
@@ -5316,7 +5316,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5337,8 +5337,8 @@ TX_START_ERROR:
 				UCHAR    str[LEN_OF_ARG];
 
 				NdisZeroMemory(str, LEN_OF_ARG);
-				
-				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_FRAME_LEN\n"));				
+
+				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_FRAME_LEN\n"));
 
 				memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
 				value = ntohs(value);
@@ -5349,7 +5349,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5370,8 +5370,8 @@ TX_START_ERROR:
 				UCHAR    str[LEN_OF_ARG];
 
 				NdisZeroMemory(str, LEN_OF_ARG);
-				
-				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_FRAME_COUNT\n"));				
+
+				ATEDBGPRINT(RT_DEBUG_TRACE,("RACFG_CMD_ATE_SET_TX_FRAME_COUNT\n"));
 
 				memcpy((PUCHAR)&value, (PUCHAR)&(pRaCfg->status), 2);
 				value = ntohs(value);
@@ -5397,7 +5397,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5422,7 +5422,7 @@ TX_START_ERROR:
 				pRaCfg->length = htons(2);
 				pRaCfg->status = htons(0);
 				wrq->u.data.length = sizeof(pRaCfg->magic_no) + sizeof(pRaCfg->command_type)
-									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length) 
+									+ sizeof(pRaCfg->command_id) + sizeof(pRaCfg->length)
 									+ sizeof(pRaCfg->sequence) + ntohs(pRaCfg->length);
 
             	if (copy_to_user(wrq->u.data.pointer, pRaCfg, wrq->u.data.length))
@@ -5437,7 +5437,7 @@ TX_START_ERROR:
 			}
 			break;
 		default:
-			break;		
+			break;
 	}
     ASSERT(pRaCfg != NULL);
     if (pRaCfg != NULL)
@@ -5448,7 +5448,7 @@ TX_START_ERROR:
 }
 
 VOID BubbleSort(INT32 n, INT32 a[])
-{ 
+{
 	INT32 k, j, temp;
 
 	for (k = n-1;  k>0;  k--)
@@ -5457,13 +5457,13 @@ VOID BubbleSort(INT32 n, INT32 a[])
 		{
 			if(a[j] > a[j+1])
 			{
-				temp = a[j]; 
-				a[j]=a[j+1]; 
+				temp = a[j];
+				a[j]=a[j+1];
 				a[j+1]=temp;
 			}
 		}
 	}
-} 
+}
 
 VOID CalNoiseLevel(PRTMP_ADAPTER pAd, UCHAR channel, INT32 RSSI[3][10])
 {
@@ -5477,18 +5477,18 @@ VOID CalNoiseLevel(PRTMP_ADAPTER pAd, UCHAR channel, INT32 RSSI[3][10])
 	USHORT	    GainValue = 0, OffsetValue = 0;
 
 	ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &Org_BBP66value);
-	ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R69, &Org_BBP69value);	
+	ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R69, &Org_BBP69value);
 	ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R70, &Org_BBP70value);
 
 	//**********************************************************************
-	// Read the value of LNA gain and Rssi offset 
+	// Read the value of LNA gain and Rssi offset
 	//**********************************************************************
 	RT28xx_EEPROM_READ16(pAd, EEPROM_LNA_OFFSET, GainValue);
 
 	// for Noise Level
 	if (channel <= 14)
 	{
-		LNA_Gain = GainValue & 0x00FF;		 
+		LNA_Gain = GainValue & 0x00FF;
 
 		RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET, OffsetValue);
 		Rssi0Offset = OffsetValue & 0x00FF;
@@ -5506,14 +5506,14 @@ VOID CalNoiseLevel(PRTMP_ADAPTER pAd, UCHAR channel, INT32 RSSI[3][10])
 		RT28xx_EEPROM_READ16(pAd, (EEPROM_RSSI_A_OFFSET + 2)/* 0x4C */, OffsetValue);
 		Rssi2Offset = OffsetValue & 0x00FF;
 	}
-	//**********************************************************************	
+	//**********************************************************************
 	{
 		pAd->ate.Channel = channel;
 		ATEAsicSwitchChannel(pAd);
 		mdelay(5);
 
 		data = 0x10;
-		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, data);	
+		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, data);
 		data = 0x40;
 		ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, data);
 		data = 0x40;
@@ -5529,7 +5529,7 @@ VOID CalNoiseLevel(PRTMP_ADAPTER pAd, UCHAR channel, INT32 RSSI[3][10])
 		for (j = 0; j < 10; j++)
 		{
 			ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R50, &BbpR50Rssi0);
-			ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R51, &BbpR51Rssi1);	
+			ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R51, &BbpR51Rssi1);
 			ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R52, &BbpR52Rssi2);
 
 			mdelay(10);
@@ -5576,17 +5576,17 @@ VOID CalNoiseLevel(PRTMP_ADAPTER pAd, UCHAR channel, INT32 RSSI[3][10])
 
 		mdelay(5);
 
-#if 0// Debug Message................		
+#if 0// Debug Message................
 		ate_print("\n**********************************************************\n");
 		ate_print("Noise Level: Channel %d\n", channel);
-		ate_print("RSSI0 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", 
+		ate_print("RSSI0 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
 			RSSI[0][0], RSSI[0][1], RSSI[0][2],
 			RSSI[0][3], RSSI[0][4], RSSI[0][5],
 			RSSI[0][6], RSSI[0][7], RSSI[0][8],
 			RSSI[0][9]);
 		if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
 		{
-			ate_print("RSSI1 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", 
+			ate_print("RSSI1 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
 				RSSI[1][0], RSSI[1][1], RSSI[1][2],
 				RSSI[1][3], RSSI[1][4], RSSI[1][5],
 				RSSI[1][6], RSSI[1][7], RSSI[1][8],
@@ -5594,14 +5594,14 @@ VOID CalNoiseLevel(PRTMP_ADAPTER pAd, UCHAR channel, INT32 RSSI[3][10])
 		}
 		if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
 		{
-			ate_print("RSSI2 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", 
+			ate_print("RSSI2 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
 				RSSI[2][0], RSSI[2][1], RSSI[2][2],
 				RSSI[2][3], RSSI[2][4], RSSI[2][5],
 				RSSI[2][6], RSSI[2][7], RSSI[2][8],
 				RSSI[2][9]);
 		}
 #endif // 0 //
-		BubbleSort(10, RSSI[0]);	// 1R		
+		BubbleSort(10, RSSI[0]);	// 1R
 
 		if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
 		{
@@ -5611,18 +5611,18 @@ VOID CalNoiseLevel(PRTMP_ADAPTER pAd, UCHAR channel, INT32 RSSI[3][10])
 		if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
 		{
 			BubbleSort(10, RSSI[2]);
-		}	
+		}
 
-#if 0// Debug Message................		
+#if 0// Debug Message................
 		ate_print("\nAfter Sorting....Channel %d\n", channel);
-		ate_print("RSSI0 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", 
+		ate_print("RSSI0 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
 			RSSI[0][0], RSSI[0][1], RSSI[0][2],
 			RSSI[0][3], RSSI[0][4], RSSI[0][5],
 			RSSI[0][6], RSSI[0][7], RSSI[0][8],
 			RSSI[0][9]);
 		if ( pAd->Antenna.field.RxPath >= 2 ) // 2R
 		{
-			ate_print("RSSI1 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", 
+			ate_print("RSSI1 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
 				RSSI[1][0], RSSI[1][1], RSSI[1][2],
 				RSSI[1][3], RSSI[1][4], RSSI[1][5],
 				RSSI[1][6], RSSI[1][7], RSSI[1][8],
@@ -5630,19 +5630,19 @@ VOID CalNoiseLevel(PRTMP_ADAPTER pAd, UCHAR channel, INT32 RSSI[3][10])
 		}
 		if ( pAd->Antenna.field.RxPath >= 3 ) // 3R
 		{
-			ate_print("RSSI2 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", 
+			ate_print("RSSI2 = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
 				RSSI[2][0], RSSI[2][1], RSSI[2][2],
 				RSSI[2][3], RSSI[2][4], RSSI[2][5],
 				RSSI[2][6], RSSI[2][7], RSSI[2][8],
 				RSSI[2][9]);
-		}	
+		}
 		ate_print("**********************************************************\n");
 #endif // 0 //
 	}
 
 	pAd->ate.Channel = Org_Channel;
 	ATEAsicSwitchChannel(pAd);
-	
+
 	// Restore original value
     ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R66, Org_BBP66value);
     ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, Org_BBP69value);
@@ -5652,7 +5652,7 @@ VOID CalNoiseLevel(PRTMP_ADAPTER pAd, UCHAR channel, INT32 RSSI[3][10])
 }
 
 BOOLEAN SyncTxRxConfig(PRTMP_ADAPTER pAd, USHORT offset, UCHAR value)
-{ 
+{
 	UCHAR tmp = 0, bbp_data = 0;
 
 	if (ATE_ON(pAd))
@@ -5690,7 +5690,7 @@ BOOLEAN SyncTxRxConfig(PRTMP_ADAPTER pAd, USHORT offset, UCHAR value)
 					pAd->ate.TxAntennaSel = 2;
 		            break;
 		        default:
-		            DBGPRINT(RT_DEBUG_TRACE, ("%s -- Sth. wrong!  : return FALSE; \n", __FUNCTION__));    
+		            DBGPRINT(RT_DEBUG_TRACE, ("%s -- Sth. wrong!  : return FALSE; \n", __FUNCTION__));
 		            return FALSE;
 		    }
 			break;/* case BBP_R1 */
@@ -5728,35 +5728,35 @@ BOOLEAN SyncTxRxConfig(PRTMP_ADAPTER pAd, USHORT offset, UCHAR value)
 					pAd->ate.RxAntennaSel = 3;
 		            break;
 		        default:
-		            DBGPRINT(RT_DEBUG_ERROR, ("%s -- Impossible!  : return FALSE; \n", __FUNCTION__));    
+		            DBGPRINT(RT_DEBUG_ERROR, ("%s -- Impossible!  : return FALSE; \n", __FUNCTION__));
 		            return FALSE;
 		    }
 			break;/* case BBP_R3 */
 
         default:
-            DBGPRINT(RT_DEBUG_ERROR, ("%s -- Sth. wrong!  : return FALSE; \n", __FUNCTION__));    
+            DBGPRINT(RT_DEBUG_ERROR, ("%s -- Sth. wrong!  : return FALSE; \n", __FUNCTION__));
             return FALSE;
-		
+
 	}
 	return TRUE;
-} 
+}
 
 static VOID memcpy_exl(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len)
 {
 	ULONG i, Value = 0;
 	ULONG *pDst, *pSrc;
 	UCHAR *p8;
-	
+
 	p8 = src;
 	pDst = (ULONG *) dst;
 	pSrc = (ULONG *) src;
-	
+
 	for (i = 0 ; i < (len/4); i++)
 	{
 		/* For alignment issue, we need a variable "Value". */
 		memmove(&Value, pSrc, 4);
-		Value = htonl(Value); 
-		memmove(pDst, &Value, 4);		
+		Value = htonl(Value);
+		memmove(pDst, &Value, 4);
 		pDst++;
 		pSrc++;
 	}
@@ -5764,7 +5764,7 @@ static VOID memcpy_exl(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len)
 	{
 		/* wish that it will never reach here */
 		memmove(&Value, pSrc, (len % 4));
-		Value = htonl(Value); 
+		Value = htonl(Value);
 		memmove(pDst, &Value, (len % 4));
 	}
 }
@@ -5773,9 +5773,9 @@ static VOID memcpy_exs(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, ULONG len)
 {
 	ULONG i;
 	UCHAR *pDst, *pSrc;
-	
+
 	pDst = dst;
-	pSrc = src;	
+	pSrc = src;
 
 	for (i = 0; i < (len/2); i++)
 	{
@@ -5795,7 +5795,7 @@ static VOID RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, UINT32
 {
 	UINT32 i, Value;
 	UINT32 *pDst, *pSrc;
-	
+
 	pDst = (UINT32 *) dst;
 	pSrc = (UINT32 *) src;
 
@@ -5807,23 +5807,23 @@ static VOID RTMP_IO_READ_BULK(PRTMP_ADAPTER pAd, UCHAR *dst, UCHAR *src, UINT32
 		pDst++;
 		pSrc++;
 	}
-	return;	
+	return;
 }
 
 // TODO:
 #if 0
 /* These work only when RALINK_ATE is defined */
 INT Set_TxStart_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ULONG value = simple_strtol(arg, 0, 10);
-	UCHAR buffer[26] = {0x88, 0x02, 0x2c, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x00, 0x55, 0x44, 0x33, 0x22, 0x11, 0xc0, 0x22, 0x00, 0x00};	
+	UCHAR buffer[26] = {0x88, 0x02, 0x2c, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x00, 0x55, 0x44, 0x33, 0x22, 0x11, 0xc0, 0x22, 0x00, 0x00};
 	POS_COOKIE pObj;
 
 	if (pAd->ate.TxStatus != 0)
 		return FALSE;
-	
+
 	pAd->ate.TxInfo = 0x04000000;
 	bzero(&pAd->ate.TxWI, sizeof(TXWI_STRUC));
 	pAd->ate.TxWI.PHYMODE = 0;// MODE_CCK
@@ -5845,7 +5845,7 @@ INT Set_TxStart_Proc(
 #endif  /* end of #if 0 */
 
 INT Set_TxStop_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ATEDBGPRINT(RT_DEBUG_TRACE,("Set_TxStop_Proc\n"));
@@ -5861,7 +5861,7 @@ INT Set_TxStop_Proc(
 }
 
 INT Set_RxStop_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	ATEDBGPRINT(RT_DEBUG_TRACE,("Set_RxStop_Proc\n"));
@@ -5878,17 +5878,17 @@ INT Set_RxStop_Proc(
 
 #if 0
 INT Set_EEWrite_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	USHORT offset = 0, value;
 	PUCHAR p2 = arg;
-	
+
 	while((*p2 != ':') && (*p2 != '\0'))
 	{
 		p2++;
 	}
-	
+
 	if (*p2 == ':')
 	{
 		A2Hex(offset, arg);
@@ -5898,26 +5898,26 @@ INT Set_EEWrite_Proc(
 	{
 		A2Hex(value, arg);
 	}
-	
+
 	if (offset >= EEPROM_SIZE)
 	{
-		ate_print("Offset can not exceed EEPROM_SIZE( == 0x%04x)\n", EEPROM_SIZE);	
+		ate_print("Offset can not exceed EEPROM_SIZE( == 0x%04x)\n", EEPROM_SIZE);
 		return FALSE;
 	}
-	
+
 	RTMP_EEPROM_WRITE16(pAd, offset, value);
 
 	return TRUE;
 }
 
 INT Set_BBPRead_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UCHAR value = 0, offset;
 
-	A2Hex(offset, arg);	
-			
+	A2Hex(offset, arg);
+
 	if (ATE_ON(pAd))
 	{
 		ATE_BBP_IO_READ8_BY_REG_ID(pAd, offset,  &value);
@@ -5928,32 +5928,32 @@ INT Set_BBPRead_Proc(
 	}
 
 	ate_print("%x\n", value);
-		
+
 	return TRUE;
 }
 
 
 INT Set_BBPWrite_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	USHORT offset = 0;
 	PUCHAR p2 = arg;
 	UCHAR value;
-	
+
 	while((*p2 != ':') && (*p2 != '\0'))
 	{
 		p2++;
 	}
-	
+
 	if (*p2 == ':')
 	{
-		A2Hex(offset, arg);	
-		A2Hex(value, p2+ 1);	
+		A2Hex(offset, arg);
+		A2Hex(value, p2+ 1);
 	}
 	else
 	{
-		A2Hex(value, arg);	
+		A2Hex(value, arg);
 	}
 
 	if (ATE_ON(pAd))
@@ -5969,22 +5969,22 @@ INT Set_BBPWrite_Proc(
 }
 
 INT Set_RFWrite_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	PUCHAR p2, p3, p4;
 	ULONG R1, R2, R3, R4;
-	
+
 	p2 = arg;
 
 	while((*p2 != ':') && (*p2 != '\0'))
 	{
 		p2++;
 	}
-	
+
 	if (*p2 != ':')
 		return FALSE;
-	
+
 	p3 = p2 + 1;
 
 	while((*p3 != ':') && (*p3 != '\0'))
@@ -5994,7 +5994,7 @@ INT Set_RFWrite_Proc(
 
 	if (*p3 != ':')
 		return FALSE;
-	
+
 	p4 = p3 + 1;
 
 	while((*p4 != ':') && (*p4 != '\0'))
@@ -6005,17 +6005,17 @@ INT Set_RFWrite_Proc(
 	if (*p4 != ':')
 		return FALSE;
 
-		
-	A2Hex(R1, arg);	
-	A2Hex(R2, p2 + 1);	
-	A2Hex(R3, p3 + 1);	
-	A2Hex(R4, p4 + 1);	
-	
+
+	A2Hex(R1, arg);
+	A2Hex(R2, p2 + 1);
+	A2Hex(R3, p3 + 1);
+	A2Hex(R4, p4 + 1);
+
 	RTMP_RF_IO_WRITE32(pAd, R1);
 	RTMP_RF_IO_WRITE32(pAd, R2);
 	RTMP_RF_IO_WRITE32(pAd, R3);
 	RTMP_RF_IO_WRITE32(pAd, R4);
-	
+
 	return TRUE;
 }
 #endif  // end of #if 0 //
diff --git a/include/rt_ate.h b/rt_ate.h
similarity index 90%
rename from include/rt_ate.h
rename to rt_ate.h
index e97a971..48aa70d 100644
--- a/include/rt_ate.h
+++ b/rt_ate.h
@@ -7,23 +7,23 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
- */ 
+ */
 
 #ifndef __ATE_H__
 #define __ATE_H__
@@ -156,27 +156,27 @@ VOID rt_ee_write_all(
 	IN  USHORT *Data);
 
 INT Set_ATE_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ATE_DA_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ATE_SA_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ATE_BSSID_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ATE_CHANNEL_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ATE_TX_POWER0_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ATE_TX_POWER1_Proc(
@@ -190,21 +190,21 @@ INT	Set_ATE_TX_Antenna_Proc(
 INT	Set_ATE_RX_Antenna_Proc(
 	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
-	
+
 INT	Set_ATE_TX_FREQOFFSET_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ATE_TX_BW_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ATE_TX_LENGTH_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ATE_TX_COUNT_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ATE_TX_MCS_Proc(
@@ -221,43 +221,43 @@ INT	Set_ATE_TX_GI_Proc(
 
 
 INT	Set_ATE_RX_FER_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_ATE_Read_RF_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_ATE_Write_RF1_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_ATE_Write_RF2_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_ATE_Write_RF3_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_ATE_Write_RF4_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_ATE_Load_E2P_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_ATE_Read_E2P_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ATE_Show_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ATE_Help_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 #ifdef RALINK_ATE
@@ -267,9 +267,9 @@ VOID ATE_QA_Statistics(
 	IN PRXWI_STRUC			pRxWI,
 	IN PRT28XX_RXD_STRUC    p28xxRxD,
 	IN PHEADER_802_11		pHeader);
-	
+
 VOID RtmpDoAte(
-	IN	PRTMP_ADAPTER	pAdapter, 
+	IN	PRTMP_ADAPTER	pAdapter,
 	IN	struct iwreq	*wrq);
 
 VOID BubbleSort(
@@ -282,50 +282,50 @@ VOID CalNoiseLevel(
 	OUT INT32           buffer[3][10]);
 
 BOOLEAN SyncTxRxConfig(
-	IN	PRTMP_ADAPTER	pAdapter, 
-	IN	USHORT			offset, 
+	IN	PRTMP_ADAPTER	pAdapter,
+	IN	USHORT			offset,
 	IN	UCHAR			value);
 
 #if 0
 INT Set_TxStart_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 #endif  // 0 //
 
 INT Set_TxStop_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_RxStop_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 #if 0
 INT Set_EERead_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_EEWrite_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_BBPRead_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_BBPWrite_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_RFWrite_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
-#endif // end of #if 0 // 
+#endif // end of #if 0 //
 #endif // RALINK_28xx_QA //
 #endif // RALINK_ATE //
 
 VOID ATEAsicSwitchChannel(
-	IN PRTMP_ADAPTER pAd); 
+	IN PRTMP_ADAPTER pAd);
 
 VOID ATEAsicAdjustTxPower(
 	IN PRTMP_ADAPTER pAd);
diff --git a/include/rt_config.h b/rt_config.h
similarity index 93%
rename from include/rt_config.h
rename to rt_config.h
index 09f853a..7ee7a40 100644
--- a/include/rt_config.h
+++ b/rt_config.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -45,7 +45,7 @@
 #include "includes.h"
 #include <stdio.h>
 #include 	"rt_ucos.h"
-#endif 
+#endif
 
 #ifdef LINUX
 #include	"rt_linux.h"
diff --git a/os/linux/rt_linux.c b/rt_linux.c
similarity index 91%
rename from os/linux/rt_linux.c
rename to rt_linux.c
index e39d80c..374c174 100644
--- a/os/linux/rt_linux.c
+++ b/rt_linux.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
  */
 
@@ -58,31 +58,31 @@ BUILD_TIMER_FUNCTION(DlsTimeoutAction);
 #endif // CONFIG_STA_SUPPORT //
 
 // for wireless system event message
-char const *pWirelessSysEventText[IW_SYS_EVENT_TYPE_NUM] = {    
-	// system status event     
+char const *pWirelessSysEventText[IW_SYS_EVENT_TYPE_NUM] = {
+	// system status event
     "had associated successfully",							/* IW_ASSOC_EVENT_FLAG */
     "had disassociated",									/* IW_DISASSOC_EVENT_FLAG */
     "had deauthenticated",									/* IW_DEAUTH_EVENT_FLAG */
     "had been aged-out and disassociated",					/* IW_AGEOUT_EVENT_FLAG */
-    "occurred CounterMeasures attack",						/* IW_COUNTER_MEASURES_EVENT_FLAG */	
+    "occurred CounterMeasures attack",						/* IW_COUNTER_MEASURES_EVENT_FLAG */
     "occurred replay counter different in Key Handshaking",	/* IW_REPLAY_COUNTER_DIFF_EVENT_FLAG */
     "occurred RSNIE different in Key Handshaking",			/* IW_RSNIE_DIFF_EVENT_FLAG */
     "occurred MIC different in Key Handshaking",			/* IW_MIC_DIFF_EVENT_FLAG */
     "occurred ICV error in RX",								/* IW_ICV_ERROR_EVENT_FLAG */
     "occurred MIC error in RX",								/* IW_MIC_ERROR_EVENT_FLAG */
-	"Group Key Handshaking timeout",						/* IW_GROUP_HS_TIMEOUT_EVENT_FLAG */ 
-	"Pairwise Key Handshaking timeout",						/* IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG */ 
-	"RSN IE sanity check failure",							/* IW_RSNIE_SANITY_FAIL_EVENT_FLAG */ 
-	"set key done in WPA/WPAPSK",							/* IW_SET_KEY_DONE_WPA1_EVENT_FLAG */ 
-	"set key done in WPA2/WPA2PSK",                         /* IW_SET_KEY_DONE_WPA2_EVENT_FLAG */ 
-	"connects with our wireless client",                    /* IW_STA_LINKUP_EVENT_FLAG */ 
+	"Group Key Handshaking timeout",						/* IW_GROUP_HS_TIMEOUT_EVENT_FLAG */
+	"Pairwise Key Handshaking timeout",						/* IW_PAIRWISE_HS_TIMEOUT_EVENT_FLAG */
+	"RSN IE sanity check failure",							/* IW_RSNIE_SANITY_FAIL_EVENT_FLAG */
+	"set key done in WPA/WPAPSK",							/* IW_SET_KEY_DONE_WPA1_EVENT_FLAG */
+	"set key done in WPA2/WPA2PSK",                         /* IW_SET_KEY_DONE_WPA2_EVENT_FLAG */
+	"connects with our wireless client",                    /* IW_STA_LINKUP_EVENT_FLAG */
 	"disconnects with our wireless client",                 /* IW_STA_LINKDOWN_EVENT_FLAG */
 	"scan completed"										/* IW_SCAN_COMPLETED_EVENT_FLAG */
 	"scan terminate!! Busy!! Enqueue fail!!"				/* IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG */
-	};						
+	};
 
 // for wireless IDS_spoof_attack event message
-char const *pWirelessSpoofEventText[IW_SPOOF_EVENT_TYPE_NUM] = {   	
+char const *pWirelessSpoofEventText[IW_SPOOF_EVENT_TYPE_NUM] = {
     "detected conflict SSID",								/* IW_CONFLICT_SSID_EVENT_FLAG */
     "detected spoofed association response",				/* IW_SPOOF_ASSOC_RESP_EVENT_FLAG */
     "detected spoofed reassociation responses",				/* IW_SPOOF_REASSOC_RESP_EVENT_FLAG */
@@ -92,23 +92,23 @@ char const *pWirelessSpoofEventText[IW_SPOOF_EVENT_TYPE_NUM] = {
     "detected spoofed authentication",						/* IW_SPOOF_AUTH_EVENT_FLAG */
     "detected spoofed deauthentication",					/* IW_SPOOF_DEAUTH_EVENT_FLAG */
     "detected spoofed unknown management frame",			/* IW_SPOOF_UNKNOWN_MGMT_EVENT_FLAG */
-	"detected replay attack"								/* IW_REPLAY_ATTACK_EVENT_FLAG */	
+	"detected replay attack"								/* IW_REPLAY_ATTACK_EVENT_FLAG */
 	};
 
 // for wireless IDS_flooding_attack event message
-char const *pWirelessFloodEventText[IW_FLOOD_EVENT_TYPE_NUM] = {   	
+char const *pWirelessFloodEventText[IW_FLOOD_EVENT_TYPE_NUM] = {
 	"detected authentication flooding",						/* IW_FLOOD_AUTH_EVENT_FLAG */
     "detected association request flooding",				/* IW_FLOOD_ASSOC_REQ_EVENT_FLAG */
     "detected reassociation request flooding",				/* IW_FLOOD_REASSOC_REQ_EVENT_FLAG */
     "detected probe request flooding",						/* IW_FLOOD_PROBE_REQ_EVENT_FLAG */
     "detected disassociation flooding",						/* IW_FLOOD_DISASSOC_EVENT_FLAG */
     "detected deauthentication flooding",					/* IW_FLOOD_DEAUTH_EVENT_FLAG */
-    "detected 802.1x eap-request flooding"					/* IW_FLOOD_EAP_REQ_EVENT_FLAG */	
+    "detected 802.1x eap-request flooding"					/* IW_FLOOD_EAP_REQ_EVENT_FLAG */
 	};
 
 /* timeout -- ms */
 VOID RTMP_SetPeriodicTimer(
-	IN	NDIS_MINIPORT_TIMER *pTimer, 
+	IN	NDIS_MINIPORT_TIMER *pTimer,
 	IN	unsigned long timeout)
 {
 	timeout = ((timeout*HZ) / 1000);
@@ -119,13 +119,13 @@ VOID RTMP_SetPeriodicTimer(
 /* convert NdisMInitializeTimer --> RTMP_OS_Init_Timer */
 VOID RTMP_OS_Init_Timer(
 	IN	PRTMP_ADAPTER pAd,
-	IN	NDIS_MINIPORT_TIMER *pTimer, 
+	IN	NDIS_MINIPORT_TIMER *pTimer,
 	IN	TIMER_FUNCTION function,
 	IN	PVOID data)
 {
 	init_timer(pTimer);
     pTimer->data = (unsigned long)data;
-    pTimer->function = function;		
+    pTimer->function = function;
 }
 
 
@@ -154,14 +154,14 @@ VOID RTMP_OS_Del_Timer(
 	OUT	BOOLEAN					*pCancelled)
 {
 	if (timer_pending(pTimer))
-	{	
-		*pCancelled = del_timer_sync(pTimer);	
+	{
+		*pCancelled = del_timer_sync(pTimer);
 	}
 	else
 	{
 		*pCancelled = TRUE;
 	}
-	
+
 }
 
 VOID RTMP_OS_Release_Packet(
@@ -170,7 +170,7 @@ VOID RTMP_OS_Release_Packet(
 {
 	//RTMPFreeNdisPacket(pAd, (struct sk_buff *)pEntry);
 }
-	
+
 // Unify all delay routine by using udelay
 VOID RTMPusecDelay(
 	IN	ULONG	usec)
@@ -194,7 +194,7 @@ NDIS_STATUS os_alloc_mem(
 	IN	PRTMP_ADAPTER pAd,
 	OUT	PUCHAR *mem,
 	IN	ULONG  size)
-{	
+{
 	*mem = (PUCHAR) kmalloc(size, GFP_ATOMIC);
 	if (*mem)
 		return (NDIS_STATUS_SUCCESS);
@@ -207,7 +207,7 @@ NDIS_STATUS os_free_mem(
 	IN	PRTMP_ADAPTER pAd,
 	IN	PUCHAR mem)
 {
-	
+
 	ASSERT(mem);
 	kfree(mem);
 	return (NDIS_STATUS_SUCCESS);
@@ -230,9 +230,9 @@ PNDIS_PACKET RTMP_AllocateFragPacketBuffer(
 	if (pkt)
 	{
 		RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
-	}	
+	}
 
-	return (PNDIS_PACKET) pkt;	
+	return (PNDIS_PACKET) pkt;
 }
 
 
@@ -254,14 +254,14 @@ PNDIS_PACKET RTMP_AllocateTxPacketBuffer(
 	if (pkt)
 	{
 		RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(pkt), PKTSRC_NDIS);
-		*VirtualAddress = (PVOID) pkt->data;	
+		*VirtualAddress = (PVOID) pkt->data;
 	}
 	else
 	{
 		*VirtualAddress = (PVOID) NULL;
-	}	
+	}
 
-	return (PNDIS_PACKET) pkt;	
+	return (PNDIS_PACKET) pkt;
 }
 
 
@@ -277,14 +277,14 @@ VOID build_tx_packet(
 	ASSERT(pPacket);
 	pTxPkt = RTPKT_TO_OSPKT(pPacket);
 
-	NdisMoveMemory(skb_put(pTxPkt, FrameLen), pFrame, FrameLen);	
+	NdisMoveMemory(skb_put(pTxPkt, FrameLen), pFrame, FrameLen);
 }
 
 VOID	RTMPFreeAdapter(
 	IN	PRTMP_ADAPTER	pAd)
 {
     POS_COOKIE os_cookie;
-	int index;	
+	int index;
 
 	os_cookie=(POS_COOKIE)pAd->OS_Cookie;
 
@@ -292,8 +292,8 @@ VOID	RTMPFreeAdapter(
 
 
 	NdisFreeSpinLock(&pAd->MgmtRingLock);
-	
-#ifdef RT2860 
+
+#ifdef RT2860
 	NdisFreeSpinLock(&pAd->RxRingLock);
 #endif // RT2860 //
 
@@ -303,7 +303,7 @@ VOID	RTMPFreeAdapter(
 		NdisFreeSpinLock(&pAd->DeQueueLock[index]);
 		pAd->DeQueueRunning[index] = FALSE;
 	}
-	
+
 	NdisFreeSpinLock(&pAd->irq_lock);
 
 	vfree(pAd); // pci_free_consistent(os_cookie->pci_dev,sizeof(RTMP_ADAPTER),pAd,os_cookie->pAd_pa);
@@ -312,7 +312,7 @@ VOID	RTMPFreeAdapter(
 
 BOOLEAN OS_Need_Clone_Packet(void)
 {
-	return (FALSE);	
+	return (FALSE);
 }
 
 
@@ -325,18 +325,18 @@ BOOLEAN OS_Need_Clone_Packet(void)
 		must have only one NDIS BUFFER
 		return - byte copied. 0 means can't create NDIS PACKET
 		NOTE: internally created NDIS_PACKET should be destroyed by RTMPFreeNdisPacket
-		
+
 	Arguments:
 		pAd 	Pointer to our adapter
 		pInsAMSDUHdr	EWC A-MSDU format has extra 14-bytes header. if TRUE, insert this 14-byte hdr in front of MSDU.
 		*pSrcTotalLen			return total packet length. This lenght is calculated with 802.3 format packet.
-		
+
 	Return Value:
-		NDIS_STATUS_SUCCESS 	
-		NDIS_STATUS_FAILURE 	
-		
+		NDIS_STATUS_SUCCESS
+		NDIS_STATUS_FAILURE
+
 	Note:
-	
+
 	========================================================================
 */
 NDIS_STATUS RTMPCloneNdisPacket(
@@ -351,16 +351,16 @@ NDIS_STATUS RTMPCloneNdisPacket(
 	ASSERT(pInPacket);
 	ASSERT(ppOutPacket);
 
-	// 1. Allocate a packet 
+	// 1. Allocate a packet
 	pkt = dev_alloc_skb(2048);
-	
+
 	if (pkt == NULL)
 	{
 		return NDIS_STATUS_FAILURE;
 	}
 
  	skb_put(pkt, GET_OS_PKT_LEN(pInPacket));
-	NdisMoveMemory(pkt->data, GET_OS_PKT_DATAPTR(pInPacket), GET_OS_PKT_LEN(pInPacket));  
+	NdisMoveMemory(pkt->data, GET_OS_PKT_DATAPTR(pInPacket), GET_OS_PKT_LEN(pInPacket));
 	*ppOutPacket = OSPKT_TO_RTPKT(pkt);
 
 
@@ -385,7 +385,7 @@ NDIS_STATUS RTMPAllocateNdisPacket(
 	ASSERT(pData);
 	ASSERT(DataLen);
 
-	// 1. Allocate a packet 
+	// 1. Allocate a packet
 	pPacket = (PNDIS_PACKET *) dev_alloc_skb(HeaderLen + DataLen + TXPADDING_SIZE);
 	if (pPacket == NULL)
  	{
@@ -427,7 +427,7 @@ VOID RTMPFreeNdisPacket(
 
 
 // IRQL = DISPATCH_LEVEL
-// NOTE: we do have an assumption here, that Byte0 and Byte1 always reasid at the same 
+// NOTE: we do have an assumption here, that Byte0 and Byte1 always reasid at the same
 //			 scatter gather buffer
 NDIS_STATUS Sniff2BytesFromNdisBuffer(
 	IN	PNDIS_BUFFER	pFirstBuffer,
@@ -454,7 +454,7 @@ void RTMP_QueryPacketInfo(
 	pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
 
 	*pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
-	*pSrcBufLen = GET_OS_PKT_LEN(pPacket); 	
+	*pSrcBufLen = GET_OS_PKT_LEN(pPacket);
 }
 
 void RTMP_QueryNextPacketInfo(
@@ -476,8 +476,8 @@ void RTMP_QueryNextPacketInfo(
 		pPacketInfo->TotalPacketLength = GET_OS_PKT_LEN(pPacket);
 
 		*pSrcBufVA = GET_OS_PKT_DATAPTR(pPacket);
-		*pSrcBufLen = GET_OS_PKT_LEN(pPacket); 	
-		*ppPacket = GET_OS_PKT_NEXT(pPacket);		
+		*pSrcBufLen = GET_OS_PKT_LEN(pPacket);
+		*ppPacket = GET_OS_PKT_NEXT(pPacket);
 	}
 	else
 	{
@@ -487,7 +487,7 @@ void RTMP_QueryNextPacketInfo(
 		pPacketInfo->TotalPacketLength = 0;
 
 		*pSrcBufVA = NULL;
-		*pSrcBufLen = 0; 	
+		*pSrcBufLen = 0;
 		*ppPacket = NULL;
 	}
 }
@@ -509,9 +509,9 @@ PNET_DEV get_netdev_from_bssid(
 	ASSERT(dev_p);
 	return dev_p; /* return one of MBSS */
 }
-	
+
 PNDIS_PACKET DuplicatePacket(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PNDIS_PACKET	pPacket,
 	IN	UCHAR			FromWhichBSSID)
 {
@@ -521,7 +521,7 @@ PNDIS_PACKET DuplicatePacket(
 	UCHAR			*pData;
 
 	DataSize = (USHORT) GET_OS_PKT_LEN(pPacket);
-	pData = (PUCHAR) GET_OS_PKT_DATAPTR(pPacket);	
+	pData = (PUCHAR) GET_OS_PKT_DATAPTR(pPacket);
 
 
 	skb = skb_clone(RTPKT_TO_OSPKT(pPacket), MEM_ALLOC_FLAG);
@@ -536,7 +536,7 @@ PNDIS_PACKET DuplicatePacket(
 }
 
 PNDIS_PACKET duplicate_pkt(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			pHeader802_3,
     IN  UINT            HdrLen,
 	IN	PUCHAR			pData,
@@ -549,7 +549,7 @@ PNDIS_PACKET duplicate_pkt(
 
 	if ((skb = __dev_alloc_skb(HdrLen + DataSize + 2, MEM_ALLOC_FLAG)) != NULL)
 	{
-		skb_reserve(skb, 2);				
+		skb_reserve(skb, 2);
 		NdisMoveMemory(skb->tail, pHeader802_3, HdrLen);
 		skb_put(skb, HdrLen);
 		NdisMoveMemory(skb->tail, pData, DataSize);
@@ -568,7 +568,7 @@ PNDIS_PACKET duplicate_pkt_with_TKIP_MIC(
 	IN	PNDIS_PACKET	pPacket)
 {
 	struct sk_buff	*skb, *newskb;
-	
+
 
 	skb = RTPKT_TO_OSPKT(pPacket);
 	if (skb_tailroom(skb) < TKIP_TX_MIC_SIZE)
@@ -591,8 +591,8 @@ PNDIS_PACKET duplicate_pkt_with_TKIP_MIC(
 
 
 PNDIS_PACKET ClonePacket(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	PNDIS_PACKET	pPacket,	
+	IN	PRTMP_ADAPTER	pAd,
+	IN	PNDIS_PACKET	pPacket,
 	IN	PUCHAR			pData,
 	IN	ULONG			DataSize)
 {
@@ -602,7 +602,7 @@ PNDIS_PACKET ClonePacket(
 	ASSERT(pPacket);
 	pRxPkt = RTPKT_TO_OSPKT(pPacket);
 
-	// clone the packet 
+	// clone the packet
 	pClonedPkt = skb_clone(pRxPkt, MEM_ALLOC_FLAG);
 
 	if (pClonedPkt)
@@ -617,11 +617,11 @@ PNDIS_PACKET ClonePacket(
 	return pClonedPkt;
 }
 
-// 
+//
 // change OS packet DataPtr and DataLen
-// 
+//
 void  update_os_packet_info(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	RX_BLK			*pRxBlk,
 	IN  UCHAR			FromWhichBSSID)
 {
@@ -630,7 +630,7 @@ void  update_os_packet_info(
 	ASSERT(pRxBlk->pRxPacket);
 	pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
 
-	pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID); 
+	pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
 	pOSPkt->data = pRxBlk->pData;
 	pOSPkt->len = pRxBlk->DataSize;
 	pOSPkt->tail = pOSPkt->data + pOSPkt->len;
@@ -638,7 +638,7 @@ void  update_os_packet_info(
 
 
 void wlan_802_11_to_802_3_packet(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	RX_BLK			*pRxBlk,
 	IN	PUCHAR			pHeader802_3,
 	IN  UCHAR			FromWhichBSSID)
@@ -650,15 +650,15 @@ void wlan_802_11_to_802_3_packet(
 
 	pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
 
-	pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID); 
+	pOSPkt->dev = get_netdev_from_bssid(pAd, FromWhichBSSID);
 	pOSPkt->data = pRxBlk->pData;
 	pOSPkt->len = pRxBlk->DataSize;
 	pOSPkt->tail = pOSPkt->data + pOSPkt->len;
 
 	//
 	// copy 802.3 header
-	// 
-	// 
+	//
+	//
 
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
@@ -669,7 +669,7 @@ void wlan_802_11_to_802_3_packet(
 
 
 void announce_802_3_packet(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PNDIS_PACKET	pPacket)
 {
 
@@ -694,8 +694,8 @@ PRTMP_SCATTER_GATHER_LIST
 rt_get_sg_list_from_packet(PNDIS_PACKET pPacket, RTMP_SCATTER_GATHER_LIST *sg)
 {
 	sg->NumberOfElements = 1;
-	sg->Elements[0].Address =  GET_OS_PKT_DATAPTR(pPacket);	
-	sg->Elements[0].Length = GET_OS_PKT_LEN(pPacket);	
+	sg->Elements[0].Address =  GET_OS_PKT_DATAPTR(pPacket);
+	sg->Elements[0].Length = GET_OS_PKT_LEN(pPacket);
 	return (sg);
 }
 
@@ -706,12 +706,12 @@ void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen)
 
 	if (RTDebugLevel < RT_DEBUG_TRACE)
 		return;
-	
+
 	pt = pSrcBufVA;
 	printk("%s: %p, len = %d\n",str,  pSrcBufVA, SrcBufLen);
 	for (x=0; x<SrcBufLen; x++)
 	{
-		if (x % 16 == 0) 
+		if (x % 16 == 0)
 			printk("0x%04x : ", x);
 		printk("%02x ", ((unsigned char)pt[x]));
 		if (x%16 == 15) printk("\n");
@@ -721,13 +721,13 @@ void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen)
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Send log message through wireless event
 
 		Support standard iw_event with IWEVCUSTOM. It is used below.
 
-		iwreq_data.data.flags is used to store event_flag that is defined by user. 
+		iwreq_data.data.flags is used to store event_flag that is defined by user.
 		iwreq_data.data.length is the length of the event log.
 
 		The format of the event log is composed of the entry's MAC address and
@@ -735,7 +735,7 @@ void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen)
 
 			ex: 11:22:33:44:55:66 has associated successfully
 
-		p.s. The requirement of Wireless Extension is v15 or newer. 
+		p.s. The requirement of Wireless Extension is v15 or newer.
 
 	========================================================================
 */
@@ -750,10 +750,10 @@ VOID RTMPSendWirelessEvent(
 
 	union 	iwreq_data      wrqu;
 	PUCHAR 	pBuf = NULL, pBufPtr = NULL;
-	USHORT	event, type, BufLen;	
+	USHORT	event, type, BufLen;
 	UCHAR	event_table_len = 0;
 
-	type = Event_flag & 0xFF00;	
+	type = Event_flag & 0xFF00;
 	event = Event_flag & 0x00FF;
 
 	switch (type)
@@ -770,29 +770,29 @@ VOID RTMPSendWirelessEvent(
 			event_table_len = IW_FLOOD_EVENT_TYPE_NUM;
 			break;
 	}
-	
+
 	if (event_table_len == 0)
 	{
-		DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __FUNCTION__, type));			       		       		
+		DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __FUNCTION__, type));
 		return;
 	}
-	
+
 	if (event >= event_table_len)
 	{
-		DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __FUNCTION__, event));			       		       		
+		DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __FUNCTION__, event));
 		return;
-	}	
- 
+	}
+
 	//Allocate memory and copy the msg.
 	if((pBuf = kmalloc(IW_CUSTOM_MAX_LEN, GFP_ATOMIC)) != NULL)
 	{
-		//Prepare the payload 
+		//Prepare the payload
 		memset(pBuf, 0, IW_CUSTOM_MAX_LEN);
 
-		pBufPtr = pBuf;		
+		pBufPtr = pBuf;
 
 		if (pAddr)
-			pBufPtr += sprintf(pBufPtr, "(RT2860) STA(%02x:%02x:%02x:%02x:%02x:%02x) ", PRINT_MAC(pAddr));				
+			pBufPtr += sprintf(pBufPtr, "(RT2860) STA(%02x:%02x:%02x:%02x:%02x:%02x) ", PRINT_MAC(pAddr));
 		else if (BssIdx < MAX_MBSSID_NUM)
 			pBufPtr += sprintf(pBufPtr, "(RT2860) BSS(ra%d) ", BssIdx);
 		else
@@ -806,34 +806,34 @@ VOID RTMPSendWirelessEvent(
 			pBufPtr += sprintf(pBufPtr, "%s", pWirelessFloodEventText[event]);
 		else
 			pBufPtr += sprintf(pBufPtr, "%s", "unknown event");
-		
+
 		pBufPtr[pBufPtr - pBuf] = '\0';
 		BufLen = pBufPtr - pBuf;
-		
-		memset(&wrqu, 0, sizeof(wrqu));	
+
+		memset(&wrqu, 0, sizeof(wrqu));
 	    wrqu.data.flags = Event_flag;
-		wrqu.data.length = BufLen;	
-		
+		wrqu.data.length = BufLen;
+
 		//send wireless event
 	    wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, pBuf);
-	
-		//DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __FUNCTION__, pBuf));	
-	
+
+		//DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __FUNCTION__, pBuf));
+
 		kfree(pBuf);
 	}
 	else
-		DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __FUNCTION__));			       		       				
+		DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __FUNCTION__));
 #else
-	DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __FUNCTION__));	
-#endif  /* WIRELESS_EXT >= 15 */  
+	DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __FUNCTION__));
+#endif  /* WIRELESS_EXT >= 15 */
 }
 
 
 #ifdef CONFIG_STA_SUPPORT
 void send_monitor_packets(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	RX_BLK			*pRxBlk)
-{   	
+{
     struct sk_buff	*pOSPkt;
     wlan_ng_prism2_header *ph;
     int rate_index = 0;
@@ -844,7 +844,7 @@ void send_monitor_packets(
 	54, 108, 162, 216, 324, 432, 486, 540,  14, 29, 43, 57, 87, 115, 130, 144, 29, 59,87,115, 173, 230,260, 288, 30, 60,90,120,180,240,270,300,60,120,180,240,360,480,540,600, 0,1,2,3,4,5,6,7,8,9,10,
 	11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80};
 
-    
+
     ASSERT(pRxBlk->pRxPacket);
     if (pRxBlk->DataSize < 10)
     {
@@ -857,9 +857,9 @@ void send_monitor_packets(
         DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __FUNCTION__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
 		goto err_free_sk_buff;
     }
-        
+
     pOSPkt = RTPKT_TO_OSPKT(pRxBlk->pRxPacket);
-	pOSPkt->dev = get_netdev_from_bssid(pAd, BSS0); 
+	pOSPkt->dev = get_netdev_from_bssid(pAd, BSS0);
     if (pRxBlk->pHeader->FC.Type == BTYPE_DATA)
     {
         pRxBlk->DataSize -= LENGTH_802_11;
@@ -889,7 +889,7 @@ void send_monitor_packets(
         if (header_len <= 40)
             NdisMoveMemory(temp_header, pRxBlk->pData, header_len);
 
-        // skip HW padding 
+        // skip HW padding
     	if (pRxBlk->RxD.L2PAD)
     	    pRxBlk->pData += (header_len + 2);
         else
@@ -920,7 +920,7 @@ void send_monitor_packets(
 
     ph = (wlan_ng_prism2_header *) skb_push(pOSPkt, sizeof(wlan_ng_prism2_header));
 	NdisZeroMemory(ph, sizeof(wlan_ng_prism2_header));
-    
+
     ph->msgcode		    = DIDmsg_lnxind_wlansniffrm;
 	ph->msglen		    = sizeof(wlan_ng_prism2_header);
 	strcpy(ph->devname, pAd->net_dev->name);
@@ -939,7 +939,7 @@ void send_monitor_packets(
 	ph->istx.status = 0;
 	ph->istx.len = 0;
 	ph->istx.data = 0;
- 
+
     ph->channel.did = DIDmsg_lnxind_wlansniffrm_channel;
 	ph->channel.status = 0;
 	ph->channel.len = 4;
@@ -950,12 +950,12 @@ void send_monitor_packets(
 	ph->rssi.status = 0;
 	ph->rssi.len = 4;
     ph->rssi.data = (u_int32_t)RTMPMaxRssi(pAd, ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI0, RSSI_0), ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI1, RSSI_1), ConvertToRssi(pAd, pRxBlk->pRxWI->RSSI2, RSSI_2));;
-            
+
 	ph->signal.did = DIDmsg_lnxind_wlansniffrm_signal;
 	ph->signal.status = 0;
 	ph->signal.len = 4;
 	ph->signal.data = 0; //rssi + noise;
-            
+
 	ph->noise.did = DIDmsg_lnxind_wlansniffrm_noise;
 	ph->noise.status = 0;
 	ph->noise.len = 4;
@@ -970,13 +970,13 @@ void send_monitor_packets(
 #endif // DOT11_N_SUPPORT //
 	if (pRxBlk->pRxWI->PHYMODE == MODE_OFDM)
     	rate_index = (UCHAR)(pRxBlk->pRxWI->MCS) + 4;
-    else 
+    else
     	rate_index = (UCHAR)(pRxBlk->pRxWI->MCS);
     if (rate_index < 0)
         rate_index = 0;
     if (rate_index > 255)
         rate_index = 255;
-    
+
 	ph->rate.did = DIDmsg_lnxind_wlansniffrm_rate;
 	ph->rate.status = 0;
 	ph->rate.len = 4;
@@ -986,19 +986,19 @@ void send_monitor_packets(
     ph->frmlen.status = 0;
 	ph->frmlen.len = 4;
 	ph->frmlen.data	= (u_int32_t)pRxBlk->DataSize;
-    
-    
+
+
     pOSPkt->pkt_type = PACKET_OTHERHOST;
     pOSPkt->protocol = eth_type_trans(pOSPkt, pOSPkt->dev);
     pOSPkt->ip_summed = CHECKSUM_NONE;
     netif_rx(pOSPkt);
-    
+
     return;
 
 err_free_sk_buff:
-	RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);	
+	RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
 	return;
-	
+
 }
 #endif // CONFIG_STA_SUPPORT //
 
@@ -1019,8 +1019,8 @@ void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify)
 	reparent_to_init();
 	strcpy(current->comm, pThreadName);
 
-	siginitsetinv(&current->blocked, sigmask(SIGTERM) | sigmask(SIGKILL));	
-	
+	siginitsetinv(&current->blocked, sigmask(SIGTERM) | sigmask(SIGKILL));
+
 	/* Allow interception of SIGKILL only
 	 * Don't allow other signals to interrupt the transmission */
 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,22)
@@ -1030,25 +1030,25 @@ void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify)
 	spin_unlock_irqrestore(&current->sigmask_lock, flags);
 #endif
 #endif
-	
+
     /* signal that we've started the thread */
 	complete(pNotify);
 
 }
 
-void RTMP_IndicateMediaState(	
+void RTMP_IndicateMediaState(
 	IN	PRTMP_ADAPTER	pAd)
-{	
-	if (pAd->CommonCfg.bWirelessEvent)	
+{
+	if (pAd->CommonCfg.bWirelessEvent)
 	{
 		if (pAd->IndicateMediaState == NdisMediaStateConnected)
 		{
 			RTMPSendWirelessEvent(pAd, IW_STA_LINKUP_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
 		}
 		else
-		{							
-			RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); 		
-		}	
+		{
+			RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
+		}
 	}
 }
 
diff --git a/include/rt_linux.h b/rt_linux.h
similarity index 97%
rename from include/rt_linux.h
rename to rt_linux.h
index 48e5f3e..0cc7cf2 100644
--- a/include/rt_linux.h
+++ b/rt_linux.h
@@ -7,23 +7,23 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
- */ 
+ */
 
 /***********************************************************************/
 /*                                                                     */
@@ -83,7 +83,7 @@
 //#define CONFIG_CKIP_SUPPORT
 
 #undef __inline
-#define __inline	   static inline 
+#define __inline	   static inline
 
 typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_dev);
 
@@ -198,7 +198,7 @@ struct os_cookie {
 	struct pci_dev 			*pci_dev;
 	struct pci_dev 			*parent_pci_dev;
 	dma_addr_t		  		pAd_pa;
-#endif // RT2860 //	
+#endif // RT2860 //
 
 
 	struct tasklet_struct 	rx_done_task;
@@ -211,13 +211,13 @@ struct os_cookie {
 	struct tasklet_struct	tbtt_task;
 #ifdef RT2860
 	struct tasklet_struct	fifo_statistic_full_task;
-#endif // RT2860 //	
+#endif // RT2860 //
 
 
 	unsigned long			apd_pid; //802.1x daemon pid
 	INT						ioctl_if_type;
 	INT 					ioctl_if;
-};	
+};
 
 typedef struct _VIRTUAL_ADAPTER
 {
@@ -233,9 +233,9 @@ typedef struct _VIRTUAL_ADAPTER
         printk(KERN_WARNING __FILE__ ":%d assert " #x "failed\n", __LINE__);    \
     }                                                                           \
 }
-	
-typedef struct os_cookie	* POS_COOKIE;	
-typedef struct pci_dev 		* PPCI_DEV;	
+
+typedef struct os_cookie	* POS_COOKIE;
+typedef struct pci_dev 		* PPCI_DEV;
 typedef struct net_device	* PNET_DEV;
 typedef void				* PNDIS_PACKET;
 typedef char				NDIS_PACKET;
@@ -298,14 +298,14 @@ void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int
 
 
 typedef struct timer_list	RTMP_OS_TIMER;
-	
+
 
 
 typedef struct  _RALINK_TIMER_STRUCT    {
     RTMP_OS_TIMER		TimerObj;       // Ndis Timer object
 	BOOLEAN				Valid;			// Set to True when call RTMPInitTimer
     BOOLEAN             State;          // True if timer cancelled
-    BOOLEAN	      		PeriodicType;	// True if timer is periodic timer 
+    BOOLEAN	      		PeriodicType;	// True if timer is periodic timer
     BOOLEAN             Repeat;         // True if periodic timer
     ULONG               TimerValue;     // Timer value in milliseconds
 	ULONG				cookie;			// os specific object
@@ -344,7 +344,7 @@ extern ULONG    RTDebugLevel;
 {									\
 	printk Fmt;					\
 }
-			
+
 
 #else
 #define DBGPRINT(Level, Fmt)
@@ -559,10 +559,10 @@ void linux_##_func(unsigned long data)											\
 
 
 #define DECLARE_TIMER_FUNCTION(_func)			\
-void linux_##_func(unsigned long data)			
+void linux_##_func(unsigned long data)
 
 #define GET_TIMER_FUNCTION(_func)				\
-		linux_##_func							
+		linux_##_func
 
 DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
 DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
@@ -596,10 +596,10 @@ void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
 
 
 /*
- * packet helper 
- * 	- convert internal rt packet to os packet or 
+ * packet helper
+ * 	- convert internal rt packet to os packet or
  *             os packet to rt packet
- */      
+ */
 #define RTPKT_TO_OSPKT(_p)		((struct sk_buff *)(_p))
 #define OSPKT_TO_RTPKT(_p)		((PNDIS_PACKET)(_p))
 
@@ -663,10 +663,10 @@ void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
 #define RTMP_GET_PACKET_UP(_p)					(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0])
 
 // Fragment #
-#define RTMP_SET_PACKET_FRAGMENTS(_p, _num)		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num)   
+#define RTMP_SET_PACKET_FRAGMENTS(_p, _num)		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num)
 #define RTMP_GET_PACKET_FRAGMENTS(_p)			(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1])
 
-// 0x0 ~0x7f: TX to AP's own BSS which has the specified AID. if AID>127, set bit 7 in RTMP_SET_PACKET_EMACTAB too. 
+// 0x0 ~0x7f: TX to AP's own BSS which has the specified AID. if AID>127, set bit 7 in RTMP_SET_PACKET_EMACTAB too.
 //(this value also as MAC(on-chip WCID) table index)
 // 0x80~0xff: TX to a WDS link. b0~6: WDS index
 #define RTMP_SET_PACKET_WCID(_p, _wdsidx)		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx)
@@ -674,18 +674,18 @@ void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
 
 // 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet
 #define RTMP_SET_PACKET_SOURCE(_p, _pktsrc)		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc)
-#define RTMP_GET_PACKET_SOURCE(_p)       		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3])  
+#define RTMP_GET_PACKET_SOURCE(_p)       		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3])
 
 // RTS/CTS-to-self protection method
 #define RTMP_SET_PACKET_RTS(_p, _num)      		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num)
-#define RTMP_GET_PACKET_RTS(_p)          		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4])  
+#define RTMP_GET_PACKET_RTS(_p)          		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4])
 // see RTMP_S(G)ET_PACKET_EMACTAB
 
 // TX rate index
 #define RTMP_SET_PACKET_TXRATE(_p, _rate)		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate)
 #define RTMP_GET_PACKET_TXRATE(_p)		  		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5])
 
-// From which Interface 
+// From which Interface
 #define RTMP_SET_PACKET_IF(_p, _ifdx)		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx)
 #define RTMP_GET_PACKET_IF(_p)		  		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6])
 #define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss)		RTMP_SET_PACKET_IF((_p), (_bss))
@@ -716,7 +716,7 @@ void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
 #define RTMP_PACKET_SPECIFIC_LLCSNAP	0x20
 
 //Specific
-#define RTMP_SET_PACKET_SPECIFIC(_p, _flg)	   	(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)												
+#define RTMP_SET_PACKET_SPECIFIC(_p, _flg)	   	(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
 
 //DHCP
 #define RTMP_SET_PACKET_DHCP(_p, _flg)   													\
@@ -768,7 +768,7 @@ void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
 				else																		\
 					(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_LLCSNAP);		\
 			}while(0)
-			
+
 #define RTMP_GET_PACKET_LLCSNAP(_p)		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP)
 
 // IP
@@ -779,13 +779,13 @@ void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
 				else																		\
 					(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_IPV4);	\
 			}while(0)
-			
+
 #define RTMP_GET_PACKET_IPV4(_p)		(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4)
-	
+
 #endif
 
 
-// If this flag is set, it indicates that this EAPoL frame MUST be clear. 
+// If this flag is set, it indicates that this EAPoL frame MUST be clear.
 #define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg)   (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg)
 #define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p)         (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12])
 
@@ -807,7 +807,7 @@ void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
 #define NdisZeroMemory(Destination, Length)         memset(Destination, 0, Length)
 #define NdisFillMemory(Destination, Length, Fill)   memset(Destination, Fill, Length)
 #define NdisEqualMemory(Source1, Source2, Length)   (!memcmp(Source1, Source2, Length))
-#define RTMPEqualMemory(Source1, Source2, Length)	(!memcmp(Source1, Source2, Length))							
+#define RTMPEqualMemory(Source1, Source2, Length)	(!memcmp(Source1, Source2, Length))
 
 
 #define RTMP_INC_REF(_A)		0
diff --git a/os/linux/rt_main_dev.c b/rt_main_dev.c
similarity index 98%
rename from os/linux/rt_main_dev.c
rename to rt_main_dev.c
index c346743..98d1bbb 100644
--- a/os/linux/rt_main_dev.c
+++ b/rt_main_dev.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
     Module Name:
@@ -235,19 +235,19 @@ int rt28xx_close(IN PNET_DEV dev)
 #ifdef CONFIG_STA_SUPPORT
 	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 	{
-#ifdef RT2860	
+#ifdef RT2860
 		RTMPPCIeLinkCtrlValueRestore(pAd, RESTORE_CLOSE);
 #endif // RT2860 //
 
 		// If dirver doesn't wake up firmware here,
 		// NICLoadFirmware will hang forever when interface is up again.
 		if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
-        {      
+        {
 		    AsicForceWakeup(pAd, TRUE);
         }
 
 #ifdef QOS_DLS_SUPPORT
-		// send DLS-TEAR_DOWN message, 
+		// send DLS-TEAR_DOWN message,
 		if (pAd->CommonCfg.bDLSCapable)
 		{
 			UCHAR i;
@@ -282,7 +282,7 @@ int rt28xx_close(IN PNET_DEV dev)
 		{
 			MLME_DISASSOC_REQ_STRUCT	DisReq;
 			MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
-    
+
 			COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid);
 			DisReq.Reason =  REASON_DEAUTH_STA_LEAVING;
 
@@ -298,7 +298,7 @@ int rt28xx_close(IN PNET_DEV dev)
 			pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;
 			MlmeDisassocReqAction(pAd, MsgElem);
 			kfree(MsgElem);
-			
+
 			RTMPusecDelay(1000);
 		}
 
@@ -324,7 +324,7 @@ int rt28xx_close(IN PNET_DEV dev)
 
 		MlmeRadioOff(pAd);
 #ifdef RT2860
-		pAd->bPCIclkOff = FALSE;    
+		pAd->bPCIclkOff = FALSE;
 #endif // RT2860 //
 	}
 #endif // CONFIG_STA_SUPPORT //
@@ -339,7 +339,7 @@ int rt28xx_close(IN PNET_DEV dev)
 			RTMPusecDelay(1000);
 		}
 	}
-	
+
 	// Stop Mlme state machine
 	MlmeHalt(pAd);
 
@@ -387,7 +387,7 @@ int rt28xx_close(IN PNET_DEV dev)
 	// Free BA reorder resource
 	ba_reordering_resource_release(pAd);
 #endif // DOT11_N_SUPPORT //
-	
+
 
 	RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);
 
@@ -498,9 +498,9 @@ static int rt28xx_init(IN struct net_device *net_dev)
 		DBGPRINT_ERR(("NICInitializeAdapter failed, Status[=0x%08x]\n", Status));
 		if (Status != NDIS_STATUS_SUCCESS)
 		goto err3;
-	}	
+	}
 
-	// Read parameters from Config File 
+	// Read parameters from Config File
 	Status = RTMPReadParametersHook(pAd);
 
 	printk("1. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
@@ -527,7 +527,7 @@ static int rt28xx_init(IN struct net_device *net_dev)
 	printk("2. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
 
 	// We should read EEPROM for all cases.  rt2860b
-	NICReadEEPROMParameters(pAd, mac);	
+	NICReadEEPROMParameters(pAd, mac);
 
 	printk("3. Phy Mode = %d\n", pAd->CommonCfg.PhyMode);
 
@@ -562,7 +562,7 @@ static int rt28xx_init(IN struct net_device *net_dev)
 	// Initialize RF register to default value
 	//
 	AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
-	AsicLockChannel(pAd, pAd->CommonCfg.Channel);		
+	AsicLockChannel(pAd, pAd->CommonCfg.Channel);
 
 	// 8051 firmware require the signal during booting time.
 	AsicSendCommandToMcu(pAd, 0x72, 0xFF, 0x00, 0x00);
@@ -631,7 +631,7 @@ Note:
 ========================================================================
 */
 int rt28xx_open(IN PNET_DEV dev)
-{				 
+{
 	struct net_device * net_dev = (struct net_device *)dev;
 	PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)net_dev->priv;
 	int retval = 0;
@@ -657,7 +657,7 @@ int rt28xx_open(IN PNET_DEV dev)
 	}
 
 #if WIRELESS_EXT >= 12
-	if (net_dev->priv_flags == INT_MAIN) 
+	if (net_dev->priv_flags == INT_MAIN)
 	{
 		if (pAd->OpMode == OPMODE_AP)
 			net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_ap_iw_handler_def;
@@ -711,7 +711,7 @@ int rt28xx_open(IN PNET_DEV dev)
 		NdisZeroMemory(pAd->StaCfg.dev_name, 16);
 		NdisMoveMemory(pAd->StaCfg.dev_name, net_dev->name, strlen(net_dev->name));
 	}
-#endif // CONFIG_STA_SUPPORT //	
+#endif // CONFIG_STA_SUPPORT //
 
 	// Set up the Mac address
 	NdisMoveMemory(net_dev->dev_addr, (void *) pAd->CurrentAddress, 6);
@@ -808,7 +808,7 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p
 	dev->stop = MainVirtualIF_close; //rt28xx_close;
 	dev->priv_flags = INT_MAIN;
 	dev->do_ioctl = rt28xx_ioctl;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)    
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
     dev->validate_addr = NULL;
 #endif
 	// find available device name
@@ -820,7 +820,7 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p
 		else
 #endif // MULTIPLE_CARD_SUPPORT //
 		sprintf(slot_name, "ra%d", i);
-	    
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
@@ -839,16 +839,16 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p
 				break;
 		}
 #endif
-		if(device == NULL)  
+		if(device == NULL)
 			break;
 	}
-	
+
 	if(i == 8)
 	{
 		DBGPRINT(RT_DEBUG_ERROR, ("No available slot name\n"));
 		Status = NDIS_STATUS_FAILURE;
-	} 
-	else 
+	}
+	else
 	{
 #ifdef MULTIPLE_CARD_SUPPORT
 		if (pAd->MC_RowID >= 0)
@@ -860,7 +860,7 @@ static NDIS_STATUS rt_ieee80211_if_setup(struct net_device *dev, PRTMP_ADAPTER p
 	}
 
 	return Status;
-	
+
 }
 
 
@@ -882,7 +882,7 @@ Note:
 */
 extern INT RTMPGetKeyParameter(
     IN  PCHAR   key,
-    OUT PCHAR   dest,   
+    OUT PCHAR   dest,
     IN  INT     destsize,
     IN  PCHAR   buffer);
 
@@ -971,7 +971,7 @@ BOOLEAN RTMP_CardInfoRead(
 
 	// open card information file
 	srcf = filp_open(CARD_INFO_PATH, O_RDONLY, 0);
-	if (IS_ERR(srcf)) 
+	if (IS_ERR(srcf))
 	{
 		/* card information file does not exist */
 			DBGPRINT(RT_DEBUG_TRACE,
@@ -1188,7 +1188,7 @@ BOOLEAN RTMP_CardInfoRead(
 						NdisMoveMemory(pAd->MC_FileName, tmpbuf , strlen(tmpbuf));
 						pAd->MC_FileName[strlen(tmpbuf)] = '\0';
 						flg_match_ok = TRUE;
-	
+
 						DBGPRINT(RT_DEBUG_TRACE,
 								("Card Profile Name = %s\n", pAd->MC_FileName));
 					}
@@ -1282,7 +1282,7 @@ INT __devinit   rt28xx_probe(
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
     SET_MODULE_OWNER(net_dev);
-#endif 
+#endif
 
 	netif_stop_queue(net_dev);
 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
@@ -1300,7 +1300,7 @@ INT __devinit   rt28xx_probe(
 	RT28XX_HANDLE_DEV_ASSIGN(handle, dev_p);
 
 	status = RTMPAllocAdapterBlock(handle, &pAd);
-	if (status != NDIS_STATUS_SUCCESS) 
+	if (status != NDIS_STATUS_SUCCESS)
 		goto err_out_free_netdev;
 
 	net_dev->priv = (PVOID)pAd;
@@ -1360,7 +1360,7 @@ INT __devinit   rt28xx_probe(
 err_out_unmap:
 	RTMPFreeAdapter(pAd);
 	RT28XX_UNMAP();
-	
+
 err_out_free_netdev:
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
     free_netdev(net_dev);
@@ -1388,11 +1388,11 @@ Arguments:
     sk_buff *skb		the pointer refer to a sk_buffer.
 
 Return Value:
-    0					
+    0
 
 Note:
-	This function is the entry point of Tx Path for Os delivery packet to 
-	our driver. You only can put OS-depened & STA/AP common handle procedures 
+	This function is the entry point of Tx Path for Os delivery packet to
+	our driver. You only can put OS-depened & STA/AP common handle procedures
 	in here.
 ========================================================================
 */
@@ -1432,7 +1432,7 @@ int rt28xx_packet_xmit(struct sk_buff *skb)
 		RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
 		goto done;
 	}
-	
+
 	RTMP_SET_PACKET_5VT(pPacket, 0);
 #ifdef CONFIG_5VT_ENHANCE
     if (*(int*)(skb->cb) == BRIDGE_TAG) {
@@ -1453,7 +1453,7 @@ int rt28xx_packet_xmit(struct sk_buff *skb)
 
 	status = 0;
 done:
-			   
+
 	return status;
 }
 
@@ -1475,7 +1475,7 @@ Note:
 ========================================================================
 */
 INT rt28xx_send_packets(
-	IN struct sk_buff 		*skb_p, 
+	IN struct sk_buff 		*skb_p,
 	IN struct net_device 	*net_dev)
 {
     RTMP_ADAPTER *pAd = net_dev->priv;
@@ -1544,7 +1544,7 @@ struct iw_statistics *rt28xx_get_wireless_stats(
 
 
 	DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
-	
+
 	pAd->iw_stats.status = 0; // Status - device dependent for now
 
 	// link quality
@@ -1558,7 +1558,7 @@ struct iw_statistics *rt28xx_get_wireless_stats(
 #endif // CONFIG_STA_SUPPORT //
 
 	pAd->iw_stats.qual.noise = pAd->BbpWriteLatch[66]; // noise level (dBm)
-	
+
 	pAd->iw_stats.qual.noise += 256 - 143;
 	pAd->iw_stats.qual.updated = 1;     // Flags to know if updated
 #ifdef IW_QUAL_DBM
@@ -1567,7 +1567,7 @@ struct iw_statistics *rt28xx_get_wireless_stats(
 
 	pAd->iw_stats.discard.nwid = 0;     // Rx : Wrong nwid/essid
 	pAd->iw_stats.miss.beacon = 0;      // Missed beacons/superframe
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("<--- rt28xx_get_wireless_stats\n"));
 	return &pAd->iw_stats;
 } /* End of rt28xx_get_wireless_stats */
@@ -1582,8 +1582,8 @@ void tbtt_tasklet(unsigned long data)
 }
 
 INT rt28xx_ioctl(
-	IN	struct net_device	*net_dev, 
-	IN	OUT	struct ifreq	*rq, 
+	IN	struct net_device	*net_dev,
+	IN	OUT	struct ifreq	*rq,
 	IN	INT					cmd)
 {
 	VIRTUAL_ADAPTER	*pVirtualAd = NULL;
@@ -1644,7 +1644,7 @@ struct net_device_stats *RT28xx_get_ether_stats(
 
 	if (pAd)
 	{
-	   
+
 		pAd->stats.rx_packets = pAd->WlanCounters.ReceivedFragmentCount.QuadPart;
 		pAd->stats.tx_packets = pAd->WlanCounters.TransmittedFragmentCount.QuadPart;
 
@@ -1677,7 +1677,7 @@ struct net_device_stats *RT28xx_get_ether_stats(
 	    // for cslip etc
 	    pAd->stats.rx_compressed = 0;
 	    pAd->stats.tx_compressed = 0;
-		
+
 		return &pAd->stats;
 	}
 	else
diff --git a/os/linux/rt_profile.c b/rt_profile.c
similarity index 95%
rename from os/linux/rt_profile.c
rename to rt_profile.c
index 8dc5471..a38e557 100644
--- a/os/linux/rt_profile.c
+++ b/rt_profile.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
  */
 
@@ -29,7 +29,7 @@
 
 #ifdef DOT11_N_SUPPORT
 static void HTParametersHook(
-	IN	PRTMP_ADAPTER pAd, 
+	IN	PRTMP_ADAPTER pAd,
 	IN	CHAR		  *pValueStr,
 	IN	CHAR		  *pInput);
 #endif // DOT11_N_SUPPORT //
@@ -66,10 +66,10 @@ BOOLEAN rtstrmactohex(char *s1, char *s2)
 BOOLEAN rtstrcasecmp(char *s1, char *s2)
 {
 	char *p1 = s1, *p2 = s2;
-	
+
 	if (strlen(s1) != strlen(s2))
 		return FALSE;
-	
+
 	while(*p1 != '\0')
 	{
 		if((*p1 != *p2) && ((*p1 ^ *p2) != 0x20))
@@ -77,7 +77,7 @@ BOOLEAN rtstrcasecmp(char *s1, char *s2)
 		p1++;
 		p2++;
 	}
-	
+
 	return TRUE;
 }
 
@@ -116,7 +116,7 @@ char * rtstrstruncasecmp(char * s1, char * s2)
 
 		s1++;
 	}
-	
+
 	return NULL; // not found
 }
 
@@ -134,9 +134,9 @@ char * rtstrstr(const char * s1,const char * s2)
 	l2 = strlen(s2);
 	if (!l2)
 		return (char *) s1;
-	
+
 	l1 = strlen(s1);
-	
+
 	while (l1 >= l2)
 	{
 		l1--;
@@ -144,10 +144,10 @@ char * rtstrstr(const char * s1,const char * s2)
 			return (char *) s1;
 		s1++;
 	}
-	
+
 	return NULL;
 }
- 
+
 /**
  * rstrtok - Split a string into tokens
  * @s: The string to be searched
@@ -191,7 +191,7 @@ INT delimitcnt(char * s,const char * ct)
 {
 	INT count = 0;
 	/* point to the beginning of the line */
-	const char *token = s; 
+	const char *token = s;
 
 	for ( ;; )
 	{
@@ -200,17 +200,17 @@ INT delimitcnt(char * s,const char * ct)
         if ( token == NULL )
 		{
 			/* advanced to the terminating null character */
-			break; 
+			break;
 		}
 		/* skip the delimiter */
-	    ++token; 
+	    ++token;
 
 		/*
 		 * Print the found text: use len with %.*s to specify field width.
 		 */
-        
+
 		/* accumulate delimiter count */
-	    ++count; 
+	    ++count;
 	}
     return count;
 }
@@ -218,7 +218,7 @@ INT delimitcnt(char * s,const char * ct)
 /*
   * converts the Internet host address from the standard numbers-and-dots notation
   * into binary data.
-  * returns nonzero if the address is valid, zero if not.	
+  * returns nonzero if the address is valid, zero if not.
   */
 int rtinet_aton(const char *cp, unsigned int *addr)
 {
@@ -231,8 +231,8 @@ int rtinet_aton(const char *cp, unsigned int *addr)
 	for (;;)
     {
          /*
-          * Collect number up to ``.''. 
-          * Values are specified as for C: 
+          * Collect number up to ``.''.
+          * Values are specified as for C:
           *	0x=hex, 0=octal, other=decimal.
           */
          val = 0;
@@ -274,43 +274,43 @@ int rtinet_aton(const char *cp, unsigned int *addr)
          else
              break;
      }
- 
+
      /*
       * Check for trailing junk.
       */
      while (*cp)
          if (!isspace((unsigned char) *cp++))
              return 0;
- 
+
      /*
       * Concoct the address according to the number of parts specified.
       */
      n = pp - parts + 1;
      switch (n)
      {
- 
+
          case 1:         /* a -- 32 bits */
              break;
- 
+
          case 2:         /* a.b -- 8.24 bits */
              if (val > 0xffffff)
                  return 0;
              val |= parts[0] << 24;
              break;
- 
+
          case 3:         /* a.b.c -- 8.8.16 bits */
              if (val > 0xffff)
                  return 0;
              val |= (parts[0] << 24) | (parts[1] << 16);
              break;
- 
+
          case 4:         /* a.b.c.d -- 8.8.8.8 bits */
              if (val > 0xff)
                  return 0;
              val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
              break;
      }
-	      
+
      *addr = htonl(val);
      return 1;
 
@@ -353,7 +353,7 @@ PUCHAR  RTMPFindSection(
 
     Arguments:
         key                         Pointer to key string
-        dest                        Pointer to destination      
+        dest                        Pointer to destination
         destsize                    The datasize of the destination
         buffer                      Pointer to the buffer to start find the key
 
@@ -367,7 +367,7 @@ PUCHAR  RTMPFindSection(
 */
 INT RTMPGetKeyParameter(
     IN  PCHAR   key,
-    OUT PCHAR   dest,   
+    OUT PCHAR   dest,
     IN  INT     destsize,
     IN  PCHAR   buffer)
 {
@@ -384,7 +384,7 @@ INT RTMPGetKeyParameter(
 
 	if(temp_buf1 == NULL)
         return (FALSE);
-	
+
 	//temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
 	os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
 	if(temp_buf2 == NULL)
@@ -392,7 +392,7 @@ INT RTMPGetKeyParameter(
 		os_free_mem(NULL, temp_buf1);
         return (FALSE);
 	}
-	
+
     //find section
     if((offset = RTMPFindSection(buffer)) == NULL)
     {
@@ -446,7 +446,7 @@ INT RTMPGetKeyParameter(
            break;
     }
 
-    len = strlen(ptr);    
+    len = strlen(ptr);
     memset(dest, 0x00, destsize);
     strncpy(dest, ptr, len >= destsize ?  destsize: len);
 
@@ -463,7 +463,7 @@ INT RTMPGetKeyParameter(
 
     Arguments:
         key                         Pointer to key string
-        dest                        Pointer to destination      
+        dest                        Pointer to destination
         destsize                    The datasize of the destination
         buffer                      Pointer to the buffer to start find the key
 
@@ -478,7 +478,7 @@ INT RTMPGetKeyParameter(
 */
 INT RTMPGetCriticalParameter(
     IN  PCHAR   key,
-    OUT PCHAR   dest,   
+    OUT PCHAR   dest,
     IN  INT     destsize,
     IN  PCHAR   buffer)
 {
@@ -495,7 +495,7 @@ INT RTMPGetCriticalParameter(
 
 	if(temp_buf1 == NULL)
         return (FALSE);
-	
+
 	//temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
 	os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
 	if(temp_buf2 == NULL)
@@ -503,7 +503,7 @@ INT RTMPGetCriticalParameter(
 		os_free_mem(NULL, temp_buf1);
         return (FALSE);
 	}
-	
+
     //find section
     if((offset = RTMPFindSection(buffer)) == NULL)
     {
@@ -560,7 +560,7 @@ INT RTMPGetCriticalParameter(
            break;
     }
 
-    len = strlen(ptr);    
+    len = strlen(ptr);
     memset(dest, 0x00, destsize);
     strncpy(dest, ptr, len >= destsize ?  destsize: len);
 
@@ -577,7 +577,7 @@ INT RTMPGetCriticalParameter(
 
     Arguments:
         key                         Pointer to key string
-        dest                        Pointer to destination      
+        dest                        Pointer to destination
         destsize                    The datasize of the destination
         buffer                      Pointer to the buffer to start find the key
 
@@ -591,8 +591,8 @@ INT RTMPGetCriticalParameter(
 */
 INT RTMPGetKeyParameterWithOffset(
     IN  PCHAR   key,
-    OUT PCHAR   dest,   
-    OUT	USHORT	*end_offset,		
+    OUT PCHAR   dest,
+    OUT	USHORT	*end_offset,
     IN  INT     destsize,
     IN  PCHAR   buffer,
     IN	BOOLEAN	bTrimSpace)
@@ -607,20 +607,20 @@ INT RTMPGetKeyParameterWithOffset(
 
 	if (*end_offset >= MAX_INI_BUFFER_SIZE)
 		return (FALSE);
-	
+
 	os_alloc_mem(NULL, &temp_buf1, MAX_PARAM_BUFFER_SIZE);
 
 	if(temp_buf1 == NULL)
         return (FALSE);
-		
+
 	os_alloc_mem(NULL, &temp_buf2, MAX_PARAM_BUFFER_SIZE);
 	if(temp_buf2 == NULL)
 	{
 		os_free_mem(NULL, temp_buf1);
         return (FALSE);
 	}
-	
-    //find section		
+
+    //find section
 	if(*end_offset == 0)
     {
 		if ((offset = RTMPFindSection(buffer)) == NULL)
@@ -631,8 +631,8 @@ INT RTMPGetKeyParameterWithOffset(
 		}
     }
 	else
-		offset = buffer + (*end_offset);	
-		
+		offset = buffer + (*end_offset);
+
     strcpy(temp_buf1, "\n");
     strcat(temp_buf1, key);
     strcat(temp_buf1, "=");
@@ -648,7 +648,7 @@ INT RTMPGetKeyParameterWithOffset(
     start_ptr+=strlen("\n");
     if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
        end_ptr=start_ptr+strlen(start_ptr);
-	
+
     if (end_ptr<start_ptr)
     {
 		os_free_mem(NULL, temp_buf1);
@@ -680,7 +680,7 @@ INT RTMPGetKeyParameterWithOffset(
            break;
     }
 
-    len = strlen(ptr);    
+    len = strlen(ptr);
     memset(dest, 0x00, destsize);
     strncpy(dest, ptr, len >= destsize ?  destsize: len);
 
@@ -696,12 +696,12 @@ static int rtmp_parse_key_buffer_from_file(IN  PRTMP_ADAPTER pAd,IN  char *buffe
 	INT			i = BSSIdx, idx = KeyIdx;
 	ULONG		KeyLen;
 	UCHAR		CipherAlg = CIPHER_WEP64;
-	
+
 	keybuff = buffer;
 	KeyLen = strlen(keybuff);
 
 	if (KeyType == 1)
-	{//Ascii								
+	{//Ascii
 		if( (KeyLen == 5) || (KeyLen == 13))
 		{
 			pAd->SharedKey[i][idx].KeyLen = KeyLen;
@@ -711,8 +711,8 @@ static int rtmp_parse_key_buffer_from_file(IN  PRTMP_ADAPTER pAd,IN  char *buffe
 			else
 				CipherAlg = CIPHER_WEP128;
 			pAd->SharedKey[i][idx].CipherAlg = CipherAlg;
-	
-			DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));		
+
+			DBGPRINT(RT_DEBUG_TRACE, ("I/F(ra%d) Key%dStr=%s and type=%s\n", i, idx+1, keybuff, (KeyType == 0) ? "Hex":"Ascii"));
 			return 1;
 		}
 		else
@@ -746,7 +746,7 @@ static int rtmp_parse_key_buffer_from_file(IN  PRTMP_ADAPTER pAd,IN  char *buffe
 static void rtmp_read_key_parms_from_file(IN  PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
 {
 	char		tok_str[16];
-	PUCHAR		macptr;						
+	PUCHAR		macptr;
 	INT			i = 0, idx;
 	ULONG		KeyType[MAX_MBSSID_NUM];
 	ULONG		KeyIdx;
@@ -768,8 +768,8 @@ static void rtmp_read_key_parms_from_file(IN  PRTMP_ADAPTER pAd, char *tmpbuf, c
 
 			DBGPRINT(RT_DEBUG_TRACE, ("DefaultKeyID(0~3)=%d\n", pAd->StaCfg.DefaultKeyId));
 		}
-#endif // CONFIG_STA_SUPPORT //		
-	}	   
+#endif // CONFIG_STA_SUPPORT //
+	}
 
 
 	for (idx = 0; idx < 4; idx++)
@@ -801,10 +801,10 @@ static void rtmp_read_key_parms_from_file(IN  PRTMP_ADAPTER pAd, char *tmpbuf, c
 #ifdef CONFIG_STA_SUPPORT
 static void rtmp_read_sta_wmm_parms_from_file(IN  PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
 {
-	PUCHAR					macptr;						
+	PUCHAR					macptr;
 	INT						i=0;
 	BOOLEAN					bWmmEnable = FALSE;
-	
+
 	//WmmCapable
 	if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer))
 	{
@@ -817,7 +817,7 @@ static void rtmp_read_sta_wmm_parms_from_file(IN  PRTMP_ADAPTER pAd, char *tmpbu
 		{
 			pAd->CommonCfg.bWmmCapable = FALSE;
 		}
-		
+
 		DBGPRINT(RT_DEBUG_TRACE, ("WmmCapable=%d\n", pAd->CommonCfg.bWmmCapable));
 	}
 
@@ -840,7 +840,7 @@ static void rtmp_read_sta_wmm_parms_from_file(IN  PRTMP_ADAPTER pAd, char *tmpbu
 
 	//AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
 	if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer))
-	{			
+	{
 		for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
 		{
 			pAd->CommonCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
@@ -866,14 +866,14 @@ static void rtmp_read_sta_wmm_parms_from_file(IN  PRTMP_ADAPTER pAd, char *tmpbu
 		if(RTMPGetKeyParameter("APSDAC", tmpbuf, 32, buffer))
 		{
 			BOOLEAN apsd_ac[4];
-						
+
 			for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
 			{
 				apsd_ac[i] = (BOOLEAN)simple_strtol(macptr, 0, 10);
 
 				DBGPRINT(RT_DEBUG_TRACE, ("APSDAC%d  %d\n", i,  apsd_ac[i]));
 			}
-					
+
 			pAd->CommonCfg.bAPSDAC_BE = apsd_ac[0];
 			pAd->CommonCfg.bAPSDAC_BK = apsd_ac[1];
 			pAd->CommonCfg.bAPSDAC_VI = apsd_ac[2];
@@ -901,7 +901,7 @@ NDIS_STATUS	RTMPReadParametersHook(
 #endif // CONFIG_STA_SUPPORT //
 
 
-	PUCHAR					macptr;							
+	PUCHAR					macptr;
 	INT						i = 0;
 
 	buffer = kmalloc(MAX_INI_BUFFER_SIZE, MEM_ALLOC_FLAG);
@@ -924,7 +924,7 @@ NDIS_STATUS	RTMPReadParametersHook(
 #endif // MULTIPLE_CARD_SUPPORT //
 
 	// Save uid and gid used for filesystem access.
-	// Set user and group to 0 (root)	
+	// Set user and group to 0 (root)
 	orgfsuid = current->fsuid;
 	orgfsgid = current->fsgid;
 	current->fsuid=current->fsgid = 0;
@@ -934,11 +934,11 @@ NDIS_STATUS	RTMPReadParametersHook(
 	if (src && *src)
 	{
 		srcf = filp_open(src, O_RDONLY, 0);
-		if (IS_ERR(srcf)) 
+		if (IS_ERR(srcf))
 		{
 			DBGPRINT(RT_DEBUG_ERROR, ("--> Error %ld opening %s\n", -PTR_ERR(srcf),src));
 		}
-		else 
+		else
 		{
 			// The object must have a read method
 			if (srcf->f_op && srcf->f_op->read)
@@ -994,7 +994,7 @@ NDIS_STATUS	RTMPReadParametersHook(
 						IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 							pAd->StaCfg.StaOriGeography = pAd->CommonCfg.Geography;
 #endif // EXT_BUILD_CHANNEL_LIST //
-#endif // CONFIG_STA_SUPPORT //							
+#endif // CONFIG_STA_SUPPORT //
 							DBGPRINT(RT_DEBUG_TRACE, ("ChannelGeography=%d\n", pAd->CommonCfg.Geography));
 						}
 					}
@@ -1028,7 +1028,7 @@ NDIS_STATUS	RTMPReadParametersHook(
 					}
 #endif // CONFIG_STA_SUPPORT //
 
-#ifdef CONFIG_STA_SUPPORT										
+#ifdef CONFIG_STA_SUPPORT
 					IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 					{
 						//NetworkType
@@ -1044,7 +1044,7 @@ NDIS_STATUS	RTMPReadParametersHook(
 							DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __FUNCTION__, pAd->StaCfg.BssType));
 						}
 					}
-#endif // CONFIG_STA_SUPPORT //				
+#endif // CONFIG_STA_SUPPORT //
 					//Channel
 					if(RTMPGetKeyParameter("Channel", tmpbuf, 10, buffer))
 					{
@@ -1148,12 +1148,12 @@ NDIS_STATUS	RTMPReadParametersHook(
 							pAd->CommonCfg.RtsThreshold  = (USHORT)RtsThresh;
 						else
 							pAd->CommonCfg.RtsThreshold = MAX_RTS_THRESHOLD;
-						
+
 						DBGPRINT(RT_DEBUG_TRACE, ("RTSThreshold=%d\n", pAd->CommonCfg.RtsThreshold));
 					}
 					//FragThreshold
 					if(RTMPGetKeyParameter("FragThreshold", tmpbuf, 10, buffer))
-					{		
+					{
 						FragThresh = simple_strtol(tmpbuf, 0, 10);
 						pAd->CommonCfg.bUseZeroToDisableFragment = FALSE;
 
@@ -1288,7 +1288,7 @@ NDIS_STATUS	RTMPReadParametersHook(
 
 					//WirelessEvent
 					if(RTMPGetKeyParameter("WirelessEvent", tmpbuf, 10, buffer))
-					{				
+					{
 #if WIRELESS_EXT >= 15
 					    if(simple_strtol(tmpbuf, 0, 10) != 0)
 							pAd->CommonCfg.bWirelessEvent = simple_strtol(tmpbuf, 0, 10);
@@ -1300,7 +1300,7 @@ NDIS_STATUS	RTMPReadParametersHook(
    						DBGPRINT(RT_DEBUG_TRACE, ("WirelessEvent=%d\n", pAd->CommonCfg.bWirelessEvent));
 					}
 					if(RTMPGetKeyParameter("WiFiTest", tmpbuf, 10, buffer))
-					{				
+					{
 					    if(simple_strtol(tmpbuf, 0, 10) != 0)
 							pAd->CommonCfg.bWiFiTest= simple_strtol(tmpbuf, 0, 10);
 						else
@@ -1324,11 +1324,11 @@ NDIS_STATUS	RTMPReadParametersHook(
 							    pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
 							else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
 							    pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-#ifdef WPA_SUPPLICANT_SUPPORT							
+#ifdef WPA_SUPPLICANT_SUPPORT
 							else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
 							    pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
 							else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
-							    pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;  
+							    pAd->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
 #endif // WPA_SUPPLICANT_SUPPORT //
 				                        else
 				                            pAd->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
@@ -1343,24 +1343,24 @@ NDIS_STATUS	RTMPReadParametersHook(
 					if(RTMPGetKeyParameter("EncrypType", tmpbuf, 128, buffer))
 					{
 
-#ifdef CONFIG_STA_SUPPORT 
+#ifdef CONFIG_STA_SUPPORT
 						IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 						{
-							if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))						
-								pAd->StaCfg.WepStatus	= Ndis802_11WEPEnabled;													
-							else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))						
-								pAd->StaCfg.WepStatus	= Ndis802_11Encryption2Enabled;													
-							else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))						
-								pAd->StaCfg.WepStatus	= Ndis802_11Encryption3Enabled;														 
-							else						
-								pAd->StaCfg.WepStatus	= Ndis802_11WEPDisabled;													
+							if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
+								pAd->StaCfg.WepStatus	= Ndis802_11WEPEnabled;
+							else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))
+								pAd->StaCfg.WepStatus	= Ndis802_11Encryption2Enabled;
+							else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))
+								pAd->StaCfg.WepStatus	= Ndis802_11Encryption3Enabled;
+							else
+								pAd->StaCfg.WepStatus	= Ndis802_11WEPDisabled;
 
 							// Update all wepstatus related
 							pAd->StaCfg.PairCipher		= pAd->StaCfg.WepStatus;
 							pAd->StaCfg.GroupCipher 	= pAd->StaCfg.WepStatus;
-							pAd->StaCfg.OrigWepStatus 	= pAd->StaCfg.WepStatus; 
-							pAd->StaCfg.bMixCipher 		= FALSE;	
-							
+							pAd->StaCfg.OrigWepStatus 	= pAd->StaCfg.WepStatus;
+							pAd->StaCfg.bMixCipher 		= FALSE;
+
 							DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus));
 						}
 #endif // CONFIG_STA_SUPPORT //
@@ -1372,14 +1372,14 @@ NDIS_STATUS	RTMPReadParametersHook(
 					IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 					{
 						if(RTMPGetCriticalParameter("WPAPSK", tmpbuf, 512, buffer))
-						{						
+						{
 							int     err=0;
 
-							tmpbuf[strlen(tmpbuf)] = '\0'; // make STA can process .$^& for WPAPSK input 
+							tmpbuf[strlen(tmpbuf)] = '\0'; // make STA can process .$^& for WPAPSK input
 
 							if ((pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
 								(pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
-								(pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone) 
+								(pAd->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
 								)
 							{
 								err = 1;
@@ -1388,7 +1388,7 @@ NDIS_STATUS	RTMPReadParametersHook(
 							{
 								PasswordHash((char *)tmpbuf, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen, keyMaterial);
 								NdisMoveMemory(pAd->StaCfg.PMK, keyMaterial, 32);
-	                            
+
 							}
 							else if (strlen(tmpbuf) == 64)
 							{
@@ -1415,13 +1415,13 @@ NDIS_STATUS	RTMPReadParametersHook(
 								}
 
 								DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __FUNCTION__, tmpbuf));
-							} 
+							}
 						}
 					}
-#endif // CONFIG_STA_SUPPORT //													
+#endif // CONFIG_STA_SUPPORT //
 
 					//DefaultKeyID, KeyType, KeyStr
-					rtmp_read_key_parms_from_file(pAd, tmpbuf, buffer);					
+					rtmp_read_key_parms_from_file(pAd, tmpbuf, buffer);
 
 #ifdef DOT11_N_SUPPORT
 					HTParametersHook(pAd, tmpbuf, buffer);
@@ -1463,8 +1463,8 @@ NDIS_STATUS	RTMPReadParametersHook(
 										pAd->StaCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
 									pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
 									pAd->StaCfg.DefaultListenCount = 5;
-								}							
-								else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0) 
+								}
+								else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0)
 									|| (strcmp(tmpbuf, "FAST_PSP") == 0))
 								{
 									// do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
@@ -1476,7 +1476,7 @@ NDIS_STATUS	RTMPReadParametersHook(
 									pAd->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
 									pAd->StaCfg.DefaultListenCount = 3;
 								}
-								else if ((strcmp(tmpbuf, "Legacy_PSP") == 0) || (strcmp(tmpbuf, "legacy_psp") == 0) 
+								else if ((strcmp(tmpbuf, "Legacy_PSP") == 0) || (strcmp(tmpbuf, "legacy_psp") == 0)
 									|| (strcmp(tmpbuf, "LEGACY_PSP") == 0))
 								{
 									// do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
@@ -1517,14 +1517,14 @@ NDIS_STATUS	RTMPReadParametersHook(
 
 							if (lInfo > 90 || lInfo < 60)
 								pAd->StaCfg.dBmToRoam = -70;
-							else    
+							else
 								pAd->StaCfg.dBmToRoam = (CHAR)(-1)*lInfo;
 
 							DBGPRINT(RT_DEBUG_TRACE, ("RoamThreshold=%d  dBm\n", pAd->StaCfg.dBmToRoam));
 						}
 
 						if(RTMPGetKeyParameter("TGnWifiTest", tmpbuf, 10, buffer))
-						{				
+						{
 							if(simple_strtol(tmpbuf, 0, 10) == 0)
 								pAd->StaCfg.bTGnWifiTest = FALSE;
 							else
@@ -1540,9 +1540,9 @@ NDIS_STATUS	RTMPReadParametersHook(
 			{
 				DBGPRINT(RT_DEBUG_TRACE, ("--> %s does not have a write method\n", src));
 			}
-			
+
 			retval=filp_close(srcf,NULL);
-			
+
 			if (retval)
 			{
 				DBGPRINT(RT_DEBUG_TRACE, ("--> Error %d closing %s\n", -retval, src));
@@ -1557,12 +1557,12 @@ NDIS_STATUS	RTMPReadParametersHook(
 	kfree(buffer);
 	kfree(tmpbuf);
 
-	return (NDIS_STATUS_SUCCESS);	
+	return (NDIS_STATUS_SUCCESS);
 }
 
 #ifdef DOT11_N_SUPPORT
 static void	HTParametersHook(
-	IN	PRTMP_ADAPTER pAd, 
+	IN	PRTMP_ADAPTER pAd,
 	IN	CHAR		  *pValueStr,
 	IN	CHAR		  *pInput)
 {
@@ -1694,7 +1694,7 @@ static void	HTParametersHook(
 	{
 		Value = simple_strtol(pValueStr, 0, 10);
 		if (Value == 0)
-		{			
+		{
 			pAd->CommonCfg.bRdg = FALSE;
 		}
 		else
@@ -1728,7 +1728,7 @@ static void	HTParametersHook(
 	{
 		Value = simple_strtol(pValueStr, 0, 10);
 		if (Value <=7 && Value >= 0)
-		{		
+		{
 			pAd->CommonCfg.BACapability.field.MpduDensity = Value;
 			DBGPRINT(RT_DEBUG_TRACE, ("HT: MPDU Density = %d\n", Value));
 		}
@@ -1745,7 +1745,7 @@ static void	HTParametersHook(
 		Value = simple_strtol(pValueStr, 0, 10);
 
 		if (Value >=1 && Value <= 64)
-		{		
+		{
 			pAd->CommonCfg.REGBACapability.field.RxBAWinLimit = Value;
 			pAd->CommonCfg.BACapability.field.RxBAWinLimit = Value;
 			DBGPRINT(RT_DEBUG_TRACE, ("HT: BA Windw Size = %d\n", Value));
@@ -1772,7 +1772,7 @@ static void	HTParametersHook(
 		{
 			pAd->CommonCfg.RegTransmitSetting.field.ShortGI = GI_800;
 		}
-		
+
 		DBGPRINT(RT_DEBUG_TRACE, ("HT: Guard Interval = %s\n", (Value==GI_400) ? "400" : "800" ));
 	}
 
@@ -1789,7 +1789,7 @@ static void	HTParametersHook(
 		else
 		{
 			pAd->CommonCfg.RegTransmitSetting.field.HTMODE  = HTMODE_MM;
-		}		
+		}
 
 		DBGPRINT(RT_DEBUG_TRACE, ("HT: Operate Mode = %s\n", (Value==HTMODE_GF) ? "Green Field" : "Mixed Mode" ));
 	}
@@ -1798,7 +1798,7 @@ static void	HTParametersHook(
 	if (RTMPGetKeyParameter("FixedTxMode", pValueStr, 25, pInput))
 	{
 		UCHAR	fix_tx_mode;
-	
+
 #ifdef CONFIG_STA_SUPPORT
 		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 		{
@@ -1807,7 +1807,7 @@ static void	HTParametersHook(
 			if (strcmp(pValueStr, "OFDM") == 0 || strcmp(pValueStr, "ofdm") == 0)
 			{
 				fix_tx_mode = FIXED_TXMODE_OFDM;
-			}	
+			}
 			else if (strcmp(pValueStr, "CCK") == 0 || strcmp(pValueStr, "cck") == 0)
 			{
 		        fix_tx_mode = FIXED_TXMODE_CCK;
@@ -1815,22 +1815,22 @@ static void	HTParametersHook(
 			else if (strcmp(pValueStr, "HT") == 0 || strcmp(pValueStr, "ht") == 0)
 			{
 		        fix_tx_mode = FIXED_TXMODE_HT;
-		}	
-		else 
+		}
+		else
 		{
 				Value = simple_strtol(pValueStr, 0, 10);
 				// 1 : CCK
 				// 2 : OFDM
 				// otherwise : HT
 				if (Value == FIXED_TXMODE_CCK || Value == FIXED_TXMODE_OFDM)
-					fix_tx_mode = Value;	
+					fix_tx_mode = Value;
 				else
 					fix_tx_mode = FIXED_TXMODE_HT;
 		}
 
 			pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode = fix_tx_mode;
 			DBGPRINT(RT_DEBUG_TRACE, ("Fixed Tx Mode = %d\n", fix_tx_mode));
-			
+
 		}
 #endif // CONFIG_STA_SUPPORT //
 	}
@@ -1848,7 +1848,7 @@ static void	HTParametersHook(
 		else
 		{
             pAd->CommonCfg.RegTransmitSetting.field.BW  = BW_20;
-		}		
+		}
 
 #ifdef MCAST_RATE_SPECIFIC
 		pAd->CommonCfg.MCastPhyMode.field.BW = pAd->CommonCfg.RegTransmitSetting.field.BW;
@@ -1863,13 +1863,13 @@ static void	HTParametersHook(
 
 		if (Value == 0)
 		{
-			
+
 			pAd->CommonCfg.RegTransmitSetting.field.EXTCHA  = EXTCHA_BELOW;
 		}
 		else
 		{
             pAd->CommonCfg.RegTransmitSetting.field.EXTCHA = EXTCHA_ABOVE;
-		}		
+		}
 
 		DBGPRINT(RT_DEBUG_TRACE, ("HT: Ext Channel = %s\n", (Value==0) ? "BELOW" : "ABOVE" ));
 	}
@@ -1878,7 +1878,7 @@ static void	HTParametersHook(
 	if (RTMPGetKeyParameter("HT_MCS", pValueStr, 50, pInput))
 	{
 
-#ifdef CONFIG_STA_SUPPORT 	
+#ifdef CONFIG_STA_SUPPORT
 		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
 		{
 			Value = simple_strtol(pValueStr, 0, 10);
@@ -1896,15 +1896,15 @@ static void	HTParametersHook(
 				DBGPRINT(RT_DEBUG_TRACE, ("HT: MCS = AUTO\n"));
 		}
 	}
-#endif // CONFIG_STA_SUPPORT //		
+#endif // CONFIG_STA_SUPPORT //
 	}
 
-	// STBC 
+	// STBC
     if (RTMPGetKeyParameter("HT_STBC", pValueStr, 25, pInput))
 	{
 		Value = simple_strtol(pValueStr, 0, 10);
 		if (Value == STBC_USE)
-		{		
+		{
 			pAd->CommonCfg.RegTransmitSetting.field.STBC = STBC_USE;
 		}
 		else
@@ -1919,7 +1919,7 @@ static void	HTParametersHook(
 	{
 		Value = simple_strtol(pValueStr, 0, 10);
 		if (Value == 0)
-		{		
+		{
 			pAd->CommonCfg.bForty_Mhz_Intolerant = FALSE;
 		}
 		else
diff --git a/include/rtmp.h b/rtmp.h
similarity index 91%
rename from include/rtmp.h
rename to rtmp.h
index 7259f38..4119542 100644
--- a/include/rtmp.h
+++ b/rtmp.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
     Module Name:
@@ -35,7 +35,7 @@
     --------    ----------    ----------------------------------------------
     Paul Lin    2002-08-01    created
     James Tan   2002-09-06    modified (Revise NTCRegTable)
-    John Chang  2004-09-06    modified for RT2600     
+    John Chang  2004-09-06    modified for RT2600
 */
 #ifndef __RTMP_H__
 #define __RTMP_H__
@@ -45,7 +45,7 @@
 
 
 #ifdef CONFIG_STA_SUPPORT
-#include <aironet.h>
+#include "aironet.h"
 #endif // CONFIG_STA_SUPPORT //
 
 //#define DBG_DIAGNOSE		1
@@ -418,7 +418,7 @@ typedef struct  _QUEUE_HEADER   {
 }
 
 // Increase TxTsc value for next transmission
-// TODO: 
+// TODO:
 // When i==6, means TSC has done one full cycle, do re-keying stuff follow specs
 // Should send a special event microsoft defined to request re-key
 #define INC_TX_TSC(_tsc)                                \
@@ -799,7 +799,7 @@ typedef struct _RTMP_SCATTER_GATHER_LIST {
 #define LEAP_ON(_p)                 (((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP)
 #define LEAP_CCKM_ON(_p)            ((((_p)->StaCfg.LeapAuthMode) == CISCO_AuthModeLEAP) && ((_p)->StaCfg.LeapAuthInfo.CCKM == TRUE))
 
-// if orginal Ethernet frame contains no LLC/SNAP, then an extra LLC/SNAP encap is required 
+// if orginal Ethernet frame contains no LLC/SNAP, then an extra LLC/SNAP encap is required
 #define EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(_pBufVA, _pExtraLlcSnapEncap)		\
 {																\
 	if (((*(_pBufVA + 12) << 8) + *(_pBufVA + 13)) > 1500)		\
@@ -844,7 +844,7 @@ typedef struct _RTMP_SCATTER_GATHER_LIST {
 }
 
 // if pData has no LLC/SNAP (neither RFC1042 nor Bridge tunnel), keep it that way.
-// else if the received frame is LLC/SNAP-encaped IPX or APPLETALK, preserve the LLC/SNAP field 
+// else if the received frame is LLC/SNAP-encaped IPX or APPLETALK, preserve the LLC/SNAP field
 // else remove the LLC/SNAP field from the result Ethernet frame
 // Patch for WHQL only, which did not turn on Netbios but use IPX within its payload
 // Note:
@@ -1006,7 +1006,7 @@ typedef struct  _RTMP_REORDERBUF
 }   RTMP_REORDERBUF, *PRTMP_REORDERBUF;
 
 //
-// Control block (Descriptor) for all ring descriptor DMA operation, buffer must be 
+// Control block (Descriptor) for all ring descriptor DMA operation, buffer must be
 // contiguous physical memory. NDIS_PACKET stored the binding Rx packet descriptor
 // which won't be released, driver has to wait until upper layer return the packet
 // before giveing up this rx ring descriptor to ASIC. NDIS_BUFFER is assocaited pair
@@ -1042,8 +1042,8 @@ typedef struct _RTMP_RX_BUF
 typedef struct _RTMP_TX_RING
 {
 	RTMP_DMACB  Cell[TX_RING_SIZE];
-	UINT32		TxCpuIdx;	
-	UINT32		TxDmaIdx;   
+	UINT32		TxCpuIdx;
+	UINT32		TxDmaIdx;
 	UINT32		TxSwFreeIdx; 	// software next free tx index
 } RTMP_TX_RING, *PRTMP_TX_RING;
 
@@ -1154,13 +1154,13 @@ typedef struct _COUNTER_RALINK {
 	ULONG		TxAgg15MPDUCount;
 	ULONG		TxAgg16MPDUCount;
 
-	LARGE_INTEGER       TransmittedOctetsInAMSDU; 
-	LARGE_INTEGER       TransmittedAMSDUCount; 
-	LARGE_INTEGER       ReceivedOctesInAMSDUCount; 
-	LARGE_INTEGER       ReceivedAMSDUCount; 
+	LARGE_INTEGER       TransmittedOctetsInAMSDU;
+	LARGE_INTEGER       TransmittedAMSDUCount;
+	LARGE_INTEGER       ReceivedOctesInAMSDUCount;
+	LARGE_INTEGER       ReceivedAMSDUCount;
 	LARGE_INTEGER       TransmittedAMPDUCount;
 	LARGE_INTEGER       TransmittedMPDUsInAMPDUCount;
-	LARGE_INTEGER       TransmittedOctetsInAMPDUCount; 		
+	LARGE_INTEGER       TransmittedOctetsInAMPDUCount;
 	LARGE_INTEGER       MPDUInReceivedAMPDUCount;
 } COUNTER_RALINK, *PCOUNTER_RALINK;
 
@@ -1199,17 +1199,17 @@ typedef struct  _RECEIVE_SETTING {
 #ifdef RT_BIG_ENDIAN
 	USHORT		MIMO:1;
 	USHORT		OFDM:1;
-	USHORT		rsv:3;	
-	USHORT		STBC:2;	//SPACE 
+	USHORT		rsv:3;
+	USHORT		STBC:2;	//SPACE
 	USHORT		ShortGI:1;
 	USHORT		Mode:2;	//channel bandwidth 20MHz or 40 MHz
-	USHORT   	NumOfRX:2;                 // MIMO. WE HAVE 3R 
+	USHORT   	NumOfRX:2;                 // MIMO. WE HAVE 3R
 #else
-	USHORT   	NumOfRX:2;                 // MIMO. WE HAVE 3R 
+	USHORT   	NumOfRX:2;                 // MIMO. WE HAVE 3R
 	USHORT		Mode:2;	//channel bandwidth 20MHz or 40 MHz
 	USHORT		ShortGI:1;
-	USHORT		STBC:2;	//SPACE 
-	USHORT		rsv:3;	 
+	USHORT		STBC:2;	//SPACE
+	USHORT		rsv:3;
 	USHORT		OFDM:1;
 	USHORT		MIMO:1;
 #endif
@@ -1223,12 +1223,12 @@ typedef struct  _WEP_KEY {
 
 typedef struct _CIPHER_KEY {
 	UCHAR   Key[16];            // right now we implement 4 keys, 128 bits max
-	UCHAR   RxMic[8];			// make alignment 
+	UCHAR   RxMic[8];			// make alignment
 	UCHAR   TxMic[8];
 	UCHAR   TxTsc[6];           // 48bit TSC value
 	UCHAR   RxTsc[6];           // 48bit TSC value
 	UCHAR   CipherAlg;          // 0-none, 1:WEP64, 2:WEP128, 3:TKIP, 4:AES, 5:CKIP64, 6:CKIP128
-	UCHAR   KeyLen; 
+	UCHAR   KeyLen;
 #ifdef CONFIG_STA_SUPPORT
 	UCHAR   BssId[6];
 #endif // CONFIG_STA_SUPPORT //
@@ -1253,8 +1253,8 @@ typedef struct _SOFT_RX_ANT_DIVERSITY_STRUCT {
 	UCHAR     Pair2SecondaryRxAnt;   // 0:Ant-E3, 1:Ant-E4
 	SHORT     Pair1AvgRssi[2];       // AvgRssi[0]:E1, AvgRssi[1]:E2
 	SHORT     Pair2AvgRssi[2];       // AvgRssi[0]:E3, AvgRssi[1]:E4
-	SHORT     Pair1LastAvgRssi;      // 
-	SHORT     Pair2LastAvgRssi;      // 
+	SHORT     Pair1LastAvgRssi;      //
+	SHORT     Pair2LastAvgRssi;      //
 	ULONG     RcvPktNumWhenEvaluate;
 	BOOLEAN   FirstPktArrivedWhenEvaluate;
 	RALINK_TIMER_STRUCT    RxAntDiversityTimer;
@@ -1296,7 +1296,7 @@ typedef struct {
 typedef struct  _TUPLE_CACHE    {
 	BOOLEAN         Valid;
 	UCHAR           MacAddress[MAC_ADDR_LEN];
-	USHORT          Sequence; 
+	USHORT          Sequence;
 	USHORT          Frag;
 } TUPLE_CACHE, *PTUPLE_CACHE;
 
@@ -1328,7 +1328,7 @@ typedef struct  _PACKET_INFO    {
 typedef struct  _TKIP_KEY_INFO  {
 	UINT        nBytesInM;  // # bytes in M for MICKEY
 	ULONG       IV16;
-	ULONG       IV32;   
+	ULONG       IV32;
 	ULONG       K0;         // for MICKEY Low
 	ULONG       K1;         // for MICKEY Hig
 	ULONG       L;          // Current state for MICKEY
@@ -1410,7 +1410,7 @@ typedef struct _MLME_STRUCT {
 	STATE_MACHINE_FUNC      AironetFunc[AIRONET_FUNC_SIZE];
 #endif // CONFIG_STA_SUPPORT //
 	STATE_MACHINE_FUNC      ActFunc[ACT_FUNC_SIZE];
-	// Action 
+	// Action
 	STATE_MACHINE           ActMachine;
 
 
@@ -1419,8 +1419,8 @@ typedef struct _MLME_STRUCT {
 	STATE_MACHINE_FUNC      DlsFunc[DLS_FUNC_SIZE];
 #endif // QOS_DLS_SUPPORT //
 
-	
-	
+
+
 
 	ULONG                   ChannelQuality;  // 0..100, Channel Quality Indication for Roaming
 	ULONG                   Now32;           // latch the value of NdisGetSystemUpTime()
@@ -1438,7 +1438,7 @@ typedef struct _MLME_STRUCT {
 	RALINK_TIMER_STRUCT     LinkUpTimer;
 #ifdef RT2860
     UCHAR                   bPsPollTimerRunning;
-    RALINK_TIMER_STRUCT     PsPollTimer;    
+    RALINK_TIMER_STRUCT     PsPollTimer;
 	RALINK_TIMER_STRUCT     RadioOnOffTimer;
 #endif // RT2860 //
 	ULONG                   PeriodicRound;
@@ -1449,7 +1449,7 @@ typedef struct _MLME_STRUCT {
 	BOOLEAN					bEnableAutoAntennaCheck;
 	RALINK_TIMER_STRUCT		RxAntEvalTimer;
 
-	
+
 } MLME_STRUCT, *PMLME_STRUCT;
 
 // structure for radar detection and channel switch
@@ -1490,7 +1490,7 @@ typedef struct CARRIER_DETECTION_s
 #endif // CARRIER_DETECTION_SUPPORT //
 
 typedef enum _REC_BLOCKACK_STATUS
-{	
+{
     Recipient_NONE=0,
 	Recipient_USED,
 	Recipient_HandleRes,
@@ -1547,7 +1547,7 @@ typedef struct {
 typedef struct  PACKED _OID_BA_REC_ENTRY{
 	UCHAR   MACAddr[MAC_ADDR_LEN];
 	UCHAR   BaBitmap;   // if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize
-	UCHAR   rsv; 
+	UCHAR   rsv;
 	UCHAR   BufSize[8];
 	REC_BLOCKACK_STATUS	REC_BA_Status[8];
 } OID_BA_REC_ENTRY, *POID_BA_REC_ENTRY;
@@ -1556,7 +1556,7 @@ typedef struct  PACKED _OID_BA_REC_ENTRY{
 typedef struct  PACKED _OID_BA_ORI_ENTRY{
 	UCHAR   MACAddr[MAC_ADDR_LEN];
 	UCHAR   BaBitmap;  // if (BaBitmap&(1<<TID)), this session with{MACAddr, TID}exists, so read BufSize[TID] for BufferSize, read ORI_BA_Status[TID] for status
-	UCHAR   rsv; 
+	UCHAR   rsv;
 	UCHAR   BufSize[8];
 	ORI_BLOCKACK_STATUS  ORI_BA_Status[8];
 } OID_BA_ORI_ENTRY, *POID_BA_ORI_ENTRY;
@@ -1577,9 +1577,9 @@ typedef	union	_BACAP_STRUC	{
 		UINT32     MMPSmode:2;	// MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
 		UINT32     AmsduSize:1;	// 0:3839, 1:7935 bytes. UINT  MSDUSizeToBytes[]	= { 3839, 7935};
 		UINT32     AmsduEnable:1;	//Enable AMSDU transmisstion
-		UINT32		MpduDensity:3;	
+		UINT32		MpduDensity:3;
 		UINT32		Policy:2;	// 0: DELAY_BA 1:IMMED_BA  (//BA Policy subfiled value in ADDBA frame)   2:BA-not use
-		UINT32		AutoBA:1;	// automatically BA  	
+		UINT32		AutoBA:1;	// automatically BA
 		UINT32		TxBAWinLimit:8;
 		UINT32		RxBAWinLimit:8;
 	}	field;
@@ -1587,15 +1587,15 @@ typedef	union	_BACAP_STRUC	{
 	struct	{
 		UINT32		RxBAWinLimit:8;
 		UINT32		TxBAWinLimit:8;
-		UINT32		AutoBA:1;	// automatically BA  	
+		UINT32		AutoBA:1;	// automatically BA
 		UINT32		Policy:2;	// 0: DELAY_BA 1:IMMED_BA  (//BA Policy subfiled value in ADDBA frame)   2:BA-not use
-		UINT32		MpduDensity:3;	
+		UINT32		MpduDensity:3;
 		UINT32       	AmsduEnable:1;	//Enable AMSDU transmisstion
 		UINT32       	AmsduSize:1;	// 0:3839, 1:7935 bytes. UINT  MSDUSizeToBytes[]	= { 3839, 7935};
 		UINT32       	MMPSmode:2;	// MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable
 		UINT32       	bHtAdhoc:1;			// adhoc can use ht rate.
 		UINT32       	b2040CoexistScanSup:1;		//As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz.
-		UINT32       	:4;	
+		UINT32       	:4;
 	}	field;
 #endif
 	UINT32			word;
@@ -1615,7 +1615,7 @@ typedef	struct	_IOT_STRUC	{
 	UCHAR			RTSShortProt;
 	UCHAR			RTSLongProt;
 	BOOLEAN			bRTSLongProtOn;
-#ifdef CONFIG_STA_SUPPORT 
+#ifdef CONFIG_STA_SUPPORT
 	BOOLEAN			bLastAtheros;
     BOOLEAN			bCurrentAtheros;
     BOOLEAN         bNowAtherosBurstOn;
@@ -1631,8 +1631,8 @@ typedef union _REG_TRANSMIT_SETTING {
          UINT32  rsv:13;
 		 UINT32  EXTCHA:2;
 		 UINT32  HTMODE:1;
-		 UINT32  TRANSNO:2; 
-		 UINT32  STBC:1; //SPACE 
+		 UINT32  TRANSNO:2;
+		 UINT32  STBC:1; //SPACE
 		 UINT32  ShortGI:1;
 		 UINT32  BW:1; //channel bandwidth 20MHz or 40 MHz
 		 UINT32  TxBF:1; // 3*3
@@ -1644,8 +1644,8 @@ typedef union _REG_TRANSMIT_SETTING {
 		 UINT32  TxBF:1;
          UINT32  BW:1; //channel bandwidth 20MHz or 40 MHz
          UINT32  ShortGI:1;
-         UINT32  STBC:1; //SPACE 
-         UINT32  TRANSNO:2; 
+         UINT32  STBC:1; //SPACE
+         UINT32  TRANSNO:2;
          UINT32  HTMODE:1;
          UINT32  EXTCHA:2;
          UINT32  rsv:13;
@@ -1657,17 +1657,17 @@ typedef union _REG_TRANSMIT_SETTING {
 typedef union  _DESIRED_TRANSMIT_SETTING {
 #ifdef RT_BIG_ENDIAN
 	struct	{
-			USHORT		rsv:3;	 
+			USHORT		rsv:3;
 			USHORT		FixedTxMode:2;			// If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode.
-			USHORT		PhyMode:4;	
+			USHORT		PhyMode:4;
 			USHORT   	MCS:7;                 // MCS
 	}	field;
 #else
 	struct	{
 			USHORT   	MCS:7;                 	// MCS
-			USHORT		PhyMode:4;				
+			USHORT		PhyMode:4;
 			USHORT	 	FixedTxMode:2;			// If MCS isn't AUTO, fix rate in CCK, OFDM or HT mode.
-			USHORT		rsv:3;	 	 
+			USHORT		rsv:3;
 	}	field;
 #endif
 	USHORT		word;
@@ -1714,7 +1714,7 @@ typedef struct _MULTISSID_STRUCT {
     UCHAR                               SsidLen;
     CHAR                                Ssid[MAX_LEN_OF_SSID];
     USHORT                              CapabilityInfo;
-    
+
     PNET_DEV                   			MSSIDDev;
 
 	NDIS_802_11_AUTHENTICATION_MODE     AuthMode;
@@ -1729,11 +1729,11 @@ typedef struct _MULTISSID_STRUCT {
 	ULONG								RxErrorCount;
 	ULONG								RxDropCount;
 
-	HTTRANSMIT_SETTING					HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.	
+	HTTRANSMIT_SETTING					HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
 	RT_HT_PHY_INFO						DesiredHtPhyInfo;
 	DESIRED_TRANSMIT_SETTING        	DesiredTransmitSetting; // Desired transmit setting. this is for reading registry setting only. not useful.
 	BOOLEAN								bAutoTxRateSwitch;
-	
+
 	UCHAR                               DefaultKeyId;
 
 	UCHAR								TxRate;       // RATE_1, RATE_2, RATE_5_5, RATE_11, ...
@@ -1762,7 +1762,7 @@ typedef struct _MULTISSID_STRUCT {
     UCHAR                   			TimIELocationInBeacon;
     UCHAR                   			CapabilityInfoLocationInBeacon;
     // outgoing BEACON frame buffer and corresponding TXWI
-	// PTXWI_STRUC                           BeaconTxWI; // 
+	// PTXWI_STRUC                           BeaconTxWI; //
     CHAR                                BeaconBuf[MAX_BEACON_SIZE]; // NOTE: BeaconBuf should be 4-byte aligned
 
     BOOLEAN                             bHideSsid;
@@ -1778,38 +1778,38 @@ typedef struct _MULTISSID_STRUCT {
     BOOLEAN								bDLSCapable;	// 0:disable DLS, 1:enable DLS
 
 	UCHAR           					DlsPTK[64];		// Due to windows dirver count on meetinghouse to handle 4-way shake
-	
+
 	// For 802.1x daemon setting per BSS
 	UCHAR								radius_srv_num;
 	RADIUS_SRV_INFO						radius_srv_info[MAX_RADIUS_SRV_NUM];
-	
+
 #ifdef RTL865X_SOC
 	unsigned int						mylinkid;
-#endif 
+#endif
 
 
-	UINT32					RcvdConflictSsidCount;					
-	UINT32					RcvdSpoofedAssocRespCount;	
-	UINT32					RcvdSpoofedReassocRespCount;	
+	UINT32					RcvdConflictSsidCount;
+	UINT32					RcvdSpoofedAssocRespCount;
+	UINT32					RcvdSpoofedReassocRespCount;
 	UINT32					RcvdSpoofedProbeRespCount;
 	UINT32					RcvdSpoofedBeaconCount;
-	UINT32					RcvdSpoofedDisassocCount;	
+	UINT32					RcvdSpoofedDisassocCount;
 	UINT32					RcvdSpoofedAuthCount;
-	UINT32					RcvdSpoofedDeauthCount;	
-	UINT32					RcvdSpoofedUnknownMgmtCount;	
+	UINT32					RcvdSpoofedDeauthCount;
+	UINT32					RcvdSpoofedUnknownMgmtCount;
 	UINT32					RcvdReplayAttackCount;
 
-	CHAR					RssiOfRcvdConflictSsid;					
-	CHAR					RssiOfRcvdSpoofedAssocResp;	
-	CHAR					RssiOfRcvdSpoofedReassocResp;	
+	CHAR					RssiOfRcvdConflictSsid;
+	CHAR					RssiOfRcvdSpoofedAssocResp;
+	CHAR					RssiOfRcvdSpoofedReassocResp;
 	CHAR					RssiOfRcvdSpoofedProbeResp;
 	CHAR					RssiOfRcvdSpoofedBeacon;
-	CHAR					RssiOfRcvdSpoofedDisassoc;	
+	CHAR					RssiOfRcvdSpoofedDisassoc;
 	CHAR					RssiOfRcvdSpoofedAuth;
-	CHAR					RssiOfRcvdSpoofedDeauth;	
-	CHAR					RssiOfRcvdSpoofedUnknownMgmt;	
-	CHAR					RssiOfRcvdReplayAttack;		
-	
+	CHAR					RssiOfRcvdSpoofedDeauth;
+	CHAR					RssiOfRcvdSpoofedUnknownMgmt;
+	CHAR					RssiOfRcvdReplayAttack;
+
 	BOOLEAN					bBcnSntReq;
 	UCHAR					BcnBufIdx;
 } MULTISSID_STRUCT, *PMULTISSID_STRUCT;
@@ -1844,9 +1844,9 @@ typedef struct _COMMON_CONFIG {
 	UCHAR		LastBssid[MAC_ADDR_LEN];
 
 	UCHAR       Bssid[MAC_ADDR_LEN];
-	USHORT      BeaconPeriod;       
-	UCHAR       Channel;            
-	UCHAR       CentralChannel;    	// Central Channel when using 40MHz is indicating. not real channel.        
+	USHORT      BeaconPeriod;
+	UCHAR       Channel;
+	UCHAR       CentralChannel;    	// Central Channel when using 40MHz is indicating. not real channel.
 
 	UCHAR       SupRate[MAX_LEN_OF_SUPPORTED_RATES];
 	UCHAR       SupRateLen;
@@ -1870,7 +1870,7 @@ typedef struct _COMMON_CONFIG {
 	UCHAR		MaxSPLength;
 	UCHAR		BBPCurrentBW;	// BW_10, 	BW_20, BW_40
 	REG_TRANSMIT_SETTING        RegTransmitSetting; //registry transmit setting. this is for reading registry setting only. not useful.
-	UCHAR       TxRate;                 // Same value to fill in TXD. TxRate is 6-bit 
+	UCHAR       TxRate;                 // Same value to fill in TXD. TxRate is 6-bit
 	UCHAR       MaxTxRate;              // RATE_1, RATE_2, RATE_5_5, RATE_11
 	UCHAR       TxRateIndex;            // Tx rate index in RateSwitchTable
 	UCHAR       TxRateTableSize;        // Valid Tx rate table size in RateSwitchTable
@@ -1893,14 +1893,14 @@ typedef struct _COMMON_CONFIG {
 #endif // DOT11_N_SUPPORT //
 	IOT_STRUC		IOTestParm;	// 802.11n InterOpbility Test Parameter;
 	ULONG       TxPreamble;             // Rt802_11PreambleLong, Rt802_11PreambleShort, Rt802_11PreambleAuto
-	BOOLEAN     bUseZeroToDisableFragment;     // Microsoft use 0 as disable 
+	BOOLEAN     bUseZeroToDisableFragment;     // Microsoft use 0 as disable
 	ULONG       UseBGProtection;        // 0: auto, 1: always use, 2: always not use
 	BOOLEAN     bUseShortSlotTime;      // 0: disable, 1 - use short slot (9us)
 	BOOLEAN     bEnableTxBurst;         // 1: enble TX PACKET BURST, 0: disable TX PACKET BURST
 	BOOLEAN     bAggregationCapable;      // 1: enable TX aggregation when the peer supports it
 	BOOLEAN     bPiggyBackCapable;		// 1: enable TX piggy-back according MAC's version
 	BOOLEAN     bIEEE80211H;			// 1: enable IEEE802.11h spec.
-	ULONG		DisableOLBCDetect;		// 0: enable OLBC detect; 1 disable OLBC detect 
+	ULONG		DisableOLBCDetect;		// 0: enable OLBC detect; 1 disable OLBC detect
 
 #ifdef DOT11_N_SUPPORT
 	BOOLEAN				bRdg;
@@ -1913,13 +1913,13 @@ typedef struct _COMMON_CONFIG {
 #ifdef CONFIG_STA_SUPPORT
 	BOOLEAN				bDLSCapable;		// 0:disable DLS, 1:enable DLS
 #endif // CONFIG_STA_SUPPORT //
-	// a bitmap of BOOLEAN flags. each bit represent an operation status of a particular 
+	// a bitmap of BOOLEAN flags. each bit represent an operation status of a particular
 	// BOOLEAN control, either ON or OFF. These flags should always be accessed via
 	// OPSTATUS_TEST_FLAG(), OPSTATUS_SET_FLAG(), OP_STATUS_CLEAR_FLAG() macros.
 	// see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition
 	ULONG               OpStatusFlags;
 
-	BOOLEAN				NdisRadioStateOff; //For HCT 12.0, set this flag to TRUE instead of called MlmeRadioOff.       
+	BOOLEAN				NdisRadioStateOff; //For HCT 12.0, set this flag to TRUE instead of called MlmeRadioOff.
 	ABGBAND_STATE		BandState;		// For setting BBP used on B/G or A mode.
 
 	// IEEE802.11H--DFS.
@@ -1934,7 +1934,7 @@ typedef struct _COMMON_CONFIG {
 	UCHAR			BASize;		// USer desired BAWindowSize. Should not exceed our max capability
 	//RT_HT_CAPABILITY	SupportedHtPhy;
 	RT_HT_CAPABILITY	DesiredHtPhy;
-	HT_CAPABILITY_IE		HtCapability;	
+	HT_CAPABILITY_IE		HtCapability;
 	ADD_HT_INFO_IE		AddHTInfo;	// Useful as AP.
 	//This IE is used with channel switch announcement element when changing to a new 40MHz.
 	//This IE is included in channel switch ammouncement frames 7.4.1.5, beacons, probe Rsp.
@@ -1954,10 +1954,10 @@ typedef struct _COMMON_CONFIG {
 	USHORT					Dot11OBssScanActiveTotalPerChannel;	// Unit : TU. 20~10000
 	USHORT					Dot11BssWidthChanTranDelayFactor;
 	USHORT					Dot11OBssScanActivityThre;				// Unit : percentage
-	
+
 	ULONG					Dot11BssWidthChanTranDelay;			// multiple of (Dot11BssWidthTriggerScanInt * Dot11BssWidthChanTranDelayFactor)
 	ULONG					CountDownCtr;	// CountDown Counter from (Dot11BssWidthTriggerScanInt * Dot11BssWidthChanTranDelayFactor)
-	
+
 	NDIS_SPIN_LOCK          TriggerEventTabLock;
 	BSS_2040_COEXIST_IE		LastBSSCoexist2040;
 	BSS_2040_COEXIST_IE		BSSCoexist2040;
@@ -1976,12 +1976,12 @@ typedef struct _COMMON_CONFIG {
 	BOOLEAN					bRcvBSSWidthTriggerEvents;
 	ULONG					LastRcvBSSWidthTriggerEventsTime;
 
-	UCHAR					TxBASize;	
+	UCHAR					TxBASize;
 #endif // DOT11_N_SUPPORT //
 
 	// Enable wireless event
 	BOOLEAN				bWirelessEvent;
-	BOOLEAN				bWiFiTest;				// Enable this parameter for WiFi test		
+	BOOLEAN				bWiFiTest;				// Enable this parameter for WiFi test
 
 	// Tx & Rx Stream number selection
 	UCHAR				TxStream;
@@ -2016,14 +2016,14 @@ typedef struct _COMMON_CONFIG {
 } COMMON_CONFIG, *PCOMMON_CONFIG;
 
 
-#ifdef CONFIG_STA_SUPPORT 
+#ifdef CONFIG_STA_SUPPORT
 /* Modified by Wu Xi-Kun 4/21/2006 */
 // STA configuration and status
 typedef struct _STA_ADMIN_CONFIG {
 	// GROUP 1 -
 	//   User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe
-	//   the user intended configuration, but not necessary fully equal to the final 
-	//   settings in ACTIVE BSS after negotiation/compromize with the BSS holder (either 
+	//   the user intended configuration, but not necessary fully equal to the final
+	//   settings in ACTIVE BSS after negotiation/compromize with the BSS holder (either
 	//   AP or IBSS holder).
 	//   Once initialized, user configuration can only be changed via OID_xxx
 	UCHAR       BssType;              // BSS_INFRA or BSS_ADHOC
@@ -2031,7 +2031,7 @@ typedef struct _STA_ADMIN_CONFIG {
 
 	// GROUP 2 -
 	//   User configuration loaded from Registry, E2PROM or OID_xxx. These settings describe
-	//   the user intended configuration, and should be always applied to the final 
+	//   the user intended configuration, and should be always applied to the final
 	//   settings in ACTIVE BSS without compromising with the BSS holder.
 	//   Once initialized, user configuration can only be changed via OID_xxx
 	UCHAR       RssiTrigger;
@@ -2062,7 +2062,7 @@ typedef struct _STA_ADMIN_CONFIG {
 	NDIS_802_11_ENCRYPTION_STATUS		PairCipher;			// Unicast cipher suite
 	BOOLEAN								bMixCipher;			// Indicate current Pair & Group use different cipher suites
 	USHORT								RsnCapability;
-	
+
 	NDIS_802_11_WEP_STATUS              GroupKeyWepStatus;
 
 	UCHAR		PMK[32];                // WPA PSK mode PMK
@@ -2071,7 +2071,7 @@ typedef struct _STA_ADMIN_CONFIG {
 	BSSID_INFO	SavedPMK[PMKID_NO];
 	UINT		SavedPMKNum;			// Saved PMKID number
 
-	UCHAR		DefaultKeyId;			
+	UCHAR		DefaultKeyId;
 
 
 	// WPA 802.1x port control, WPA_802_1X_PORT_SECURED, WPA_802_1X_PORT_NOT_SECURED
@@ -2096,7 +2096,7 @@ typedef struct _STA_ADMIN_CONFIG {
 	ULONG       Last11bBeaconRxTime;  // OS's timestamp of the last 11B BEACON RX time
 	ULONG		Last11gBeaconRxTime;	// OS's timestamp of the last 11G BEACON RX time
 	ULONG		Last20NBeaconRxTime;	// OS's timestamp of the last 20MHz N BEACON RX time
-	
+
 	ULONG       LastScanTime;       // Record last scan time for issue BSSID_SCAN_LIST
 	ULONG       ScanCnt;            // Scan counts since most recent SSID, BSSID, SCAN OID request
 	BOOLEAN     bSwRadio;           // Software controlled Radio On/Off, TRUE: On
@@ -2108,7 +2108,7 @@ typedef struct _STA_ADMIN_CONFIG {
     BOOLEAN		AdhocBOnlyJoined;	// Indicate Adhoc B Join.
     BOOLEAN		AdhocBGJoined;		// Indicate Adhoc B/G Join.
     BOOLEAN		Adhoc20NJoined;		// Indicate Adhoc 20MHz N Join.
-    
+
 	// New for WPA, windows want us to to keep association information and
 	// Fixed IEs from last association response
 	NDIS_802_11_ASSOCIATION_INFORMATION     AssocInfo;
@@ -2129,12 +2129,12 @@ typedef struct _STA_ADMIN_CONFIG {
 	UCHAR               TxSEQ[4];
 	UCHAR               CKIPMIC[4];
 	UCHAR               LeapAuthMode;
-	LEAP_AUTH_INFO      LeapAuthInfo;   
+	LEAP_AUTH_INFO      LeapAuthInfo;
 	UCHAR               HashPwd[16];
 	UCHAR               NetworkChallenge[8];
 	UCHAR               NetworkChallengeResponse[24];
 	UCHAR               PeerChallenge[8];
-	
+
 	UCHAR               PeerChallengeResponse[24];
 	UCHAR               SessionKey[16]; //Network session keys (NSK)
 	RALINK_TIMER_STRUCT LeapAuthTimer;
@@ -2179,7 +2179,7 @@ typedef struct _STA_ADMIN_CONFIG {
 	UCHAR               AironetIPAddress[4];        //eg. 192.168.1.1
 	BOOLEAN             CCXAdjacentAPReportFlag;    //flag for determining report Assoc Lost time
 	CHAR                CCXAdjacentAPSsid[MAX_LEN_OF_SSID]; //Adjacent AP's SSID report
-	UCHAR               CCXAdjacentAPSsidLen;               // the actual ssid length in used    
+	UCHAR               CCXAdjacentAPSsidLen;               // the actual ssid length in used
 	UCHAR               CCXAdjacentAPBssid[MAC_ADDR_LEN];         //Adjacent AP's BSSID report
 	USHORT              CCXAdjacentAPChannel;
 	ULONG               CCXAdjacentAPLinkDownTime;  //for Spec S32.
@@ -2198,18 +2198,18 @@ typedef struct _STA_ADMIN_CONFIG {
 	// This is only for WHQL test.
 	BOOLEAN				WhqlTest;
 	////////////////////////////////////////////////////////////////////////////////////////
-	
+
     RALINK_TIMER_STRUCT WpaDisassocAndBlockAssocTimer;
     // Fast Roaming
 	BOOLEAN		        bFastRoaming;       // 0:disable fast roaming, 1:enable fast roaming
 	CHAR		        dBmToRoam;          // the condition to roam when receiving Rssi less than this value. It's negative value.
-	
+
 #ifdef WPA_SUPPLICANT_SUPPORT
     BOOLEAN             IEEE8021X;
     BOOLEAN             IEEE8021x_required_keys;
-    CIPHER_KEY	        DesireSharedKey[4];	// Record user desired WEP keys	
+    CIPHER_KEY	        DesireSharedKey[4];	// Record user desired WEP keys
     UCHAR               DesireSharedKeyId;
-    
+
     // 0: driver ignores wpa_supplicant
     // 1: wpa_supplicant initiates scanning and AP selection
     // 2: driver takes care of scanning, AP selection, and IEEE 802.11 association parameters
@@ -2223,7 +2223,7 @@ typedef struct _STA_ADMIN_CONFIG {
     BOOLEAN             bTGnWifiTest;
 	BOOLEAN			    bScanReqIsFromWebUI;
 
-	HTTRANSMIT_SETTING				HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.	
+	HTTRANSMIT_SETTING				HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
 	DESIRED_TRANSMIT_SETTING       	DesiredTransmitSetting;
 	RT_HT_PHY_INFO					DesiredHtPhyInfo;
 	BOOLEAN							bAutoTxRateSwitch;
@@ -2241,7 +2241,7 @@ typedef struct _STA_ADMIN_CONFIG {
 
 // This data structure keep the current active BSS/IBSS's configuration that this STA
 // had agreed upon joining the network. Which means these parameters are usually decided
-// by the BSS/IBSS creator instead of user configuration. Data in this data structurre 
+// by the BSS/IBSS creator instead of user configuration. Data in this data structurre
 // is valid only when either ADHOC_ON(pAd) or INFRA_ON(pAd) is TRUE.
 // Normally, after SCAN or failed roaming attempts, we need to recover back to
 // the current active settings.
@@ -2292,13 +2292,13 @@ typedef struct _MAC_TABLE_ENTRY {
 	//jan for wpa
 	// record which entry revoke MIC Failure , if it leaves the BSS itself, AP won't update aMICFailTime MIB
 	UCHAR           CMTimerRunning;
-	UCHAR           apidx;			// MBSS number 
+	UCHAR           apidx;			// MBSS number
 	UCHAR           RSNIE_Len;
 	UCHAR           RSN_IE[MAX_LEN_OF_RSNIE];
 	UCHAR           ANonce[LEN_KEY_DESC_NONCE];
 	UCHAR           R_Counter[LEN_KEY_DESC_REPLAY];
 	UCHAR           PTK[64];
-	UCHAR           ReTryCounter;   
+	UCHAR           ReTryCounter;
 	RALINK_TIMER_STRUCT                 RetryTimer;
 	RALINK_TIMER_STRUCT					EnqueueStartForPSKTimer;	// A timer which enqueue EAPoL-Start for triggering PSK SM
 	NDIS_802_11_AUTHENTICATION_MODE     AuthMode;   // This should match to whatever microsoft defined
@@ -2326,7 +2326,7 @@ typedef struct _MAC_TABLE_ENTRY {
 	ULONG           PsQIdleCount;
 	QUEUE_HEADER    PsQueue;
 
-	UINT32			StaConnectTime;		// the live time of this station since associated with AP 
+	UINT32			StaConnectTime;		// the live time of this station since associated with AP
 
 
 #ifdef DOT11_N_SUPPORT
@@ -2370,11 +2370,11 @@ typedef struct _MAC_TABLE_ENTRY {
 	BOOLEAN         fNoisyEnvironment;
 	BOOLEAN			fLastSecAccordingRSSI;
 	UCHAR           LastSecTxRateChangeAction; // 0: no change, 1:rate UP, 2:rate down
-	CHAR			LastTimeTxRateChangeAction; //Keep last time value of LastSecTxRateChangeAction	
+	CHAR			LastTimeTxRateChangeAction; //Keep last time value of LastSecTxRateChangeAction
 	ULONG			LastTxOkCount;
 	UCHAR           PER[MAX_STEP_OF_TX_RATE_SWITCH];
 
-	// a bitmap of BOOLEAN flags. each bit represent an operation status of a particular 
+	// a bitmap of BOOLEAN flags. each bit represent an operation status of a particular
 	// BOOLEAN control, either ON or OFF. These flags should always be accessed via
 	// CLIENT_STATUS_TEST_FLAG(), CLIENT_STATUS_SET_FLAG(), CLIENT_STATUS_CLEAR_FLAG() macros.
 	// see fOP_STATUS_xxx in RTMP_DEF.C for detail bit definition. fCLIENT_STATUS_AMSDU_INUSED
@@ -2382,11 +2382,11 @@ typedef struct _MAC_TABLE_ENTRY {
 
 	// TODO: Shall we move that to DOT11_N_SUPPORT???
 	HTTRANSMIT_SETTING	HTPhyMode, MaxHTPhyMode, MinHTPhyMode;// For transmit phy setting in TXWI.
-	
+
 #ifdef DOT11_N_SUPPORT
 	// HT EWC MIMO-N used parameters
 	USHORT		RXBAbitmap;	// fill to on-chip  RXWI_BA_BITMASK in 8.1.3RX attribute entry format
-	USHORT		TXBAbitmap;	// This bitmap as originator, only keep in software used to mark AMPDU bit in TXWI 
+	USHORT		TXBAbitmap;	// This bitmap as originator, only keep in software used to mark AMPDU bit in TXWI
 	USHORT		TXAutoBAbitmap;
 	USHORT		BADeclineBitmap;
 	USHORT		BARecWcidArray[NUM_OF_TID];	// The mapping wcid of recipient session. if RXBAbitmap bit is masked
@@ -2397,7 +2397,7 @@ typedef struct _MAC_TABLE_ENTRY {
 	UCHAR		MpduDensity;
 	UCHAR		MaxRAmpduFactor;
 	UCHAR		AMsduSize;
-	UCHAR		MmpsMode;	// MIMO power save more. 
+	UCHAR		MmpsMode;	// MIMO power save more.
 
 	HT_CAPABILITY_IE		HTCapability;
 
@@ -2427,15 +2427,15 @@ typedef struct _MAC_TABLE {
 	MAC_TABLE_ENTRY Content[MAX_LEN_OF_MAC_TABLE];
 	QUEUE_HEADER    McastPsQueue;
 	ULONG           PsQIdleCount;
-	BOOLEAN         fAnyStationInPsm;   
-	BOOLEAN         fAnyStationBadAtheros;	// Check if any Station is atheros 802.11n Chip.  We need to use RTS/CTS with Atheros 802,.11n chip. 
+	BOOLEAN         fAnyStationInPsm;
+	BOOLEAN         fAnyStationBadAtheros;	// Check if any Station is atheros 802.11n Chip.  We need to use RTS/CTS with Atheros 802,.11n chip.
 	BOOLEAN			fAnyTxOPForceDisable;	// Check if it is necessary to disable BE TxOP
-#ifdef DOT11_N_SUPPORT	
+#ifdef DOT11_N_SUPPORT
 	BOOLEAN         fAnyStationIsLegacy;	// Check if I use legacy rate to transmit to my BSS Station/
 	BOOLEAN         fAnyStationNonGF;		// Check if any Station can't support GF.
 	BOOLEAN         fAnyStation20Only;		// Check if any Station can't support GF.
 	BOOLEAN			fAnyStationMIMOPSDynamic; // Check if any Station is MIMO Dynamic
-	BOOLEAN         fAnyBASession;   // Check if there is BA session.  Force turn on RTS/CTS 
+	BOOLEAN         fAnyBASession;   // Check if there is BA session.  Force turn on RTS/CTS
 #endif // DOT11_N_SUPPORT //
 } MAC_TABLE, *PMAC_TABLE;
 
@@ -2531,7 +2531,7 @@ typedef struct _APCLI_STRUCT {
 	NDIS_802_11_ENCRYPTION_STATUS		PairCipher;			// Unicast cipher suite
 	BOOLEAN								bMixCipher;			// Indicate current Pair & Group use different cipher suites
 	USHORT								RsnCapability;
-	
+
 	UCHAR		PSK[100];				// reserve PSK key material
 	UCHAR       PSKLen;
 	UCHAR       PMK[32];                // WPA PSK mode PMK
@@ -2542,7 +2542,7 @@ typedef struct _APCLI_STRUCT {
 
 	// store RSN_IE built by driver
 	UCHAR		RSN_IE[MAX_LEN_OF_RSNIE];  // The content saved here should be convert to little-endian format.
-	UCHAR		RSNIE_Len; 
+	UCHAR		RSNIE_Len;
 
 	// For WPA countermeasures
 	ULONG       LastMicErrorTime;   // record last MIC error time
@@ -2551,10 +2551,10 @@ typedef struct _APCLI_STRUCT {
 	// For WPA-PSK supplicant state
 	UCHAR       	SNonce[32];         // SNonce for WPA-PSK
 	UCHAR			GNonce[32];			// GNonce for WPA-PSK from authenticator
-	
+
 #ifdef WSC_AP_SUPPORT
 	WSC_CTRL	           WscControl;
-#endif // WSC_AP_SUPPORT //	
+#endif // WSC_AP_SUPPORT //
 
 	HTTRANSMIT_SETTING				HTPhyMode, MaxHTPhyMode, MinHTPhyMode;
 	RT_HT_PHY_INFO					DesiredHtPhyInfo;
@@ -2590,7 +2590,7 @@ typedef struct _INF_USB_CONFIG
 {
 	UINT                BulkInEpAddr;		// bulk-in endpoint address
 	UINT                BulkOutEpAddr[6];	// bulk-out endpoint address
-	
+
 }INF_USB_CONFIG;
 
 #ifdef IKANOS_VX_1X0
@@ -2635,7 +2635,7 @@ typedef struct _RtmpDiagStrcut_
 	unsigned char		ArrayCurIdx;
 	// Tx Related Count
 	USHORT			TxDataCnt[DIAGNOSE_TIME];
-	USHORT			TxFailCnt[DIAGNOSE_TIME];				
+	USHORT			TxFailCnt[DIAGNOSE_TIME];
 	USHORT			TxDescCnt[DIAGNOSE_TIME][24]; // 3*3	// TxDesc queue length in scale of 0~14, >=15
 	USHORT			TxMcsCnt[DIAGNOSE_TIME][24]; // 3*3
 	USHORT			TxSWQueCnt[DIAGNOSE_TIME][9];		// TxSwQueue length in scale of 0, 1, 2, 3, 4, 5, 6, 7, >=8
@@ -2671,9 +2671,9 @@ typedef struct _RTMP_ADAPTER
     USHORT                  HostLnkCtrlOffset;
 	USHORT		            PCIePowerSaveLevel;
    	BOOLEAN					bPCIclkOff;						// flag that indicate if the PICE power status in Configuration SPace..
-	BOOLEAN					bPCIclkOffDisableTx;			// 
+	BOOLEAN					bPCIclkOffDisableTx;			//
+
 
-    
 /*****************************************************************************************/
 /*      PCI related parameters                                                           */
 /*****************************************************************************************/
@@ -2682,7 +2682,7 @@ typedef struct _RTMP_ADAPTER
 	UINT					int_enable_reg;
 	UINT					int_disable_mask;
 	UINT					int_pending;
-	
+
 
 	RTMP_DMABUF             TxBufSpace[NUM_OF_TX_RING]; // Shared memory of all 1st pre-allocated TxBuf associated with each TXD
 	RTMP_DMABUF             RxDescRing;                 // Shared memory for RX descriptors
@@ -2699,19 +2699,19 @@ typedef struct _RTMP_ADAPTER
 /*****************************************************************************************/
 	/*      Both PCI/USB related parameters                                                  */
 /*****************************************************************************************/
-	
+
 
 /*****************************************************************************************/
 /*      Tx related parameters                                                           */
 /*****************************************************************************************/
 	BOOLEAN                 DeQueueRunning[NUM_OF_TX_RING];  // for ensuring RTUSBDeQueuePacket get call once
 	NDIS_SPIN_LOCK          DeQueueLock[NUM_OF_TX_RING];
-		
+
 
 	// resource for software backlog queues
 	QUEUE_HEADER            TxSwQueue[NUM_OF_TX_RING];  // 4 AC + 1 HCCA
 	NDIS_SPIN_LOCK          TxSwQueueLock[NUM_OF_TX_RING];	// TxSwQueue spinlock
-	
+
 	RTMP_DMABUF             MgmtDescRing;               	// Shared memory for MGMT descriptors
 	RTMP_MGMT_RING          MgmtRing;
 	NDIS_SPIN_LOCK          MgmtRingLock;               	// Prio Ring spinlock
@@ -2725,7 +2725,7 @@ typedef struct _RTMP_ADAPTER
 	RTMP_RX_RING            RxRing;
 	NDIS_SPIN_LOCK          RxRingLock;                 // Rx Ring spinlock
 #endif // RT2860 //
-	
+
 
 
 /*****************************************************************************************/
@@ -2758,7 +2758,7 @@ typedef struct _RTMP_ADAPTER
 	EEPROM_ANTENNA_STRUC    Antenna;                            // Since ANtenna definition is different for a & g. We need to save it for future reference.
 	EEPROM_NIC_CONFIG2_STRUC    NicConfig2;
 
-	// This soft Rx Antenna Diversity mechanism is used only when user set 
+	// This soft Rx Antenna Diversity mechanism is used only when user set
 	// RX Antenna = DIVERSITY ON
 	SOFT_RX_ANT_DIVERSITY   RxAnt;
 
@@ -2767,7 +2767,7 @@ typedef struct _RTMP_ADAPTER
 	CHANNEL_TX_POWER        ChannelList[MAX_NUM_OF_CHANNELS];   // list all supported channels for site survey
 	CHANNEL_11J_TX_POWER    TxPower11J[MAX_NUM_OF_11JCHANNELS];       // 802.11j channel and bw
 	CHANNEL_11J_TX_POWER    ChannelList11J[MAX_NUM_OF_11JCHANNELS];   // list all supported channels for site survey
-	
+
 	UCHAR                   ChannelListNum;                     // number of channel in ChannelList[]
 	UCHAR					Bbp94;
 	BOOLEAN					BbpForCCK;
@@ -2775,16 +2775,16 @@ typedef struct _RTMP_ADAPTER
 	ULONG		Tx20MPwrCfgGBand[5];
 	ULONG		Tx40MPwrCfgABand[5];
 	ULONG		Tx40MPwrCfgGBand[5];
-	
+
 	BOOLEAN     bAutoTxAgcA;                // Enable driver auto Tx Agc control
-	UCHAR	    TssiRefA;					// Store Tssi reference value as 25 temperature.	
+	UCHAR	    TssiRefA;					// Store Tssi reference value as 25 temperature.
 	UCHAR	    TssiPlusBoundaryA[5];		// Tssi boundary for increase Tx power to compensate.
 	UCHAR	    TssiMinusBoundaryA[5];		// Tssi boundary for decrease Tx power to compensate.
 	UCHAR	    TxAgcStepA;					// Store Tx TSSI delta increment / decrement value
 	CHAR		TxAgcCompensateA;			// Store the compensation (TxAgcStep * (idx-1))
-	
+
 	BOOLEAN     bAutoTxAgcG;                // Enable driver auto Tx Agc control
-	UCHAR	    TssiRefG;					// Store Tssi reference value as 25 temperature.	
+	UCHAR	    TssiRefG;					// Store Tssi reference value as 25 temperature.
 	UCHAR	    TssiPlusBoundaryG[5];		// Tssi boundary for increase Tx power to compensate.
 	UCHAR	    TssiMinusBoundaryG[5];		// Tssi boundary for decrease Tx power to compensate.
 	UCHAR	    TxAgcStepG;					// Store Tx TSSI delta increment / decrement value
@@ -2792,16 +2792,16 @@ typedef struct _RTMP_ADAPTER
 
 	//+++For RT2870, the parameteres is start from BGRssiOffset1 ~ BGRssiOffset3
 	CHAR		BGRssiOffset0;				// Store B/G RSSI#0 Offset value on EEPROM 0x46h
-	CHAR		BGRssiOffset1;				// Store B/G RSSI#1 Offset value 
-	CHAR		BGRssiOffset2;				// Store B/G RSSI#2 Offset value 
+	CHAR		BGRssiOffset1;				// Store B/G RSSI#1 Offset value
+	CHAR		BGRssiOffset2;				// Store B/G RSSI#2 Offset value
 	//---
 
-	//+++For RT2870, the parameteres is start from ARssiOffset1 ~ ARssiOffset3	
+	//+++For RT2870, the parameteres is start from ARssiOffset1 ~ ARssiOffset3
 	CHAR		ARssiOffset0;				// Store A RSSI#0 Offset value on EEPROM 0x4Ah
-	CHAR		ARssiOffset1;				// Store A RSSI#1 Offset value 
-	CHAR		ARssiOffset2;				// Store A RSSI#2 Offset value 
+	CHAR		ARssiOffset1;				// Store A RSSI#1 Offset value
+	CHAR		ARssiOffset2;				// Store A RSSI#2 Offset value
 	//---
-	
+
 	CHAR		BLNAGain;					// Store B/G external LNA#0 value on EEPROM 0x44h
 	CHAR		ALNAGain0;					// Store A external LNA#0 value for ch36~64
 	CHAR		ALNAGain1;					// Store A external LNA#1 value for ch100~128
@@ -2822,7 +2822,7 @@ typedef struct _RTMP_ADAPTER
 /*****************************************************************************************/
 /*      802.11 related parameters                                                        */
 /*****************************************************************************************/
-	// outgoing BEACON frame buffer and corresponding TXD 
+	// outgoing BEACON frame buffer and corresponding TXD
 	TXWI_STRUC              	BeaconTxWI;
 	PUCHAR						BeaconBuf;
 	USHORT						BeaconOffset[HW_BEACON_MAX_COUNT];
@@ -2835,7 +2835,7 @@ typedef struct _RTMP_ADAPTER
 
 
 //=======STA===========
-#ifdef CONFIG_STA_SUPPORT	
+#ifdef CONFIG_STA_SUPPORT
 /* Modified by Wu Xi-Kun 4/21/2006 */
 	// -----------------------------------------------
 	// STA specific configuration & operation status
@@ -2843,14 +2843,14 @@ typedef struct _RTMP_ADAPTER
 	// -----------------------------------------------
 	STA_ADMIN_CONFIG        StaCfg;           // user desired settings
 	STA_ACTIVE_CONFIG       StaActive;         // valid only when ADHOC_ON(pAd) || INFRA_ON(pAd)
-	CHAR                    nickname[IW_ESSID_MAX_SIZE+1]; // nickname, only used in the iwconfig i/f 
+	CHAR                    nickname[IW_ESSID_MAX_SIZE+1]; // nickname, only used in the iwconfig i/f
 	NDIS_MEDIA_STATE        PreMediaState;
 #endif // CONFIG_STA_SUPPORT //
 
 //=======Common===========
 	// OP mode: either AP or STA
 	UCHAR                   OpMode;                     // OPMODE_STA, OPMODE_AP
-	
+
 	NDIS_MEDIA_STATE        IndicateMediaState;			// Base on Indication state, default is NdisMediaStateDisConnected
 
 	// MAT related parameters
@@ -2879,14 +2879,14 @@ typedef struct _RTMP_ADAPTER
 #endif // DOT11_N_SUPPORT //
 	NDIS_SPIN_LOCK          BATabLock;
 	RALINK_TIMER_STRUCT RECBATimer;
-	
+
 	// encryption/decryption KEY tables
 	CIPHER_KEY              SharedKey[MAX_MBSSID_NUM][4]; // STA always use SharedKey[BSS0][0..3]
 
 		// RX re-assembly buffer for fragmentation
 	FRAGMENT_FRAME          FragFrame;                  // Frame storage for fragment frame
 
-	// various Counters 
+	// various Counters
 	COUNTER_802_3           Counters8023;               // 802.3 counters
 	COUNTER_802_11          WlanCounters;               // 802.11 MIB counters
 	COUNTER_RALINK          RalinkCounters;             // Ralink propriety counters
@@ -2913,7 +2913,7 @@ typedef struct _RTMP_ADAPTER
 	//+++Used only for Station
 	BOOLEAN                 bConfigChanged;         // Config Change flag for the same SSID setting
 	//---
-	
+
 	ULONG                   ExtraInfo;              // Extra information for displaying status
 	ULONG                   SystemErrorBitmap;      // b0: E2PROM version error
 
@@ -2928,12 +2928,12 @@ typedef struct _RTMP_ADAPTER
 
 
 	BOOLEAN		HTCEnable;
-	
+
 	/*****************************************************************************************/
 	/*      Statistic related parameters                                                     */
 	/*****************************************************************************************/
 
-	BOOLEAN						bUpdateBcnCntDone;		
+	BOOLEAN						bUpdateBcnCntDone;
 	ULONG						watchDogMacDeadlock;	// prevent MAC/BBP into deadlock condition
 	// ----------------------------
 	// DEBUG paramerts
@@ -2942,7 +2942,7 @@ typedef struct _RTMP_ADAPTER
 	BOOLEAN		bPromiscuous;
 
 	// ----------------------------
-	// rt2860c emulation-use Parameters 
+	// rt2860c emulation-use Parameters
 	// ----------------------------
 	ULONG		rtsaccu[30];
 	ULONG		ctsaccu[30];
@@ -2979,7 +2979,7 @@ typedef struct _RTMP_ADAPTER
 	struct reordering_mpdu_pool mpdu_blk_pool;
 #endif // DOT11_N_SUPPORT //
 
-	ULONG					OneSecondnonBEpackets;		// record non BE packets per second 
+	ULONG					OneSecondnonBEpackets;		// record non BE packets per second
 
 #if WIRELESS_EXT >= 12
     struct iw_statistics    iw_stats;
@@ -3038,13 +3038,13 @@ typedef struct  _CISCO_IAPP_CONTENT_
 	USHORT     Length;        //IAPP Length
 	UCHAR      MessageType;      //IAPP type
 	UCHAR      FunctionCode;     //IAPP function type
-	UCHAR      DestinaionMAC[MAC_ADDR_LEN];   
+	UCHAR      DestinaionMAC[MAC_ADDR_LEN];
 	UCHAR      SourceMAC[MAC_ADDR_LEN];
 	USHORT     Tag;           //Tag(element IE) - Adjacent AP report
 	USHORT     TagLength;     //Length of element not including 4 byte header
 	UCHAR      OUI[4];           //0x00, 0x40, 0x96, 0x00
 	UCHAR      PreviousAP[MAC_ADDR_LEN];       //MAC Address of access point
-	USHORT     Channel;       
+	USHORT     Channel;
 	USHORT     SsidLen;
 	UCHAR      Ssid[MAX_LEN_OF_SSID];
 	USHORT     Seconds;          //Seconds that the client has been disassociated.
@@ -3055,8 +3055,8 @@ typedef struct  _CISCO_IAPP_CONTENT_
 #define IndMask				0x0003fffc
 #define RxINT				0x00000005	// Delayed Rx or indivi rx
 #define TxDataInt			0x000000fa	// Delayed Tx or indivi tx
-#define TxMgmtInt			0x00000102	// Delayed Tx or indivi tx 
-#define TxCoherent			0x00020000	// tx coherent 
+#define TxMgmtInt			0x00000102	// Delayed Tx or indivi tx
+#define TxCoherent			0x00020000	// tx coherent
 #define RxCoherent			0x00010000	// rx coherent
 #define McuCommand			0x00000200	// mcu
 #define PreTBTTInt			0x00001000	// Pre-TBTT interrupt
@@ -3123,7 +3123,7 @@ typedef struct _TX_BLK_
 	QUEUE_HEADER		TxPacketList;
 	MAC_TABLE_ENTRY		*pMacEntry;					// NULL: packet with 802.11 RA field is multicast/broadcast address
 	HTTRANSMIT_SETTING	*pTransmit;
-	
+
 	// Following structure used for the characteristics of a specific packet.
 	PNDIS_PACKET		pPacket;
 	PUCHAR				pSrcBufHeader;				// Reference to the head of sk_buff->data
@@ -3133,7 +3133,7 @@ typedef struct _TX_BLK_
 	UCHAR				HeaderBuf[80];				// TempBuffer for TX_INFO + TX_WI + 802.11 Header + padding + AMSDU SubHeader + LLC/SNAP
 	UCHAR				MpduHeaderLen;				// 802.11 header length NOT including the padding
 	UCHAR				HdrPadLen;					// recording Header Padding Length;
-	UCHAR				apidx;						// The interface associated to this packet 
+	UCHAR				apidx;						// The interface associated to this packet
 	UCHAR				Wcid;						// The MAC entry associated to this packet
 	UCHAR				UserPriority;				// priority class of packet
 	UCHAR				FrameGap;					// what kind of IFS this packet use
@@ -3141,7 +3141,7 @@ typedef struct _TX_BLK_
 	UCHAR				TxRate;						// TODO: Obsoleted? Should change to MCS?
 	UCHAR				CipherAlg;					// cipher alogrithm
 	PCIPHER_KEY			pKey;
-	
+
 
 
 	USHORT				Flags;						//See following definitions for detail.
@@ -3155,7 +3155,7 @@ typedef struct _TX_BLK_
 #define fTX_bAckRequired       	0x0002	// the packet need ack response
 #define fTX_bPiggyBack     		0x0004	// Legacy device use Piggback or not
 #define fTX_bHTRate         	0x0008	// allow to use HT rate
-#define fTX_bForceNonQoS       	0x0010	// force to transmit frame without WMM-QoS in HT mode 
+#define fTX_bForceNonQoS       	0x0010	// force to transmit frame without WMM-QoS in HT mode
 #define fTX_bAllowFrag       	0x0020	// allow to fragment the packet, A-MPDU, A-MSDU, A-Ralink is not allowed to fragment
 #define fTX_bMoreData			0x0040	// there are more data packets in PowerSave Queue
 #define fTX_bWMM				0x0080	// QOS Data
@@ -3169,11 +3169,11 @@ typedef struct _TX_BLK_
 			else 									\
 				(_pTxBlk->Flags &= ~(_flag))		\
 		}while(0)
-		
+
 #define TX_BLK_SET_FLAG(_pTxBlk, _flag)		(_pTxBlk->Flags |= _flag)
 #define TX_BLK_TEST_FLAG(_pTxBlk, _flag)	(((_pTxBlk->Flags & _flag) == _flag) ? 1 : 0)
 #define TX_BLK_CLEAR_FLAG(_pTxBlk, _flag)	(_pTxBlk->Flags &= ~(_flag))
-	
+
 
 
 
@@ -3189,8 +3189,8 @@ typedef struct _TX_BLK_
 __inline    VOID    NICDisableInterrupt(
     IN  PRTMP_ADAPTER   pAd)
 {
-	RTMP_IO_WRITE32(pAd, INT_MASK_CSR, 0x0);     // 0: disable 
-	//RTMP_IO_WRITE32(pAd, PBF_INT_ENA, 0x0);	 	// 0x418 is for firmware . SW doesn't handle here. 
+	RTMP_IO_WRITE32(pAd, INT_MASK_CSR, 0x0);     // 0: disable
+	//RTMP_IO_WRITE32(pAd, PBF_INT_ENA, 0x0);	 	// 0x418 is for firmware . SW doesn't handle here.
 	RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);
 }
 
@@ -3210,7 +3210,7 @@ __inline    VOID    NICEnableInterrupt(
 	}
 	//else
 	//	DBGPRINT(RT_DEBUG_TRACE, ("fOP_STATUS_DOZE !\n"));
-		
+
 	//RTMP_IO_WRITE32(pAd, PBF_INT_ENA, 0x00000030); // 1 : enable
 	RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_ACTIVE);
 }
@@ -3227,7 +3227,7 @@ static inline VOID	WriteBackToDescriptor(
 
 	p1 = ((UINT32 *)Dest);
 	p2 = ((UINT32 *)Src);
-	
+
 	*p1 = *p2;
 	*(p1+2) = *(p2+2);
 	*(p1+3) = *(p2+3);
@@ -3258,14 +3258,14 @@ static inline VOID	RTMPWIEndianChange(
 {
 	int size;
 	int i;
-	
+
 	size = ((DescriptorType == TYPE_TXWI) ? TXWI_SIZE : RXWI_SIZE);
-	
+
 	if(DescriptorType == TYPE_TXWI)
 	{
 		*((UINT32 *)(pData)) = SWAP32(*((UINT32 *)(pData)));		// Byte 0~3
 		*((UINT32 *)(pData + 4)) = SWAP32(*((UINT32 *)(pData+4)));	// Byte 4~7
-	} 
+	}
 	else
 	{
 		for(i=0; i < size/4 ; i++)
@@ -3323,8 +3323,8 @@ static inline VOID	RTMPDescriptorEndianChange(
 	========================================================================
 */
 static inline VOID	RTMPFrameEndianChange(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	PUCHAR			pData, 
+	IN	PRTMP_ADAPTER	pAd,
+	IN	PUCHAR			pData,
 	IN	ULONG			Dir,
 	IN	BOOLEAN 		FromRxDoneInt)
 {
@@ -3431,7 +3431,7 @@ static inline VOID	RTMPFrameEndianChange(
 				}
 				break;
 			case SUBTYPE_BLOCK_ACK:
-				// For Block Ack packet, the HT_CONTROL field is in the same offset with Addr3 
+				// For Block Ack packet, the HT_CONTROL field is in the same offset with Addr3
 				*(UINT32 *)(&pFrame->Addr3[0]) = SWAP32(*(UINT32 *)(&pFrame->Addr3[0]));
 				break;
 
@@ -3457,7 +3457,7 @@ static inline VOID	RTMPFrameEndianChange(
 
 static inline VOID ConvertMulticastIP2MAC(
 	IN PUCHAR pIpAddr,
-	IN PUCHAR *ppMacAddr, 
+	IN PUCHAR *ppMacAddr,
 	IN UINT16 ProtoType)
 {
 	if (pIpAddr == NULL)
@@ -3531,7 +3531,7 @@ NDIS_STATUS NICReadRegParameters(
 	IN  NDIS_HANDLE         WrapperConfigurationContext
 	);
 
-	
+
 VOID NICReadEEPROMParameters(
 	IN  PRTMP_ADAPTER       pAd,
 	IN	PUCHAR				mac_addr);
@@ -3658,11 +3658,11 @@ VOID RTMPCancelTimer(
 	OUT BOOLEAN                 *pCancelled);
 
 VOID RTMPSetLED(
-	IN PRTMP_ADAPTER 	pAd, 
+	IN PRTMP_ADAPTER 	pAd,
 	IN UCHAR			Status);
 
 VOID RTMPSetSignalLED(
-	IN PRTMP_ADAPTER 	pAd, 
+	IN PRTMP_ADAPTER 	pAd,
 	IN NDIS_802_11_RSSI Dbm);
 
 VOID RTMPEnableRxTx(
@@ -3672,45 +3672,45 @@ VOID RTMPEnableRxTx(
 // prototype in action.c
 //
 VOID ActionStateMachineInit(
-    IN	PRTMP_ADAPTER	pAd, 
-    IN  STATE_MACHINE *S, 
+    IN	PRTMP_ADAPTER	pAd,
+    IN  STATE_MACHINE *S,
     OUT STATE_MACHINE_FUNC Trans[]);
 
 VOID MlmeADDBAAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 
 VOID MlmeDELBAAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 
 VOID MlmeDLSAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 
 VOID MlmeInvalidAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 
 VOID MlmeQOSAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 
 #ifdef DOT11_N_SUPPORT
 VOID PeerAddBAReqAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID PeerAddBARspAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID PeerDelBAAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID PeerBAAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 #endif // DOT11_N_SUPPORT //
 
@@ -3718,7 +3718,7 @@ VOID SendPSMPAction(
 	IN PRTMP_ADAPTER	pAd,
 	IN UCHAR			Wcid,
 	IN UCHAR			Psmp);
-				   
+
 
 #ifdef DOT11N_DRAFT3
 VOID SendBSS2040CoexistMgmtAction(
@@ -3731,7 +3731,7 @@ VOID SendNotifyBWActionFrame(
 	IN PRTMP_ADAPTER pAd,
 	IN UCHAR  Wcid,
 	IN UCHAR apidx);
-	
+
 BOOLEAN ChannelSwitchSanityCheck(
 	IN	PRTMP_ADAPTER	pAd,
 	IN    UCHAR  Wcid,
@@ -3746,13 +3746,13 @@ VOID ChannelSwitchAction(
 
 ULONG BuildIntolerantChannelRep(
 	IN	PRTMP_ADAPTER	pAd,
-	IN    PUCHAR  pDest); 
+	IN    PUCHAR  pDest);
 
 VOID Update2040CoexistFrameAndNotify(
 	IN	PRTMP_ADAPTER	pAd,
 	IN    UCHAR  Wcid,
 	IN	BOOLEAN	bAddIntolerantCha);
-	
+
 VOID Send2040CoexistAction(
 	IN	PRTMP_ADAPTER	pAd,
 	IN    UCHAR  Wcid,
@@ -3760,44 +3760,44 @@ VOID Send2040CoexistAction(
 #endif // DOT11N_DRAFT3 //
 
 VOID PeerRMAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID PeerPublicAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 #ifdef CONFIG_STA_SUPPORT
 VOID StaPublicAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN UCHAR Bss2040Coexist);
 #endif // CONFIG_STA_SUPPORT //
 
 
 VOID PeerBSSTranAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 #ifdef DOT11_N_SUPPORT
 VOID PeerHTAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 #endif // DOT11_N_SUPPORT //
 
 VOID PeerQOSAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 
 #ifdef QOS_DLS_SUPPORT
 VOID PeerDLSAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 #endif // QOS_DLS_SUPPORT //
 
 #ifdef CONFIG_STA_SUPPORT
 #ifdef QOS_DLS_SUPPORT
 VOID DlsParmFill(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN OUT MLME_DLS_REQ_STRUCT *pDlsReq,
 	IN PRT_802_11_DLS pDls,
 	IN USHORT reason);
@@ -3806,9 +3806,9 @@ VOID DlsParmFill(
 
 #ifdef DOT11_N_SUPPORT
 VOID RECBATimerTimeout(
-    IN PVOID SystemSpecific1, 
-    IN PVOID FunctionContext, 
-    IN PVOID SystemSpecific2, 
+    IN PVOID SystemSpecific1,
+    IN PVOID FunctionContext,
+    IN PVOID SystemSpecific2,
     IN PVOID SystemSpecific3);
 
 VOID ORIBATimerTimeout(
@@ -3818,17 +3818,17 @@ VOID SendRefreshBAR(
 	IN	PRTMP_ADAPTER	pAd,
 	IN	MAC_TABLE_ENTRY	*pEntry);
 #endif // DOT11_N_SUPPORT //
-	
+
 VOID ActHeaderInit(
-    IN	PRTMP_ADAPTER	pAd, 
-    IN OUT PHEADER_802_11 pHdr80211, 
-    IN PUCHAR Addr1, 
+    IN	PRTMP_ADAPTER	pAd,
+    IN OUT PHEADER_802_11 pHdr80211,
+    IN PUCHAR Addr1,
     IN PUCHAR Addr2,
     IN PUCHAR Addr3);
 
 VOID BarHeaderInit(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN OUT PFRAME_BAR pCntlBar, 
+	IN	PRTMP_ADAPTER	pAd,
+	IN OUT PFRAME_BAR pCntlBar,
 	IN PUCHAR pDA,
 	IN PUCHAR pSA);
 
@@ -3840,21 +3840,21 @@ VOID InsertActField(
 	IN UINT8 ActCode);
 
 BOOLEAN QosBADataParse(
-	IN PRTMP_ADAPTER	pAd, 
+	IN PRTMP_ADAPTER	pAd,
 	IN BOOLEAN bAMSDU,
 	IN PUCHAR p8023Header,
 	IN UCHAR	WCID,
 	IN UCHAR	TID,
 	IN USHORT Sequence,
-	IN UCHAR DataOffset, 
+	IN UCHAR DataOffset,
 	IN USHORT Datasize,
 	IN UINT   CurRxIndex);
 
 #ifdef DOT11_N_SUPPORT
 BOOLEAN CntlEnqueueForRecv(
-    IN	PRTMP_ADAPTER	pAd, 
-	IN ULONG Wcid, 
-    IN ULONG MsgLen, 
+    IN	PRTMP_ADAPTER	pAd,
+	IN ULONG Wcid,
+    IN ULONG MsgLen,
 	IN PFRAME_BA_REQ pMsg);
 
 VOID BaAutoManSwitch(
@@ -3969,8 +3969,8 @@ USHORT  RTMPCalcDuration(
 
 VOID RTMPWriteTxWI(
 	IN	PRTMP_ADAPTER	pAd,
-	IN	PTXWI_STRUC		pTxWI,	
-	IN  BOOLEAN    		FRAG,	
+	IN	PTXWI_STRUC		pTxWI,
+	IN  BOOLEAN    		FRAG,
 	IN  BOOLEAN    		CFACK,
 	IN  BOOLEAN    		InsTimestamp,
 	IN	BOOLEAN			AMPDU,
@@ -3982,8 +3982,8 @@ VOID RTMPWriteTxWI(
 	IN  UCHAR      		PID,
 	IN	UCHAR			TID,
 	IN	UCHAR			TxRate,
-	IN	UCHAR			Txopmode,	
-	IN	BOOLEAN			CfAck,	
+	IN	UCHAR			Txopmode,
+	IN	BOOLEAN			CfAck,
 	IN	HTTRANSMIT_SETTING	*pTransmit);
 
 
@@ -3992,12 +3992,12 @@ VOID RTMPWriteTxWI_Data(
 	IN	OUT PTXWI_STRUC		pTxWI,
 	IN	TX_BLK				*pTxBlk);
 
-	
+
 VOID RTMPWriteTxWI_Cache(
 	IN	PRTMP_ADAPTER		pAd,
 	IN	OUT PTXWI_STRUC		pTxWI,
 	IN	TX_BLK				*pTxBlk);
-	
+
 VOID RTMPWriteTxDescriptor(
 	IN	PRTMP_ADAPTER	pAd,
 	IN	PTXD_STRUC		pTxD,
@@ -4036,8 +4036,8 @@ VOID RTMPSendRTSFrame(
 
 
 NDIS_STATUS RTMPApplyPacketFilter(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  PRT28XX_RXD_STRUC      pRxD, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  PRT28XX_RXD_STRUC      pRxD,
 	IN  PHEADER_802_11  pHeader);
 
 PQUEUE_HEADER   RTMPCheckTxSwQueue(
@@ -4046,17 +4046,17 @@ PQUEUE_HEADER   RTMPCheckTxSwQueue(
 
 #ifdef CONFIG_STA_SUPPORT
 VOID RTMPReportMicError(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  PCIPHER_KEY     pWpaKey);
 
 VOID	WpaMicFailureReportFrame(
-	IN  PRTMP_ADAPTER    pAd, 
+	IN  PRTMP_ADAPTER    pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID    WpaDisassocApAndBlockAssoc(
-    IN  PVOID SystemSpecific1, 
-    IN  PVOID FunctionContext, 
-    IN  PVOID SystemSpecific2, 
+    IN  PVOID SystemSpecific1,
+    IN  PVOID FunctionContext,
+    IN  PVOID SystemSpecific2,
     IN  PVOID SystemSpecific3);
 #endif // CONFIG_STA_SUPPORT //
 
@@ -4079,21 +4079,21 @@ VOID RTMPFreeNdisPacket(
 	IN  PNDIS_PACKET    pPacket);
 
 BOOLEAN RTMPFreeTXDUponTxDmaDone(
-	IN PRTMP_ADAPTER    pAd, 
+	IN PRTMP_ADAPTER    pAd,
 	IN UCHAR            QueIdx);
 
 BOOLEAN RTMPCheckDHCPFrame(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PNDIS_PACKET	pPacket);
 
 
 BOOLEAN RTMPCheckEtherType(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PNDIS_PACKET	pPacket);
 
 
 VOID RTMPCckBbpTuning(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	UINT			TxRate);
 
 //
@@ -4103,7 +4103,7 @@ VOID RTMPInitWepEngine(
 	IN  PRTMP_ADAPTER   pAd,
 	IN  PUCHAR          pKey,
 	IN  UCHAR           KeyId,
-	IN  UCHAR           KeyLen, 
+	IN  UCHAR           KeyLen,
 	IN  PUCHAR          pDest);
 
 VOID RTMPEncryptData(
@@ -4138,7 +4138,7 @@ UCHAR   ARCFOUR_BYTE(
 
 VOID ARCFOUR_DECRYPT(
 	IN  PARCFOURCONTEXT Ctx,
-	IN  PUCHAR          pDest, 
+	IN  PUCHAR          pDest,
 	IN  PUCHAR          pSrc,
 	IN  UINT            Len);
 
@@ -4176,12 +4176,12 @@ VOID 	AsicUpdateProtect(
 	IN		BOOLEAN			bNonGFExist);
 
 VOID AsicSwitchChannel(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN	UCHAR			Channel,
 	IN	BOOLEAN			bScan);
 
 VOID AsicLockChannel(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN UCHAR Channel) ;
 
 VOID AsicAntennaSelect(
@@ -4200,7 +4200,7 @@ VOID AsicRfTuningExec(
 
 #ifdef CONFIG_STA_SUPPORT
 VOID AsicSleepThenAutoWakeup(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  USHORT TbttNumToNextWakeUp);
 
 VOID AsicForceSleep(
@@ -4212,7 +4212,7 @@ VOID AsicForceWakeup(
 #endif // CONFIG_STA_SUPPORT //
 
 VOID AsicSetBssid(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  PUCHAR pBssid);
 
 VOID AsicSetMcastWC(
@@ -4282,7 +4282,7 @@ VOID AsicAddKeyEntry(
 	IN USHORT		WCID,
 	IN UCHAR		BssIndex,
 	IN UCHAR		KeyIdx,
-	IN PCIPHER_KEY	pCipherKey,	
+	IN PCIPHER_KEY	pCipherKey,
 	IN BOOLEAN		bUsePairewiseKeyTable,
 	IN BOOLEAN		bTxKey);
 
@@ -4311,15 +4311,15 @@ BOOLEAN AsicCheckCommanOk(
 #endif // RT2860 //
 
 VOID MacAddrRandomBssid(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	OUT PUCHAR pAddr);
 
 VOID MgtMacHeaderInit(
-	IN  PRTMP_ADAPTER     pAd, 
-	IN OUT PHEADER_802_11 pHdr80211, 
-	IN UCHAR SubType, 
-	IN UCHAR ToDs, 
-	IN PUCHAR pDA, 
+	IN  PRTMP_ADAPTER     pAd,
+	IN OUT PHEADER_802_11 pHdr80211,
+	IN UCHAR SubType,
+	IN UCHAR ToDs,
+	IN PUCHAR pDA,
 	IN PUCHAR pBssid);
 
 VOID MlmeRadioOff(
@@ -4339,69 +4339,69 @@ VOID BATableInit(
 #endif // DOT11_N_SUPPORT //
 
 ULONG BssTableSearch(
-	IN BSS_TABLE *Tab, 
+	IN BSS_TABLE *Tab,
 	IN PUCHAR pBssid,
 	IN UCHAR Channel);
 
 ULONG BssSsidTableSearch(
-	IN BSS_TABLE *Tab, 
+	IN BSS_TABLE *Tab,
 	IN PUCHAR    pBssid,
 	IN PUCHAR    pSsid,
 	IN UCHAR     SsidLen,
 	IN UCHAR     Channel);
 
 ULONG BssTableSearchWithSSID(
-	IN BSS_TABLE *Tab, 
+	IN BSS_TABLE *Tab,
 	IN PUCHAR    Bssid,
 	IN PUCHAR    pSsid,
 	IN UCHAR     SsidLen,
 	IN UCHAR     Channel);
 
 VOID BssTableDeleteEntry(
-	IN OUT  PBSS_TABLE pTab, 
+	IN OUT  PBSS_TABLE pTab,
 	IN      PUCHAR pBssid,
 	IN      UCHAR Channel);
 
 #ifdef DOT11_N_SUPPORT
 VOID BATableDeleteORIEntry(
-	IN OUT	PRTMP_ADAPTER pAd, 
+	IN OUT	PRTMP_ADAPTER pAd,
 	IN		BA_ORI_ENTRY	*pBAORIEntry);
 
 VOID BATableDeleteRECEntry(
-	IN OUT	PRTMP_ADAPTER pAd, 
+	IN OUT	PRTMP_ADAPTER pAd,
 	IN		BA_REC_ENTRY	*pBARECEntry);
 
 VOID BATableTearORIEntry(
-	IN OUT	PRTMP_ADAPTER pAd, 
-	IN		UCHAR TID, 
-	IN		UCHAR Wcid, 
-	IN		BOOLEAN bForceDelete, 
+	IN OUT	PRTMP_ADAPTER pAd,
+	IN		UCHAR TID,
+	IN		UCHAR Wcid,
+	IN		BOOLEAN bForceDelete,
 	IN		BOOLEAN ALL);
 
 VOID BATableTearRECEntry(
-	IN OUT	PRTMP_ADAPTER pAd, 
-	IN		UCHAR TID, 
-	IN		UCHAR WCID, 
+	IN OUT	PRTMP_ADAPTER pAd,
+	IN		UCHAR TID,
+	IN		UCHAR WCID,
 	IN		BOOLEAN ALL);
 #endif // DOT11_N_SUPPORT //
 
 VOID  BssEntrySet(
-	IN  PRTMP_ADAPTER   pAd, 
-	OUT PBSS_ENTRY pBss, 
-	IN PUCHAR pBssid, 
-	IN CHAR Ssid[], 
-	IN UCHAR SsidLen, 
-	IN UCHAR BssType, 
+	IN  PRTMP_ADAPTER   pAd,
+	OUT PBSS_ENTRY pBss,
+	IN PUCHAR pBssid,
+	IN CHAR Ssid[],
+	IN UCHAR SsidLen,
+	IN UCHAR BssType,
 	IN USHORT BeaconPeriod,
-	IN PCF_PARM CfParm, 
-	IN USHORT AtimWin, 
-	IN USHORT CapabilityInfo, 
-	IN UCHAR SupRate[], 
+	IN PCF_PARM CfParm,
+	IN USHORT AtimWin,
+	IN USHORT CapabilityInfo,
+	IN UCHAR SupRate[],
 	IN UCHAR SupRateLen,
-	IN UCHAR ExtRate[], 
+	IN UCHAR ExtRate[],
 	IN UCHAR ExtRateLen,
 	IN HT_CAPABILITY_IE *pHtCapability,
-	IN ADD_HT_INFO_IE *pAddHtInfo,	// AP might use this additional ht info IE 
+	IN ADD_HT_INFO_IE *pAddHtInfo,	// AP might use this additional ht info IE
 	IN UCHAR			HtCapabilityLen,
 	IN UCHAR			AddHtInfoLen,
 	IN UCHAR			NewExtChanOffset,
@@ -4416,22 +4416,22 @@ VOID  BssEntrySet(
 	IN PNDIS_802_11_VARIABLE_IEs pVIE);
 
 ULONG  BssTableSetEntry(
-	IN  PRTMP_ADAPTER   pAd, 
-	OUT PBSS_TABLE pTab, 
-	IN PUCHAR pBssid, 
-	IN CHAR Ssid[], 
-	IN UCHAR SsidLen, 
-	IN UCHAR BssType, 
-	IN USHORT BeaconPeriod, 
-	IN CF_PARM *CfParm, 
-	IN USHORT AtimWin, 
-	IN USHORT CapabilityInfo, 
-	IN UCHAR SupRate[], 
+	IN  PRTMP_ADAPTER   pAd,
+	OUT PBSS_TABLE pTab,
+	IN PUCHAR pBssid,
+	IN CHAR Ssid[],
+	IN UCHAR SsidLen,
+	IN UCHAR BssType,
+	IN USHORT BeaconPeriod,
+	IN CF_PARM *CfParm,
+	IN USHORT AtimWin,
+	IN USHORT CapabilityInfo,
+	IN UCHAR SupRate[],
 	IN UCHAR SupRateLen,
 	IN UCHAR ExtRate[],
 	IN UCHAR ExtRateLen,
 	IN HT_CAPABILITY_IE *pHtCapability,
-	IN ADD_HT_INFO_IE *pAddHtInfo,	// AP might use this additional ht info IE 
+	IN ADD_HT_INFO_IE *pAddHtInfo,	// AP might use this additional ht info IE
 	IN UCHAR			HtCapabilityLen,
 	IN UCHAR			AddHtInfoLen,
 	IN UCHAR			NewExtChanOffset,
@@ -4447,20 +4447,20 @@ ULONG  BssTableSetEntry(
 
 #ifdef DOT11_N_SUPPORT
 VOID BATableInsertEntry(
-    IN	PRTMP_ADAPTER	pAd, 
-	IN USHORT Aid,    
+    IN	PRTMP_ADAPTER	pAd,
+	IN USHORT Aid,
     IN USHORT		TimeOutValue,
 	IN USHORT		StartingSeq,
-    IN UCHAR TID, 
-	IN UCHAR BAWinSize, 
-	IN UCHAR OriginatorStatus, 
+    IN UCHAR TID,
+	IN UCHAR BAWinSize,
+	IN UCHAR OriginatorStatus,
     IN BOOLEAN IsRecipient);
 
 #ifdef DOT11N_DRAFT3
 VOID Bss2040CoexistTimeOut(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 
@@ -4468,9 +4468,9 @@ VOID  TriEventInit(
 	IN	PRTMP_ADAPTER	pAd);
 
 ULONG TriEventTableSetEntry(
-	IN	PRTMP_ADAPTER	pAd, 
-	OUT TRIGGER_EVENT_TAB *Tab, 
-	IN PUCHAR pBssid, 
+	IN	PRTMP_ADAPTER	pAd,
+	OUT TRIGGER_EVENT_TAB *Tab,
+	IN PUCHAR pBssid,
 	IN HT_CAPABILITY_IE *pHtCapability,
 	IN UCHAR			HtCapabilityLen,
 	IN UCHAR			RegClass,
@@ -4482,9 +4482,9 @@ VOID TriEventCounterMaintenance(
 #endif // DOT11_N_SUPPORT //
 
 VOID BssTableSsidSort(
-	IN  PRTMP_ADAPTER   pAd, 
-	OUT BSS_TABLE *OutTab, 
-	IN  CHAR Ssid[], 
+	IN  PRTMP_ADAPTER   pAd,
+	OUT BSS_TABLE *OutTab,
+	IN  CHAR Ssid[],
 	IN  UCHAR SsidLen);
 
 VOID  BssTableSortByRssi(
@@ -4500,27 +4500,27 @@ VOID  MlmeQueueDestroy(
 	IN MLME_QUEUE *Queue);
 
 BOOLEAN MlmeEnqueue(
-	IN PRTMP_ADAPTER pAd, 
-	IN ULONG Machine, 
-	IN ULONG MsgType, 
-	IN ULONG MsgLen, 
+	IN PRTMP_ADAPTER pAd,
+	IN ULONG Machine,
+	IN ULONG MsgType,
+	IN ULONG MsgLen,
 	IN VOID *Msg);
 
 BOOLEAN MlmeEnqueueForRecv(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN ULONG Wcid, 
-	IN ULONG TimeStampHigh, 
-	IN ULONG TimeStampLow, 
-	IN UCHAR Rssi0, 
-	IN UCHAR Rssi1, 
-	IN UCHAR Rssi2, 
-	IN ULONG MsgLen, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN ULONG Wcid,
+	IN ULONG TimeStampHigh,
+	IN ULONG TimeStampLow,
+	IN UCHAR Rssi0,
+	IN UCHAR Rssi1,
+	IN UCHAR Rssi2,
+	IN ULONG MsgLen,
 	IN PVOID Msg,
 	IN UCHAR Signal);
 
 
 BOOLEAN MlmeDequeue(
-	IN MLME_QUEUE *Queue, 
+	IN MLME_QUEUE *Queue,
 	OUT MLME_QUEUE_ELEM **Elem);
 
 VOID    MlmeRestartStateMachine(
@@ -4533,116 +4533,116 @@ BOOLEAN  MlmeQueueFull(
 	IN MLME_QUEUE *Queue);
 
 BOOLEAN  MsgTypeSubst(
-	IN PRTMP_ADAPTER pAd, 
-	IN PFRAME_802_11 pFrame, 
-	OUT INT *Machine, 
+	IN PRTMP_ADAPTER pAd,
+	IN PFRAME_802_11 pFrame,
+	OUT INT *Machine,
 	OUT INT *MsgType);
 
 VOID StateMachineInit(
-	IN STATE_MACHINE *Sm, 
-	IN STATE_MACHINE_FUNC Trans[], 
-	IN ULONG StNr, 
-	IN ULONG MsgNr, 
-	IN STATE_MACHINE_FUNC DefFunc, 
-	IN ULONG InitState, 
+	IN STATE_MACHINE *Sm,
+	IN STATE_MACHINE_FUNC Trans[],
+	IN ULONG StNr,
+	IN ULONG MsgNr,
+	IN STATE_MACHINE_FUNC DefFunc,
+	IN ULONG InitState,
 	IN ULONG Base);
 
 VOID StateMachineSetAction(
-	IN STATE_MACHINE *S, 
-	IN ULONG St, 
-	ULONG Msg, 
+	IN STATE_MACHINE *S,
+	IN ULONG St,
+	ULONG Msg,
 	IN STATE_MACHINE_FUNC F);
 
 VOID StateMachinePerformAction(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN STATE_MACHINE *S, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN STATE_MACHINE *S,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID Drop(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID AssocStateMachineInit(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  STATE_MACHINE *Sm, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  STATE_MACHINE *Sm,
 	OUT STATE_MACHINE_FUNC Trans[]);
 
 VOID ReassocTimeout(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID AssocTimeout(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID DisassocTimeout(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 //----------------------------------------------
 VOID MlmeDisassocReqAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID MlmeAssocReqAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID MlmeReassocReqAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID MlmeDisassocReqAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID PeerAssocRspAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID PeerReassocRspAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID PeerDisassocAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID DisassocTimeoutAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID AssocTimeoutAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID  ReassocTimeoutAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID  Cls3errAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  PUCHAR pAddr);
 
 VOID SwitchBetweenWepAndCkip(
 	IN PRTMP_ADAPTER pAd);
 
 VOID  InvalidStateWhenAssoc(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID  InvalidStateWhenReassoc(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID InvalidStateWhenDisassociate(
-	IN  PRTMP_ADAPTER pAd, 
+	IN  PRTMP_ADAPTER pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 
@@ -4653,11 +4653,11 @@ VOID  ComposeNullFrame(
 	IN  PRTMP_ADAPTER pAd);
 
 VOID  AssocPostProc(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  PUCHAR pAddr2, 
-	IN  USHORT CapabilityInfo, 
-	IN  USHORT Aid, 
-	IN  UCHAR SupRate[], 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  PUCHAR pAddr2,
+	IN  USHORT CapabilityInfo,
+	IN  USHORT Aid,
+	IN  UCHAR SupRate[],
 	IN  UCHAR SupRateLen,
 	IN  UCHAR ExtRate[],
 	IN  UCHAR ExtRateLen,
@@ -4667,61 +4667,61 @@ VOID  AssocPostProc(
 	IN ADD_HT_INFO_IE		*pAddHtInfo);
 
 VOID AuthStateMachineInit(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN PSTATE_MACHINE sm, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN PSTATE_MACHINE sm,
 	OUT STATE_MACHINE_FUNC Trans[]);
 
 VOID AuthTimeout(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID MlmeAuthReqAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID PeerAuthRspAtSeq2Action(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID PeerAuthRspAtSeq4Action(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID AuthTimeoutAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID Cls2errAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  PUCHAR pAddr);
 
 VOID MlmeDeauthReqAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID InvalidStateWhenAuth(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 //=============================================
 
 VOID AuthRspStateMachineInit(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  PSTATE_MACHINE Sm, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  PSTATE_MACHINE Sm,
 	IN  STATE_MACHINE_FUNC Trans[]);
 
 VOID PeerDeauthAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID PeerAuthSimpleRspGenAndSend(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  PHEADER_802_11  pHdr80211, 
-	IN  USHORT Alg, 
-	IN  USHORT Seq, 
-	IN  USHORT Reason, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  PHEADER_802_11  pHdr80211,
+	IN  USHORT Alg,
+	IN  USHORT Seq,
+	IN  USHORT Reason,
 	IN  USHORT Status);
 
 //
@@ -4731,28 +4731,28 @@ VOID PeerAuthSimpleRspGenAndSend(
 #ifdef CONFIG_STA_SUPPORT
 #ifdef QOS_DLS_SUPPORT
 void DlsStateMachineInit(
-    IN PRTMP_ADAPTER pAd, 
-    IN STATE_MACHINE *Sm, 
+    IN PRTMP_ADAPTER pAd,
+    IN STATE_MACHINE *Sm,
     OUT STATE_MACHINE_FUNC Trans[]);
 
 VOID MlmeDlsReqAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 
 VOID PeerDlsReqAction(
-    IN PRTMP_ADAPTER	pAd, 
+    IN PRTMP_ADAPTER	pAd,
     IN MLME_QUEUE_ELEM	*Elem);
 
 VOID PeerDlsRspAction(
-    IN PRTMP_ADAPTER	pAd, 
+    IN PRTMP_ADAPTER	pAd,
     IN MLME_QUEUE_ELEM	*Elem);
 
 VOID MlmeDlsTearDownAction(
-    IN PRTMP_ADAPTER pAd, 
+    IN PRTMP_ADAPTER pAd,
     IN MLME_QUEUE_ELEM *Elem);
 
 VOID PeerDlsTearDownAction(
-    IN PRTMP_ADAPTER	pAd, 
+    IN PRTMP_ADAPTER	pAd,
     IN MLME_QUEUE_ELEM	*Elem);
 
 VOID RTMPCheckDLSTimeOut(
@@ -4781,24 +4781,24 @@ NDIS_STATUS RTMPSendSTAKeyHandShake(
 	IN	PUCHAR			pDA);
 
 VOID DlsTimeoutAction(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 BOOLEAN MlmeDlsReqSanity(
-	IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
+	IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
     IN ULONG MsgLen,
     OUT PRT_802_11_DLS *pDLS,
     OUT PUSHORT pReason);
 
 INT Set_DlsEntryInfo_Display_Proc(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR arg);
 
 MAC_TABLE_ENTRY *MacTableInsertDlsEntry(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  PUCHAR	pAddr,
 	IN  UINT	DlsEntryIdx);
 
@@ -4819,23 +4819,23 @@ MAC_TABLE_ENTRY *DlsEntryTableLookupByWcid(
 	IN BOOLEAN	bResetIdelCount);
 
 INT	Set_DlsAddEntry_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_DlsTearDownEntry_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 #endif // QOS_DLS_SUPPORT //
 #endif // CONFIG_STA_SUPPORT //
 
 #ifdef QOS_DLS_SUPPORT
 BOOLEAN PeerDlsReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
     IN ULONG MsgLen,
     OUT PUCHAR pDA,
     OUT PUCHAR pSA,
-    OUT USHORT *pCapabilityInfo, 
+    OUT USHORT *pCapabilityInfo,
     OUT USHORT *pDlsTimeout,
     OUT UCHAR *pRatesLen,
     OUT UCHAR Rates[],
@@ -4843,12 +4843,12 @@ BOOLEAN PeerDlsReqSanity(
     OUT HT_CAPABILITY_IE *pHtCapability);
 
 BOOLEAN PeerDlsRspSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
     IN ULONG MsgLen,
     OUT PUCHAR pDA,
     OUT PUCHAR pSA,
-    OUT USHORT *pCapabilityInfo, 
+    OUT USHORT *pCapabilityInfo,
     OUT USHORT *pStatus,
     OUT UCHAR *pRatesLen,
     OUT UCHAR Rates[],
@@ -4856,8 +4856,8 @@ BOOLEAN PeerDlsRspSanity(
     OUT HT_CAPABILITY_IE *pHtCapability);
 
 BOOLEAN PeerDlsTearDownSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
     IN ULONG MsgLen,
     OUT PUCHAR pDA,
     OUT PUCHAR pSA,
@@ -4867,40 +4867,40 @@ BOOLEAN PeerDlsTearDownSanity(
 //========================================
 
 VOID SyncStateMachineInit(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  STATE_MACHINE *Sm, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  STATE_MACHINE *Sm,
 	OUT STATE_MACHINE_FUNC Trans[]);
 
 VOID BeaconTimeout(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID ScanTimeout(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID MlmeScanReqAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID InvalidStateWhenScan(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID InvalidStateWhenJoin(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID InvalidStateWhenStart(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID PeerBeacon(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID EnqueueProbeRequest(
@@ -4911,17 +4911,17 @@ BOOLEAN ScanRunning(
 //=========================================
 
 VOID MlmeCntlInit(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  STATE_MACHINE *S, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  STATE_MACHINE *S,
 	OUT STATE_MACHINE_FUNC Trans[]);
 
 VOID MlmeCntlMachinePerformAction(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  STATE_MACHINE *S, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  STATE_MACHINE *S,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID CntlIdleProc(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID CntlOidScanProc(
@@ -4929,43 +4929,43 @@ VOID CntlOidScanProc(
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID CntlOidSsidProc(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM * Elem);
 
 VOID CntlOidRTBssidProc(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM * Elem);
 
 VOID CntlMlmeRoamingProc(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM * Elem);
 
 VOID CntlWaitDisassocProc(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID CntlWaitJoinProc(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID CntlWaitReassocProc(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID CntlWaitStartProc(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID CntlWaitAuthProc(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID CntlWaitAuthProc2(
-	IN  PRTMP_ADAPTER pAd, 
+	IN  PRTMP_ADAPTER pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID CntlWaitAssocProc(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 #ifdef QOS_DLS_SUPPORT
@@ -4989,84 +4989,84 @@ VOID IterateOnBssTab2(
 	IN  PRTMP_ADAPTER   pAd);;
 
 VOID JoinParmFill(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  OUT MLME_JOIN_REQ_STRUCT *JoinReq, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  OUT MLME_JOIN_REQ_STRUCT *JoinReq,
 	IN  ULONG BssIdx);
 
 VOID AssocParmFill(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq, 
-	IN  PUCHAR pAddr, 
-	IN  USHORT CapabilityInfo, 
-	IN  ULONG Timeout, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN OUT MLME_ASSOC_REQ_STRUCT *AssocReq,
+	IN  PUCHAR pAddr,
+	IN  USHORT CapabilityInfo,
+	IN  ULONG Timeout,
 	IN  USHORT ListenIntv);
 
 VOID ScanParmFill(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  OUT MLME_SCAN_REQ_STRUCT *ScanReq, 
-	IN  CHAR Ssid[], 
-	IN  UCHAR SsidLen, 
-	IN  UCHAR BssType, 
-	IN  UCHAR ScanType); 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  OUT MLME_SCAN_REQ_STRUCT *ScanReq,
+	IN  CHAR Ssid[],
+	IN  UCHAR SsidLen,
+	IN  UCHAR BssType,
+	IN  UCHAR ScanType);
 
 VOID DisassocParmFill(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq, 
-	IN  PUCHAR pAddr, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  OUT MLME_DISASSOC_REQ_STRUCT *DisassocReq,
+	IN  PUCHAR pAddr,
 	IN  USHORT Reason);
 
 VOID StartParmFill(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  OUT MLME_START_REQ_STRUCT *StartReq, 
-	IN  CHAR Ssid[], 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  OUT MLME_START_REQ_STRUCT *StartReq,
+	IN  CHAR Ssid[],
 	IN  UCHAR SsidLen);
 
 VOID AuthParmFill(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  OUT MLME_AUTH_REQ_STRUCT *AuthReq, 
-	IN  PUCHAR pAddr, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  OUT MLME_AUTH_REQ_STRUCT *AuthReq,
+	IN  PUCHAR pAddr,
 	IN  USHORT Alg);
 
 VOID EnqueuePsPoll(
 	IN  PRTMP_ADAPTER   pAd);
 
 VOID EnqueueBeaconFrame(
-	IN  PRTMP_ADAPTER   pAd); 
+	IN  PRTMP_ADAPTER   pAd);
 
 VOID MlmeJoinReqAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID MlmeScanReqAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID MlmeStartReqAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID ScanTimeoutAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID BeaconTimeoutAtJoinAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID PeerBeaconAtScanAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID PeerBeaconAtJoinAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID PeerBeacon(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID PeerProbeReqAction(
-	IN  PRTMP_ADAPTER pAd, 
+	IN  PRTMP_ADAPTER pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID ScanNextChannel(
@@ -5079,36 +5079,36 @@ VOID CCXAdjacentAPReport(
 	IN  PRTMP_ADAPTER   pAd);
 
 BOOLEAN MlmeScanReqSanity(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  VOID *Msg, 
-	IN  ULONG MsgLen, 
-	OUT UCHAR *BssType, 
-	OUT CHAR ssid[], 
-	OUT UCHAR *SsidLen, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  VOID *Msg,
+	IN  ULONG MsgLen,
+	OUT UCHAR *BssType,
+	OUT CHAR ssid[],
+	OUT UCHAR *SsidLen,
 	OUT UCHAR *ScanType);
 
 BOOLEAN PeerBeaconAndProbeRspSanity(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  VOID *Msg, 
-	IN  ULONG MsgLen, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  VOID *Msg,
+	IN  ULONG MsgLen,
 	IN  UCHAR MsgChannel,
-	OUT PUCHAR pAddr2, 
-	OUT PUCHAR pBssid, 
-	OUT CHAR Ssid[], 
-	OUT UCHAR *pSsidLen, 
-	OUT UCHAR *pBssType, 
-	OUT USHORT *pBeaconPeriod, 
-	OUT UCHAR *pChannel, 
-	OUT UCHAR *pNewChannel, 
-	OUT LARGE_INTEGER *pTimestamp, 
-	OUT CF_PARM *pCfParm, 
-	OUT USHORT *pAtimWin, 
-	OUT USHORT *pCapabilityInfo, 
+	OUT PUCHAR pAddr2,
+	OUT PUCHAR pBssid,
+	OUT CHAR Ssid[],
+	OUT UCHAR *pSsidLen,
+	OUT UCHAR *pBssType,
+	OUT USHORT *pBeaconPeriod,
+	OUT UCHAR *pChannel,
+	OUT UCHAR *pNewChannel,
+	OUT LARGE_INTEGER *pTimestamp,
+	OUT CF_PARM *pCfParm,
+	OUT USHORT *pAtimWin,
+	OUT USHORT *pCapabilityInfo,
 	OUT UCHAR *pErp,
-	OUT UCHAR *pDtimCount, 
-	OUT UCHAR *pDtimPeriod, 
-	OUT UCHAR *pBcastFlag, 
-	OUT UCHAR *pMessageToMe, 
+	OUT UCHAR *pDtimCount,
+	OUT UCHAR *pDtimPeriod,
+	OUT UCHAR *pBcastFlag,
+	OUT UCHAR *pMessageToMe,
 	OUT UCHAR SupRate[],
 	OUT UCHAR *pSupRateLen,
 	OUT UCHAR ExtRate[],
@@ -5131,70 +5131,70 @@ BOOLEAN PeerBeaconAndProbeRspSanity(
 	OUT PNDIS_802_11_VARIABLE_IEs pVIE);
 
 BOOLEAN PeerAddBAReqActionSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *pMsg, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *pMsg,
     IN ULONG MsgLen,
 	OUT PUCHAR pAddr2);
 
 BOOLEAN PeerAddBARspActionSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *pMsg, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *pMsg,
     IN ULONG MsgLen);
 
 BOOLEAN PeerDelBAActionSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN UCHAR Wcid, 
-    IN VOID *pMsg, 
+    IN PRTMP_ADAPTER pAd,
+    IN UCHAR Wcid,
+    IN VOID *pMsg,
     IN ULONG MsgLen);
 
 BOOLEAN MlmeAssocReqSanity(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  VOID *Msg, 
-	IN  ULONG MsgLen, 
-	OUT PUCHAR pApAddr, 
-	OUT USHORT *CapabilityInfo, 
-	OUT ULONG *Timeout, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  VOID *Msg,
+	IN  ULONG MsgLen,
+	OUT PUCHAR pApAddr,
+	OUT USHORT *CapabilityInfo,
+	OUT ULONG *Timeout,
 	OUT USHORT *ListenIntv);
 
 BOOLEAN MlmeAuthReqSanity(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  VOID *Msg, 
-	IN  ULONG MsgLen, 
-	OUT PUCHAR pAddr, 
-	OUT ULONG *Timeout, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  VOID *Msg,
+	IN  ULONG MsgLen,
+	OUT PUCHAR pAddr,
+	OUT ULONG *Timeout,
 	OUT USHORT *Alg);
 
 BOOLEAN MlmeStartReqSanity(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  VOID *Msg, 
-	IN  ULONG MsgLen, 
-	OUT CHAR Ssid[], 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  VOID *Msg,
+	IN  ULONG MsgLen,
+	OUT CHAR Ssid[],
 	OUT UCHAR *Ssidlen);
 
 BOOLEAN PeerAuthSanity(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  VOID *Msg, 
-	IN  ULONG MsgLen, 
-	OUT PUCHAR pAddr, 
-	OUT USHORT *Alg, 
-	OUT USHORT *Seq, 
-	OUT USHORT *Status, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  VOID *Msg,
+	IN  ULONG MsgLen,
+	OUT PUCHAR pAddr,
+	OUT USHORT *Alg,
+	OUT USHORT *Seq,
+	OUT USHORT *Status,
 	OUT CHAR ChlgText[]);
 
 BOOLEAN PeerAssocRspSanity(
-	IN  PRTMP_ADAPTER   pAd, 
-    IN VOID *pMsg, 
-	IN  ULONG MsgLen, 
-	OUT PUCHAR pAddr2, 
-	OUT USHORT *pCapabilityInfo, 
-	OUT USHORT *pStatus, 
-	OUT USHORT *pAid, 
-	OUT UCHAR SupRate[], 
+	IN  PRTMP_ADAPTER   pAd,
+    IN VOID *pMsg,
+	IN  ULONG MsgLen,
+	OUT PUCHAR pAddr2,
+	OUT USHORT *pCapabilityInfo,
+	OUT USHORT *pStatus,
+	OUT USHORT *pAid,
+	OUT UCHAR SupRate[],
 	OUT UCHAR *pSupRateLen,
 	OUT UCHAR ExtRate[],
 	OUT UCHAR *pExtRateLen,
     OUT HT_CAPABILITY_IE		*pHtCapability,
-    OUT ADD_HT_INFO_IE		*pAddHtInfo,	// AP might use this additional ht info IE 
+    OUT ADD_HT_INFO_IE		*pAddHtInfo,	// AP might use this additional ht info IE
     OUT UCHAR			*pHtCapabilityLen,
     OUT UCHAR			*pAddHtInfoLen,
     OUT UCHAR			*pNewExtChannelOffset,
@@ -5202,67 +5202,67 @@ BOOLEAN PeerAssocRspSanity(
 	OUT UCHAR *pCkipFlag);
 
 BOOLEAN PeerDisassocSanity(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  VOID *Msg, 
-	IN  ULONG MsgLen, 
-	OUT PUCHAR pAddr2, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  VOID *Msg,
+	IN  ULONG MsgLen,
+	OUT PUCHAR pAddr2,
 	OUT USHORT *Reason);
 
 BOOLEAN PeerWpaMessageSanity(
-    IN 	PRTMP_ADAPTER 		pAd, 
-    IN 	PEAPOL_PACKET 		pMsg, 
-    IN 	ULONG 				MsgLen, 
+    IN 	PRTMP_ADAPTER 		pAd,
+    IN 	PEAPOL_PACKET 		pMsg,
+    IN 	ULONG 				MsgLen,
     IN 	UCHAR				MsgType,
     IN 	MAC_TABLE_ENTRY  	*pEntry);
 
 BOOLEAN PeerDeauthSanity(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  VOID *Msg, 
-	IN  ULONG MsgLen, 
-	OUT PUCHAR pAddr2, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  VOID *Msg,
+	IN  ULONG MsgLen,
+	OUT PUCHAR pAddr2,
 	OUT USHORT *Reason);
 
 BOOLEAN PeerProbeReqSanity(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  VOID *Msg, 
-	IN  ULONG MsgLen, 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  VOID *Msg,
+	IN  ULONG MsgLen,
 	OUT PUCHAR pAddr2,
-	OUT CHAR Ssid[], 
+	OUT CHAR Ssid[],
 	OUT UCHAR *pSsidLen);
 
 BOOLEAN GetTimBit(
-	IN  CHAR *Ptr, 
-	IN  USHORT Aid, 
-	OUT UCHAR *TimLen, 
-	OUT UCHAR *BcastFlag, 
-	OUT UCHAR *DtimCount, 
-	OUT UCHAR *DtimPeriod, 
+	IN  CHAR *Ptr,
+	IN  USHORT Aid,
+	OUT UCHAR *TimLen,
+	OUT UCHAR *BcastFlag,
+	OUT UCHAR *DtimCount,
+	OUT UCHAR *DtimPeriod,
 	OUT UCHAR *MessageToMe);
 
 UCHAR ChannelSanity(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN UCHAR channel);
 
 NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(
 	IN PBSS_ENTRY pBss);
 
 BOOLEAN MlmeDelBAReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
     IN ULONG MsgLen);
 
 BOOLEAN MlmeAddBAReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
     OUT PUCHAR pAddr2);
 
 ULONG MakeOutgoingFrame(
-	OUT CHAR *Buffer, 
+	OUT CHAR *Buffer,
 	OUT ULONG *Length, ...);
 
 VOID  LfsrInit(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  ULONG Seed);
 
 UCHAR RandomByte(
@@ -5273,21 +5273,21 @@ VOID AsicUpdateAutoFallBackTable(
 	IN	PUCHAR			pTxRate);
 
 VOID  MlmePeriodicExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID LinkDownExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID LinkUpExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID STAMlmePeriodicExec(
@@ -5301,7 +5301,7 @@ VOID MlmeAutoReconnectLastSSID(
 
 BOOLEAN MlmeValidateSSID(
 	IN PUCHAR pSsid,
-	IN UCHAR  SsidLen); 
+	IN UCHAR  SsidLen);
 
 VOID MlmeCheckForRoaming(
 	IN PRTMP_ADAPTER pAd,
@@ -5335,11 +5335,11 @@ VOID MlmeCheckPsmChange(
 	IN ULONG    Now32);
 
 VOID MlmeSetPsmBit(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN USHORT psm);
 
 VOID MlmeSetTxPreamble(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN USHORT TxPreamble);
 
 VOID UpdateBasicRateBitmap(
@@ -5375,9 +5375,9 @@ BOOLEAN 	RTMPCheckHt(
 	IN OUT	ADD_HT_INFO_IE			*pAddHtInfo);
 
 VOID StaQuickResponeForRateUpExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID AsicBbpTuning1(
@@ -5399,15 +5399,15 @@ VOID AsicEvaluateRxAnt(
 	IN PRTMP_ADAPTER	pAd);
 
 VOID AsicRxAntEvalTimeout(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID APSDPeriodicExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 BOOLEAN RTMPCheckEntryEnableAutoRateSwitch(
@@ -5444,7 +5444,7 @@ UCHAR FirstChannel(
 	IN  PRTMP_ADAPTER   pAd);
 
 UCHAR NextChannel(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  UCHAR channel);
 
 VOID ChangeToCellPowerLimit(
@@ -5489,7 +5489,7 @@ VOID RTMP_EEPROM_WRITE16(
 // Prototypes of function definition in rtmp_tkip.c
 //
 VOID    RTMPInitTkipEngine(
-	IN  PRTMP_ADAPTER   pAd,    
+	IN  PRTMP_ADAPTER   pAd,
 	IN  PUCHAR          pTKey,
 	IN  UCHAR           KeyId,
 	IN  PUCHAR          pTA,
@@ -5499,7 +5499,7 @@ VOID    RTMPInitTkipEngine(
 	OUT PULONG          pIV32);
 
 VOID    RTMPInitMICEngine(
-	IN  PRTMP_ADAPTER   pAd,    
+	IN  PRTMP_ADAPTER   pAd,
 	IN  PUCHAR          pKey,
 	IN  PUCHAR          pDA,
 	IN  PUCHAR          pSA,
@@ -5531,29 +5531,29 @@ BOOLEAN RTMPTkipCompareMICValueWithLLC(
 	IN  PUCHAR          pMICKey,
 	IN  UINT            Len);
 
-VOID    RTMPTkipAppendByte( 
-	IN  PTKIP_KEY_INFO  pTkip,  
+VOID    RTMPTkipAppendByte(
+	IN  PTKIP_KEY_INFO  pTkip,
 	IN  UCHAR           uChar);
 
-VOID    RTMPTkipAppend( 
-	IN  PTKIP_KEY_INFO  pTkip,  
+VOID    RTMPTkipAppend(
+	IN  PTKIP_KEY_INFO  pTkip,
 	IN  PUCHAR          pSrc,
 	IN  UINT            nBytes);
 
-VOID    RTMPTkipGetMIC( 
+VOID    RTMPTkipGetMIC(
 	IN  PTKIP_KEY_INFO  pTkip);
 
 BOOLEAN RTMPSoftDecryptTKIP(
 	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR	pData,
-	IN ULONG	DataByteCnt, 
+	IN ULONG	DataByteCnt,
 	IN UCHAR    UserPriority,
 	IN PCIPHER_KEY	pWpaKey);
 
 BOOLEAN RTMPSoftDecryptAES(
 	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR	pData,
-	IN ULONG	DataByteCnt, 
+	IN ULONG	DataByteCnt,
 	IN PCIPHER_KEY	pWpaKey);
 
 //
@@ -5567,9 +5567,9 @@ VOID    RTMPWPARemoveAllKeys(
 	IN  PRTMP_ADAPTER   pAd);
 
 BOOLEAN RTMPCheckStrPrintAble(
-    IN  CHAR *pInPutStr, 
+    IN  CHAR *pInPutStr,
     IN  UCHAR strLen);
-    
+
 VOID    RTMPSetPhyMode(
 	IN  PRTMP_ADAPTER   pAd,
 	IN  ULONG phymode);
@@ -5594,11 +5594,11 @@ CHAR *GetAuthMode(
 	CHAR auth);
 
 VOID RTMPIoctlGetSiteSurvey(
-	IN	PRTMP_ADAPTER	pAdapter, 
+	IN	PRTMP_ADAPTER	pAdapter,
 	IN	struct iwreq	*wrq);
 
 VOID RTMPIoctlGetMacTable(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN struct iwreq *wrq);
 
 VOID RTMPIndicateWPA2Status(
@@ -5645,38 +5645,38 @@ BOOLEAN WpaMsgTypeSubst(
 	OUT INT		*MsgType);
 
 VOID WpaPskStateMachineInit(
-	IN  PRTMP_ADAPTER       pAd, 
-	IN  STATE_MACHINE       *S, 
+	IN  PRTMP_ADAPTER       pAd,
+	IN  STATE_MACHINE       *S,
 	OUT STATE_MACHINE_FUNC Trans[]);
 
 VOID WpaEAPOLKeyAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID    WpaPairMsg1Action(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID    WpaPairMsg3Action(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  MLME_QUEUE_ELEM *Elem); 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID    WpaGroupMsg1Action(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID    WpaMacHeaderInit(
-	IN      PRTMP_ADAPTER   pAd, 
-	IN OUT  PHEADER_802_11  pHdr80211, 
-	IN      UCHAR           wep, 
-	IN      PUCHAR          pAddr1); 
+	IN      PRTMP_ADAPTER   pAd,
+	IN OUT  PHEADER_802_11  pHdr80211,
+	IN      UCHAR           wep,
+	IN      PUCHAR          pAddr1);
 
 VOID    Wpa2PairMsg1Action(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
     IN  MLME_QUEUE_ELEM *Elem);
 
 VOID    Wpa2PairMsg3Action(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
     IN  MLME_QUEUE_ELEM *Elem);
 
 BOOLEAN ParseKeyData(
@@ -5729,7 +5729,7 @@ VOID WpaCountPTK(
 	IN  UINT    len);
 
 VOID    GenRandom(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN	UCHAR			*macAddr,
 	OUT	UCHAR			*random);
 
@@ -5737,48 +5737,48 @@ VOID    GenRandom(
 // prototype in aironet.c
 //
 VOID    AironetStateMachineInit(
-	IN  PRTMP_ADAPTER       pAd, 
-	IN  STATE_MACHINE       *S, 
+	IN  PRTMP_ADAPTER       pAd,
+	IN  STATE_MACHINE       *S,
 	OUT STATE_MACHINE_FUNC  Trans[]);
 
 VOID    AironetMsgAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID    AironetRequestAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID    ChannelLoadRequestAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  UCHAR           Index);
 
 VOID    NoiseHistRequestAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  UCHAR           Index);
 
 VOID    BeaconRequestAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  UCHAR           Index);
 
 VOID    AironetReportAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MLME_QUEUE_ELEM *Elem);
 
 VOID    ChannelLoadReportAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  UCHAR           Index);
 
 VOID    NoiseHistReportAction(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  UCHAR           Index);
 
 VOID    AironetFinalReportAction(
 	IN  PRTMP_ADAPTER   pAd);
 
 VOID    BeaconReportAction(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  UCHAR           Index); 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  UCHAR           Index);
 
 VOID    AironetAddBeaconReport(
 	IN  PRTMP_ADAPTER       pAd,
@@ -5814,17 +5814,17 @@ VOID APAsicEvaluateRxAnt(
 VOID APAsicRxAntEvalTimeout(
 	IN PRTMP_ADAPTER	pAd);
 
-// 
+//
 // function prototype in cmm_wpa.c
 //
 BOOLEAN RTMPCheckWPAframe(
 	IN PRTMP_ADAPTER pAd,
 	IN PMAC_TABLE_ENTRY	pEntry,
 	IN PUCHAR 			pData,
-	IN ULONG 			DataByteCount,	
+	IN ULONG 			DataByteCount,
 	IN UCHAR			FromWhichBSSID);
 
-VOID AES_GTK_KEY_UNWRAP( 
+VOID AES_GTK_KEY_UNWRAP(
 	IN  UCHAR   *key,
 	OUT UCHAR   *plaintext,
 	IN	UCHAR	c_len,
@@ -5851,7 +5851,7 @@ VOID	ConstructEapolMsg(
     IN 	UCHAR				PeerAuthMode,
     IN 	UCHAR				PeerWepStatus,
     IN 	UCHAR				MyGroupKeyWepStatus,
-    IN 	UCHAR				MsgType,  
+    IN 	UCHAR				MsgType,
     IN	UCHAR				DefaultKeyIdx,
     IN 	UCHAR				*ReplayCounter,
 	IN 	UCHAR				*KeyNonce,
@@ -5894,7 +5894,7 @@ VOID RTMPMakeRSNIE(
 	IN  UINT            WepStatus,
 	IN	UCHAR			apidx);
 
-// 
+//
 // function prototype in ap_wpa.c
 //
 
@@ -5903,7 +5903,7 @@ BOOLEAN APWpaMsgTypeSubst(
 	OUT INT *MsgType) ;
 
 MAC_TABLE_ENTRY *PACInquiry(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  ULONG           Wcid);
 
 BOOLEAN RTMPCheckMcast(
@@ -5922,91 +5922,91 @@ BOOLEAN RTMPCheckAUTH(
 	IN MAC_TABLE_ENTRY  *pEntry);
 
 VOID WPAStart4WayHS(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MAC_TABLE_ENTRY *pEntry,
 	IN	ULONG			TimeInterval);
 
 VOID WPAStart2WayGroupHS(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  MAC_TABLE_ENTRY *pEntry);
 
 VOID APWpaEAPPacketAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID APWpaEAPOLStartAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID APWpaEAPOLLogoffAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID APWpaEAPOLKeyAction(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID APWpaEAPOLASFAlertAction(
-	IN  PRTMP_ADAPTER    pAd, 
+	IN  PRTMP_ADAPTER    pAd,
 	IN  MLME_QUEUE_ELEM  *Elem);
 
 VOID HandleCounterMeasure(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MAC_TABLE_ENTRY  *pEntry);
 
 VOID PeerPairMsg2Action(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MAC_TABLE_ENTRY  *pEntry,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID PeerPairMsg4Action(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN MAC_TABLE_ENTRY  *pEntry,
 	IN MLME_QUEUE_ELEM *Elem);
 
 VOID CMTimerExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID WPARetryExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID EnqueueStartForPSKExec(
-    IN PVOID SystemSpecific1, 
-    IN PVOID FunctionContext, 
-    IN PVOID SystemSpecific2, 
-    IN PVOID SystemSpecific3); 
+    IN PVOID SystemSpecific1,
+    IN PVOID FunctionContext,
+    IN PVOID SystemSpecific2,
+    IN PVOID SystemSpecific3);
 
 VOID RTMPHandleSTAKey(
-    IN PRTMP_ADAPTER    pAdapter, 
+    IN PRTMP_ADAPTER    pAdapter,
     IN MAC_TABLE_ENTRY  *pEntry,
     IN MLME_QUEUE_ELEM  *Elem);
 
 VOID PeerGroupMsg2Action(
-	IN  PRTMP_ADAPTER    pAd, 
+	IN  PRTMP_ADAPTER    pAd,
 	IN  PMAC_TABLE_ENTRY pEntry,
 	IN  VOID             *Msg,
 	IN  UINT             MsgLen);
 
 VOID PairDisAssocAction(
-	IN  PRTMP_ADAPTER    pAd, 
+	IN  PRTMP_ADAPTER    pAd,
 	IN  PMAC_TABLE_ENTRY pEntry,
 	IN  USHORT           Reason);
 
 VOID MlmeDeAuthAction(
-	IN  PRTMP_ADAPTER    pAd, 
+	IN  PRTMP_ADAPTER    pAd,
 	IN  PMAC_TABLE_ENTRY pEntry,
 	IN  USHORT           Reason);
 
 VOID GREKEYPeriodicExec(
-	IN  PVOID   SystemSpecific1, 
-	IN  PVOID   FunctionContext, 
-	IN  PVOID   SystemSpecific2, 
+	IN  PVOID   SystemSpecific1,
+	IN  PVOID   FunctionContext,
+	IN  PVOID   SystemSpecific2,
 	IN  PVOID   SystemSpecific3);
 
 VOID CountGTK(
@@ -6029,10 +6029,10 @@ VOID    GetLarge(
 	IN  ULONG   Length);
 
 VOID APGenRandom(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	OUT UCHAR       *random);
 
-VOID AES_GTK_KEY_WRAP( 
+VOID AES_GTK_KEY_WRAP(
 	IN UCHAR *key,
 	IN UCHAR *plaintext,
 	IN UCHAR p_len,
@@ -6082,12 +6082,12 @@ VOID	RTMPSendTriggerFrame(
 
 /* timeout -- ms */
 VOID RTMP_SetPeriodicTimer(
-	IN	NDIS_MINIPORT_TIMER *pTimer, 
+	IN	NDIS_MINIPORT_TIMER *pTimer,
 	IN	unsigned long timeout);
 
 VOID RTMP_OS_Init_Timer(
-	IN	PRTMP_ADAPTER pAd, 
-	IN	NDIS_MINIPORT_TIMER *pTimer, 
+	IN	PRTMP_ADAPTER pAd,
+	IN	NDIS_MINIPORT_TIMER *pTimer,
 	IN	TIMER_FUNCTION function,
 	IN	PVOID data);
 
@@ -6206,24 +6206,24 @@ rt_get_sg_list_from_packet(PNDIS_PACKET pPacket, RTMP_SCATTER_GATHER_LIST *sg);
 
 
  void announce_802_3_packet(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PNDIS_PACKET	pPacket);
 
 
 UINT BA_Reorder_AMSDU_Annnounce(
-	IN	PRTMP_ADAPTER	pAd, 	
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PNDIS_PACKET	pPacket);
 
 
 UINT Handle_AMSDU_Packet(
-	IN	PRTMP_ADAPTER	pAd, 	
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			pData,
 	IN	ULONG			DataSize,
 	IN  UCHAR			FromWhichBSSID);
 
 
 void convert_802_11_to_802_3_packet(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PNDIS_PACKET	pPacket,
 	IN	PUCHAR			p8023hdr,
 	IN	PUCHAR			pData,
@@ -6237,7 +6237,7 @@ PNET_DEV get_netdev_from_bssid(
 
 
 PNDIS_PACKET duplicate_pkt(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			pHeader802_3,
     IN  UINT            HdrLen,
 	IN	PUCHAR			pData,
@@ -6248,9 +6248,9 @@ PNDIS_PACKET duplicate_pkt(
 PNDIS_PACKET duplicate_pkt_with_TKIP_MIC(
 	IN	PRTMP_ADAPTER	pAd,
 	IN	PNDIS_PACKET	pOldPkt);
-	
+
 PNDIS_PACKET duplicate_pkt_with_VLAN(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			pHeader802_3,
     IN  UINT            HdrLen,
 	IN	PUCHAR			pData,
@@ -6264,7 +6264,7 @@ PNDIS_PACKET duplicate_pkt_with_WPI(
 	IN	UINT32			ext_tail_len);
 
 UCHAR VLAN_8023_Header_Copy(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			pHeader802_3,
 	IN	UINT            HdrLen,
 	OUT PUCHAR			pData,
@@ -6272,13 +6272,13 @@ UCHAR VLAN_8023_Header_Copy(
 
 #ifdef DOT11_N_SUPPORT
 void ba_flush_reordering_timeout_mpdus(
-	IN PRTMP_ADAPTER	pAd, 
+	IN PRTMP_ADAPTER	pAd,
 	IN PBA_REC_ENTRY	pBAEntry,
 	IN ULONG			Now32);
 
 
 VOID BAOriSessionSetUp(
-			IN PRTMP_ADAPTER    pAd, 
+			IN PRTMP_ADAPTER    pAd,
 			IN MAC_TABLE_ENTRY	*pEntry,
 			IN UCHAR			TID,
 			IN USHORT			TimeOut,
@@ -6286,7 +6286,7 @@ VOID BAOriSessionSetUp(
 			IN BOOLEAN		isForced);
 
 VOID BASessionTearDownALL(
-	IN OUT	PRTMP_ADAPTER pAd, 
+	IN OUT	PRTMP_ADAPTER pAd,
 	IN		UCHAR Wcid);
 #endif // DOT11_N_SUPPORT //
 
@@ -6301,14 +6301,14 @@ VOID build_tx_packet(
 
 
 VOID BAOriSessionTearDown(
-	IN OUT	PRTMP_ADAPTER	pAd, 
+	IN OUT	PRTMP_ADAPTER	pAd,
 	IN		UCHAR			Wcid,
 	IN		UCHAR			TID,
 	IN		BOOLEAN			bPassive,
 	IN		BOOLEAN			bForceSend);
 
 VOID BARecSessionTearDown(
-	IN OUT	PRTMP_ADAPTER	pAd, 
+	IN OUT	PRTMP_ADAPTER	pAd,
 	IN		UCHAR			Wcid,
 	IN		UCHAR			TID,
 	IN		BOOLEAN			bPassive);
@@ -6320,7 +6320,7 @@ ULONG AutoChBssInsertEntry(
 	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR pBssid,
 	IN CHAR Ssid[],
-	IN UCHAR SsidLen, 
+	IN UCHAR SsidLen,
 	IN UCHAR ChannelNo,
 	IN CHAR Rssi);
 
@@ -6358,30 +6358,30 @@ char    *rtstrstr(
 char *rstrtok(
 	IN char * s,
 	IN const char * ct);
-	
+
 int rtinet_aton(
-	const char *cp, 
+	const char *cp,
 	unsigned int *addr);
-	
+
 ////////// common ioctl functions //////////
 INT Set_DriverVersion_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_CountryRegion_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_CountryRegionABand_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_WirelessMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT Set_Channel_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ShortSlot_Proc(
@@ -6393,7 +6393,7 @@ INT	Set_TxPower_Proc(
 	IN	PUCHAR			arg);
 
 INT Set_BGProtection_Proc(
-	IN  PRTMP_ADAPTER		pAd, 
+	IN  PRTMP_ADAPTER		pAd,
 	IN  PUCHAR			arg);
 
 INT Set_TxPreamble_Proc(
@@ -6419,92 +6419,92 @@ INT	Set_PktAggregate_Proc(
 #endif
 
 INT	Set_IEEE80211H_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 #ifdef DBG
 INT	Set_Debug_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 #endif
 
 INT	Show_DescInfo_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_ResetStatCounter_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 #ifdef DOT11_N_SUPPORT
 INT	Set_BASetup_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_BADecline_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_BAOriTearDown_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_BARecTearDown_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_HtBw_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_HtMcs_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_HtGi_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_HtOpMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_HtStbc_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_HtHtc_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_HtExtcha_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_HtMpduDensity_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_HtBaWinSize_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_HtRdg_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
-INT	Set_HtLinkAdapt_Proc(																																																																																																																																																																																																																																									
-	IN	PRTMP_ADAPTER	pAd, 
+INT	Set_HtLinkAdapt_Proc(
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
-INT	Set_HtAmsdu_Proc(																																																																																																																																																																																																																																																																																																																			
-	IN	PRTMP_ADAPTER	pAd, 
+INT	Set_HtAmsdu_Proc(
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
-	
-INT	Set_HtAutoBa_Proc(																																																																																																																																																																																																																																																																																																																			
-	IN	PRTMP_ADAPTER	pAd, 
+
+INT	Set_HtAutoBa_Proc(
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
-					
+
 INT	Set_HtProtect_Proc(
 	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
@@ -6526,16 +6526,16 @@ INT	SetCommonHT(
 	IN	PRTMP_ADAPTER	pAd);
 
 INT	Set_SendPSMPAction_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 INT	Set_HtMIMOPSmode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 
 INT	Set_HtTxBASize_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 #endif // DOT11_N_SUPPORT //
 
@@ -6565,7 +6565,7 @@ VOID    WpaSendMicFailureToWpaSupplicant(
     IN  PRTMP_ADAPTER       pAd,
     IN  BOOLEAN             bUnicast);
 
-VOID    SendAssocIEsToWpaSupplicant( 
+VOID    SendAssocIEsToWpaSupplicant(
     IN  PRTMP_ADAPTER       pAd);
 #endif // WPA_SUPPLICANT_SUPPORT //
 
@@ -6621,12 +6621,12 @@ VOID Indicate_EAPOL_Packet(
 	IN	UCHAR			FromWhichBSSID);
 
 void  update_os_packet_info(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	RX_BLK			*pRxBlk,
 	IN	UCHAR			FromWhichBSSID);
 
 void wlan_802_11_to_802_3_packet(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	RX_BLK			*pRxBlk,
 	IN	PUCHAR			pHeader802_3,
 	IN  UCHAR			FromWhichBSSID);
@@ -6696,14 +6696,14 @@ VOID Sta_Announce_or_Forward_802_3_Packet(
 
 
 PNDIS_PACKET DuplicatePacket(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PNDIS_PACKET	pPacket,
 	IN	UCHAR			FromWhichBSSID);
 
 
 PNDIS_PACKET ClonePacket(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	PNDIS_PACKET	pPacket,	
+	IN	PRTMP_ADAPTER	pAd,
+	IN	PNDIS_PACKET	pPacket,
 	IN	PUCHAR			pData,
 	IN	ULONG			DataSize);
 
@@ -6846,13 +6846,13 @@ enum ieee80211_radiotap_type {
 typedef struct _wlan_radiotap_header {
 	ieee80211_radiotap_header wt_ihdr;
 	INT64 wt_tsft;
-	UINT8 wt_flags;	
+	UINT8 wt_flags;
 	UINT8 wt_rate;
 } wlan_radiotap_header;
 /* Definition from madwifi */
 
 void send_monitor_packets(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	RX_BLK			*pRxBlk);
 
 #if WIRELESS_EXT >= 12
@@ -6867,12 +6867,12 @@ VOID    RTMPSetDesiredRates(
 #endif // CONFIG_STA_SUPPORT //
 
 INT	Set_FixedTxMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 
 #ifdef CONFIG_APSTA_MIXED_SUPPORT
 INT	Set_OpMode_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 #endif // CONFIG_APSTA_MIXED_SUPPORT //
 
@@ -6940,23 +6940,23 @@ VOID RT28XXDMADisable(
 
 VOID RT28XXDMAEnable(
 	IN RTMP_ADAPTER 		*pAd);
-	
+
 VOID RT28xx_UpdateBeaconToAsic(
-	IN RTMP_ADAPTER * pAd, 
+	IN RTMP_ADAPTER * pAd,
 	IN INT apidx,
 	IN ULONG BeaconLen,
 	IN ULONG UpdatePos);
 
 INT rt28xx_ioctl(
-	IN	struct net_device	*net_dev, 
-	IN	OUT	struct ifreq	*rq, 
+	IN	struct net_device	*net_dev,
+	IN	OUT	struct ifreq	*rq,
 	IN	INT			cmd);
 
 
 #ifdef CONFIG_STA_SUPPORT
 INT rt28xx_sta_ioctl(
-	IN	struct net_device	*net_dev, 
-	IN	OUT	struct ifreq	*rq, 
+	IN	struct net_device	*net_dev,
+	IN	OUT	struct ifreq	*rq,
 	IN	INT			cmd);
 #endif // CONFIG_STA_SUPPORT //
 
@@ -6993,7 +6993,7 @@ USHORT RtmpPCI_WriteSingleTxResource(
 	IN	TX_BLK			*pTxBlk,
 	IN	BOOLEAN			bIsLast,
 	OUT	USHORT			*FreeNumber);
-	
+
 USHORT RtmpPCI_WriteMultiTxResource(
 	IN	PRTMP_ADAPTER	pAd,
 	IN	TX_BLK			*pTxBlk,
@@ -7005,7 +7005,7 @@ USHORT	RtmpPCI_WriteFragTxResource(
 	IN	TX_BLK			*pTxBlk,
 	IN	UCHAR			fragNum,
 	OUT	USHORT			*FreeNumber);
-	
+
 USHORT RtmpPCI_WriteSubTxResource(
 	IN	PRTMP_ADAPTER	pAd,
 	IN	TX_BLK			*pTxBlk,
@@ -7030,7 +7030,7 @@ VOID RtmpPCIDataKickOut(
 
 
 int RtmpPCIMgmtKickOut(
-	IN RTMP_ADAPTER 	*pAd, 
+	IN RTMP_ADAPTER 	*pAd,
 	IN UCHAR 			QueIdx,
 	IN PNDIS_PACKET		pPacket,
 	IN PUCHAR			pSrcBufVA,
@@ -7038,7 +7038,7 @@ int RtmpPCIMgmtKickOut(
 
 
 NDIS_STATUS RTMPCheckRxError(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  PHEADER_802_11  pHeader,
 	IN	PRXWI_STRUC	pRxWI,
 	IN  PRT28XX_RXD_STRUC      pRxD);
@@ -7060,7 +7060,7 @@ VOID RTMPPCIeLinkCtrlSetting(
 
 VOID RT28xxPciAsicRadioOff(
 	IN PRTMP_ADAPTER    pAd,
-	IN UCHAR            Level, 
+	IN UCHAR            Level,
 	IN USHORT           TbttNumToNextWakeUp);
 
 BOOLEAN RT28xxPciAsicRadioOn(
@@ -7072,19 +7072,19 @@ VOID RT28xxPciStaAsicForceWakeup(
 	IN BOOLEAN       bFromTx);
 
 VOID RT28xxPciStaAsicSleepThenAutoWakeup(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN USHORT TbttNumToNextWakeUp);
 
 VOID PsPollWakeExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 
 VOID  RadioOnExec(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
 	IN PVOID SystemSpecific3);
 #endif // CONFIG_STA_SUPPORT //
 
@@ -7096,11 +7096,11 @@ VOID RT28xxPciMlmeRadioOFF(
 #endif // RT2860 //
 
 VOID AsicTurnOffRFClk(
-	IN PRTMP_ADAPTER    pAd, 
+	IN PRTMP_ADAPTER    pAd,
 	IN	UCHAR           Channel);
 
 VOID AsicTurnOnRFClk(
-	IN PRTMP_ADAPTER 	pAd, 
+	IN PRTMP_ADAPTER 	pAd,
 	IN	UCHAR			Channel);
 
 
@@ -7118,7 +7118,7 @@ VOID QBSS_LoadUpdate(
 
 ///////////////////////////////////////
 INT RTMPShowCfgValue(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			pName,
 	IN	PUCHAR			pBuf);
 
@@ -7132,9 +7132,9 @@ PCHAR   RTMPGetRalinkEncryModeStr(
 #ifdef CONFIG_STA_SUPPORT
 VOID AsicStaBbpTuning(
 	IN PRTMP_ADAPTER pAd);
-#endif // CONFIG_STA_SUPPORT // 
+#endif // CONFIG_STA_SUPPORT //
 
-void RTMP_IndicateMediaState(	
+void RTMP_IndicateMediaState(
 	IN	PRTMP_ADAPTER	pAd);
 
 VOID ReSyncBeaconTime(
diff --git a/include/rtmp_ckipmic.h b/rtmp_ckipmic.h
similarity index 92%
rename from include/rtmp_ckipmic.h
rename to rtmp_ckipmic.h
index 6fc4b99..a3d949a 100644
--- a/include/rtmp_ckipmic.h
+++ b/rtmp_ckipmic.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -52,13 +52,13 @@ VOID	CKIP_key_permute(
 	IN	UCHAR	toDsFromDs,		/* input toDs/FromDs bits */
 	IN	UCHAR	*piv);			/* input pointer to IV */
 
-VOID	RTMPCkipMicInit(    
+VOID	RTMPCkipMicInit(
 	IN	PMIC_CONTEXT		pContext,
 	IN	PUCHAR				CK);
 
 VOID RTMPMicUpdate(
-    IN  PMIC_CONTEXT        pContext, 
-    IN  PUCHAR              pOctets, 
+    IN  PMIC_CONTEXT        pContext,
+    IN  PUCHAR              pOctets,
     IN  INT                 len);
 
 ULONG RTMPMicGetCoefficient(
diff --git a/include/rtmp_def.h b/rtmp_def.h
similarity index 97%
rename from include/rtmp_def.h
rename to rtmp_def.h
index bac1b0a..bb6f37b 100644
--- a/include/rtmp_def.h
+++ b/rtmp_def.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
     Module Name:
@@ -55,12 +55,12 @@
 #define NIC_DBG_STRING      ("**RT28xx**")
 
 #ifdef SNMP_SUPPORT
-// for snmp 
+// for snmp
 // to get manufacturer OUI, kathy, 2008_0220
 #define ManufacturerOUI_LEN			3
 #define ManufacturerNAME			("Ralink Technology Company.")
 #define	ResourceTypeIdName			("Ralink_ID")
-#endif 
+#endif
 
 
 #define RALINK_2883_VERSION		((UINT32)0x28830300)
@@ -151,7 +151,7 @@
 
 
 #define MAX_PACKETS_IN_QUEUE				(512) //(512)    // to pass WMM A5-WPAPSK
-#define MAX_PACKETS_IN_MCAST_PS_QUEUE		32	 
+#define MAX_PACKETS_IN_MCAST_PS_QUEUE		32
 #define MAX_PACKETS_IN_PS_QUEUE				128	//32
 #define WMM_NUM_OF_AC                       4  /* AC0, AC1, AC2, and AC3 */
 
@@ -249,7 +249,7 @@
 //  STA configuration flags
 //
 
-// 802.11n Operating Mode Definition. 0-3 also used in ASICUPdateProtect switch case 
+// 802.11n Operating Mode Definition. 0-3 also used in ASICUPdateProtect switch case
 #define HT_NO_PROTECT	0
 #define HT_LEGACY_PROTECT	1
 #define HT_40_PROTECT	2
@@ -343,8 +343,8 @@
 
 
 #define MAX_BEACON_SIZE				512
-// If the MAX_MBSSID_NUM is larger than 6, 
-// it shall reserve some WCID space(wcid 222~253) for beacon frames. 
+// If the MAX_MBSSID_NUM is larger than 6,
+// it shall reserve some WCID space(wcid 222~253) for beacon frames.
 // -	these wcid 238~253 are reserved for beacon#6(ra6).
 // -	these wcid 222~237 are reserved for beacon#7(ra7).
 #if defined(MAX_MBSSID_NUM) && (MAX_MBSSID_NUM == 8)
@@ -360,9 +360,9 @@
 #define CS_CTS_WCID 		(HW_RESERVED_WCID - 2)
 #define LAST_SPECIFIC_WCID	(HW_RESERVED_WCID - 2)
 
-// If MAX_MBSSID_NUM is 8, the maximum available wcid for the associated STA is 211. 
+// If MAX_MBSSID_NUM is 8, the maximum available wcid for the associated STA is 211.
 // If MAX_MBSSID_NUM is 7, the maximum available wcid for the associated STA is 228.
-#define MAX_AVAILABLE_CLIENT_WCID	(LAST_SPECIFIC_WCID - MAX_MBSSID_NUM - 1) 
+#define MAX_AVAILABLE_CLIENT_WCID	(LAST_SPECIFIC_WCID - MAX_MBSSID_NUM - 1)
 
 // TX need WCID to find Cipher Key
 // these wcid 212 ~ 219 are reserved for bc/mc packets if MAX_MBSSID_NUM is 8.
@@ -398,22 +398,22 @@
 #define CIPHER_TEXT_LEN                 128
 #define HASH_TABLE_SIZE                 256
 #define MAX_VIE_LEN                     1024   // New for WPA cipher suite variable IE sizes.
-#define MAX_SUPPORT_MCS             32    
+#define MAX_SUPPORT_MCS             32
 
 //============================================================
 // ASIC WCID Table definition.
 //============================================================
-#define BSSID_WCID		1	// in infra mode, always put bssid with this WCID 
-#define MCAST_WCID	0x0	 
-#define BSS0Mcast_WCID	0x0	 
-#define BSS1Mcast_WCID	0xf8	 
+#define BSSID_WCID		1	// in infra mode, always put bssid with this WCID
+#define MCAST_WCID	0x0
+#define BSS0Mcast_WCID	0x0
+#define BSS1Mcast_WCID	0xf8
 #define BSS2Mcast_WCID	0xf9
 #define BSS3Mcast_WCID	0xfa
 #define BSS4Mcast_WCID	0xfb
 #define BSS5Mcast_WCID	0xfc
 #define BSS6Mcast_WCID	0xfd
 #define BSS7Mcast_WCID	0xfe
-#define RESERVED_WCID		0xff	
+#define RESERVED_WCID		0xff
 
 #define MAX_NUM_OF_ACL_LIST				MAX_NUMBER_OF_ACL
 
@@ -426,11 +426,11 @@
 #define MAX_NUM_OF_WDS_LINK_PERBSSID	            3
 #define MAX_NUM_OF_WDS_LINK	            (MAX_NUM_OF_WDS_LINK_PERBSSID*MAX_MBSSID_NUM)
 #define MAX_NUM_OF_EVENT                MAX_NUMBER_OF_EVENT
-#define WDS_LINK_START_WCID				(MAX_LEN_OF_MAC_TABLE-1)	
+#define WDS_LINK_START_WCID				(MAX_LEN_OF_MAC_TABLE-1)
 
 #define NUM_OF_TID			8
 #define MAX_AID_BA                    4
-#define MAX_LEN_OF_BA_REC_TABLE          ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)//   (NUM_OF_TID*MAX_AID_BA + 32)	 //Block ACK recipient 
+#define MAX_LEN_OF_BA_REC_TABLE          ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)//   (NUM_OF_TID*MAX_AID_BA + 32)	 //Block ACK recipient
 #define MAX_LEN_OF_BA_ORI_TABLE          ((NUM_OF_TID * MAX_LEN_OF_MAC_TABLE)/2)//   (NUM_OF_TID*MAX_AID_BA + 32)   // Block ACK originator
 #define MAX_LEN_OF_BSS_TABLE             64
 #define MAX_REORDERING_MPDU_NUM			 512
@@ -487,8 +487,8 @@
 #define REASON_CIPHER_SUITE_REJECTED    24
 #define REASON_DECLINED                 37
 
-#define REASON_QOS_UNSPECIFY              32	
-#define REASON_QOS_LACK_BANDWIDTH         33	
+#define REASON_QOS_UNSPECIFY              32
+#define REASON_QOS_LACK_BANDWIDTH         33
 #define REASON_POOR_CHANNEL_CONDITION     34
 #define REASON_QOS_OUTSIDE_TXOP_LIMITION  35
 #define REASON_QOS_QSTA_LEAVING_QBSS      36
@@ -501,7 +501,7 @@
 #define MLME_SUCCESS                    0
 #define MLME_UNSPECIFY_FAIL             1
 #define MLME_CANNOT_SUPPORT_CAP         10
-#define MLME_REASSOC_DENY_ASSOC_EXIST   11 
+#define MLME_REASSOC_DENY_ASSOC_EXIST   11
 #define MLME_ASSOC_DENY_OUT_SCOPE       12
 #define MLME_ALG_NOT_SUPPORT            13
 #define MLME_SEQ_NR_OUT_OF_SEQUENCE     14
@@ -538,7 +538,7 @@
 #define IE_802_11D_REQUEST              10    // 802.11d
 #define IE_QBSS_LOAD                    11    // 802.11e d9
 #define IE_EDCA_PARAMETER               12    // 802.11e d9
-#define IE_TSPEC                        13    // 802.11e d9 
+#define IE_TSPEC                        13    // 802.11e d9
 #define IE_TCLAS                        14    // 802.11e d9
 #define IE_SCHEDULE                     15    // 802.11e d9
 #define IE_CHALLENGE_TEXT               16
@@ -563,7 +563,7 @@
 #define IE_WPA2                         48    // WPA2
 #define IE_EXT_SUPP_RATES               50    // 802.11g
 #define IE_SUPP_REG_CLASS               59    // 802.11y. Supported regulatory classes.
-#define IE_EXT_CHANNEL_SWITCH_ANNOUNCEMENT	60	// 802.11n 
+#define IE_EXT_CHANNEL_SWITCH_ANNOUNCEMENT	60	// 802.11n
 #define IE_ADD_HT                         61    // 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD
 #define IE_ADD_HT2                        53    // 802.11n d1. ADDITIONAL HT CAPABILITY. ELEMENT ID TBD
 
@@ -574,19 +574,19 @@
 #define IE_2040_BSS_COEXIST               72    // 802.11n D3.0.3
 #define IE_2040_BSS_INTOLERANT_REPORT     73    // 802.11n D3.03
 #define IE_OVERLAPBSS_SCAN_PARM           74    // 802.11n D3.03
-#define IE_EXT_CAPABILITY                127   // 802.11n D3.03 
+#define IE_EXT_CAPABILITY                127   // 802.11n D3.03
 
 
 #define IE_WPA                          221   // WPA
 #define IE_VENDOR_SPECIFIC              221   // Wifi WMM (WME)
 
-#define OUI_BROADCOM_HT              51   //  
-#define OUI_BROADCOM_HTADD              52   //  
-#define OUI_PREN_HT_CAP              51   //  
-#define OUI_PREN_ADD_HT              52   //  
+#define OUI_BROADCOM_HT              51   //
+#define OUI_BROADCOM_HTADD              52   //
+#define OUI_PREN_HT_CAP              51   //
+#define OUI_PREN_ADD_HT              52   //
 
 // CCX information
-#define IE_AIRONET_CKIP                 133   // CCX1.0 ID 85H for CKIP 
+#define IE_AIRONET_CKIP                 133   // CCX1.0 ID 85H for CKIP
 #define IE_AP_TX_POWER                  150   // CCX 2.0 for AP transmit power
 #define IE_MEASUREMENT_CAPABILITY       221   // CCX 2.0
 #define IE_CCX_V2                       221
@@ -665,7 +665,7 @@
 #define ASSOC_MACHINE_BASE              0
 #define MT2_MLME_ASSOC_REQ              0
 #define MT2_MLME_REASSOC_REQ            1
-#define MT2_MLME_DISASSOC_REQ           2  
+#define MT2_MLME_DISASSOC_REQ           2
 #define MT2_PEER_DISASSOC_REQ           3
 #define MT2_PEER_ASSOC_REQ              4
 #define MT2_PEER_ASSOC_RSP              5
@@ -687,7 +687,7 @@
 #define ACT_MACHINE_BASE              0
 
 //Those PEER_xx_CATE number is based on real Categary value in IEEE spec. Please don'es modify it by your self.
-//Category 
+//Category
 #define MT2_PEER_SPECTRUM_CATE              0
 #define MT2_PEER_QOS_CATE              1
 #define MT2_PEER_DLS_CATE             2
@@ -826,7 +826,7 @@
 
 //
 // STA's WPA-PSK State machine: states, events, total function #
-// 
+//
 #define WPA_PSK_IDLE					0
 #define MAX_WPA_PSK_STATE				1
 
@@ -855,9 +855,9 @@
 
 #define	AIRONET_FUNC_SIZE				(MAX_AIRONET_STATE * MAX_AIRONET_MSG)
 
-// 
+//
 // AP's CONTROL/CONNECT state machine: states, events, total function #
-// 
+//
 #define AP_CNTL_FUNC_SIZE               1
 
 //
@@ -961,7 +961,7 @@
 
 #define APCLI_ASSOC_MACHINE_BASE           0
 #define APCLI_MT2_MLME_ASSOC_REQ           0
-#define APCLI_MT2_MLME_DISASSOC_REQ        1  
+#define APCLI_MT2_MLME_DISASSOC_REQ        1
 #define APCLI_MT2_PEER_DISASSOC_REQ        2
 #define APCLI_MT2_PEER_ASSOC_RSP           3
 #define APCLI_MT2_ASSOC_TIMEOUT            4
@@ -1117,7 +1117,7 @@
 #define MCS_RATE_24                     4  // OFDM
 #define MCS_RATE_36                     5   // OFDM
 #define MCS_RATE_48                     6  // OFDM
-#define MCS_RATE_54                     7 // OFDM	
+#define MCS_RATE_54                     7 // OFDM
 // HT
 #define MCS_0		0	// 1S
 #define MCS_1		1
@@ -1149,7 +1149,7 @@
 #ifdef DOT11_N_SUPPORT
 // OID_HTPHYMODE
 // MODE
-#define HTMODE_MM	0	 
+#define HTMODE_MM	0
 #define HTMODE_GF	1
 #endif // DOT11_N_SUPPORT //
 
@@ -1168,7 +1168,7 @@
 #define GI_400		GAP_INTERVAL_400	// only support in HT mode
 #define GI_BOTH		GAP_INTERVAL_BOTH
 #endif // DOT11_N_SUPPORT //
-#define GI_800		GAP_INTERVAL_800	
+#define GI_800		GAP_INTERVAL_800
 // STBC
 #define STBC_NONE	0
 #ifdef DOT11_N_SUPPORT
@@ -1182,7 +1182,7 @@
 #define MCSFBK_UNSOLICIT	2	// only support unsolict mcs feedback
 #define MCSFBK_MRQ	3	// response to both MRQ and unsolict mcs feedback
 
-// MIMO power safe 
+// MIMO power safe
 #define	MMPS_STATIC	0
 #define	MMPS_DYNAMIC		1
 #define   MMPS_RSV		2
@@ -1195,7 +1195,7 @@
 
 #endif // DOT11_N_SUPPORT //
 
-// MCS use 7 bits 
+// MCS use 7 bits
 #define TXRATEMIMO		0x80
 #define TXRATEMCS		0x7F
 #define TXRATEOFDM		0x7F
@@ -1237,7 +1237,7 @@
 #define IFS_SIFS                    2
 #define IFS_BACKOFF                 3
 
-// pTxD->RetryMode 
+// pTxD->RetryMode
 #define LONG_RETRY                  1
 #define SHORT_RETRY                 0
 
@@ -1265,7 +1265,7 @@
 #define REGION_7_A_BAND                   7       // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165
 #define REGION_8_A_BAND                   8       // 52, 56, 60, 64
 #define REGION_9_A_BAND                   9       // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165
-#define REGION_10_A_BAND                  10	  // 36, 40, 44, 48, 149, 153, 157, 161, 165	
+#define REGION_10_A_BAND                  10	  // 36, 40, 44, 48, 149, 153, 157, 161, 165
 #define REGION_11_A_BAND                  11	  // 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161
 #define REGION_MAXIMUM_A_BAND             11
 
@@ -1385,11 +1385,11 @@
 #define ENTRY_NOT_FOUND             0xFF
 
 
-/* After Linux 2.6.9, 
- * VLAN module use Private (from user) interface flags (netdevice->priv_flags). 
- * #define IFF_802_1Q_VLAN 0x1         --    802.1Q VLAN device.  in if.h     
+/* After Linux 2.6.9,
+ * VLAN module use Private (from user) interface flags (netdevice->priv_flags).
+ * #define IFF_802_1Q_VLAN 0x1         --    802.1Q VLAN device.  in if.h
  * ref to ip_sabotage_out() [ out->priv_flags & IFF_802_1Q_VLAN ] in br_netfilter.c
- * 
+ *
  * For this reason, we MUST use EVEN value in priv_flags
  */
 #define INT_MAIN                    0x0100
@@ -1426,9 +1426,9 @@
 
 // WIRELESS EVENTS definition
 /* Max number of char in custom event, refer to wireless_tools.28/wireless.20.h */
-#define IW_CUSTOM_MAX_LEN				  			255	/* In bytes */	
+#define IW_CUSTOM_MAX_LEN				  			255	/* In bytes */
 
-// For system event - start 
+// For system event - start
 #define	IW_SYS_EVENT_FLAG_START                     0x0200
 #define	IW_ASSOC_EVENT_FLAG                         0x0200
 #define	IW_DISASSOC_EVENT_FLAG                      0x0201
@@ -1452,7 +1452,7 @@
 // if add new system event flag, please upadte the IW_SYS_EVENT_FLAG_END
 #define	IW_SYS_EVENT_FLAG_END                       0x0212
 #define	IW_SYS_EVENT_TYPE_NUM						(IW_SYS_EVENT_FLAG_END - IW_SYS_EVENT_FLAG_START + 1)
-// For system event - end 
+// For system event - end
 
 // For spoof attack event - start
 #define	IW_SPOOF_EVENT_FLAG_START                   0x0300
@@ -1469,7 +1469,7 @@
 // if add new spoof attack event flag, please upadte the IW_SPOOF_EVENT_FLAG_END
 #define	IW_SPOOF_EVENT_FLAG_END                     0x0309
 #define	IW_SPOOF_EVENT_TYPE_NUM						(IW_SPOOF_EVENT_FLAG_END - IW_SPOOF_EVENT_FLAG_START + 1)
-// For spoof attack event - end 
+// For spoof attack event - end
 
 // For flooding attack event - start
 #define	IW_FLOOD_EVENT_FLAG_START                   0x0400
@@ -1483,7 +1483,7 @@
 // if add new flooding attack event flag, please upadte the IW_FLOOD_EVENT_FLAG_END
 #define	IW_FLOOD_EVENT_FLAG_END                   	0x0406
 #define	IW_FLOOD_EVENT_TYPE_NUM						(IW_FLOOD_EVENT_FLAG_END - IW_FLOOD_EVENT_FLAG_START + 1)
-// For flooding attack - end 
+// For flooding attack - end
 
 // End - WIRELESS EVENTS definition
 
@@ -1550,7 +1550,7 @@
     (UINT64)(((UINT64)(x) & (UINT64) 0x0000ff0000000000ULL) >> 24) | \
     (UINT64)(((UINT64)(x) & (UINT64) 0x00ff000000000000ULL) >> 40) | \
     (UINT64)(((UINT64)(x) & (UINT64) 0xff00000000000000ULL) >> 56) ))
- 
+
 #ifdef RT_BIG_ENDIAN
 
 #define cpu2le64(x) SWAP64((x))
diff --git a/include/rtmp_type.h b/rtmp_type.h
similarity index 92%
rename from include/rtmp_type.h
rename to rtmp_type.h
index fd469b8..1fd7df1 100644
--- a/include/rtmp_type.h
+++ b/rtmp_type.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
     Module Name:
@@ -60,7 +60,7 @@ typedef signed char			CHAR;
 typedef signed short		SHORT;
 typedef signed int			INT;
 typedef signed long			LONG;
-typedef signed long long	LONGLONG;	
+typedef signed long long	LONGLONG;
 
 
 typedef unsigned char		UCHAR;
diff --git a/include/spectrum.h b/spectrum.h
similarity index 94%
rename from include/spectrum.h
rename to spectrum.h
index db94378..60f25db 100644
--- a/include/spectrum.h
+++ b/spectrum.h
@@ -7,28 +7,28 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 */
-
-#ifndef __SPECTRUM_H__
-#define __SPECTRUM_H__
-
-#include "rtmp_type.h"
+
+#ifndef __SPECTRUM_H__
+#define __SPECTRUM_H__
+
+#include "rtmp_type.h"
 #include "spectrum_def.h"
 
 typedef struct PACKED _TPC_REPORT_INFO
@@ -44,28 +44,28 @@ typedef struct PACKED _CH_SW_ANN_INFO
 	UINT8 ChSwCnt;
 } CH_SW_ANN_INFO, *PCH_SW_ANN_INFO;
 
-typedef union PACKED _MEASURE_REQ_MODE
+typedef union PACKED _MEASURE_REQ_MODE
 {
-#ifdef RT_BIG_ENDIAN
-	struct PACKED
-	{
-		UINT8 Rev1:4;
+#ifdef RT_BIG_ENDIAN
+	struct PACKED
+	{
+		UINT8 Rev1:4;
 		UINT8 Report:1;
 		UINT8 Request:1;
 		UINT8 Enable:1;
 		UINT8 Rev0:1;
-	} field;
-#else
-	struct PACKED
-	{
-		UINT8 Rev0:1;
+	} field;
+#else
+	struct PACKED
+	{
+		UINT8 Rev0:1;
 		UINT8 Enable:1;
 		UINT8 Request:1;
 		UINT8 Report:1;
 		UINT8 Rev1:4;
-	} field;
-#endif // RT_BIG_ENDIAN //
-	UINT8 word;
+	} field;
+#endif // RT_BIG_ENDIAN //
+	UINT8 word;
 } MEASURE_REQ_MODE, *PMEASURE_REQ_MODE;
 
 typedef struct PACKED _MEASURE_REQ
@@ -83,30 +83,30 @@ typedef struct PACKED _MEASURE_REQ_INFO
 	MEASURE_REQ MeasureReq;
 } MEASURE_REQ_INFO, *PMEASURE_REQ_INFO;
 
-typedef union PACKED _MEASURE_BASIC_REPORT_MAP
+typedef union PACKED _MEASURE_BASIC_REPORT_MAP
 {
-#ifdef RT_BIG_ENDIAN
-	struct PACKED
-	{
-		UINT8 Rev:3;
+#ifdef RT_BIG_ENDIAN
+	struct PACKED
+	{
+		UINT8 Rev:3;
 		UINT8 Unmeasure:1;
 		UINT8 Radar:1;
 		UINT8 UnidentifiedSignal:1;
 		UINT8 OfdmPreamble:1;
 		UINT8 BSS:1;
-	} field;
-#else
-	struct PACKED
-	{
-		UINT8 BSS:1;
+	} field;
+#else
+	struct PACKED
+	{
+		UINT8 BSS:1;
 		UINT8 OfdmPreamble:1;
 		UINT8 UnidentifiedSignal:1;
 		UINT8 Radar:1;
 		UINT8 Unmeasure:1;
 		UINT8 Rev:3;
-	} field;
-#endif // RT_BIG_ENDIAN //
-	UINT8 word;
+	} field;
+#endif // RT_BIG_ENDIAN //
+	UINT8 word;
 } MEASURE_BASIC_REPORT_MAP, *PMEASURE_BASIC_REPORT_MAP;
 
 typedef struct PACKED _MEASURE_BASIC_REPORT
@@ -135,7 +135,7 @@ typedef struct PACKED _MEASURE_RPI_REPORT
 
 typedef union PACKED _MEASURE_REPORT_MODE
 {
-	struct PACKED
+	struct PACKED
 	{
 #ifdef RT_BIG_ENDIAN
 		UINT8 Rev:5;
@@ -166,140 +166,140 @@ typedef struct PACKED _QUIET_INFO
 	UINT8 QuietPeriod;
 	UINT8 QuietDuration;
 	UINT8 QuietOffset;
-} QUIET_INFO, *PQUIET_INFO;
-
+} QUIET_INFO, *PQUIET_INFO;
+
 /*
 	==========================================================================
 	Description:
 		Prepare Measurement request action frame and enqueue it into
 		management queue waiting for transmition.
-		
+
 	Parametrs:
 		1. the destination mac address of the frame.
-	
+
 	Return	: None.
 	==========================================================================
  */
 VOID EnqueueMeasurementReq(
 	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR pDA,
-	IN UINT8 MeasureToken, 
+	IN UINT8 MeasureToken,
 	IN UINT8 MeasureReqMode,
 	IN UINT8 MeasureReqType,
 	IN UINT8 MeasureCh,
-	IN UINT16 MeasureDuration);
-
+	IN UINT16 MeasureDuration);
+
 /*
 	==========================================================================
 	Description:
 		Prepare Measurement report action frame and enqueue it into
 		management queue waiting for transmition.
-		
+
 	Parametrs:
 		1. the destination mac address of the frame.
-	
+
 	Return	: None.
 	==========================================================================
  */
-VOID EnqueueMeasurementRep(
+VOID EnqueueMeasurementRep(
 	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR pDA,
-	IN UINT8 DialogToken,
-	IN UINT8 MeasureToken, 
+	IN UINT8 DialogToken,
+	IN UINT8 MeasureToken,
 	IN UINT8 MeasureReqMode,
-	IN UINT8 MeasureReqType,
-	IN UINT8 ReportInfoLen,
-	IN PUINT8 pReportInfo);
-
+	IN UINT8 MeasureReqType,
+	IN UINT8 ReportInfoLen,
+	IN PUINT8 pReportInfo);
+
 /*
 	==========================================================================
 	Description:
 		Prepare TPC Request action frame and enqueue it into
 		management queue waiting for transmition.
-		
+
 	Parametrs:
 		1. the destination mac address of the frame.
-	
+
 	Return	: None.
 	==========================================================================
  */
 VOID EnqueueTPCReq(
 	IN PRTMP_ADAPTER pAd,
-	IN PUCHAR pDA,
-	IN UCHAR DialogToken);
-
+	IN PUCHAR pDA,
+	IN UCHAR DialogToken);
+
 /*
 	==========================================================================
 	Description:
 		Prepare TPC Report action frame and enqueue it into
 		management queue waiting for transmition.
-		
+
 	Parametrs:
 		1. the destination mac address of the frame.
-	
+
 	Return	: None.
 	==========================================================================
  */
 VOID EnqueueTPCRep(
 	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR pDA,
-	IN UINT8 DialogToken,
-	IN UINT8 TxPwr,
-	IN UINT8 LinkMargin);
-
+	IN UINT8 DialogToken,
+	IN UINT8 TxPwr,
+	IN UINT8 LinkMargin);
+
 /*
 	==========================================================================
 	Description:
 		Prepare Channel Switch Announcement action frame and enqueue it into
 		management queue waiting for transmition.
-		
+
 	Parametrs:
 		1. the destination mac address of the frame.
 		2. Channel switch announcement mode.
 		2. a New selected channel.
-	
+
 	Return	: None.
 	==========================================================================
  */
 VOID EnqueueChSwAnn(
 	IN PRTMP_ADAPTER pAd,
-	IN PUCHAR pDA, 
+	IN PUCHAR pDA,
 	IN UINT8 ChSwMode,
-	IN UINT8 NewCh);
-
+	IN UINT8 NewCh);
+
 /*
 	==========================================================================
 	Description:
 		Spectrun action frames Handler such as channel switch annoucement,
 		measurement report, measurement request actions frames.
-		
+
 	Parametrs:
 		Elme - MLME message containing the received frame
-	
+
 	Return	: None.
 	==========================================================================
- */
-VOID PeerSpectrumAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem);
-
-/*
+ */
+VOID PeerSpectrumAction(
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem);
+
+/*
 	==========================================================================
 	Description:
-		
+
 	Parametrs:
-	
+
 	Return	: None.
 	==========================================================================
- */
-INT Set_MeasureReq_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	PUCHAR			arg);
-
-INT Set_TpcReq_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	PUCHAR			arg);
-
+ */
+INT Set_MeasureReq_Proc(
+	IN	PRTMP_ADAPTER	pAd,
+	IN	PUCHAR			arg);
+
+INT Set_TpcReq_Proc(
+	IN	PRTMP_ADAPTER	pAd,
+	IN	PUCHAR			arg);
+
 VOID MeasureReqTabInit(
 	IN PRTMP_ADAPTER pAd);
 
@@ -318,5 +318,5 @@ VOID NotifyChSwAnnToPeerAPs(
 	IN PUCHAR pTA,
 	IN UINT8 ChSwMode,
 	IN UINT8 Channel);
-#endif // __SPECTRUM_H__ //
-
+#endif // __SPECTRUM_H__ //
+
diff --git a/include/spectrum_def.h b/spectrum_def.h
similarity index 94%
rename from include/spectrum_def.h
rename to spectrum_def.h
index 3a1566c..4ca4817 100644
--- a/include/spectrum_def.h
+++ b/spectrum_def.h
@@ -7,29 +7,29 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
     Module Name:
 	spectrum_def.h
- 
+
     Abstract:
     Handle association related requests either from WSTA or from local MLME
- 
+
     Revision History:
     Who          When          What
     ---------    ----------    ----------------------------------------------
diff --git a/sta/aironet.c b/sta/aironet.c
index d143f14..4af4a19 100644
--- a/sta/aironet.c
+++ b/sta/aironet.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -34,20 +34,20 @@
 	--------	----------		----------------------------------------------
 	Paul Lin	04-06-15		Initial
 */
-#include "rt_config.h"
+#include "../rt_config.h"
 
-/*	
+/*
 	==========================================================================
-	Description: 
+	Description:
 		association	state machine init,	including state	transition and timer init
-	Parameters:	
+	Parameters:
 		S -	pointer	to the association state machine
 	==========================================================================
  */
 VOID	AironetStateMachineInit(
-	IN	PRTMP_ADAPTER		pAd, 
-	IN	STATE_MACHINE		*S, 
-	OUT	STATE_MACHINE_FUNC	Trans[])	
+	IN	PRTMP_ADAPTER		pAd,
+	IN	STATE_MACHINE		*S,
+	OUT	STATE_MACHINE_FUNC	Trans[])
 {
 	StateMachineInit(S,	Trans, MAX_AIRONET_STATE, MAX_AIRONET_MSG, (STATE_MACHINE_FUNC)Drop, AIRONET_IDLE, AIRONET_MACHINE_BASE);
 	StateMachineSetAction(S, AIRONET_IDLE, MT2_AIRONET_MSG, (STATE_MACHINE_FUNC)AironetMsgAction);
@@ -58,10 +58,10 @@ VOID	AironetStateMachineInit(
 /*
 	==========================================================================
 	Description:
-		This is	state machine function.	
-		When receiving EAPOL packets which is  for 802.1x key management. 
-		Use	both in	WPA, and WPAPSK	case. 
-		In this	function, further dispatch to different	functions according	to the received	packet.	 3 categories are :	
+		This is	state machine function.
+		When receiving EAPOL packets which is  for 802.1x key management.
+		Use	both in	WPA, and WPAPSK	case.
+		In this	function, further dispatch to different	functions according	to the received	packet.	 3 categories are :
 		  1.  normal 4-way pairwisekey and 2-way groupkey handshake
 		  2.  MIC error	(Countermeasures attack)  report packet	from STA.
 		  3.  Request for pairwise/group key update	from STA
@@ -69,7 +69,7 @@ VOID	AironetStateMachineInit(
 	==========================================================================
 */
 VOID	AironetMsgAction(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	MLME_QUEUE_ELEM	*Elem)
 {
 	USHORT							Length;
@@ -77,9 +77,9 @@ VOID	AironetMsgAction(
 	PUCHAR							pData;
 	PAIRONET_RM_REQUEST_FRAME		pRMReq;
 	PRM_REQUEST_ACTION				pReqElem;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("-----> AironetMsgAction\n"));
-	
+
 	// 0. Get Aironet IAPP header first
 	pRMReq = (PAIRONET_RM_REQUEST_FRAME) &Elem->Msg[LENGTH_802_11];
 	pData  = (PUCHAR) &Elem->Msg[LENGTH_802_11];
@@ -102,7 +102,7 @@ VOID	AironetMsgAction(
 	DBGPRINT(RT_DEBUG_TRACE, ("IAPP Dialog Token %x\n", pRMReq->IAPP.Token));
 	DBGPRINT(RT_DEBUG_TRACE, ("IAPP Activation Delay %x\n", pRMReq->Delay));
 	DBGPRINT(RT_DEBUG_TRACE, ("IAPP Measurement Offset %x\n", pRMReq->Offset));
-	
+
 	// 3. Check IAPP frame type, it must be 0x32 for Cisco Aironet extension
 	if (pRMReq->IAPP.Type != AIRONET_IAPP_TYPE)
 	{
@@ -150,14 +150,14 @@ VOID	AironetMsgAction(
 	// Reset the statistics
 	for (i = 0; i < 8; i++)
 		pAd->StaCfg.RPIDensity[i] = 0;
-		
+
 	Index = 0;
-	
+
 	// 8. Save dialog token for report
 	pAd->StaCfg.IAPPToken = pRMReq->IAPP.Token;
-	
+
 	// Save Activation delay & measurement offset, Not really needed
-	
+
 	// 9. Point to the first request element
 	pData += sizeof(AIRONET_RM_REQUEST_FRAME);
 	//    Length should exclude the CISCO Aironet SNAP header
@@ -202,21 +202,21 @@ VOID	AironetMsgAction(
 								if (pReqElem->Measurement.Duration > pAd->StaCfg.CCXControl.field.TuLimit)
 									break;
 						}
-							
+
 						// Save requests and execute actions later
 						NdisMoveMemory(&pAd->StaCfg.MeasurementRequest[Index], pReqElem, sizeof(RM_REQUEST_ACTION));
 						Index += 1;
 						break;
-							
+
 					case MSRN_TYPE_FRAME_REQ:
 						// Since it's option, we will support later
 						// FrameRequestAction(pAd, pData);
 						break;
-						
+
 					default:
 						break;
 				}
-				
+
 				// Point to next Measurement request
 				pData  += sizeof(RM_REQUEST_ACTION);
 				Length -= sizeof(RM_REQUEST_ACTION);
@@ -227,8 +227,8 @@ VOID	AironetMsgAction(
 			case IE_AP_TX_POWER:
 			case IE_MEASUREMENT_CAPABILITY:
 			default:
-				return;				
-		}		
+				return;
+		}
 	}
 
 	// 11. Update some flags and index
@@ -236,40 +236,40 @@ VOID	AironetMsgAction(
 
 	if (Index)
 	{
-		MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_REQ, 0, NULL);		
+		MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_REQ, 0, NULL);
 		RT28XX_MLME_HANDLER(pAd);
 	}
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("<----- AironetMsgAction\n"));
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 
 	Arguments:
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-			
+
 	========================================================================
 */
 VOID	AironetRequestAction(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	MLME_QUEUE_ELEM	*Elem)
 {
 	PRM_REQUEST_ACTION	pReq;
 
 	// 1. Point to next request element
 	pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx];
-		
+
 	// 2. Parse measurement type and call appropriate functions
 	if (pReq->ReqElem.Type == MSRN_TYPE_CHANNEL_LOAD_REQ)
 		// Channel Load measurement request
-		ChannelLoadRequestAction(pAd, pAd->StaCfg.CurrentRMReqIdx);	
+		ChannelLoadRequestAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
 	else if (pReq->ReqElem.Type == MSRN_TYPE_NOISE_HIST_REQ)
 		// Noise Histogram measurement request
 		NoiseHistRequestAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
@@ -292,17 +292,17 @@ VOID	AironetRequestAction(
 			pAd->StaCfg.CCXScanTime = ((pReq->Measurement.Duration > pAd->StaCfg.CCXScanTime) ?
 			(pReq->Measurement.Duration) : (pAd->StaCfg.CCXScanTime));
 		}
-	}	
+	}
 
 	// 4. Call RT28XX_MLME_HANDLER to execute the request mlme commands, Scan request is the only one used
 	RT28XX_MLME_HANDLER(pAd);
-	
+
 }
 
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Prepare channel load report action, special scan operation added
 		to support
@@ -310,17 +310,17 @@ VOID	AironetRequestAction(
 	Arguments:
 		pAd	Pointer	to our adapter
 		pData		Start from element ID
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	ChannelLoadRequestAction(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	UCHAR			Index) 
+	IN	PRTMP_ADAPTER	pAd,
+	IN	UCHAR			Index)
 {
 	PRM_REQUEST_ACTION				pReq;
 	MLME_SCAN_REQ_STRUCT			ScanReq;
@@ -328,12 +328,12 @@ VOID	ChannelLoadRequestAction(
 	NDIS_STATUS						NStatus;
 	PUCHAR							pOutBuffer = NULL;
 	PHEADER_802_11					pNullFrame;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("ChannelLoadRequestAction ----->\n"));
 
 	pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[Index];
 	NdisZeroMemory(ZeroSsid, 32);
-	
+
 	// Prepare for special scan request
 	// The scan definition is different with our Active, Passive scan definition.
 	// For CCX2, Active means send out probe request with broadcast BSSID.
@@ -345,26 +345,26 @@ VOID	ChannelLoadRequestAction(
 	// Control state machine is not idle, reject the request
 	if ((pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (Index == 0))
 		return;
-		
+
 	// Fill out stuff for scan request
 	ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_CISCO_CHANNEL_LOAD);
 	MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
 	pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
 
 	// Reset some internal control flags to make sure this scan works.
-	BssTableInit(&pAd->StaCfg.CCXBssTab); 
+	BssTableInit(&pAd->StaCfg.CCXBssTab);
 	pAd->StaCfg.ScanCnt        = 0;
 	pAd->StaCfg.CCXScanChannel = pReq->Measurement.Channel;
 	pAd->StaCfg.CCXScanTime    = pReq->Measurement.Duration;
 
-	DBGPRINT(RT_DEBUG_TRACE, ("Duration %d, Channel %d!\n", pReq->Measurement.Duration, pReq->Measurement.Channel));	
+	DBGPRINT(RT_DEBUG_TRACE, ("Duration %d, Channel %d!\n", pReq->Measurement.Duration, pReq->Measurement.Channel));
 
 	// If it's non serving channel scan, send out a null frame with PSM bit on.
 	if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
 	{
 		// Use MLME enqueue method
 		NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer);  //Get an unused nonpaged memory
-		if (NStatus	!= NDIS_STATUS_SUCCESS)	
+		if (NStatus	!= NDIS_STATUS_SUCCESS)
 			return;
 
 		pNullFrame = (PHEADER_802_11) pOutBuffer;;
@@ -388,15 +388,15 @@ VOID	ChannelLoadRequestAction(
 
 	// Set channel load measurement flag
 	RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_MEASUREMENT);
-		
+
 	pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("ChannelLoadRequestAction <-----\n"));
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Prepare noise histogram report action, special scan operation added
 		to support
@@ -404,17 +404,17 @@ VOID	ChannelLoadRequestAction(
 	Arguments:
 		pAd	Pointer	to our adapter
 		pData		Start from element ID
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	NoiseHistRequestAction(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	UCHAR			Index) 
+	IN	PRTMP_ADAPTER	pAd,
+	IN	UCHAR			Index)
 {
 	PRM_REQUEST_ACTION				pReq;
 	MLME_SCAN_REQ_STRUCT			ScanReq;
@@ -422,12 +422,12 @@ VOID	NoiseHistRequestAction(
 	NDIS_STATUS						NStatus;
 	PUCHAR							pOutBuffer = NULL;
 	PHEADER_802_11					pNullFrame;
-	   
+
 	DBGPRINT(RT_DEBUG_TRACE, ("NoiseHistRequestAction ----->\n"));
-	
+
 	pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[Index];
 	NdisZeroMemory(ZeroSsid, 32);
-	
+
 	// Prepare for special scan request
 	// The scan definition is different with our Active, Passive scan definition.
 	// For CCX2, Active means send out probe request with broadcast BSSID.
@@ -439,27 +439,27 @@ VOID	NoiseHistRequestAction(
 	// Control state machine is not idle, reject the request
 	if ((pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (Index == 0))
 		return;
-		
+
 	// Fill out stuff for scan request
 	ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_CISCO_NOISE);
 	MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
 	pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
 
 	// Reset some internal control flags to make sure this scan works.
-	BssTableInit(&pAd->StaCfg.CCXBssTab); 
+	BssTableInit(&pAd->StaCfg.CCXBssTab);
 	pAd->StaCfg.ScanCnt        = 0;
 	pAd->StaCfg.CCXScanChannel = pReq->Measurement.Channel;
 	pAd->StaCfg.CCXScanTime    = pReq->Measurement.Duration;
 	pAd->StaCfg.CCXReqType     = MSRN_TYPE_NOISE_HIST_REQ;
 
-	DBGPRINT(RT_DEBUG_TRACE, ("Duration %d, Channel %d!\n", pReq->Measurement.Duration, pReq->Measurement.Channel));	
+	DBGPRINT(RT_DEBUG_TRACE, ("Duration %d, Channel %d!\n", pReq->Measurement.Duration, pReq->Measurement.Channel));
 
 	// If it's non serving channel scan, send out a null frame with PSM bit on.
 	if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
 	{
 		// Use MLME enqueue method
 		NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer);  //Get an unused nonpaged memory
-		if (NStatus	!= NDIS_STATUS_SUCCESS)	
+		if (NStatus	!= NDIS_STATUS_SUCCESS)
 			return;
 
 		pNullFrame = (PHEADER_802_11) pOutBuffer;
@@ -471,7 +471,7 @@ VOID	NoiseHistRequestAction(
 
 		// Send using priority queue
 		MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
-		MlmeFreeMemory(pAd, pOutBuffer);		
+		MlmeFreeMemory(pAd, pOutBuffer);
 		DBGPRINT(RT_DEBUG_TRACE, ("Send PSM Data frame for off channel RM\n"));
 		RTMPusecDelay(5000);
 	}
@@ -479,21 +479,21 @@ VOID	NoiseHistRequestAction(
 	// Reset the statistics
 	for (i = 0; i < 8; i++)
 		pAd->StaCfg.RPIDensity[i] = 0;
-		
+
 	// Enable Rx with promiscuous reception
 	RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, 0x1010);
 
 	// Set channel load measurement flag
 	RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_MEASUREMENT);
-				
+
 	pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("NoiseHistRequestAction <-----\n"));
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Prepare Beacon report action, special scan operation added
 		to support
@@ -501,30 +501,30 @@ VOID	NoiseHistRequestAction(
 	Arguments:
 		pAd	Pointer	to our adapter
 		pData		Start from element ID
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	BeaconRequestAction(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	UCHAR			Index) 
+	IN	PRTMP_ADAPTER	pAd,
+	IN	UCHAR			Index)
 {
 	PRM_REQUEST_ACTION				pReq;
 	NDIS_STATUS						NStatus;
 	PUCHAR							pOutBuffer = NULL;
-	PHEADER_802_11					pNullFrame;	
+	PHEADER_802_11					pNullFrame;
 	MLME_SCAN_REQ_STRUCT			ScanReq;
 	UCHAR							ZeroSsid[32];
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("BeaconRequestAction ----->\n"));
 
 	pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[Index];
 	NdisZeroMemory(ZeroSsid, 32);
-	
+
 	// Prepare for special scan request
 	// The scan definition is different with our Active, Passive scan definition.
 	// For CCX2, Active means send out probe request with broadcast BSSID.
@@ -534,31 +534,31 @@ VOID	BeaconRequestAction(
 	if (pReq->Measurement.ScanMode == MSRN_SCAN_MODE_PASSIVE)
 	{
 		// Passive scan Mode
-		DBGPRINT(RT_DEBUG_TRACE, ("Passive Scan Mode!\n"));	
+		DBGPRINT(RT_DEBUG_TRACE, ("Passive Scan Mode!\n"));
 
 		// Control state machine is not idle, reject the request
 		if ((pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (Index == 0))
 			return;
-		
+
 		// Fill out stuff for scan request
 		ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_CISCO_PASSIVE);
 		MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
 		pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
 
 		// Reset some internal control flags to make sure this scan works.
-		BssTableInit(&pAd->StaCfg.CCXBssTab); 
+		BssTableInit(&pAd->StaCfg.CCXBssTab);
 		pAd->StaCfg.ScanCnt        = 0;
 		pAd->StaCfg.CCXScanChannel = pReq->Measurement.Channel;
 		pAd->StaCfg.CCXScanTime    = pReq->Measurement.Duration;
 		pAd->StaCfg.CCXReqType     = MSRN_TYPE_BEACON_REQ;
-		DBGPRINT(RT_DEBUG_TRACE, ("Duration %d!\n", pReq->Measurement.Duration));	
-		
+		DBGPRINT(RT_DEBUG_TRACE, ("Duration %d!\n", pReq->Measurement.Duration));
+
 		// If it's non serving channel scan, send out a null frame with PSM bit on.
 		if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
 		{
 			// Use MLME enqueue method
 			NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer);  //Get an unused nonpaged memory
-			if (NStatus	!= NDIS_STATUS_SUCCESS)	
+			if (NStatus	!= NDIS_STATUS_SUCCESS)
 				return;
 
 			pNullFrame = (PHEADER_802_11) pOutBuffer;
@@ -573,38 +573,38 @@ VOID	BeaconRequestAction(
 			MlmeFreeMemory(pAd, pOutBuffer);
 			DBGPRINT(RT_DEBUG_TRACE, ("Send PSM Data frame for off channel RM\n"));
 			RTMPusecDelay(5000);
-		}		
-		
+		}
+
 		pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
 	}
 	else if (pReq->Measurement.ScanMode == MSRN_SCAN_MODE_ACTIVE)
 	{
 		// Active scan Mode
 		DBGPRINT(RT_DEBUG_TRACE, ("Active Scan Mode!\n"));
-		
+
 		// Control state machine is not idle, reject the request
 		if (pAd->Mlme.CntlMachine.CurrState != CNTL_IDLE)
 			return;
-		
+
 		// Fill out stuff for scan request
 		ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_CISCO_ACTIVE);
 		MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
 		pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
 
 		// Reset some internal control flags to make sure this scan works.
-		BssTableInit(&pAd->StaCfg.CCXBssTab); 
+		BssTableInit(&pAd->StaCfg.CCXBssTab);
 		pAd->StaCfg.ScanCnt        = 0;
 		pAd->StaCfg.CCXScanChannel = pReq->Measurement.Channel;
 		pAd->StaCfg.CCXScanTime    = pReq->Measurement.Duration;
 		pAd->StaCfg.CCXReqType     = MSRN_TYPE_BEACON_REQ;
-		DBGPRINT(RT_DEBUG_TRACE, ("Duration %d!\n", pReq->Measurement.Duration));	
-		
+		DBGPRINT(RT_DEBUG_TRACE, ("Duration %d!\n", pReq->Measurement.Duration));
+
 		// If it's non serving channel scan, send out a null frame with PSM bit on.
 		if (pAd->StaCfg.CCXScanChannel != pAd->CommonCfg.Channel)
 		{
 			// Use MLME enqueue method
 			NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer);  //Get an unused nonpaged memory
-			if (NStatus	!= NDIS_STATUS_SUCCESS)	
+			if (NStatus	!= NDIS_STATUS_SUCCESS)
 				return;
 
 			pNullFrame = (PHEADER_802_11) pOutBuffer;
@@ -619,8 +619,8 @@ VOID	BeaconRequestAction(
 			MlmeFreeMemory(pAd, pOutBuffer);
 			DBGPRINT(RT_DEBUG_TRACE, ("Send PSM Data frame for off channel RM\n"));
 			RTMPusecDelay(5000);
-		}		
-		
+		}
+
 		pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
 	}
 	else if (pReq->Measurement.ScanMode == MSRN_SCAN_MODE_BEACON_TABLE)
@@ -632,7 +632,7 @@ VOID	BeaconRequestAction(
 		NdisMoveMemory(&pAd->StaCfg.CCXBssTab, &pAd->ScanTab, sizeof(BSS_TABLE));
 
 		// Create beacon report from Bss table
-		AironetCreateBeaconReportFromBssTable(pAd);		
+		AironetCreateBeaconReportFromBssTable(pAd);
 
 		// Set state to scanning
 		pAd->Mlme.AironetMachine.CurrState = AIRONET_SCANNING;
@@ -644,28 +644,28 @@ VOID	BeaconRequestAction(
 	else
 	{
 		// Wrong scan Mode
-		DBGPRINT(RT_DEBUG_TRACE, ("Wrong Scan Mode!\n"));		
-	}	
-	
+		DBGPRINT(RT_DEBUG_TRACE, ("Wrong Scan Mode!\n"));
+	}
+
 	DBGPRINT(RT_DEBUG_TRACE, ("BeaconRequestAction <-----\n"));
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 
 	Arguments:
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	AironetReportAction(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	MLME_QUEUE_ELEM	*Elem)
 {
 	PRM_REQUEST_ACTION	pReq;
@@ -673,11 +673,11 @@ VOID	AironetReportAction(
 
     NdisGetSystemUpTime(&Now32);
 	pAd->StaCfg.LastBeaconRxTime = Now32;
-	
+
 	pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx];
 
 	DBGPRINT(RT_DEBUG_TRACE, ("AironetReportAction ----->\n"));
-	
+
 	// 1. Parse measurement type and call appropriate functions
 	if (pReq->ReqElem.Type == MSRN_TYPE_CHANNEL_LOAD_REQ)
 		// Channel Load measurement request
@@ -691,7 +691,7 @@ VOID	AironetReportAction(
 	else
 		// Unknown. Do nothing and return
 		;
-	
+
 	// 2. Point to the correct index of action element, start from 0
 	pAd->StaCfg.CurrentRMReqIdx++;
 
@@ -699,7 +699,7 @@ VOID	AironetReportAction(
 	if (pAd->StaCfg.ParallelReq == TRUE)
 	{
 		pReq = (PRM_REQUEST_ACTION) &pAd->StaCfg.MeasurementRequest[pAd->StaCfg.CurrentRMReqIdx];
-		
+
 		// Process next action right away
 		if (pReq->ReqElem.Type == MSRN_TYPE_CHANNEL_LOAD_REQ)
 			// Channel Load measurement request
@@ -707,11 +707,11 @@ VOID	AironetReportAction(
 		else if (pReq->ReqElem.Type == MSRN_TYPE_NOISE_HIST_REQ)
 			// Noise Histogram measurement request
 			NoiseHistReportAction(pAd, pAd->StaCfg.CurrentRMReqIdx);
-		
+
 		pAd->StaCfg.ParallelReq = FALSE;
 		pAd->StaCfg.CurrentRMReqIdx++;
 	}
-	
+
 	if (pAd->StaCfg.CurrentRMReqIdx >= pAd->StaCfg.RMReqCnt)
 	{
 		// 4. There is no more unprocessed measurement request, go for transmit this report
@@ -726,9 +726,9 @@ VOID	AironetReportAction(
 		{
 			RTMPusecDelay(100000);
 		}
-	
+
 		// 5. There are more requests to be measure
-		MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_REQ, 0, NULL);		
+		MlmeEnqueue(pAd, AIRONET_STATE_MACHINE, MT2_AIRONET_SCAN_REQ, 0, NULL);
 		RT28XX_MLME_HANDLER(pAd);
 	}
 
@@ -737,16 +737,16 @@ VOID	AironetReportAction(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 
 	Arguments:
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	AironetFinalReportAction(
@@ -762,13 +762,13 @@ VOID	AironetFinalReportAction(
 	ULONG					FrameLen = 0;
 
 	DBGPRINT(RT_DEBUG_TRACE, ("AironetFinalReportAction ----->\n"));
-	
+
 	// 0. Set up the frame pointer, Frame was inited at the end of message action
 	pDest = &pAd->StaCfg.FrameReportBuf[LENGTH_802_11];
 
 	// 1. Update report IAPP fields
 	pIAPP = (PAIRONET_IAPP_HEADER) pDest;
-	
+
 	// 2. Copy Cisco SNAP header
 	NdisMoveMemory(pIAPP->CiscoSnapHeader, SNAP_AIRONET, LENGTH_802_1_H);
 
@@ -778,13 +778,13 @@ VOID	AironetFinalReportAction(
 	// 3.1 sanity check the report length, ignore it if there is nothing to report
 	if (be2cpu16(pIAPP->Length) <= 18)
 		return;
-	
+
 	// 4. Type must be 0x32
 	pIAPP->Type    = AIRONET_IAPP_TYPE;
 
 	// 5. SubType for report must be 0x81
 	pIAPP->SubType = AIRONET_IAPP_SUBTYPE_REPORT;
-	
+
 	// 6. DA is not used and must be zero, although the whole frame was cleared at the start of function
 	//    We will do it again here. We can use BSSID instead
 	COPY_MAC_ADDR(pIAPP->DA, pAd->CommonCfg.Bssid);
@@ -808,48 +808,48 @@ VOID	AironetFinalReportAction(
 
 	// Use MLME enqueue method
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-	if (NStatus	!= NDIS_STATUS_SUCCESS)	
-		return;					
+	if (NStatus	!= NDIS_STATUS_SUCCESS)
+		return;
 
 	// 10. Prepare report frame with dynamic outbuffer. Just simply copy everything.
-	MakeOutgoingFrame(pOutBuffer,                       &FrameLen,	
-	                  pAd->StaCfg.FrameReportLen, pAd->StaCfg.FrameReportBuf, 
+	MakeOutgoingFrame(pOutBuffer,                       &FrameLen,
+	                  pAd->StaCfg.FrameReportLen, pAd->StaCfg.FrameReportBuf,
 		              END_OF_ARGS);
-	
+
 	// 11. Send using priority queue
 	MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
 	MlmeFreeMemory(pAd, pOutBuffer);
 
 	pAd->StaCfg.CCXReqType = MSRN_TYPE_UNUSED;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("AironetFinalReportAction <-----\n"));
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 
 	Arguments:
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	ChannelLoadReportAction(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	UCHAR			Index) 
+	IN	PRTMP_ADAPTER	pAd,
+	IN	UCHAR			Index)
 {
 	PMEASUREMENT_REPORT_ELEMENT	pReport;
 	PCHANNEL_LOAD_REPORT		pLoad;
 	PUCHAR						pDest;
 	UCHAR						CCABusyFraction;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("ChannelLoadReportAction ----->\n"));
-	
+
 	// Disable Rx with promiscuous reception, make it back to normal
 	RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL); // Staion not drop control frame will fail WiFi Certification.
 
@@ -871,7 +871,7 @@ VOID	ChannelLoadReportAction(
 	pLoad->Channel  = pAd->StaCfg.MeasurementRequest[Index].Measurement.Channel;
 	pLoad->Spare    = 0;
 	pLoad->Duration = pAd->StaCfg.MeasurementRequest[Index].Measurement.Duration;
-	
+
 	// 3. Calculate the CCA Busy Fraction
 	//    (Bytes + ACK size) * 8 / Tx speed * 255 / 1000 / measurement duration, use 24 us Tx speed
 	//     =  (Bytes + ACK) / 12 / duration
@@ -880,10 +880,10 @@ VOID	ChannelLoadReportAction(
 	CCABusyFraction = (UCHAR) (pAd->StaCfg.CLBusyBytes / pAd->StaCfg.CLFactor / pLoad->Duration);
 	if (CCABusyFraction < 10)
 			CCABusyFraction = (UCHAR) (pAd->StaCfg.CLBusyBytes / 3 / pLoad->Duration) + 1;
-	
+
 	pLoad->CCABusy = CCABusyFraction;
 	DBGPRINT(RT_DEBUG_TRACE, ("CLBusyByte %ld, Duration %d, Result, %d\n", pAd->StaCfg.CLBusyBytes, pLoad->Duration, CCABusyFraction));
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("FrameReportLen %d\n", pAd->StaCfg.FrameReportLen));
 	pAd->StaCfg.FrameReportLen += (sizeof(MEASUREMENT_REPORT_ELEMENT) + sizeof(CHANNEL_LOAD_REPORT));
 	DBGPRINT(RT_DEBUG_TRACE, ("FrameReportLen %d\n", pAd->StaCfg.FrameReportLen));
@@ -891,28 +891,28 @@ VOID	ChannelLoadReportAction(
 	// 4. Clear channel load measurement flag
 	RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_MEASUREMENT);
 
-	// 5. reset to idle state	
+	// 5. reset to idle state
 	pAd->Mlme.AironetMachine.CurrState = AIRONET_IDLE;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("ChannelLoadReportAction <-----\n"));
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 
 	Arguments:
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	NoiseHistReportAction(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	UCHAR			Index)
 {
 	PMEASUREMENT_REPORT_ELEMENT	pReport;
@@ -920,9 +920,9 @@ VOID	NoiseHistReportAction(
 	PUCHAR						pDest;
 	UCHAR						i,NoiseCnt;
 	USHORT						TotalRPICnt, TotalRPISum;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("NoiseHistReportAction ----->\n"));
-	
+
 	// 0. Disable Rx with promiscuous reception, make it back to normal
 	RTMP_IO_WRITE32(pAd, RX_FILTR_CFG, STANORMAL); // Staion not drop control frame will fail WiFi Certification.
 	// 1. Setup pointer for processing beacon & probe response
@@ -950,7 +950,7 @@ VOID	NoiseHistReportAction(
 	// TotalRPICnt = pNoise->Duration * 3 / 10;
 	TotalRPICnt = pNoise->Duration * pAd->StaCfg.NHFactor / 10;
 	TotalRPISum = 0;
-	
+
 	for (i = 0; i < 8; i++)
 	{
 		TotalRPISum += pAd->StaCfg.RPIDensity[i];
@@ -961,9 +961,9 @@ VOID	NoiseHistReportAction(
 	// We will replace it with the total number plus a fraction.
 	if (TotalRPISum > TotalRPICnt)
 		TotalRPICnt = TotalRPISum + pNoise->Duration / 20;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("Total RPI Conuts %d\n", TotalRPICnt));
-	
+
 	// 5. Initialize noise count for the total summation of 0xff
 	NoiseCnt = 0;
 	for (i = 1; i < 8; i++)
@@ -972,77 +972,77 @@ VOID	NoiseHistReportAction(
 		if ((pNoise->Density[i] == 0) && (pAd->StaCfg.RPIDensity[i] != 0))
 			pNoise->Density[i]++;
 		NoiseCnt += pNoise->Density[i];
-		DBGPRINT(RT_DEBUG_TRACE, ("Reported RPI[%d]  = 0x%02x\n", i, pNoise->Density[i]));	
+		DBGPRINT(RT_DEBUG_TRACE, ("Reported RPI[%d]  = 0x%02x\n", i, pNoise->Density[i]));
 	}
-	
+
 	// 6. RPI[0] represents the rest of counts
 	pNoise->Density[0] = 0xff - NoiseCnt;
-	DBGPRINT(RT_DEBUG_TRACE, ("Reported RPI[0]  = 0x%02x\n", pNoise->Density[0]));	
-	
-	pAd->StaCfg.FrameReportLen += (sizeof(MEASUREMENT_REPORT_ELEMENT) + sizeof(NOISE_HIST_REPORT));	
+	DBGPRINT(RT_DEBUG_TRACE, ("Reported RPI[0]  = 0x%02x\n", pNoise->Density[0]));
+
+	pAd->StaCfg.FrameReportLen += (sizeof(MEASUREMENT_REPORT_ELEMENT) + sizeof(NOISE_HIST_REPORT));
 
 	// 7. Clear channel load measurement flag
 	RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_MEASUREMENT);
 
-	// 8. reset to idle state	
+	// 8. reset to idle state
 	pAd->Mlme.AironetMachine.CurrState = AIRONET_IDLE;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("NoiseHistReportAction <-----\n"));
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Prepare Beacon report action,
 
 	Arguments:
 		pAd	Pointer	to our adapter
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	BeaconReportAction(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	UCHAR			Index) 
+	IN	PRTMP_ADAPTER	pAd,
+	IN	UCHAR			Index)
 {
 	DBGPRINT(RT_DEBUG_TRACE, ("BeaconReportAction ----->\n"));
 
 	// Looks like we don't have anything thing need to do here.
 	// All measurement report already finished in AddBeaconReport
 	// The length is in the FrameReportLen
-	
-	// reset Beacon index for next beacon request	
+
+	// reset Beacon index for next beacon request
 	pAd->StaCfg.LastBssIndex = 0xff;
-	
-	// reset to idle state	
+
+	// reset to idle state
 	pAd->Mlme.AironetMachine.CurrState = AIRONET_IDLE;
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("BeaconReportAction <-----\n"));
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 
 	Arguments:
 		Index		Current BSSID in CCXBsstab entry index
-		
+
 	Return Value:
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	AironetAddBeaconReport(
 	IN	PRTMP_ADAPTER		pAd,
 	IN	ULONG				Index,
-	IN	PMLME_QUEUE_ELEM	pElem) 
+	IN	PMLME_QUEUE_ELEM	pElem)
 {
 	PVOID						pMsg;
 	PUCHAR						pSrc, pDest;
@@ -1054,15 +1054,15 @@ VOID	AironetAddBeaconReport(
 	PEID_STRUCT			        pEid;
 	PBEACON_REPORT				pBeaconReport;
 	PBSS_ENTRY					pBss;
-	
+
 	// 0. Setup pointer for processing beacon & probe response
 	pMsg   = pElem->Msg;
-	MsgLen = pElem->MsgLen;	
+	MsgLen = pElem->MsgLen;
 	pFrame = (PFRAME_802_11) pMsg;
 	pSrc   = pFrame->Octet;				// Start from AP TSF
 	pBss   = (PBSS_ENTRY) &pAd->StaCfg.CCXBssTab.BssEntry[Index];
 	ReqIdx = pAd->StaCfg.CurrentRMReqIdx;
-	
+
 	// 1 Check the Index, if we already create this entry, only update the average RSSI
 	if ((Index <= pAd->StaCfg.LastBssIndex) && (pAd->StaCfg.LastBssIndex != 0xff))
 	{
@@ -1078,22 +1078,22 @@ VOID	AironetAddBeaconReport(
 		pBeaconReport->RxPower  = (pBeaconReport->RxPower + pBss->Rssi) / 2;
 		// Get to dBm format
 		pBeaconReport->RxPower -= pAd->BbpRssiToDbmDelta;
-		
+
 		DBGPRINT(RT_DEBUG_TRACE, ("Bssid %02x:%02x:%02x:%02x:%02x:%02x ",
 			pBss->Bssid[0], pBss->Bssid[1], pBss->Bssid[2],
 			pBss->Bssid[3], pBss->Bssid[4], pBss->Bssid[5]));
 		DBGPRINT(RT_DEBUG_TRACE, ("RxPower[%ld] Rssi %d, Avg Rssi %d\n", Index, (pBss->Rssi - pAd->BbpRssiToDbmDelta), pBeaconReport->RxPower - 256));
 		DBGPRINT(RT_DEBUG_TRACE, ("FrameReportLen = %d\n", pAd->StaCfg.BssReportOffset[Index]));
-		
+
 		// Update other information here
 
 		// Done
 		return;
 	}
-	
+
 	// 2. Update reported Index
 	pAd->StaCfg.LastBssIndex = Index;
-	
+
 	// 3. Setup the buffer address for copying this BSSID into reporting frame
 	//    The offset should start after 802.11 header and report frame header.
 	pDest = (PUCHAR) &pAd->StaCfg.FrameReportBuf[pAd->StaCfg.FrameReportLen];
@@ -1134,8 +1134,8 @@ VOID	AironetAddBeaconReport(
 	COPY_MAC_ADDR(pBeaconReport->BSSID, pFrame->Hdr.Addr3);
 	NdisMoveMemory(pBeaconReport->ParentTSF, pSrc, 4);
 	NdisMoveMemory(pBeaconReport->TargetTSF, &pElem->TimeStamp.u.LowPart, 4);
-	NdisMoveMemory(&pBeaconReport->TargetTSF[4], &pElem->TimeStamp.u.HighPart, 4);	
-	
+	NdisMoveMemory(&pBeaconReport->TargetTSF[4], &pElem->TimeStamp.u.HighPart, 4);
+
 	// 9. Skip the beacon frame and offset to start of capabilityinfo since we already processed capabilityinfo
 	pSrc += (TIMESTAMP_LEN + 2);
 	pBeaconReport->CapabilityInfo = *(USHORT *)pSrc;
@@ -1162,7 +1162,7 @@ VOID	AironetAddBeaconReport(
 				pDest  += (pEid->Len + 2);
 				Length += (pEid->Len + 2);
 				break;
-				
+
 			case IE_MEASUREMENT_CAPABILITY:
 				// Since this IE is duplicated with WPA security IE, we has to do sanity check before
 				// recognize it.
@@ -1175,10 +1175,10 @@ VOID	AironetAddBeaconReport(
 					// Matched, this is what we want
 					NdisMoveMemory(pDest, pEid, pEid->Len + 2);
 					pDest  += (pEid->Len + 2);
-					Length += (pEid->Len + 2);					
+					Length += (pEid->Len + 2);
 				}
 				break;
-				
+
 			case IE_TIM:
 				if (pEid->Len > 4)
 				{
@@ -1194,9 +1194,9 @@ VOID	AironetAddBeaconReport(
 					Length += (pEid->Len + 2);
 				}
 				break;
-				
+
 			default:
-				break;				
+				break;
 		}
 		// 12. Move to next element ID
 		pSrc += (2 + pEid->Len);
@@ -1207,22 +1207,22 @@ VOID	AironetAddBeaconReport(
 	pReport->Length = Length - 4;
 
 	// 14. Update the frame report buffer data length
-	pAd->StaCfg.FrameReportLen += Length;	
+	pAd->StaCfg.FrameReportLen += Length;
 	DBGPRINT(RT_DEBUG_TRACE, ("FR len = %d\n", pAd->StaCfg.FrameReportLen));
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 
 	Arguments:
 		Index		Current BSSID in CCXBsstab entry index
-		
+
 	Return Value:
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	AironetCreateBeaconReportFromBssTable(
@@ -1237,7 +1237,7 @@ VOID	AironetCreateBeaconReportFromBssTable(
 
 	// 0. setup base pointer
 	ReqIdx = pAd->StaCfg.CurrentRMReqIdx;
-	
+
 	for (Index = 0; Index < pAd->StaCfg.CCXBssTab.BssNr; Index++)
 	{
 		// 1. Setup the buffer address for copying this BSSID into reporting frame
@@ -1245,7 +1245,7 @@ VOID	AironetCreateBeaconReportFromBssTable(
 		pDest  = (PUCHAR) &pAd->StaCfg.FrameReportBuf[pAd->StaCfg.FrameReportLen];
 		pBss   = (PBSS_ENTRY) &pAd->StaCfg.CCXBssTab.BssEntry[Index];
 		Length = 0;
-		
+
 		// 2. Fill Measurement report fields
 		pReport         = (PMEASUREMENT_REPORT_ELEMENT) pDest;
 		pReport->Eid    = IE_MEASUREMENT_REPORT;
@@ -1286,7 +1286,7 @@ VOID	AironetCreateBeaconReportFromBssTable(
 		NdisMoveMemory(pDest, pBss->SupRate, pBss->SupRateLen);
 		pDest  += pBss->SupRateLen;
 		Length += (2 + pBss->SupRateLen);
-		
+
 		// 7. DS Parameter
 		*pDest++ = 0x03;
 		*pDest++ = 1;
@@ -1300,7 +1300,7 @@ VOID	AironetCreateBeaconReportFromBssTable(
 			*pDest++ = 2;
 			*(PUSHORT) pDest = pBss->AtimWin;
 			pDest   += 2;
-			Length  += 4;			
+			Length  += 4;
 		}
 
 		// 9. Update length field, not include EID and length
@@ -1308,5 +1308,5 @@ VOID	AironetCreateBeaconReportFromBssTable(
 
 		// 10. Update total frame size
 		pAd->StaCfg.FrameReportLen += Length;
-	}	
+	}
 }
diff --git a/sta/assoc.c b/sta/assoc.c
index 246cc62..42db753 100644
--- a/sta/assoc.c
+++ b/sta/assoc.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -34,7 +34,7 @@
 	--------	----------		----------------------------------------------
 	John		2004-9-3		porting from RT2500
 */
-#include "rt_config.h"
+#include "../rt_config.h"
 
 UCHAR	CipherWpaTemplate[] = {
 		0xdd, 					// WPA IE
@@ -50,7 +50,7 @@ UCHAR	CipherWpaTemplate[] = {
 
 UCHAR	CipherWpa2Template[] = {
 		0x30,					// RSN IE
-		0x14,					// Length	
+		0x14,					// Length
 		0x01, 0x00,				// Version
 		0x00, 0x0f, 0xac, 0x02,	// group cipher, TKIP
 		0x01, 0x00,				// number of pairwise
@@ -62,21 +62,21 @@ UCHAR	CipherWpa2Template[] = {
 
 UCHAR	Ccx2IeInfo[] = { 0x00, 0x40, 0x96, 0x03, 0x02};
 
-/*  
+/*
 	==========================================================================
-	Description: 
+	Description:
 		association state machine init, including state transition and timer init
-	Parameters: 
+	Parameters:
 		S - pointer to the association state machine
 
 	IRQL = PASSIVE_LEVEL
-	
+
 	==========================================================================
  */
 VOID AssocStateMachineInit(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN  STATE_MACHINE *S, 
-	OUT STATE_MACHINE_FUNC Trans[]) 
+	IN	PRTMP_ADAPTER	pAd,
+	IN  STATE_MACHINE *S,
+	OUT STATE_MACHINE_FUNC Trans[])
 {
 	StateMachineInit(S, Trans, MAX_ASSOC_STATE, MAX_ASSOC_MSG, (STATE_MACHINE_FUNC)Drop, ASSOC_IDLE, ASSOC_MACHINE_BASE);
 
@@ -108,7 +108,7 @@ VOID AssocStateMachineInit(
 	//
 	// Patch, AP doesn't send Reassociate Rsp frame to Station.
 	//
-	StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP, (STATE_MACHINE_FUNC)PeerReassocRspAction);	
+	StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP, (STATE_MACHINE_FUNC)PeerReassocRspAction);
 	StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_REASSOC_TIMEOUT, (STATE_MACHINE_FUNC)ReassocTimeoutAction);
 
 	// fourth column
@@ -127,7 +127,7 @@ VOID AssocStateMachineInit(
 /*
 	==========================================================================
 	Description:
-		Association timeout procedure. After association timeout, this function 
+		Association timeout procedure. After association timeout, this function
 		will be called and it will put a message into the MLME queue
 	Parameters:
 		Standard timer parameters
@@ -136,18 +136,18 @@ VOID AssocStateMachineInit(
 
 	==========================================================================
  */
-VOID AssocTimeout(IN PVOID SystemSpecific1, 
-				 IN PVOID FunctionContext, 
-				 IN PVOID SystemSpecific2, 
-				 IN PVOID SystemSpecific3) 
+VOID AssocTimeout(IN PVOID SystemSpecific1,
+				 IN PVOID FunctionContext,
+				 IN PVOID SystemSpecific2,
+				 IN PVOID SystemSpecific3)
 {
 	RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-	
+
 	// Do nothing if the driver is starting halt state.
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
 		return;
-	
+
 	MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_ASSOC_TIMEOUT, 0, NULL);
 	RT28XX_MLME_HANDLER(pAd);
 }
@@ -155,7 +155,7 @@ VOID AssocTimeout(IN PVOID SystemSpecific1,
 /*
 	==========================================================================
 	Description:
-		Reassociation timeout procedure. After reassociation timeout, this 
+		Reassociation timeout procedure. After reassociation timeout, this
 		function will be called and put a message into the MLME queue
 	Parameters:
 		Standard timer parameters
@@ -164,18 +164,18 @@ VOID AssocTimeout(IN PVOID SystemSpecific1,
 
 	==========================================================================
  */
-VOID ReassocTimeout(IN PVOID SystemSpecific1, 
-					IN PVOID FunctionContext, 
-					IN PVOID SystemSpecific2, 
-					IN PVOID SystemSpecific3) 
+VOID ReassocTimeout(IN PVOID SystemSpecific1,
+					IN PVOID FunctionContext,
+					IN PVOID SystemSpecific2,
+					IN PVOID SystemSpecific3)
 {
 	RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-	
+
 	// Do nothing if the driver is starting halt state.
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
 		return;
-	
+
 	MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_REASSOC_TIMEOUT, 0, NULL);
 	RT28XX_MLME_HANDLER(pAd);
 }
@@ -183,7 +183,7 @@ VOID ReassocTimeout(IN PVOID SystemSpecific1,
 /*
 	==========================================================================
 	Description:
-		Disassociation timeout procedure. After disassociation timeout, this 
+		Disassociation timeout procedure. After disassociation timeout, this
 		function will be called and put a message into the MLME queue
 	Parameters:
 		Standard timer parameters
@@ -192,18 +192,18 @@ VOID ReassocTimeout(IN PVOID SystemSpecific1,
 
 	==========================================================================
  */
-VOID DisassocTimeout(IN PVOID SystemSpecific1, 
-					IN PVOID FunctionContext, 
-					IN PVOID SystemSpecific2, 
-					IN PVOID SystemSpecific3) 
+VOID DisassocTimeout(IN PVOID SystemSpecific1,
+					IN PVOID FunctionContext,
+					IN PVOID SystemSpecific2,
+					IN PVOID SystemSpecific3)
 {
 	RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-	
+
 	// Do nothing if the driver is starting halt state.
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
 		return;
-	
+
 	MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_DISASSOC_TIMEOUT, 0, NULL);
 	RT28XX_MLME_HANDLER(pAd);
 }
@@ -231,8 +231,8 @@ VOID DisassocTimeout(IN PVOID SystemSpecific1,
 	==========================================================================
  */
 VOID MlmeAssocReqAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR			ApAddr[6];
 	HEADER_802_11	AssocHdr;
@@ -263,16 +263,16 @@ VOID MlmeAssocReqAction(
 		pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
 		Status = MLME_STATE_MACHINE_REJECT;
 		MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
-	}	
+	}
 	// check sanity first
-	else if (MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv)) 
+	else if (MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
 	{
 		RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled);
 		COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
 
 		// Get an unused nonpaged memory
-		NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  
-		if (NStatus != NDIS_STATUS_SUCCESS) 
+		NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
+		if (NStatus != NDIS_STATUS_SUCCESS)
 		{
 			DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeAssocReqAction() allocate memory failed \n"));
 			pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
@@ -282,16 +282,16 @@ VOID MlmeAssocReqAction(
 		}
 
 		// Add by James 03/06/27
-		pAd->StaCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); 
+		pAd->StaCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
 		// Association don't need to report MAC address
 		pAd->StaCfg.AssocInfo.AvailableRequestFixedIEs =
 			NDIS_802_11_AI_REQFI_CAPABILITIES | NDIS_802_11_AI_REQFI_LISTENINTERVAL;
 		pAd->StaCfg.AssocInfo.RequestFixedIEs.Capabilities = CapabilityInfo;
-		pAd->StaCfg.AssocInfo.RequestFixedIEs.ListenInterval = ListenIntv;		
+		pAd->StaCfg.AssocInfo.RequestFixedIEs.ListenInterval = ListenIntv;
 		// Only reassociate need this
 		//COPY_MAC_ADDR(pAd->StaCfg.AssocInfo.RequestFixedIEs.CurrentAPAddress, ApAddr);
 		pAd->StaCfg.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
-		
+
         NdisZeroMemory(pAd->StaCfg.ReqVarIEs, MAX_VIE_LEN);
 		// First add SSID
 		VarIesOffset = 0;
@@ -311,20 +311,20 @@ VOID MlmeAssocReqAction(
 		VarIesOffset += pAd->MlmeAux.SupRateLen;
 		// End Add by James
 
-        if ((pAd->CommonCfg.Channel > 14) && 
+        if ((pAd->CommonCfg.Channel > 14) &&
             (pAd->CommonCfg.bIEEE80211H == TRUE))
             CapabilityInfo |= 0x0100;
 
 		DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send ASSOC request...\n"));
 		MgtMacHeaderInit(pAd, &AssocHdr, SUBTYPE_ASSOC_REQ, 0, ApAddr, ApAddr);
-		
+
 		// Build basic frame first
 		MakeOutgoingFrame(pOutBuffer,				&FrameLen,
 						  sizeof(HEADER_802_11),	&AssocHdr,
 						  2,						&CapabilityInfo,
 						  2,						&ListenIntv,
 						  1,						&SsidIe,
-						  1,						&pAd->MlmeAux.SsidLen, 
+						  1,						&pAd->MlmeAux.SsidLen,
 						  pAd->MlmeAux.SsidLen, 	pAd->MlmeAux.Ssid,
 						  1,						&SupRateIe,
 						  1,						&pAd->MlmeAux.SupRateLen,
@@ -336,7 +336,7 @@ VOID MlmeAssocReqAction(
 			MakeOutgoingFrame(pOutBuffer + FrameLen,    &tmp,
 							  1,                        &ExtRateIe,
 							  1,                        &pAd->MlmeAux.ExtRateLen,
-							  pAd->MlmeAux.ExtRateLen,  pAd->MlmeAux.ExtRate,							
+							  pAd->MlmeAux.ExtRateLen,  pAd->MlmeAux.ExtRate,
 							  END_OF_ARGS);
 			FrameLen += tmp;
 		}
@@ -355,20 +355,20 @@ VOID MlmeAssocReqAction(
 							  1,                                &WpaIe,
 							  1,                                &HtLen,
 							  4,                                &BROADCOM[0],
-							 pAd->MlmeAux.HtCapabilityLen,          &pAd->MlmeAux.HtCapability, 
+							 pAd->MlmeAux.HtCapabilityLen,          &pAd->MlmeAux.HtCapability,
 							  END_OF_ARGS);
 			}
-			else				
+			else
 			{
 #ifdef RT_BIG_ENDIAN
 		        HT_CAPABILITY_IE HtCapabilityTmp;
-#endif			
+#endif
 
 #ifndef RT_BIG_ENDIAN
 				MakeOutgoingFrame(pOutBuffer + FrameLen,            &TmpLen,
 							  1,                                &HtCapIe,
 							  1,                                &pAd->MlmeAux.HtCapabilityLen,
-							 pAd->MlmeAux.HtCapabilityLen,          &pAd->MlmeAux.HtCapability, 
+							 pAd->MlmeAux.HtCapabilityLen,          &pAd->MlmeAux.HtCapability,
 							  END_OF_ARGS);
 #else
                 NdisZeroMemory(&HtCapabilityTmp, sizeof(HT_CAPABILITY_IE));
@@ -379,7 +379,7 @@ VOID MlmeAssocReqAction(
         		MakeOutgoingFrame(pOutBuffer + FrameLen,         &TmpLen,
         							1,                           &HtCapIe,
         							1,                           &pAd->MlmeAux.HtCapabilityLen,
-        							pAd->MlmeAux.HtCapabilityLen,&HtCapabilityTmp, 
+        							pAd->MlmeAux.HtCapabilityLen,&HtCapabilityTmp,
         							END_OF_ARGS);
 #endif
 			}
@@ -400,7 +400,7 @@ VOID MlmeAssocReqAction(
 			if ((pAd->CommonCfg.bPiggyBackCapable) && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3))
 			{
 				ULONG TmpLen;
-				UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00}; 
+				UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00};
 				MakeOutgoingFrame(pOutBuffer+FrameLen,           &TmpLen,
 								  9,                             RalinkIe,
 								  END_OF_ARGS);
@@ -409,7 +409,7 @@ VOID MlmeAssocReqAction(
 			else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
 			{
 				ULONG TmpLen;
-				UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00}; 
+				UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
 				MakeOutgoingFrame(pOutBuffer+FrameLen,           &TmpLen,
 								  9,                             RalinkIe,
 								  END_OF_ARGS);
@@ -419,7 +419,7 @@ VOID MlmeAssocReqAction(
 		else
 		{
 			ULONG TmpLen;
-			UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x06, 0x00, 0x00, 0x00}; 
+			UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x06, 0x00, 0x00, 0x00};
 			MakeOutgoingFrame(pOutBuffer+FrameLen,		 &TmpLen,
 							  9,						 RalinkIe,
 							  END_OF_ARGS);
@@ -451,35 +451,35 @@ VOID MlmeAssocReqAction(
 							  END_OF_ARGS);
 			FrameLen += tmp;
 		}
-		
+
 		//
 		// Let WPA(#221) Element ID on the end of this association frame.
 		// Otherwise some AP will fail on parsing Element ID and set status fail on Assoc Rsp.
 		// For example: Put Vendor Specific IE on the front of WPA IE.
 		// This happens on AP (Model No:Linksys WRK54G)
-		//		
-		if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) || 
+		//
+		if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
             (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
-            (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || 
+            (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
             (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
-			)            
-            )          
+			)
+            )
 		{
 			UCHAR RSNIe = IE_WPA;
-			
+
 			if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
                 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
 			{
 				RSNIe = IE_WPA2;
-			}	
-			
+			}
+
 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
 #ifdef SIOCSIWGENIE
 			if (pAd->StaCfg.WpaSupplicantUP != 1)
 #endif // SIOCSIWGENIE //
 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
             	RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0);
-            
+
             // Check for WPA PMK cache list
 			if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
 			{
@@ -503,7 +503,7 @@ VOID MlmeAssocReqAction(
                     pAd->StaCfg.RSNIE_Len += 18;
 				}
 			}
-			
+
 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
 #ifdef SIOCSIWGENIE
 			if (pAd->StaCfg.WpaSupplicantUP == 1)
@@ -542,18 +542,18 @@ VOID MlmeAssocReqAction(
 
 			// Set Variable IEs Length
 			pAd->StaCfg.ReqVarIELen = VarIesOffset;
-		}	
+		}
 
 		// We have update that at PeerBeaconAtJoinRequest()
-		CkipFlag = pAd->StaCfg.CkipFlag;	
+		CkipFlag = pAd->StaCfg.CkipFlag;
 		if (CkipFlag != 0)
-		{				
+		{
 			NdisZeroMemory(CkipNegotiationBuffer, CKIP_NEGOTIATION_LENGTH);
 			CkipNegotiationBuffer[2] = 0x66;
 			// Make it try KP & MIC, since we have to follow the result from AssocRsp
 			CkipNegotiationBuffer[8] = 0x18;
 			CkipNegotiationBuffer[CKIP_NEGOTIATION_LENGTH - 1] = 0x22;
-			CkipFlag = 0x18;		
+			CkipFlag = 0x18;
 
 			MakeOutgoingFrame(pOutBuffer + FrameLen, 	&tmp,
 						1,						  		&AironetCkipIe,
@@ -566,7 +566,7 @@ VOID MlmeAssocReqAction(
 		// Add CCX v2 request if CCX2 admin state is on
 		if (pAd->StaCfg.CCXControl.field.Enable == 1)
 		{
-			
+
 			//
 			// Add AironetIPAddressIE for Cisco CCX 2.X
 			// Add CCX Version
@@ -584,7 +584,7 @@ VOID MlmeAssocReqAction(
 			//
 			// Add CipherSuite CCKM or LeapTkip if setting.
 			//
-#ifdef LEAP_SUPPORT			
+#ifdef LEAP_SUPPORT
 			if (LEAP_CCKM_ON(pAd))
 			{
 				MakeOutgoingFrame(pOutBuffer + FrameLen,	&tmp,
@@ -595,7 +595,7 @@ VOID MlmeAssocReqAction(
 				// Third add RSN
 				NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, CipherSuiteCiscoCCKM, CipherSuiteCiscoCCKMLen); //Save CipherSuite
 				VarIesOffset += CipherSuiteCiscoCCKMLen;
-			} 
+			}
 			else if ((pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP) && (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled))
 			{
 				MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
@@ -608,7 +608,7 @@ VOID MlmeAssocReqAction(
 				VarIesOffset += CipherSuiteCCXTkipLen;
 			}
 #endif // LEAP_SUPPORT //
-			
+
 			// Add by James 03/06/27
 			// Set Variable IEs Length
 			pAd->StaCfg.ReqVarIELen = VarIesOffset;
@@ -616,8 +616,8 @@ VOID MlmeAssocReqAction(
 
 			// OffsetResponseIEs follow ReqVarIE
 			pAd->StaCfg.AssocInfo.OffsetResponseIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) + pAd->StaCfg.ReqVarIELen;
-			// End Add by James 
-		}		
+			// End Add by James
+		}
 
 
 		MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
@@ -625,8 +625,8 @@ VOID MlmeAssocReqAction(
 
 		RTMPSetTimer(&pAd->MlmeAux.AssocTimer, Timeout);
 		pAd->Mlme.AssocMachine.CurrState = ASSOC_WAIT_RSP;
-	} 
-	else 
+	}
+	else
 	{
 		DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeAssocReqAction() sanity check failed. BUG!!!!!! \n"));
 		pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
@@ -641,7 +641,7 @@ VOID MlmeAssocReqAction(
 	Description:
 		mlme reassoc req handling procedure
 	Parameters:
-		Elem - 
+		Elem -
 	Pre:
 		-# SSID  (Adapter->StaCfg.ssid[])
 		-# BSSID (AP address, Adapter->StaCfg.bssid)
@@ -654,12 +654,12 @@ VOID MlmeAssocReqAction(
 	==========================================================================
  */
 VOID MlmeReassocReqAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR			ApAddr[6];
 	HEADER_802_11	ReassocHdr;
-	UCHAR			Ccx2Len = 5;	
+	UCHAR			Ccx2Len = 5;
 	UCHAR			WmeIe[9] = {IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
 	USHORT			CapabilityInfo, ListenIntv;
 	ULONG			Timeout;
@@ -684,7 +684,7 @@ VOID MlmeReassocReqAction(
 	UCHAR			MICMN[16];
 	UCHAR			CalcMicBuffer[80];
 	ULONG			CalcMicBufferLen = 0;
-#endif // LEAP_SUPPORT //	
+#endif // LEAP_SUPPORT //
 	USHORT			Status;
 
 	// Block all authentication request durning WPA block period
@@ -694,14 +694,14 @@ VOID MlmeReassocReqAction(
 		pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
 		Status = MLME_STATE_MACHINE_REJECT;
 		MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
-	}	
+	}
 	// the parameters are the same as the association
-	else if(MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv)) 
+	else if(MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
 	{
 		RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled);
 
 		NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-		if(NStatus != NDIS_STATUS_SUCCESS) 
+		if(NStatus != NDIS_STATUS_SUCCESS)
 		{
 			DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeReassocReqAction() allocate memory failed \n"));
 			pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
@@ -721,8 +721,8 @@ VOID MlmeReassocReqAction(
 						  2,                        &ListenIntv,
 						  MAC_ADDR_LEN,             ApAddr,
 						  1,                        &SsidIe,
-						  1,                        &pAd->MlmeAux.SsidLen, 
-						  pAd->MlmeAux.SsidLen,     pAd->MlmeAux.Ssid, 
+						  1,                        &pAd->MlmeAux.SsidLen,
+						  pAd->MlmeAux.SsidLen,     pAd->MlmeAux.Ssid,
 						  1,                        &SupRateIe,
 						  1,						&pAd->MlmeAux.SupRateLen,
 						  pAd->MlmeAux.SupRateLen,  pAd->MlmeAux.SupRate,
@@ -733,7 +733,7 @@ VOID MlmeReassocReqAction(
 			MakeOutgoingFrame(pOutBuffer + FrameLen,        &tmp,
 							  1,                            &ExtRateIe,
 							  1,                            &pAd->MlmeAux.ExtRateLen,
-							  pAd->MlmeAux.ExtRateLen,	    pAd->MlmeAux.ExtRate,							
+							  pAd->MlmeAux.ExtRateLen,	    pAd->MlmeAux.ExtRate,
 							  END_OF_ARGS);
 			FrameLen += tmp;
 		}
@@ -773,15 +773,15 @@ VOID MlmeReassocReqAction(
 							  1,                                &WpaIe,
 							  1,                                &HtLen,
 							  4,                                &BROADCOM[0],
-							 pAd->MlmeAux.HtCapabilityLen,          &pAd->MlmeAux.HtCapability, 
+							 pAd->MlmeAux.HtCapabilityLen,          &pAd->MlmeAux.HtCapability,
 							  END_OF_ARGS);
 			}
-			else				
+			else
 			{
 				MakeOutgoingFrame(pOutBuffer + FrameLen,            &TmpLen,
 							  1,                                &HtCapIe,
 							  1,                                &pAd->MlmeAux.HtCapabilityLen,
-							 pAd->MlmeAux.HtCapabilityLen,          &pAd->MlmeAux.HtCapability, 
+							 pAd->MlmeAux.HtCapabilityLen,          &pAd->MlmeAux.HtCapability,
 							  END_OF_ARGS);
 			}
 			FrameLen += TmpLen;
@@ -801,7 +801,7 @@ VOID MlmeReassocReqAction(
 			if ((pAd->CommonCfg.bPiggyBackCapable) && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3))
 			{
 				ULONG TmpLen;
-				UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00}; 
+				UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00};
 				MakeOutgoingFrame(pOutBuffer+FrameLen,           &TmpLen,
 								  9,                             RalinkIe,
 								  END_OF_ARGS);
@@ -810,7 +810,7 @@ VOID MlmeReassocReqAction(
 			else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
 			{
 				ULONG TmpLen;
-				UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00}; 
+				UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
 				MakeOutgoingFrame(pOutBuffer+FrameLen,           &TmpLen,
 								  9,                             RalinkIe,
 								  END_OF_ARGS);
@@ -820,7 +820,7 @@ VOID MlmeReassocReqAction(
 		else
 		{
 			ULONG TmpLen;
-			UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x04, 0x00, 0x00, 0x00}; 
+			UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x04, 0x00, 0x00, 0x00};
 			MakeOutgoingFrame(pOutBuffer+FrameLen,		 &TmpLen,
 							  9,						 RalinkIe,
 							  END_OF_ARGS);
@@ -873,14 +873,14 @@ VOID MlmeReassocReqAction(
 			hmac_md5(pAd->StaCfg.KRK, LEN_EAP_MICK, CalcMicBuffer, CalcMicBufferLen, MICMN);
 
 			//
-			// fill up CCKM reassociation request element 
+			// fill up CCKM reassociation request element
 			//
 			NdisMoveMemory(AironetCCKMReassocBuffer, AironetOUI, 4);
 			NdisMoveMemory(AironetCCKMReassocBuffer + 4, (PUCHAR)&pAd->StaCfg.CCKMBeaconAtJoinTimeStamp, 8);
 			NdisMoveMemory(AironetCCKMReassocBuffer + 12, (PUCHAR) &pAd->StaCfg.CCKMRN, 4);
 			NdisMoveMemory(AironetCCKMReassocBuffer +16, MICMN, 8);
 
-			MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp, 
+			MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
 							1,                      &AironetCCKMReassocIE,
 							1,                      &AironetCCKMReassocLen,
 							AironetCCKMReassocLen,  AironetCCKMReassocBuffer,
@@ -906,15 +906,15 @@ VOID MlmeReassocReqAction(
 						Ccx2Len,				    Ccx2IeInfo,
 						END_OF_ARGS);
 			FrameLen += tmp;
-		}		
+		}
 
 		MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
 		MlmeFreeMemory(pAd, pOutBuffer);
 
 		RTMPSetTimer(&pAd->MlmeAux.ReassocTimer, Timeout); /* in mSec */
 		pAd->Mlme.AssocMachine.CurrState = REASSOC_WAIT_RSP;
-	} 
-	else 
+	}
+	else
 	{
 		DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeReassocReqAction() sanity check failed. BUG!!!! \n"));
 		pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
@@ -935,8 +935,8 @@ VOID MlmeReassocReqAction(
 	==========================================================================
  */
 VOID MlmeDisassocReqAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	PMLME_DISASSOC_REQ_STRUCT pDisassocReq;
 	HEADER_802_11         DisassocHdr;
@@ -949,7 +949,7 @@ VOID MlmeDisassocReqAction(
 	USHORT                Status;
 
 #ifdef QOS_DLS_SUPPORT
-	// send DLS-TEAR_DOWN message, 
+	// send DLS-TEAR_DOWN message,
 	if (pAd->CommonCfg.bDLSCapable)
 	{
 		UCHAR i;
@@ -982,7 +982,7 @@ VOID MlmeDisassocReqAction(
 	pDisassocReq = (PMLME_DISASSOC_REQ_STRUCT)(Elem->Msg);
 
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-	if (NStatus != NDIS_STATUS_SUCCESS) 
+	if (NStatus != NDIS_STATUS_SUCCESS)
 	{
 		DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - MlmeDisassocReqAction() allocate memory failed\n"));
 		pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
@@ -995,13 +995,13 @@ VOID MlmeDisassocReqAction(
 
 	RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &TimerCancelled);
 
-	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send DISASSOC request[BSSID::%02x:%02x:%02x:%02x:%02x:%02x (Reason=%d)\n", 
+	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send DISASSOC request[BSSID::%02x:%02x:%02x:%02x:%02x:%02x (Reason=%d)\n",
 				pDisassocReq->Addr[0], pDisassocReq->Addr[1], pDisassocReq->Addr[2],
 				pDisassocReq->Addr[3], pDisassocReq->Addr[4], pDisassocReq->Addr[5], pDisassocReq->Reason));
 	MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pDisassocReq->Addr, pDisassocReq->Addr);	// patch peap ttls switching issue
-	MakeOutgoingFrame(pOutBuffer,           &FrameLen, 
-					  sizeof(HEADER_802_11),&DisassocHdr, 
-					  2,                    &pDisassocReq->Reason, 
+	MakeOutgoingFrame(pOutBuffer,           &FrameLen,
+					  sizeof(HEADER_802_11),&DisassocHdr,
+					  2,                    &pDisassocReq->Reason,
 					  END_OF_ARGS);
 	MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
 
@@ -1011,7 +1011,7 @@ VOID MlmeDisassocReqAction(
 	pDisassocHdr = (PHEADER_802_11)pOutBuffer;
 	pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH;
 	MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-	
+
 	MlmeFreeMemory(pAd, pOutBuffer);
 
 	pAd->StaCfg.DisassocReason = REASON_DISASSOC_STA_LEAVING;
@@ -1022,14 +1022,14 @@ VOID MlmeDisassocReqAction(
 
 #ifdef WPA_SUPPLICANT_SUPPORT
 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
-    if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) 
+    if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
 	{
         union iwreq_data    wrqu;
         //send disassociate event to wpa_supplicant
         memset(&wrqu, 0, sizeof(wrqu));
         wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
         wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
-    } 
+    }
 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
 #endif // WPA_SUPPLICANT_SUPPORT //
 
@@ -1039,7 +1039,7 @@ VOID MlmeDisassocReqAction(
         memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
         wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
     }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //        
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
 
 }
 
@@ -1055,8 +1055,8 @@ VOID MlmeDisassocReqAction(
 	==========================================================================
  */
 VOID PeerAssocRspAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT        CapabilityInfo, Status, Aid;
 	UCHAR         SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
@@ -1066,26 +1066,26 @@ VOID PeerAssocRspAction(
 	UCHAR         CkipFlag;
 	EDCA_PARM     EdcaParm;
 	HT_CAPABILITY_IE		HtCapability;
-	ADD_HT_INFO_IE		AddHtInfo;	// AP might use this additional ht info IE 
+	ADD_HT_INFO_IE		AddHtInfo;	// AP might use this additional ht info IE
 	UCHAR			HtCapabilityLen;
 	UCHAR			AddHtInfoLen;
 	UCHAR			NewExtChannelOffset = 0xff;
 
-	if (PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen, 
-		&HtCapability,&AddHtInfo, &HtCapabilityLen,&AddHtInfoLen,&NewExtChannelOffset, &EdcaParm, &CkipFlag)) 
+	if (PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen,
+		&HtCapability,&AddHtInfo, &HtCapabilityLen,&AddHtInfoLen,&NewExtChannelOffset, &EdcaParm, &CkipFlag))
 	{
 		// The frame is for me ?
-		if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) 
+		if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid))
 		{
 			DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspAction():ASSOC - receive ASSOC_RSP to me (status=%d)\n", Status));
 #ifdef DOT11_N_SUPPORT
 			DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspAction():MacTable [%d].AMsduSize = %d. ClientStatusFlags = 0x%lx \n",Elem->Wcid, pAd->MacTab.Content[BSSID_WCID].AMsduSize, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
 #endif // DOT11_N_SUPPORT //
 			RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled);
-			if(Status == MLME_SUCCESS) 
+			if(Status == MLME_SUCCESS)
 			{
 				// go to procedure listed on page 376
-				AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen, 
+				AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen,
 					&EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo);
 
 #ifdef WPA_SUPPLICANT_SUPPORT
@@ -1106,11 +1106,11 @@ VOID PeerAssocRspAction(
                 {
                     union iwreq_data    wrqu;
                     wext_notify_event_assoc(pAd);
-                    
+
                     memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
                     memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
                     wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-                    
+
                 }
 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
 
@@ -1127,9 +1127,9 @@ VOID PeerAssocRspAction(
 					pAd->StaCfg.bCkipOn = TRUE;
 					DBGPRINT(RT_DEBUG_TRACE, ("<CCX> pAd->StaCfg.CkipFlag = 0x%02x\n", pAd->StaCfg.CkipFlag));
 				}
-			} 
-			else 
-			{  
+			}
+			else
+			{
 				// Faile on Association, we need to check the status code
 				// Is that a Rogue AP?
 #ifdef LEAP_SUPPORT
@@ -1141,7 +1141,7 @@ VOID PeerAssocRspAction(
 			}
 			pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
 			MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
-		} 
+		}
 	}
 	else
 	{
@@ -1161,8 +1161,8 @@ VOID PeerAssocRspAction(
 	==========================================================================
  */
 VOID PeerReassocRspAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT      CapabilityInfo;
 	USHORT      Status;
@@ -1174,23 +1174,23 @@ VOID PeerReassocRspAction(
 	BOOLEAN     TimerCancelled;
 	EDCA_PARM   EdcaParm;
 	HT_CAPABILITY_IE		HtCapability;
-	ADD_HT_INFO_IE		AddHtInfo;	// AP might use this additional ht info IE 
+	ADD_HT_INFO_IE		AddHtInfo;	// AP might use this additional ht info IE
 	UCHAR			HtCapabilityLen;
 	UCHAR			AddHtInfoLen;
 	UCHAR			NewExtChannelOffset = 0xff;
 
-	if(PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen, 
-								&HtCapability,	&AddHtInfo, &HtCapabilityLen, &AddHtInfoLen,&NewExtChannelOffset, &EdcaParm, &CkipFlag)) 
+	if(PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen,
+								&HtCapability,	&AddHtInfo, &HtCapabilityLen, &AddHtInfoLen,&NewExtChannelOffset, &EdcaParm, &CkipFlag))
 	{
 		if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) // The frame is for me ?
 		{
 			DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - receive REASSOC_RSP to me (status=%d)\n", Status));
 			RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled);
 
-			if(Status == MLME_SUCCESS) 
+			if(Status == MLME_SUCCESS)
 			{
 				// go to procedure listed on page 376
-				AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen, 
+				AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen,
 					 &EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo);
 
 #ifdef WPA_SUPPLICANT_SUPPORT
@@ -1211,15 +1211,15 @@ VOID PeerReassocRspAction(
                 {
                     union iwreq_data    wrqu;
                     wext_notify_event_assoc(pAd);
-                    
+
                     memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
                     memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
                     wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-                    
+
                 }
 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
 
-			} 
+			}
 
 			//
 			// Cisco Leap CCKM supported Re-association.
@@ -1257,7 +1257,7 @@ VOID PeerReassocRspAction(
 				pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
 				MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
 			}
-		} 
+		}
 	}
 	else
 	{
@@ -1269,7 +1269,7 @@ VOID PeerReassocRspAction(
 /*
 	==========================================================================
 	Description:
-		procedures on IEEE 802.11/1999 p.376 
+		procedures on IEEE 802.11/1999 p.376
 	Parametrs:
 
 	IRQL = DISPATCH_LEVEL
@@ -1277,18 +1277,18 @@ VOID PeerReassocRspAction(
 	==========================================================================
  */
 VOID AssocPostProc(
-	IN PRTMP_ADAPTER pAd, 
-	IN PUCHAR pAddr2, 
-	IN USHORT CapabilityInfo, 
-	IN USHORT Aid, 
-	IN UCHAR SupRate[], 
+	IN PRTMP_ADAPTER pAd,
+	IN PUCHAR pAddr2,
+	IN USHORT CapabilityInfo,
+	IN USHORT Aid,
+	IN UCHAR SupRate[],
 	IN UCHAR SupRateLen,
 	IN UCHAR ExtRate[],
 	IN UCHAR ExtRateLen,
 	IN PEDCA_PARM pEdcaParm,
 	IN HT_CAPABILITY_IE		*pHtCapability,
-	IN UCHAR HtCapabilityLen, 
-	IN ADD_HT_INFO_IE		*pAddHtInfo)	// AP might use this additional ht info IE 
+	IN UCHAR HtCapabilityLen,
+	IN ADD_HT_INFO_IE		*pAddHtInfo)	// AP might use this additional ht info IE
 {
 	ULONG Idx;
 
@@ -1342,14 +1342,14 @@ VOID AssocPostProc(
 		RTMPCheckHt(pAd, BSSID_WCID, pHtCapability, pAddHtInfo);
 	}
 	DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===>  AP.AMsduSize = %d. ClientStatusFlags = 0x%lx \n", pAd->MacTab.Content[BSSID_WCID].AMsduSize, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
-		
-	DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===>    (Mmps=%d, AmsduSize=%d, )\n", 
+
+	DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===>    (Mmps=%d, AmsduSize=%d, )\n",
 		pAd->MacTab.Content[BSSID_WCID].MmpsMode, pAd->MacTab.Content[BSSID_WCID].AMsduSize));
 #endif // DOT11_N_SUPPORT //
 
 	// Set New WPA information
 	Idx = BssTableSearch(&pAd->ScanTab, pAddr2, pAd->MlmeAux.Channel);
-	if (Idx == BSS_NOT_FOUND) 
+	if (Idx == BSS_NOT_FOUND)
 	{
 		DBGPRINT_ERR(("ASSOC - Can't find BSS after receiving Assoc response\n"));
 	}
@@ -1361,7 +1361,7 @@ VOID AssocPostProc(
 
 		// Store appropriate RSN_IE for WPA SM negotiation later
 		if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAd->ScanTab.BssEntry[Idx].VarIELen != 0))
-		{					
+		{
 			PUCHAR              pVIE;
 			USHORT              len;
 			PEID_STRUCT         pEid;
@@ -1371,13 +1371,13 @@ VOID AssocPostProc(
 
 			while (len > 0)
 			{
-				pEid = (PEID_STRUCT) pVIE;	
+				pEid = (PEID_STRUCT) pVIE;
 				// For WPA/WPAPSK
-				if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4)) 
+				if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
 					&& (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
 				{
 					NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, pVIE, (pEid->Len + 2));
-					pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = (pEid->Len + 2);							
+					pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = (pEid->Len + 2);
 					DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> Store RSN_IE for WPA SM negotiation \n"));
 				}
 				// For WPA2/WPA2PSK
@@ -1385,18 +1385,18 @@ VOID AssocPostProc(
 					&& (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2 || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
 				{
 					NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, pVIE, (pEid->Len + 2));
-					pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = (pEid->Len + 2);	
+					pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = (pEid->Len + 2);
 					DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> Store RSN_IE for WPA2 SM negotiation \n"));
 				}
 
 				pVIE += (pEid->Len + 2);
 				len  -= (pEid->Len + 2);
-			}			
+			}
 		}
 
 		if (pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == 0)
-		{			
-			DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> no RSN_IE \n"));			
+		{
+			DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> no RSN_IE \n"));
 		}
 		else
 		{
@@ -1408,7 +1408,7 @@ VOID AssocPostProc(
 /*
 	==========================================================================
 	Description:
-		left part of IEEE 802.11/1999 p.374 
+		left part of IEEE 802.11/1999 p.374
 	Parameters:
 		Elem - MLME message containing the received frame
 
@@ -1417,30 +1417,30 @@ VOID AssocPostProc(
 	==========================================================================
  */
 VOID PeerDisassocAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR         Addr2[MAC_ADDR_LEN];
 	USHORT        Reason;
 
 	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction()\n"));
-	if(PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason)) 
+	if(PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason))
 	{
 		DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction() Reason = %d\n", Reason));
-		if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, Addr2)) 
+		if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, Addr2))
 		{
 
 			if (pAd->CommonCfg.bWirelessEvent)
-			{				
-				RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); 
+			{
+				RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
 			}
 
 
 #ifdef LEAP_SUPPORT
 			if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
 			{
-				// Cisco_LEAP has start a timer 
-				// We should cancel it if using LEAP			
+				// Cisco_LEAP has start a timer
+				// We should cancel it if using LEAP
 				RTMPCancelTimer(&pAd->StaCfg.LeapAuthTimer, &TimerCancelled);
 				//Check is it mach the LEAP Authentication failed as possible a Rogue AP
 				//on it's PortSecured not equal to WPA_802_1X_PORT_SECURED while process the Association.
@@ -1448,26 +1448,26 @@ VOID PeerDisassocAction(
 				{
 					RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_AUTH_TIMEOUT);
 				}
-			}	
-#endif	// LEAP_SUPPORT //		
+			}
+#endif	// LEAP_SUPPORT //
 			//
-			// Get Current System time and Turn on AdjacentAPReport 
+			// Get Current System time and Turn on AdjacentAPReport
 			//
-			NdisGetSystemUpTime(&pAd->StaCfg.CCXAdjacentAPLinkDownTime); 
+			NdisGetSystemUpTime(&pAd->StaCfg.CCXAdjacentAPLinkDownTime);
 			pAd->StaCfg.CCXAdjacentAPReportFlag = TRUE;
 			LinkDown(pAd, TRUE);
 			pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
 
 #ifdef WPA_SUPPLICANT_SUPPORT
 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
-            if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) 
+            if (pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
 			{
                 union iwreq_data    wrqu;
                 //send disassociate event to wpa_supplicant
                 memset(&wrqu, 0, sizeof(wrqu));
                 wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
                 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
-            } 
+            }
 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
 #endif // WPA_SUPPLICANT_SUPPORT //
 
@@ -1477,7 +1477,7 @@ VOID PeerDisassocAction(
                 memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
                 wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
             }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // 
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
 		}
 	}
 	else
@@ -1499,8 +1499,8 @@ VOID PeerDisassocAction(
 	==========================================================================
  */
 VOID AssocTimeoutAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT  Status;
 	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - AssocTimeoutAction\n"));
@@ -1519,8 +1519,8 @@ VOID AssocTimeoutAction(
 	==========================================================================
  */
 VOID ReassocTimeoutAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT  Status;
 	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - ReassocTimeoutAction\n"));
@@ -1539,8 +1539,8 @@ VOID ReassocTimeoutAction(
 	==========================================================================
  */
 VOID DisassocTimeoutAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT  Status;
 	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - DisassocTimeoutAction\n"));
@@ -1550,11 +1550,11 @@ VOID DisassocTimeoutAction(
 }
 
 VOID InvalidStateWhenAssoc(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT  Status;
-	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenAssoc(state=%ld), reset ASSOC state machine\n", 
+	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenAssoc(state=%ld), reset ASSOC state machine\n",
 		pAd->Mlme.AssocMachine.CurrState));
 	pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
 	Status = MLME_STATE_MACHINE_REJECT;
@@ -1562,11 +1562,11 @@ VOID InvalidStateWhenAssoc(
 }
 
 VOID InvalidStateWhenReassoc(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT Status;
-	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenReassoc(state=%ld), reset ASSOC state machine\n", 
+	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenReassoc(state=%ld), reset ASSOC state machine\n",
 		pAd->Mlme.AssocMachine.CurrState));
 	pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
 	Status = MLME_STATE_MACHINE_REJECT;
@@ -1574,11 +1574,11 @@ VOID InvalidStateWhenReassoc(
 }
 
 VOID InvalidStateWhenDisassociate(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT Status;
-	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenDisassoc(state=%ld), reset ASSOC state machine\n", 
+	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenDisassoc(state=%ld), reset ASSOC state machine\n",
 		pAd->Mlme.AssocMachine.CurrState));
 	pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
 	Status = MLME_STATE_MACHINE_REJECT;
@@ -1589,7 +1589,7 @@ VOID InvalidStateWhenDisassociate(
 	==========================================================================
 	Description:
 		right part of IEEE 802.11/1999 page 374
-	Note: 
+	Note:
 		This event should never cause ASSOC state machine perform state
 		transition, and has no relationship with CNTL machine. So we separate
 		this routine as a service outside of ASSOC state transition table.
@@ -1599,8 +1599,8 @@ VOID InvalidStateWhenDisassociate(
 	==========================================================================
  */
 VOID Cls3errAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN PUCHAR        pAddr) 
+	IN PRTMP_ADAPTER pAd,
+	IN PUCHAR        pAddr)
 {
 	HEADER_802_11         DisassocHdr;
 	PHEADER_802_11        pDisassocHdr;
@@ -1610,14 +1610,14 @@ VOID Cls3errAction(
 	USHORT                Reason = REASON_CLS3ERR;
 
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-	if (NStatus != NDIS_STATUS_SUCCESS) 
+	if (NStatus != NDIS_STATUS_SUCCESS)
 		return;
 
 	DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Class 3 Error, Send DISASSOC frame\n"));
 	MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pAddr, pAd->CommonCfg.Bssid);	// patch peap ttls switching issue
-	MakeOutgoingFrame(pOutBuffer,           &FrameLen, 
-					  sizeof(HEADER_802_11),&DisassocHdr, 
-					  2,                    &Reason, 
+	MakeOutgoingFrame(pOutBuffer,           &FrameLen,
+					  sizeof(HEADER_802_11),&DisassocHdr,
+					  2,                    &Reason,
 					  END_OF_ARGS);
 	MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
 
@@ -1627,7 +1627,7 @@ VOID Cls3errAction(
 	pDisassocHdr = (PHEADER_802_11)pOutBuffer;
 	pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH;
 	MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
-	
+
 	MlmeFreeMemory(pAd, pOutBuffer);
 
 	pAd->StaCfg.DisassocReason = REASON_CLS3ERR;
@@ -1650,7 +1650,7 @@ VOID SwitchBetweenWepAndCkip(
 	int            i;
 	SHAREDKEY_MODE_STRUC  csr1;
 
-	// if KP is required. change the CipherAlg in hardware shard key table from WEP 
+	// if KP is required. change the CipherAlg in hardware shard key table from WEP
 	// to CKIP. else remain as WEP
 	if (pAd->StaCfg.bCkipOn && (pAd->StaCfg.CkipFlag & 0x10))
 	{
@@ -1688,7 +1688,7 @@ VOID SwitchBetweenWepAndCkip(
 		}
 	}
 
-	// else if KP NOT inused. change the CipherAlg in hardware shard key table from CKIP 
+	// else if KP NOT inused. change the CipherAlg in hardware shard key table from CKIP
 	// to WEP.
 	else
 	{
@@ -1713,7 +1713,7 @@ VOID SwitchBetweenWepAndCkip(
 			csr1.field.Bss0Key3CipherAlg = CIPHER_WEP64;
 		else if (csr1.field.Bss0Key3CipherAlg == CIPHER_CKIP128)
 			csr1.field.Bss0Key3CipherAlg = CIPHER_WEP128;
- 
+
 		// modify software key table so that driver can specify correct algorithm in TXD upon TX
 		for (i=0; i<SHARE_KEY_NUM; i++)
 		{
@@ -1744,7 +1744,7 @@ VOID SwitchBetweenWepAndCkip(
 						pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_AES;
 					}
 				}
-				else 
+				else
 				{
 					pAd->SharedKey[BSS0][i].CipherAlg = CIPHER_NONE;
 				}
@@ -1756,13 +1756,13 @@ VOID SwitchBetweenWepAndCkip(
 			csr1.field.Bss0Key3CipherAlg = pAd->SharedKey[BSS0][3].CipherAlg;
 		}
 		RTMP_IO_WRITE32(pAd, SHARED_KEY_MODE_BASE, csr1.word);
-		DBGPRINT(RT_DEBUG_TRACE, ("SwitchBetweenWepAndCkip: modify BSS0 cipher to %s\n", CipherName[csr1.field.Bss0Key0CipherAlg]));		
+		DBGPRINT(RT_DEBUG_TRACE, ("SwitchBetweenWepAndCkip: modify BSS0 cipher to %s\n", CipherName[csr1.field.Bss0Key0CipherAlg]));
 	}
 }
 
 #ifdef WPA_SUPPLICANT_SUPPORT
 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
-VOID    SendAssocIEsToWpaSupplicant( 
+VOID    SendAssocIEsToWpaSupplicant(
     IN  PRTMP_ADAPTER pAd)
 {
     union iwreq_data    wrqu;
@@ -1783,7 +1783,7 @@ VOID    SendAssocIEsToWpaSupplicant(
     }
     else
         DBGPRINT(RT_DEBUG_TRACE, ("pAd->StaCfg.ReqVarIELen + 17 > MAX_CUSTOM_LEN\n"));
-    
+
     return;
 }
 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
@@ -1820,7 +1820,7 @@ int wext_notify_event_assoc(
 #endif
 
 	return 0;
-	
+
 }
 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
 
diff --git a/sta/auth.c b/sta/auth.c
index 794f6a3..73fb8d6 100644
--- a/sta/auth.c
+++ b/sta/auth.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -34,7 +34,7 @@
 	--------	----------		----------------------------------------------
 	John		2004-9-3		porting from RT2500
 */
-#include "rt_config.h"
+#include "../rt_config.h"
 
 /*
     ==========================================================================
@@ -44,24 +44,24 @@
         Sm - pointer to the auth state machine
     Note:
         The state machine looks like this
-        
+
                         AUTH_REQ_IDLE           AUTH_WAIT_SEQ2                   AUTH_WAIT_SEQ4
     MT2_MLME_AUTH_REQ   mlme_auth_req_action    invalid_state_when_auth          invalid_state_when_auth
     MT2_PEER_AUTH_EVEN  drop                    peer_auth_even_at_seq2_action    peer_auth_even_at_seq4_action
     MT2_AUTH_TIMEOUT    Drop                    auth_timeout_action              auth_timeout_action
-        
+
 	IRQL = PASSIVE_LEVEL
 
     ==========================================================================
  */
 
 void AuthStateMachineInit(
-    IN PRTMP_ADAPTER pAd, 
-    IN STATE_MACHINE *Sm, 
-    OUT STATE_MACHINE_FUNC Trans[]) 
+    IN PRTMP_ADAPTER pAd,
+    IN STATE_MACHINE *Sm,
+    OUT STATE_MACHINE_FUNC Trans[])
 {
     StateMachineInit(Sm, Trans, MAX_AUTH_STATE, MAX_AUTH_MSG, (STATE_MACHINE_FUNC)Drop, AUTH_REQ_IDLE, AUTH_MACHINE_BASE);
-     
+
     // the first column
     StateMachineSetAction(Sm, AUTH_REQ_IDLE, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)MlmeAuthReqAction);
 
@@ -69,12 +69,12 @@ void AuthStateMachineInit(
     StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAuth);
     StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_PEER_AUTH_EVEN, (STATE_MACHINE_FUNC)PeerAuthRspAtSeq2Action);
     StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_AUTH_TIMEOUT, (STATE_MACHINE_FUNC)AuthTimeoutAction);
-    
+
     // the third column
     StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAuth);
     StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_PEER_AUTH_EVEN, (STATE_MACHINE_FUNC)PeerAuthRspAtSeq4Action);
     StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_AUTH_TIMEOUT, (STATE_MACHINE_FUNC)AuthTimeoutAction);
-    
+
 	RTMPInitTimer(pAd, &pAd->MlmeAux.AuthTimer, GET_TIMER_FUNCTION(AuthTimeout), pAd, FALSE);
 }
 
@@ -82,31 +82,31 @@ void AuthStateMachineInit(
     ==========================================================================
     Description:
         function to be executed at timer thread when auth timer expires
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID AuthTimeout(
-    IN PVOID SystemSpecific1, 
-    IN PVOID FunctionContext, 
-    IN PVOID SystemSpecific2, 
-    IN PVOID SystemSpecific3) 
+    IN PVOID SystemSpecific1,
+    IN PVOID FunctionContext,
+    IN PVOID SystemSpecific2,
+    IN PVOID SystemSpecific3)
 {
     RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-    
+
     DBGPRINT(RT_DEBUG_TRACE,("AUTH - AuthTimeout\n"));
-	
+
 	// Do nothing if the driver is starting halt state.
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
 		return;
-	
+
 	// send a de-auth to reset AP's state machine (Patch AP-Dir635)
 	if (pAd->Mlme.AuthMachine.CurrState == AUTH_WAIT_SEQ2)
 		Cls2errAction(pAd, pAd->MlmeAux.Bssid);
-	
-	
+
+
     MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_AUTH_TIMEOUT, 0, NULL);
     RT28XX_MLME_HANDLER(pAd);
 }
@@ -115,14 +115,14 @@ VOID AuthTimeout(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID MlmeAuthReqAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
     UCHAR              Addr[6];
     USHORT             Alg, Seq, Status;
@@ -140,8 +140,8 @@ VOID MlmeAuthReqAction(
         pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
         Status = MLME_STATE_MACHINE_REJECT;
         MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
-	}	
-    else if(MlmeAuthReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr, &Timeout, &Alg)) 
+	}
+    else if(MlmeAuthReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr, &Timeout, &Alg))
     {
         // reset timer
         RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
@@ -149,9 +149,9 @@ VOID MlmeAuthReqAction(
         pAd->MlmeAux.Alg  = Alg;
         Seq = 1;
         Status = MLME_SUCCESS;
-        
+
         NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-        if(NStatus != NDIS_STATUS_SUCCESS) 
+        if(NStatus != NDIS_STATUS_SUCCESS)
         {
             DBGPRINT(RT_DEBUG_TRACE, ("AUTH - MlmeAuthReqAction(Alg:%d) allocate memory failed\n", Alg));
             pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
@@ -162,19 +162,19 @@ VOID MlmeAuthReqAction(
 
         DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send AUTH request seq#1 (Alg=%d)...\n", Alg));
         MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr, pAd->MlmeAux.Bssid);
-        MakeOutgoingFrame(pOutBuffer,           &FrameLen, 
-                          sizeof(HEADER_802_11),&AuthHdr, 
-                          2,                    &Alg, 
-                          2,                    &Seq, 
-                          2,                    &Status, 
+        MakeOutgoingFrame(pOutBuffer,           &FrameLen,
+                          sizeof(HEADER_802_11),&AuthHdr,
+                          2,                    &Alg,
+                          2,                    &Seq,
+                          2,                    &Status,
                           END_OF_ARGS);
         MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
     	MlmeFreeMemory(pAd, pOutBuffer);
 
         RTMPSetTimer(&pAd->MlmeAux.AuthTimer, Timeout);
         pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ2;
-    } 
-    else 
+    }
+    else
     {
         DBGPRINT_ERR(("AUTH - MlmeAuthReqAction() sanity check failed\n"));
         pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
@@ -186,14 +186,14 @@ VOID MlmeAuthReqAction(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID PeerAuthRspAtSeq2Action(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
     UCHAR         Addr2[MAC_ADDR_LEN];
     USHORT        Seq, Status, RemoteStatus, Alg;
@@ -207,37 +207,37 @@ VOID PeerAuthRspAtSeq2Action(
     ULONG         FrameLen = 0;
     USHORT        Status2;
 
-    if (PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status, ChlgText)) 
+    if (PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status, ChlgText))
     {
-        if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 2) 
+        if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 2)
         {
             DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Receive AUTH_RSP seq#2 to me (Alg=%d, Status=%d)\n", Alg, Status));
             RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
-            
-            if (Status == MLME_SUCCESS) 
+
+            if (Status == MLME_SUCCESS)
             {
                 // Authentication Mode "LEAP" has allow for CCX 1.X
-                if ((pAd->MlmeAux.Alg == Ndis802_11AuthModeOpen) 
+                if ((pAd->MlmeAux.Alg == Ndis802_11AuthModeOpen)
 #ifdef LEAP_SUPPORT
 					|| (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
 #endif // LEAP_SUPPORT //
 				)
                 {
                     pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
-#ifdef LEAP_SUPPORT					
+#ifdef LEAP_SUPPORT
                     pAd->Mlme.LeapMachine.CurrState = LEAP_IDLE;
 #endif // LEAP_SUPPORT //
                     MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
-                } 
-                else 
+                }
+                else
                 {
                     // 2. shared key, need to be challenged
                     Seq++;
                     RemoteStatus = MLME_SUCCESS;
-					
+
 					// Get an unused nonpaged memory
-                    NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  
-                    if(NStatus != NDIS_STATUS_SUCCESS) 
+                    NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
+                    if(NStatus != NDIS_STATUS_SUCCESS)
                     {
                         DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthRspAtSeq2Action() allocate memory fail\n"));
                         pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
@@ -245,7 +245,7 @@ VOID PeerAuthRspAtSeq2Action(
                         MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status2);
                         return;
                     }
-                    
+
                     DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send AUTH request seq#3...\n"));
                     MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr2, pAd->MlmeAux.Bssid);
                     AuthHdr.FC.Wep = 1;
@@ -259,7 +259,7 @@ VOID PeerAuthRspAtSeq2Action(
 
 					Alg = cpu2le16(*(USHORT *)&Alg);
 					Seq = cpu2le16(*(USHORT *)&Seq);
-					RemoteStatus= cpu2le16(*(USHORT *)&RemoteStatus);                    				
+					RemoteStatus= cpu2le16(*(USHORT *)&RemoteStatus);
 
 					RTMPEncryptData(pAd, (PUCHAR) &Alg, CyperChlgText + 4, 2);
 					RTMPEncryptData(pAd, (PUCHAR) &Seq, CyperChlgText + 6, 2);
@@ -269,9 +269,9 @@ VOID PeerAuthRspAtSeq2Action(
 					RTMPEncryptData(pAd, Element, CyperChlgText + 10, 2);
 					RTMPEncryptData(pAd, ChlgText, CyperChlgText + 12, 128);
 					RTMPSetICV(pAd, CyperChlgText + 140);
-                    MakeOutgoingFrame(pOutBuffer,               &FrameLen, 
-                                      sizeof(HEADER_802_11),    &AuthHdr,  
-                                      CIPHER_TEXT_LEN + 16,     CyperChlgText, 
+                    MakeOutgoingFrame(pOutBuffer,               &FrameLen,
+                                      sizeof(HEADER_802_11),    &AuthHdr,
+                                      CIPHER_TEXT_LEN + 16,     CyperChlgText,
                                       END_OF_ARGS);
                     MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
                 	MlmeFreeMemory(pAd, pOutBuffer);
@@ -279,12 +279,12 @@ VOID PeerAuthRspAtSeq2Action(
                     RTMPSetTimer(&pAd->MlmeAux.AuthTimer, AUTH_TIMEOUT);
                     pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ4;
                 }
-            } 
-            else 
+            }
+            else
             {
 #ifdef LEAP_SUPPORT
                 if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
-                { 
+                {
                     //Invalid Authentication possible rogue AP
                     //Add this Ap to Rogue AP.
                     RogueApTableSetEntry(pAd, &pAd->StaCfg.RogueApTab, Addr2, LEAP_REASON_INVALID_AUTH);
@@ -306,32 +306,32 @@ VOID PeerAuthRspAtSeq2Action(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID PeerAuthRspAtSeq4Action(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
     UCHAR         Addr2[MAC_ADDR_LEN];
     USHORT        Alg, Seq, Status;
     CHAR          ChlgText[CIPHER_TEXT_LEN];
     BOOLEAN       TimerCancelled;
 
-    if(PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status, ChlgText)) 
+    if(PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status, ChlgText))
     {
-        if(MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 4) 
+        if(MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 4)
         {
             DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Receive AUTH_RSP seq#4 to me\n"));
             RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
-            
-            if (Status != MLME_SUCCESS) 
+
+            if (Status != MLME_SUCCESS)
             {
                 pAd->StaCfg.AuthFailReason = Status;
                 COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
-            }                
+            }
 
             pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
             MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
@@ -346,14 +346,14 @@ VOID PeerAuthRspAtSeq4Action(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID MlmeDeauthReqAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
     MLME_DEAUTH_REQ_STRUCT *pInfo;
     HEADER_802_11 DeauthHdr;
@@ -365,7 +365,7 @@ VOID MlmeDeauthReqAction(
     pInfo = (MLME_DEAUTH_REQ_STRUCT *)Elem->Msg;
 
     NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-    if (NStatus != NDIS_STATUS_SUCCESS) 
+    if (NStatus != NDIS_STATUS_SUCCESS)
     {
         DBGPRINT(RT_DEBUG_TRACE, ("AUTH - MlmeDeauthReqAction() allocate memory fail\n"));
         pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
@@ -376,13 +376,13 @@ VOID MlmeDeauthReqAction(
 
     DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send DE-AUTH request (Reason=%d)...\n", pInfo->Reason));
     MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pInfo->Addr, pAd->MlmeAux.Bssid);
-    MakeOutgoingFrame(pOutBuffer,           &FrameLen, 
-                      sizeof(HEADER_802_11),&DeauthHdr, 
-                      2,                    &pInfo->Reason, 
+    MakeOutgoingFrame(pOutBuffer,           &FrameLen,
+                      sizeof(HEADER_802_11),&DeauthHdr,
+                      2,                    &pInfo->Reason,
                       END_OF_ARGS);
     MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
 	MlmeFreeMemory(pAd, pOutBuffer);
-    
+
     pAd->StaCfg.DeauthReason = pInfo->Reason;
     COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pInfo->Addr);
     pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
@@ -391,20 +391,20 @@ VOID MlmeDeauthReqAction(
 
 	// send wireless event - for deauthentication
 	if (pAd->CommonCfg.bWirelessEvent)
-		RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); 
+		RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
 }
 
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID AuthTimeoutAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
     USHORT Status;
     DBGPRINT(RT_DEBUG_TRACE, ("AUTH - AuthTimeoutAction\n"));
@@ -416,14 +416,14 @@ VOID AuthTimeoutAction(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID InvalidStateWhenAuth(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
     USHORT Status;
     DBGPRINT(RT_DEBUG_TRACE, ("AUTH - InvalidStateWhenAuth (state=%ld), reset AUTH state machine\n", pAd->Mlme.AuthMachine.CurrState));
@@ -439,30 +439,30 @@ VOID InvalidStateWhenAuth(
     Note:
         This action should never trigger AUTH state transition, therefore we
         separate it from AUTH state machine, and make it as a standalone service
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID Cls2errAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN PUCHAR pAddr) 
+    IN PRTMP_ADAPTER pAd,
+    IN PUCHAR pAddr)
 {
     HEADER_802_11 DeauthHdr;
     PUCHAR        pOutBuffer = NULL;
     NDIS_STATUS   NStatus;
     ULONG         FrameLen = 0;
     USHORT        Reason = REASON_CLS2ERR;
-    
+
     NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-    if (NStatus != NDIS_STATUS_SUCCESS) 
+    if (NStatus != NDIS_STATUS_SUCCESS)
         return;
 
     DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Class 2 error, Send DEAUTH frame...\n"));
     MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pAddr, pAd->MlmeAux.Bssid);
-    MakeOutgoingFrame(pOutBuffer,           &FrameLen, 
-                      sizeof(HEADER_802_11),&DeauthHdr, 
-                      2,                    &Reason, 
+    MakeOutgoingFrame(pOutBuffer,           &FrameLen,
+                      sizeof(HEADER_802_11),&DeauthHdr,
+                      2,                    &Reason,
                       END_OF_ARGS);
     MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
 	MlmeFreeMemory(pAd, pOutBuffer);
diff --git a/sta/auth_rsp.c b/sta/auth_rsp.c
index c54bfca..f7aa4b9 100644
--- a/sta/auth_rsp.c
+++ b/sta/auth_rsp.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -34,7 +34,7 @@
 	--------	----------		----------------------------------------------
 	John		2004-10-1		copy from RT2560
 */
-#include "rt_config.h"
+#include "../rt_config.h"
 
 /*
     ==========================================================================
@@ -42,15 +42,15 @@
         authentication state machine init procedure
     Parameters:
         Sm - the state machine
-        
+
 	IRQL = PASSIVE_LEVEL
 
     ==========================================================================
  */
 VOID AuthRspStateMachineInit(
-    IN PRTMP_ADAPTER pAd, 
-    IN PSTATE_MACHINE Sm, 
-    IN STATE_MACHINE_FUNC Trans[]) 
+    IN PRTMP_ADAPTER pAd,
+    IN PSTATE_MACHINE Sm,
+    IN STATE_MACHINE_FUNC Trans[])
 {
     StateMachineInit(Sm, Trans, MAX_AUTH_RSP_STATE, MAX_AUTH_RSP_MSG, (STATE_MACHINE_FUNC)Drop, AUTH_RSP_IDLE, AUTH_RSP_MACHINE_BASE);
 
@@ -65,18 +65,18 @@ VOID AuthRspStateMachineInit(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
 */
 VOID PeerAuthSimpleRspGenAndSend(
-    IN PRTMP_ADAPTER pAd, 
-    IN PHEADER_802_11 pHdr80211, 
-    IN USHORT Alg, 
-    IN USHORT Seq, 
-    IN USHORT Reason, 
-    IN USHORT Status) 
+    IN PRTMP_ADAPTER pAd,
+    IN PHEADER_802_11 pHdr80211,
+    IN USHORT Alg,
+    IN USHORT Seq,
+    IN USHORT Reason,
+    IN USHORT Status)
 {
     HEADER_802_11     AuthHdr;
     ULONG             FrameLen = 0;
@@ -90,17 +90,17 @@ VOID PeerAuthSimpleRspGenAndSend(
     }
 
 	//Get an unused nonpaged memory
-    NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  
-    if (NStatus != NDIS_STATUS_SUCCESS) 
+    NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
+    if (NStatus != NDIS_STATUS_SUCCESS)
         return;
 
     DBGPRINT(RT_DEBUG_TRACE, ("Send AUTH response (seq#2)...\n"));
     MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, pHdr80211->Addr2, pAd->MlmeAux.Bssid);
-    MakeOutgoingFrame(pOutBuffer,               &FrameLen, 
-                      sizeof(HEADER_802_11),    &AuthHdr, 
-                      2,                        &Alg, 
-                      2,                        &Seq, 
-                      2,                        &Reason, 
+    MakeOutgoingFrame(pOutBuffer,               &FrameLen,
+                      sizeof(HEADER_802_11),    &AuthHdr,
+                      2,                        &Alg,
+                      2,                        &Seq,
+                      2,                        &Reason,
                       END_OF_ARGS);
     MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
 	MlmeFreeMemory(pAd, pOutBuffer);
@@ -109,21 +109,21 @@ VOID PeerAuthSimpleRspGenAndSend(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
 */
 VOID PeerDeauthAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN PMLME_QUEUE_ELEM Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN PMLME_QUEUE_ELEM Elem)
 {
     UCHAR       Addr2[MAC_ADDR_LEN];
     USHORT      Reason;
 
-    if (PeerDeauthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason)) 
+    if (PeerDeauthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason))
     {
-        if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(Addr2, pAd->CommonCfg.Bssid)) 
+        if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(Addr2, pAd->CommonCfg.Bssid))
         {
             DBGPRINT(RT_DEBUG_TRACE,("AUTH_RSP - receive DE-AUTH from our AP (Reason=%d)\n", Reason));
 
@@ -134,16 +134,16 @@ VOID PeerDeauthAction(
                 memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
                 wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
             }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //        
-            
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+
 
 			// send wireless event - for deauthentication
 			if (pAd->CommonCfg.bWirelessEvent)
-				RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); 
+				RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
 
             LinkDown(pAd, TRUE);
 
-            // Authentication Mode Cisco_LEAP has start a timer 
+            // Authentication Mode Cisco_LEAP has start a timer
             // We should cancel it if using LEAP
 #ifdef LEAP_SUPPORT
             if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
diff --git a/sta/connect.c b/sta/connect.c
index 4c92571..36f28f8 100644
--- a/sta/connect.c
+++ b/sta/connect.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -34,7 +34,7 @@
 	--------	----------		----------------------------------------------
 	John			2004-08-08			Major modification from RT2560
 */
-#include "rt_config.h"
+#include "../rt_config.h"
 
 UCHAR	CipherSuiteWpaNoneTkip[] = {
 		0x00, 0x50, 0xf2, 0x01,	// oui
@@ -98,11 +98,11 @@ UCHAR	CipherSuiteWpaNoneAesLen = (sizeof(CipherSuiteWpaNoneAes) / sizeof(UCHAR))
 	==========================================================================
 */
 VOID MlmeCntlInit(
-	IN PRTMP_ADAPTER pAd, 
-	IN STATE_MACHINE *S, 
-	OUT STATE_MACHINE_FUNC Trans[]) 
+	IN PRTMP_ADAPTER pAd,
+	IN STATE_MACHINE *S,
+	OUT STATE_MACHINE_FUNC Trans[])
 {
-	// Control state machine differs from other state machines, the interface 
+	// Control state machine differs from other state machines, the interface
 	// follows the standard interface
 	pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
 }
@@ -112,15 +112,15 @@ VOID MlmeCntlInit(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID MlmeCntlMachinePerformAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN STATE_MACHINE *S, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN STATE_MACHINE *S,
+	IN MLME_QUEUE_ELEM *Elem)
 {
-	switch(pAd->Mlme.CntlMachine.CurrState) 
+	switch(pAd->Mlme.CntlMachine.CurrState)
 	{
 		case CNTL_IDLE:
 			{
@@ -135,8 +135,8 @@ VOID MlmeCntlMachinePerformAction(
 			break;
 
 		// CNTL_WAIT_REASSOC is the only state in CNTL machine that does
-		// not triggered directly or indirectly by "RTMPSetInformation(OID_xxx)". 
-		// Therefore not protected by NDIS's "only one outstanding OID request" 
+		// not triggered directly or indirectly by "RTMPSetInformation(OID_xxx)".
+		// Therefore not protected by NDIS's "only one outstanding OID request"
 		// rule. Which means NDIS may SET OID in the middle of ROAMing attempts.
 		// Current approach is to block new SET request at RTMPSetInformation()
 		// when CntlMachine.CurrState is not CNTL_IDLE
@@ -158,7 +158,7 @@ VOID MlmeCntlMachinePerformAction(
 			break;
 
 		case CNTL_WAIT_OID_LIST_SCAN:
-			if(Elem->MsgType == MT2_SCAN_CONF) 
+			if(Elem->MsgType == MT2_SCAN_CONF)
 			{
 				// Resume TxRing after SCANING complete. We hope the out-of-service time
 				// won't be too long to let upper layer time-out the waiting frames
@@ -189,7 +189,7 @@ VOID MlmeCntlMachinePerformAction(
 			break;
 
 		case CNTL_WAIT_OID_DISASSOC:
-			if (Elem->MsgType == MT2_DISASSOC_CONF) 
+			if (Elem->MsgType == MT2_DISASSOC_CONF)
 			{
 				LinkDown(pAd, FALSE);
 				pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
@@ -207,19 +207,19 @@ VOID MlmeCntlMachinePerformAction(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID CntlIdleProc(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	MLME_DISASSOC_REQ_STRUCT   DisassocReq;
 
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
 		return;
-		
-	switch(Elem->MsgType) 
+
+	switch(Elem->MsgType)
 	{
 		case OID_802_11_SSID:
 			CntlOidSsidProc(pAd, Elem);
@@ -234,12 +234,12 @@ VOID CntlIdleProc(
 			break;
 
 		case OID_802_11_DISASSOCIATE:
-#ifdef RALINK_ATE			
+#ifdef RALINK_ATE
 			if(ATE_ON(pAd))
 			{
 				DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
 				break;
-			}	
+			}
 #endif // RALINK_ATE //
 			DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
 			MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
@@ -289,8 +289,8 @@ VOID CntlOidScanProc(
 		return;
 #endif // RALINK_ATE //
 
-	
-	// record current BSS if network is connected. 
+
+	// record current BSS if network is connected.
 	// 2003-2-13 do not include current IBSS if this is the only STA in this IBSS.
 	if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
 	{
@@ -302,12 +302,12 @@ VOID CntlOidScanProc(
 	}
 
 	// clean up previous SCAN result, add current BSS back to table if any
-	BssTableInit(&pAd->ScanTab); 
+	BssTableInit(&pAd->ScanTab);
 	if (BssIdx != BSS_NOT_FOUND)
 	{
-		// DDK Note: If the NIC is associated with a particular BSSID and SSID 
-		//    that are not contained in the list of BSSIDs generated by this scan, the 
-		//    BSSID description of the currently associated BSSID and SSID should be 
+		// DDK Note: If the NIC is associated with a particular BSSID and SSID
+		//    that are not contained in the list of BSSIDs generated by this scan, the
+		//    BSSID description of the currently associated BSSID and SSID should be
 		//    appended to the list of BSSIDs in the NIC's database.
 		// To ensure this, we append this BSS as the first entry in SCAN result
 		NdisMoveMemory(&pAd->ScanTab.BssEntry[0], &CurrBss, sizeof(BSS_ENTRY));
@@ -315,7 +315,7 @@ VOID CntlOidScanProc(
 	}
 
 	ScanParmFill(pAd, &ScanReq, "", 0, BSS_ANY, SCAN_ACTIVE);
-	MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ, 
+	MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_MLME_SCAN_REQ,
 		sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq);
 	pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_LIST_SCAN;
 }
@@ -326,12 +326,12 @@ VOID CntlOidScanProc(
 		Before calling this routine, user desired SSID should already been
 		recorded in CommonCfg.Ssid[]
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID CntlOidSsidProc(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM * Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM * Elem)
 {
 	PNDIS_802_11_SSID          pOidSsid = (NDIS_802_11_SSID *)Elem->Msg;
 	MLME_DISASSOC_REQ_STRUCT   DisassocReq;
@@ -352,7 +352,7 @@ VOID CntlOidSsidProc(
 	NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
 	pAd->MlmeAux.AutoReconnectSsidLen = pAd->MlmeAux.SsidLen;
 
-	// step 2. find all matching BSS in the lastest SCAN result (inBssTab) 
+	// step 2. find all matching BSS in the lastest SCAN result (inBssTab)
 	//    & log them into MlmeAux.SsidBssTab for later-on iteration. Sort by RSSI order
 	BssTableSsidSort(pAd, &pAd->MlmeAux.SsidBssTab, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
 
@@ -360,30 +360,30 @@ VOID CntlOidSsidProc(
 			pAd->MlmeAux.SsidBssTab.BssNr, pAd->ScanTab.BssNr, pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid));
 	NdisGetSystemUpTime(&Now);
 
-	if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && 
+	if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) &&
 		(pAd->CommonCfg.SsidLen == pAd->MlmeAux.SsidBssTab.BssEntry[0].SsidLen) &&
 		NdisEqualMemory(pAd->CommonCfg.Ssid, pAd->MlmeAux.SsidBssTab.BssEntry[0].Ssid, pAd->CommonCfg.SsidLen) &&
 		MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, pAd->MlmeAux.SsidBssTab.BssEntry[0].Bssid))
 	{
-		// Case 1. already connected with an AP who has the desired SSID 
+		// Case 1. already connected with an AP who has the desired SSID
 		//         with highest RSSI
 
 		// Add checking Mode "LEAP" for CCX 1.0
 		if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
 			 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
 			 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
-			 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) 
+			 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
 #ifdef LEAP_SUPPORT
 			 || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
 #endif // LEAP_SUPPORT //
 			 ) &&
 			(pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
 		{
-			// case 1.1 For WPA, WPA-PSK, if the 1x port is not secured, we have to redo 
+			// case 1.1 For WPA, WPA-PSK, if the 1x port is not secured, we have to redo
 			//          connection process
 			DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
 			DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
-			MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, 
+			MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
 						sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
 			pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
 		}
@@ -392,7 +392,7 @@ VOID CntlOidSsidProc(
 			// case 1.2 Important Config has changed, we have to reconnect to the same AP
 			DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - disassociate with current AP Because config changed...\n"));
 			DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
-			MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, 
+			MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
 						sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
 			pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
 		}
@@ -402,7 +402,7 @@ VOID CntlOidSsidProc(
 			DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - already with this BSSID. ignore this SET_SSID request\n"));
 			//
 			// (HCT 12.1) 1c_wlan_mediaevents required
-			// media connect events are indicated when associating with the same AP			 
+			// media connect events are indicated when associating with the same AP
 			//
 			if (INFRA_ON(pAd))
 			{
@@ -410,7 +410,7 @@ VOID CntlOidSsidProc(
 				// Since MediaState already is NdisMediaStateConnected
 				// We just indicate the connect event again to meet the WHQL required.
 				//
-				pAd->IndicateMediaState = NdisMediaStateConnected;				
+				pAd->IndicateMediaState = NdisMediaStateConnected;
 				RTMP_IndicateMediaState(pAd);
                 pAd->ExtraInfo = GENERAL_LINK_UP;   // Update extra information to link is up
 			}
@@ -419,19 +419,19 @@ VOID CntlOidSsidProc(
 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
             {
                 union iwreq_data    wrqu;
-                
+
                 memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
                 memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
                 wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-                
+
             }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //            
-		} 
-	} 
-	else if (INFRA_ON(pAd)) 
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+		}
+	}
+	else if (INFRA_ON(pAd))
 	{
 		//
-		// For RT61 
+		// For RT61
 		// [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: )
 		// RT61 may lost SSID, and not connect to NDTEST_WEP_AP2 and will connect to NDTEST_WEP_AP2 by Autoreconnect
 		// But media status is connected, so the SSID not report correctly.
@@ -440,23 +440,23 @@ VOID CntlOidSsidProc(
 		{
 			//
 			// Different SSID means not Roaming case, so we let LinkDown() to Indicate a disconnect event.
-			// 
+			//
 			pAd->MlmeAux.CurrReqIsFromNdis = TRUE;
 		}
 		// case 2. active INFRA association existent
 		//    roaming is done within miniport driver, nothing to do with configuration
-		//    utility. so upon a new SET(OID_802_11_SSID) is received, we just 
-		//    disassociate with the current associated AP, 
-		//    then perform a new association with this new SSID, no matter the 
+		//    utility. so upon a new SET(OID_802_11_SSID) is received, we just
+		//    disassociate with the current associated AP,
+		//    then perform a new association with this new SSID, no matter the
 		//    new/old SSID are the same or not.
 		DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - disassociate with current AP...\n"));
 		DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
-		MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, 
+		MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
 					sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
 		pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
 	}
 	else
-	{   
+	{
 		if (ADHOC_ON(pAd))
 		{
 			DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():CNTL - drop current ADHOC\n"));
@@ -468,8 +468,8 @@ VOID CntlOidSsidProc(
 			DBGPRINT(RT_DEBUG_TRACE, ("CntlOidSsidProc():NDIS_STATUS_MEDIA_DISCONNECT Event C!\n"));
 		}
 
-		if ((pAd->MlmeAux.SsidBssTab.BssNr == 0) && 
-			(pAd->StaCfg.bAutoReconnect == TRUE) && 
+		if ((pAd->MlmeAux.SsidBssTab.BssNr == 0) &&
+			(pAd->StaCfg.bAutoReconnect == TRUE) &&
 			(pAd->MlmeAux.BssType == BSS_INFRA) &&
 			(MlmeValidateSSID(pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen) == TRUE)
 			)
@@ -488,7 +488,7 @@ VOID CntlOidSsidProc(
 			pAd->MlmeAux.BssIdx = 0;
 			IterateOnBssTab(pAd);
 		}
-	} 
+	}
 }
 
 
@@ -497,12 +497,12 @@ VOID CntlOidSsidProc(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID CntlOidRTBssidProc(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM * Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM * Elem)
 {
 	ULONG       BssIdx;
 	PUCHAR      pOidBssid = (PUCHAR)Elem->Msg;
@@ -525,10 +525,10 @@ VOID CntlOidRTBssidProc(
 	NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, MAX_LEN_OF_SSID);
 	pAd->MlmeAux.AutoReconnectSsidLen = pAd->MlmeAux.SsidLen;
 	NdisMoveMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
-	
+
 	// find the desired BSS in the latest SCAN result table
-	BssIdx = BssTableSearch(&pAd->ScanTab, pOidBssid, pAd->MlmeAux.Channel);	
-	if (BssIdx == BSS_NOT_FOUND) 
+	BssIdx = BssTableSearch(&pAd->ScanTab, pOidBssid, pAd->MlmeAux.Channel);
+	if (BssIdx == BSS_NOT_FOUND)
 	{
 		DBGPRINT(RT_DEBUG_TRACE, ("CNTL - BSSID not found. reply NDIS_STATUS_NOT_ACCEPTED\n"));
 		pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
@@ -548,7 +548,7 @@ VOID CntlOidRTBssidProc(
 	//   checking, we'll disassociate then re-do normal association with this AP at the new channel.
 	// 2003-1-6 Re-enable this feature based on microsoft requirement which prefer not to re-do
 	//   connection when setting the same BSSID.
-	if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && 
+	if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) &&
 		MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, pOidBssid))
 	{
 		// already connected to the same BSSID, go back to idle state directly
@@ -557,22 +557,22 @@ VOID CntlOidRTBssidProc(
 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
             {
                 union iwreq_data    wrqu;
-                
+
                 memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
                 memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
                 wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-                
+
             }
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //          
-	} 
-	else 
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
+	}
+	else
 	{
 		if (INFRA_ON(pAd))
 		{
 			// disassoc from current AP first
 			DBGPRINT(RT_DEBUG_TRACE, ("CNTL - disassociate with current AP ...\n"));
 			DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_DISASSOC_STA_LEAVING);
-			MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, 
+			MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
 						sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
 
 			pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
@@ -601,34 +601,34 @@ VOID CntlOidRTBssidProc(
 			if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
 			{
 				pAd->StaCfg.GroupCipher = pAd->ScanTab.BssEntry[BssIdx].WPA.GroupCipher;
-				
+
 				if (pAd->StaCfg.WepStatus == pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipher)
 					pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipher;
 				else if (pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipherAux != Ndis802_11WEPDisabled)
 					pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA.PairCipherAux;
 				else	// There is no PairCipher Aux, downgrade our capability to TKIP
-					pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;			
+					pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
 			}
 			else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
 			{
 				pAd->StaCfg.GroupCipher = pAd->ScanTab.BssEntry[BssIdx].WPA2.GroupCipher;
-				
+
 				if (pAd->StaCfg.WepStatus == pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipher)
 					pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipher;
 				else if (pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipherAux != Ndis802_11WEPDisabled)
 					pAd->StaCfg.PairCipher = pAd->ScanTab.BssEntry[BssIdx].WPA2.PairCipherAux;
 				else	// There is no PairCipher Aux, downgrade our capability to TKIP
-					pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;			
+					pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
 
 				// RSN capability
 				pAd->StaCfg.RsnCapability = pAd->ScanTab.BssEntry[BssIdx].WPA2.RsnCapability;
 			}
-			
+
 			// Set Mix cipher flag
 			pAd->StaCfg.bMixCipher = (pAd->StaCfg.PairCipher == pAd->StaCfg.GroupCipher) ? FALSE : TRUE;
 			if (pAd->StaCfg.bMixCipher == TRUE)
 			{
-				// If mix cipher, re-build RSNIE  
+				// If mix cipher, re-build RSNIE
 				RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
 			}
 			// No active association, join the BSS immediately
@@ -640,11 +640,11 @@ VOID CntlOidRTBssidProc(
 
 			pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_JOIN;
 		}
-	} 
+	}
 }
 
 // Roaming is the only external request triggering CNTL state machine
-// despite of other "SET OID" operation. All "SET OID" related oerations 
+// despite of other "SET OID" operation. All "SET OID" related oerations
 // happen in sequence, because no other SET OID will be sent to this device
 // until the the previous SET operation is complete (successful o failed).
 // So, how do we quarantee this ROAMING request won't corrupt other "SET OID"?
@@ -652,14 +652,14 @@ VOID CntlOidRTBssidProc(
 //
 // IRQL = DISPATCH_LEVEL
 VOID CntlMlmeRoamingProc(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
-	// TODO: 
+	// TODO:
 	// AP in different channel may show lower RSSI than actual value??
 	// should we add a weighting factor to compensate it?
 	DBGPRINT(RT_DEBUG_TRACE,("CNTL - Roaming in MlmeAux.RoamTab...\n"));
-	
+
 	NdisMoveMemory(&pAd->MlmeAux.SsidBssTab, &pAd->MlmeAux.RoamTab, sizeof(pAd->MlmeAux.RoamTab));
 	pAd->MlmeAux.SsidBssTab.BssNr = pAd->MlmeAux.RoamTab.BssNr;
 
@@ -674,7 +674,7 @@ VOID CntlMlmeRoamingProc(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID CntlOidDLSSetupProc(
@@ -699,14 +699,14 @@ VOID CntlOidDLSSetupProc(
 		for (i = 0; i < MAX_NUM_OF_DLS_ENTRY; i++)
 		{
 			if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
-				(pDLS->TimeOut == pAd->StaCfg.DLSEntry[i].TimeOut) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr)) 
+				(pDLS->TimeOut == pAd->StaCfg.DLSEntry[i].TimeOut) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
 			{
 				// 1. Same setting, just drop it
 				DBGPRINT(RT_DEBUG_TRACE,("CNTL - setting unchanged\n"));
 				break;
 			}
 			else if (!pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) &&
-				MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr)) 
+				MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
 			{
 				// 2. Disable DLS link case, just tear down DLS link
 				reason = REASON_QOS_UNWANTED_MECHANISM;
@@ -717,7 +717,7 @@ VOID CntlOidDLSSetupProc(
 				DBGPRINT(RT_DEBUG_TRACE,("CNTL - start tear down procedure\n"));
 				break;
 			}
-			else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && !pAd->StaCfg.DLSEntry[i].Valid) 
+			else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && !pAd->StaCfg.DLSEntry[i].Valid)
 			{
 				// 3. Enable case, start DLS setup procedure
 				NdisMoveMemory(&pAd->StaCfg.DLSEntry[i], pDLS, sizeof(RT_802_11_DLS_UI));
@@ -730,7 +730,7 @@ VOID CntlOidDLSSetupProc(
 				break;
 			}
 			else if ((i < MAX_NUM_OF_DLS_ENTRY) && pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
-				(pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) && !MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr)) 
+				(pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH) && !MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
 			{
 				// 4. update mac case, tear down old DLS and setup new DLS
 				reason = REASON_QOS_UNWANTED_MECHANISM;
@@ -744,8 +744,8 @@ VOID CntlOidDLSSetupProc(
 				DBGPRINT(RT_DEBUG_TRACE,("CNTL - DLS tear down and restart case\n"));
 				break;
 			}
-			else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid && 
-				MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr) && (pAd->StaCfg.DLSEntry[i].TimeOut != pDLS->TimeOut)) 
+			else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
+				MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr) && (pAd->StaCfg.DLSEntry[i].TimeOut != pDLS->TimeOut))
 			{
 				// 5. update timeout case, start DLS setup procedure (no tear down)
 				pAd->StaCfg.DLSEntry[i].TimeOut	= pDLS->TimeOut;
@@ -757,7 +757,7 @@ VOID CntlOidDLSSetupProc(
 				break;
 			}
 			else if (pDLS->Valid && pAd->StaCfg.DLSEntry[i].Valid &&
-				(pAd->StaCfg.DLSEntry[i].Status != DLS_FINISH) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr)) 
+				(pAd->StaCfg.DLSEntry[i].Status != DLS_FINISH) && MAC_ADDR_EQUAL(pDLS->MacAddr, pAd->StaCfg.DLSEntry[i].MacAddr))
 			{
 				// 6. re-setup case, start DLS setup procedure (no tear down)
 				DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
@@ -780,27 +780,27 @@ VOID CntlOidDLSSetupProc(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID CntlWaitDisassocProc(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	MLME_START_REQ_STRUCT     StartReq;
 
-	if (Elem->MsgType == MT2_DISASSOC_CONF) 
+	if (Elem->MsgType == MT2_DISASSOC_CONF)
 	{
 		DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Dis-associate successful\n"));
-        
+
 	    if (pAd->CommonCfg.bWirelessEvent)
-		{				
-			RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); 
+		{
+			RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
 		}
-        		
+
 		LinkDown(pAd, FALSE);
-		
-		// case 1. no matching BSS, and user wants ADHOC, so we just start a new one        
+
+		// case 1. no matching BSS, and user wants ADHOC, so we just start a new one
 		if ((pAd->MlmeAux.SsidBssTab.BssNr==0) && (pAd->StaCfg.BssType == BSS_ADHOC))
 		{
 			DBGPRINT(RT_DEBUG_TRACE, ("CNTL - No matching BSS, start a new ADHOC (Ssid=%s)...\n",pAd->MlmeAux.Ssid));
@@ -823,20 +823,20 @@ VOID CntlWaitDisassocProc(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID CntlWaitJoinProc(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT                      Reason;
 	MLME_AUTH_REQ_STRUCT        AuthReq;
 
-	if (Elem->MsgType == MT2_JOIN_CONF) 
+	if (Elem->MsgType == MT2_JOIN_CONF)
 	{
 		NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
-		if (Reason == MLME_SUCCESS) 
+		if (Reason == MLME_SUCCESS)
 		{
 			// 1. joined an IBSS, we are pretty much done here
 			if (pAd->MlmeAux.BssType == BSS_ADHOC)
@@ -845,7 +845,7 @@ VOID CntlWaitJoinProc(
 				// 5G bands rules of Japan:
 				// Ad hoc must be disabled in W53(ch52,56,60,64) channels.
 				//
-				if ( (pAd->CommonCfg.bIEEE80211H == 1) && 
+				if ( (pAd->CommonCfg.bIEEE80211H == 1) &&
                       RadarChannelCheck(pAd, pAd->CommonCfg.Channel)
 				   )
 				{
@@ -853,27 +853,27 @@ VOID CntlWaitJoinProc(
 					DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Channel=%d, Join adhoc on W53(52,56,60,64) Channels are not accepted\n", pAd->CommonCfg.Channel));
 					return;
 				}
-                
+
 				LinkUp(pAd, BSS_ADHOC);
 				pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-				DBGPRINT(RT_DEBUG_TRACE, ("CNTL - join the IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n", 
+				DBGPRINT(RT_DEBUG_TRACE, ("CNTL - join the IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n",
 				pAd->CommonCfg.Bssid[0],pAd->CommonCfg.Bssid[1],pAd->CommonCfg.Bssid[2],
 				pAd->CommonCfg.Bssid[3],pAd->CommonCfg.Bssid[4],pAd->CommonCfg.Bssid[5]));
 
                 pAd->IndicateMediaState = NdisMediaStateConnected;
                 pAd->ExtraInfo = GENERAL_LINK_UP;
-			} 
+			}
 			// 2. joined a new INFRA network, start from authentication
-			else 
+			else
 			{
-#ifdef LEAP_SUPPORT			
+#ifdef LEAP_SUPPORT
 				// Add AuthMode "LEAP" for CCX 1.X
 				if (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
 				{
 					AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, CISCO_AuthModeLEAP);
 				}
 				else
-#endif // LEAP_SUPPORT //					
+#endif // LEAP_SUPPORT //
 				{
 					// either Ndis802_11AuthModeShared or Ndis802_11AuthModeAutoSwitch, try shared key first
 					if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeShared) ||
@@ -886,7 +886,7 @@ VOID CntlWaitJoinProc(
 						AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeOpen);
 					}
 				}
-				MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ, 
+				MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
 							sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
 
 				pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH;
@@ -897,7 +897,7 @@ VOID CntlWaitJoinProc(
 			// 3. failed, try next BSS
 			pAd->MlmeAux.BssIdx++;
 			IterateOnBssTab(pAd);
-		} 
+		}
 	}
 }
 
@@ -907,25 +907,25 @@ VOID CntlWaitJoinProc(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID CntlWaitStartProc(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT      Result;
 
-	if (Elem->MsgType == MT2_START_CONF) 
+	if (Elem->MsgType == MT2_START_CONF)
 	{
 		NdisMoveMemory(&Result, Elem->Msg, sizeof(USHORT));
-		if (Result == MLME_SUCCESS) 
+		if (Result == MLME_SUCCESS)
 		{
 		    //
 			// 5G bands rules of Japan:
 			// Ad hoc must be disabled in W53(ch52,56,60,64) channels.
 			//
-			if ( (pAd->CommonCfg.bIEEE80211H == 1) && 
+			if ( (pAd->CommonCfg.bIEEE80211H == 1) &&
                   RadarChannelCheck(pAd, pAd->CommonCfg.Channel)
 			   )
 			{
@@ -944,13 +944,13 @@ VOID CntlWaitStartProc(
 				NdisZeroMemory(&pAd->StaActive.SupportedPhyInfo.MCSSet[0], 16);
 				NdisMoveMemory(&pAd->StaActive.SupportedPhyInfo.MCSSet[0], &pAd->CommonCfg.HtCapability.MCSSet[0], 16);
 				COPY_HTSETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
-				
-				if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth  == BW_40) && 
+
+				if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth  == BW_40) &&
 					(pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_ABOVE))
 				{
 					pAd->MlmeAux.CentralChannel = pAd->CommonCfg.Channel + 2;
 				}
-				else if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth  == BW_40) && 
+				else if ((pAd->CommonCfg.HtCapability.HtCapInfo.ChannelWidth  == BW_40) &&
 						 (pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset == EXTCHA_BELOW))
 				{
 					pAd->MlmeAux.CentralChannel = pAd->CommonCfg.Channel - 2;
@@ -975,7 +975,7 @@ VOID CntlWaitStartProc(
 #endif // DFS_SUPPORT //
 			}
 
-			DBGPRINT(RT_DEBUG_TRACE, ("CNTL - start a new IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n", 
+			DBGPRINT(RT_DEBUG_TRACE, ("CNTL - start a new IBSS = %02x:%02x:%02x:%02x:%02x:%02x ...\n",
 				pAd->CommonCfg.Bssid[0],pAd->CommonCfg.Bssid[1],pAd->CommonCfg.Bssid[2],
 				pAd->CommonCfg.Bssid[3],pAd->CommonCfg.Bssid[4],pAd->CommonCfg.Bssid[5]));
 		}
@@ -992,24 +992,24 @@ VOID CntlWaitStartProc(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID CntlWaitAuthProc(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT                       Reason;
 	MLME_ASSOC_REQ_STRUCT        AssocReq;
 	MLME_AUTH_REQ_STRUCT         AuthReq;
 
-	if (Elem->MsgType == MT2_AUTH_CONF) 
+	if (Elem->MsgType == MT2_AUTH_CONF)
 	{
 		NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
-		if (Reason == MLME_SUCCESS) 
+		if (Reason == MLME_SUCCESS)
 		{
 			DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH OK\n"));
-			AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, pAd->MlmeAux.CapabilityInfo, 
+			AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, pAd->MlmeAux.CapabilityInfo,
 						  ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
 
 #ifdef LEAP_SUPPORT
@@ -1017,26 +1017,26 @@ VOID CntlWaitAuthProc(
 			// Cisco Leap CCKM supported Re-association.
 			//
 			if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
-			{ 
-				//if CCKM is turn on , that's mean Fast Reauthentication 
+			{
+				//if CCKM is turn on , that's mean Fast Reauthentication
 				//Use CCKM Reassociation instead of normal association for Fast Roaming.
-				MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ, 
+				MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ,
 							sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
 
 				pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_REASSOC;
 			}
 			else
-#endif // LEAP_SUPPORT //				
+#endif // LEAP_SUPPORT //
 			{
-				MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ, 
+				MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
 							sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
 
 				pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_ASSOC;
 			}
-		} 
+		}
 		else
 		{
-			// This fail may because of the AP already keep us in its MAC table without 
+			// This fail may because of the AP already keep us in its MAC table without
 			// ageing-out. The previous authentication attempt must have let it remove us.
 			// so try Authentication again may help. For D-Link DWL-900AP+ compatibility.
 			DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, try again...\n"));
@@ -1047,7 +1047,7 @@ VOID CntlWaitAuthProc(
 				AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, CISCO_AuthModeLEAP);
 			}
 			else
-#endif // LEAP_SUPPORT //				
+#endif // LEAP_SUPPORT //
 			{
 				if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeShared) ||
 					(pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch))
@@ -1060,7 +1060,7 @@ VOID CntlWaitAuthProc(
 					AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeOpen);
 				}
 			}
-			MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ, 
+			MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
 						sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
 
 			pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH2;
@@ -1073,30 +1073,30 @@ VOID CntlWaitAuthProc(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID CntlWaitAuthProc2(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT                       Reason;
 	MLME_ASSOC_REQ_STRUCT        AssocReq;
 	MLME_AUTH_REQ_STRUCT         AuthReq;
 
-	if (Elem->MsgType == MT2_AUTH_CONF) 
+	if (Elem->MsgType == MT2_AUTH_CONF)
 	{
 		NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
-		if (Reason == MLME_SUCCESS) 
+		if (Reason == MLME_SUCCESS)
 		{
 			DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH OK\n"));
-			AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, pAd->MlmeAux.CapabilityInfo, 
+			AssocParmFill(pAd, &AssocReq, pAd->MlmeAux.Bssid, pAd->MlmeAux.CapabilityInfo,
 						  ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
-			MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ, 
+			MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_ASSOC_REQ,
 						sizeof(MLME_ASSOC_REQ_STRUCT), &AssocReq);
 
 			pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_ASSOC;
-		} 
+		}
 		else
 		{
 #ifdef LEAP_SUPPORT
@@ -1111,19 +1111,19 @@ VOID CntlWaitAuthProc2(
 				pAd->MlmeAux.BssIdx++;
 				IterateOnBssTab(pAd);
 			}
-			else 
+			else
 #endif // LEAP_SUPPORT //
 			if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeAutoSwitch) &&
 				 (pAd->MlmeAux.Alg == Ndis802_11AuthModeShared))
 			{
 				DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, try OPEN system...\n"));
 				AuthParmFill(pAd, &AuthReq, pAd->MlmeAux.Bssid, Ndis802_11AuthModeOpen);
-				MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ, 
+				MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_MLME_AUTH_REQ,
 							sizeof(MLME_AUTH_REQ_STRUCT), &AuthReq);
 
 				pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_AUTH2;
 			}
-			else 
+			else
 			{
 				// not success, try next BSS
 				DBGPRINT(RT_DEBUG_TRACE, ("CNTL - AUTH FAIL, give up; try next BSS\n"));
@@ -1140,30 +1140,30 @@ VOID CntlWaitAuthProc2(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID CntlWaitAssocProc(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT      Reason;
 
-	if (Elem->MsgType == MT2_ASSOC_CONF) 
+	if (Elem->MsgType == MT2_ASSOC_CONF)
 	{
 		NdisMoveMemory(&Reason, Elem->Msg, sizeof(USHORT));
-		if (Reason == MLME_SUCCESS) 
+		if (Reason == MLME_SUCCESS)
 		{
 			LinkUp(pAd, BSS_INFRA);
 			pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
 			DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Association successful on BSS #%ld\n",pAd->MlmeAux.BssIdx));
 
 			if (pAd->CommonCfg.bWirelessEvent)
-			{				
-				RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); 
+			{
+				RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
 			}
-		} 
-		else 
+		}
+		else
 		{
 			// not success, try next BSS
 			DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Association fails on BSS #%ld\n",pAd->MlmeAux.BssIdx));
@@ -1178,41 +1178,41 @@ VOID CntlWaitAssocProc(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID CntlWaitReassocProc(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT      Result;
 
-	if (Elem->MsgType == MT2_REASSOC_CONF) 
+	if (Elem->MsgType == MT2_REASSOC_CONF)
 	{
 		NdisMoveMemory(&Result, Elem->Msg, sizeof(USHORT));
-		if (Result == MLME_SUCCESS) 
+		if (Result == MLME_SUCCESS)
 		{
-			// 
+			//
 			// NDIS requires a new Link UP indication but no Link Down for RE-ASSOC
 			//
 			LinkUp(pAd, BSS_INFRA);
 
 			// send wireless event - for association
 			if (pAd->CommonCfg.bWirelessEvent)
-				RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);			
+				RTMPSendWirelessEvent(pAd, IW_ASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
 
 
-#ifdef LEAP_SUPPORT			
+#ifdef LEAP_SUPPORT
 			if (LEAP_CCKM_ON(pAd))
 			{
 				STA_PORT_SECURED(pAd);
-				pAd->StaCfg.WpaState = SS_FINISH;			
+				pAd->StaCfg.WpaState = SS_FINISH;
 			}
-#endif // LEAP_SUPPORT //			
-			pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;            
+#endif // LEAP_SUPPORT //
+			pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
 			DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Re-assocition successful on BSS #%ld\n", pAd->MlmeAux.RoamIdx));
-		} 
-		else 
+		}
+		else
 		{
 			// reassoc failed, try to pick next BSS in the BSS Table
 			DBGPRINT(RT_DEBUG_TRACE, ("CNTL - Re-assocition fails on BSS #%ld\n", pAd->MlmeAux.RoamIdx));
@@ -1227,19 +1227,19 @@ VOID CntlWaitReassocProc(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID LinkUp(
 	IN PRTMP_ADAPTER pAd,
-	IN UCHAR BssType) 
+	IN UCHAR BssType)
 {
 	ULONG	Now;
 	UINT32	Data;
 	BOOLEAN	Cancelled;
 	UCHAR	Value = 0, idx;
 	MAC_TABLE_ENTRY *pEntry = NULL, *pCurrEntry;
-	
+
 	pEntry = &pAd->MacTab.Content[BSSID_WCID];
 
 	//
@@ -1247,11 +1247,11 @@ VOID LinkUp(
 	// CNTL - Dis-associate successful
 	// !!! LINK DOWN !!!
 	// [88888] OID_802_11_SSID should have returned NDTEST_WEP_AP2(Returned: )
-	// 
+	//
 	// To prevent DisassocTimeoutAction to call Link down after we link up,
 	// cancel the DisassocTimer no matter what it start or not.
 	//
-	RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer,  &Cancelled);	
+	RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer,  &Cancelled);
 
 	COPY_SETTINGS_FROM_MLME_AUX_TO_ACTIVE_CFG(pAd);
 
@@ -1265,7 +1265,7 @@ VOID LinkUp(
 	SwitchBetweenWepAndCkip(pAd);
 
 #ifdef RT2860
-	// Before power save before link up function, We will force use 1R.  
+	// Before power save before link up function, We will force use 1R.
 	// So after link up, check Rx antenna # again.
 	RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
 	if(pAd->Antenna.field.RxPath == 3)
@@ -1288,7 +1288,7 @@ VOID LinkUp(
 	{
 		OPSTATUS_SET_FLAG(pAd, fOP_STATUS_ADHOC_ON);
 		OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
-		
+
 #ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
 		// No carrier detection when adhoc
 		// CarrierDetectionStop(pAd);
@@ -1301,10 +1301,10 @@ VOID LinkUp(
 	{
 		OPSTATUS_SET_FLAG(pAd, fOP_STATUS_INFRA_ON);
 		OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_ADHOC_ON);
-	
+
 		DBGPRINT(RT_DEBUG_TRACE, ("!!!Infra LINK UP !!! \n" ));
 	}
-	
+
 	// 3*3
 	// reset Tx beamforming bit
 	RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
@@ -1315,18 +1315,18 @@ VOID LinkUp(
 #ifdef DOT11_N_SUPPORT
 	// Change to AP channel
     if ((pAd->CommonCfg.CentralChannel > pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
-	{	
+	{
 		// Must using 40MHz.
 		pAd->CommonCfg.BBPCurrentBW = BW_40;
 		AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
 		AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-			
+
 		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
 		Value &= (~0x18);
 		Value |= 0x10;
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-		
-		//  RX : control channel at lower 
+
+		//  RX : control channel at lower
 		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
 		Value &= (~0x20);
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
@@ -1337,40 +1337,40 @@ VOID LinkUp(
 		RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
 		Data &= 0xfffffffe;
 		RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-		
+
 		if (pAd->MACVersion == 0x28600100)
 		{
 			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);
 			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R70, 0x0A);
 			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x16);
             DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
-		}	
+		}
 
 		DBGPRINT(RT_DEBUG_TRACE, ("!!!40MHz Lower LINK UP !!! Control Channel at Below. Central = %d \n", pAd->CommonCfg.CentralChannel ));
 	}
 	else if ((pAd->CommonCfg.CentralChannel < pAd->CommonCfg.Channel) && (pAd->MlmeAux.HtCapability.HtCapInfo.ChannelWidth == BW_40))
-    {	
+    {
 	    // Must using 40MHz.
 		pAd->CommonCfg.BBPCurrentBW = BW_40;
 		AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
 	    AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
-		
+
 		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
 		Value &= (~0x18);
 		Value |= 0x10;
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-		
+
 		RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
 		Data |= 0x1;
 		RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-		
+
 		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
 	    Value |= (0x20);
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
 #ifdef RT2860
         pAd->StaCfg.BBPR3 = Value;
 #endif // RT2860 //
-	
+
 		if (pAd->MACVersion == 0x28600100)
 		{
 			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x1A);
@@ -1388,22 +1388,22 @@ VOID LinkUp(
 		pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
 		AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
 		AsicLockChannel(pAd, pAd->CommonCfg.Channel);
-		
+
 		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &Value);
 		Value &= (~0x18);
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, Value);
-		
+
 		RTMP_IO_READ32(pAd, TX_BAND_CFG, &Data);
 		Data &= 0xfffffffe;
 		RTMP_IO_WRITE32(pAd, TX_BAND_CFG, Data);
-		
+
 		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &Value);
 		Value &= (~0x20);
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, Value);
 #ifdef RT2860
         pAd->StaCfg.BBPR3 = Value;
 #endif // RT2860 //
-		
+
 		if (pAd->MACVersion == 0x28600100)
 		{
 			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R69, 0x16);
@@ -1411,7 +1411,7 @@ VOID LinkUp(
 			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R73, 0x11);
             DBGPRINT(RT_DEBUG_TRACE, ("!!!rt2860C !!! \n" ));
 		}
-		
+
 	    DBGPRINT(RT_DEBUG_TRACE, ("!!! 20MHz LINK UP !!! \n" ));
     }
 
@@ -1421,7 +1421,7 @@ VOID LinkUp(
 	//
 	RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R66, &pAd->BbpTuning.R66CurrentValue);
 
-	DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (BssType=%d, AID=%d, ssid=%s, Channel=%d, CentralChannel = %d)\n", 
+	DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!! (BssType=%d, AID=%d, ssid=%s, Channel=%d, CentralChannel = %d)\n",
 		BssType, pAd->StaActive.Aid, pAd->CommonCfg.Ssid, pAd->CommonCfg.Channel, pAd->CommonCfg.CentralChannel));
 
 #ifdef DOT11_N_SUPPORT
@@ -1429,7 +1429,7 @@ VOID LinkUp(
 #endif // DOT11_N_SUPPORT //
 
 		AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
-		
+
 	AsicSetSlotTime(pAd, TRUE);
 	AsicSetEdcaParm(pAd, &pAd->CommonCfg.APEdcaParm);
 
@@ -1461,7 +1461,7 @@ VOID LinkUp(
 	}
 
 	OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
- 
+
 	if (pAd->CommonCfg.RadarDetect.RDMode == RD_SILENCE_MODE)
 	{
 #ifdef DFS_SUPPORT
@@ -1469,7 +1469,7 @@ VOID LinkUp(
 #endif // DFS_SUPPORT //
 	}
 	pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE;
-	
+
 	if (BssType == BSS_ADHOC)
 	{
 		MakeIbssBeacon(pAd);
@@ -1483,50 +1483,50 @@ VOID LinkUp(
 		{
 			AsicEnableIbssSync(pAd);
 		}
-		
-		// In ad hoc mode, use MAC table from index 1. 
+
+		// In ad hoc mode, use MAC table from index 1.
 		// p.s ASIC use all 0xff as termination of WCID table search.To prevent it's 0xff-ff-ff-ff-ff-ff, Write 0 here.
 		RTMP_IO_WRITE32(pAd, MAC_WCID_BASE, 0x00);
 		RTMP_IO_WRITE32(pAd, 0x1808, 0x00);
 
 		// If WEP is enabled, add key material and cipherAlg into Asic
 		// Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)
-        
+
 		if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)
-		{			
-			PUCHAR	Key; 			
+		{
+			PUCHAR	Key;
 			UCHAR 	CipherAlg;
-			
+
 			for (idx=0; idx < SHARE_KEY_NUM; idx++)
         	{
 				CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg;
     			Key = pAd->SharedKey[BSS0][idx].Key;
-			
+
 				if (pAd->SharedKey[BSS0][idx].KeyLen > 0)
 				{
 					// Set key material and cipherAlg to Asic
-    				AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);						
-                    
+    				AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);
+
                     if (idx == pAd->StaCfg.DefaultKeyId)
 					{
-						// Update WCID attribute table and IVEIV table for this group key table  
+						// Update WCID attribute table and IVEIV table for this group key table
 						RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);
 					}
-				}	
+				}
+
 
-                
-			}    		   		  		   					
-		}		
-		// If WPANone is enabled, add key material and cipherAlg into Asic 
+			}
+		}
+		// If WPANone is enabled, add key material and cipherAlg into Asic
 		// Fill in Shared Key Table(offset: 0x6c00) and Shared Key Mode(offset: 0x7000)
 		else if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
 		{
 			pAd->StaCfg.DefaultKeyId = 0;	// always be zero
-		
-            NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));  
+
+            NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
 							pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
 			NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pAd->StaCfg.PMK, LEN_TKIP_EK);
-            
+
             if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
             {
     			NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PMK[16], LEN_TKIP_RXMICK);
@@ -1539,25 +1539,25 @@ VOID LinkUp(
 			else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
 				pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
 			else
-            {         
+            {
                 DBGPRINT(RT_DEBUG_TRACE, ("Unknow Cipher (=%d), set Cipher to AES\n", pAd->StaCfg.PairCipher));
 				pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
             }
-		
+
 			// Set key material and cipherAlg to Asic
-			AsicAddSharedKeyEntry(pAd, 
-								  BSS0, 
-								  0, 
-								  pAd->SharedKey[BSS0][0].CipherAlg, 
-								  pAd->SharedKey[BSS0][0].Key, 
-								  pAd->SharedKey[BSS0][0].TxMic, 
-								  pAd->SharedKey[BSS0][0].RxMic);	
-
-            // Update WCID attribute table and IVEIV table for this group key table  
+			AsicAddSharedKeyEntry(pAd,
+								  BSS0,
+								  0,
+								  pAd->SharedKey[BSS0][0].CipherAlg,
+								  pAd->SharedKey[BSS0][0].Key,
+								  pAd->SharedKey[BSS0][0].TxMic,
+								  pAd->SharedKey[BSS0][0].RxMic);
+
+            // Update WCID attribute table and IVEIV table for this group key table
 			RTMPAddWcidAttributeEntry(pAd, BSS0, 0, pAd->SharedKey[BSS0][0].CipherAlg, NULL);
-            
+
 		}
-		
+
 	}
 	else // BSS_INFRA
 	{
@@ -1587,16 +1587,16 @@ VOID LinkUp(
 		if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
 		{
 			ULONG 		IV;
-			
-			// Remove all WPA keys 
+
+			// Remove all WPA keys
 			RTMPWPARemoveAllKeys(pAd);
-			pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;			
+			pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
 			pAd->StaCfg.PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
-			
+
 			// Fixed connection failed with Range Maximizer - 515 AP (Marvell Chip) when security is WPAPSK/TKIP
 			// If IV related values are too large in GroupMsg2, AP would ignore this message.
 			IV = 0;
-			IV |= (pAd->StaCfg.DefaultKeyId << 30);	
+			IV |= (pAd->StaCfg.DefaultKeyId << 30);
 			AsicUpdateWCIDIVEIV(pAd, BSSID_WCID, IV, 0);
 		}
 		// NOTE:
@@ -1613,13 +1613,13 @@ VOID LinkUp(
 			AsicEnableBssSync(pAd);
 
 		// Add BSSID to WCID search table
-		AsicUpdateRxWCIDTable(pAd, BSSID_WCID, pAd->CommonCfg.Bssid);		
+		AsicUpdateRxWCIDTable(pAd, BSSID_WCID, pAd->CommonCfg.Bssid);
 
 		NdisAcquireSpinLock(&pAd->MacTabLock);
 		// add this BSSID entry into HASH table
 		{
 			UCHAR HashIdx;
-			
+
 			//pEntry = &pAd->MacTab.Content[BSSID_WCID];
 			HashIdx = MAC_ADDR_HASH_INDEX(pAd->CommonCfg.Bssid);
 			if (pAd->MacTab.Hash[HashIdx] == NULL)
@@ -1635,7 +1635,7 @@ VOID LinkUp(
 			}
 		}
 		NdisReleaseSpinLock(&pAd->MacTabLock);
-		
+
 
 		// If WEP is enabled, add paiewise and shared key
 #ifdef WPA_SUPPLICANT_SUPPORT
@@ -1646,36 +1646,36 @@ VOID LinkUp(
               (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)))
 #else
 		if (pAd->StaCfg.WepStatus == Ndis802_11WEPEnabled)
-#endif // WPA_SUPPLICANT_SUPPORT //            
-		{			
-			PUCHAR	Key; 			
+#endif // WPA_SUPPLICANT_SUPPORT //
+		{
+			PUCHAR	Key;
 			UCHAR 	CipherAlg;
-			
+
 			for (idx=0; idx < SHARE_KEY_NUM; idx++)
         	{
 				CipherAlg = pAd->SharedKey[BSS0][idx].CipherAlg;
     			Key = pAd->SharedKey[BSS0][idx].Key;
-			
+
 				if (pAd->SharedKey[BSS0][idx].KeyLen > 0)
 				{
 					// Set key material and cipherAlg to Asic
-    				AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);	
+    				AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);
 
 					if (idx == pAd->StaCfg.DefaultKeyId)
 					{
-						// Assign group key info  
+						// Assign group key info
 						RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);
 
 						// Assign pairwise key info
-						RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, pEntry);	
+						RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, pEntry);
 					}
-				}	
-			}    		   		  		   					
+				}
+			}
 		}
 
 		// only INFRASTRUCTURE mode need to indicate connectivity immediately; ADHOC mode
 		// should wait until at least 2 active nodes in this BSSID.
-		OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); 
+		OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
 
         // For GUI ++
 		if (pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
@@ -1698,7 +1698,7 @@ VOID LinkUp(
 		pAd->MacTab.Content[BSSID_WCID].WepStatus = pAd->StaCfg.WepStatus;
         NdisReleaseSpinLock(&pAd->MacTabLock);
 
-		DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!!  ClientStatusFlags=%lx)\n", 
+		DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK UP !!!  ClientStatusFlags=%lx)\n",
 			pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
 
 		MlmeUpdateTxRates(pAd, TRUE, BSS0);
@@ -1729,10 +1729,10 @@ VOID LinkUp(
 				OPSTATUS_SET_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
 			}
 		}
-		
+
 		if (pAd->MlmeAux.APRalinkIe != 0x0)
 		{
-#ifdef DOT11_N_SUPPORT		
+#ifdef DOT11_N_SUPPORT
 			if (CLIENT_STATUS_TEST_FLAG(&pAd->MacTab.Content[BSSID_WCID], fCLIENT_STATUS_RDG_CAPABLE))
 			{
 				AsicEnableRDG(pAd);
@@ -1754,7 +1754,7 @@ VOID LinkUp(
 
 	// Set LED
 	RTMPSetLED(pAd, LED_LINK_UP);
-	
+
 	pAd->Mlme.PeriodicRound = 0;
 	pAd->Mlme.OneSecPeriodicRound = 0;
 	pAd->bConfigChanged = FALSE;        // Reset config flag
@@ -1764,11 +1764,11 @@ VOID LinkUp(
 	{
 		PUCHAR					pTable;
 		UCHAR					TableSize = 0;
-		
+
 		MlmeSelectTxRateTable(pAd, &pAd->MacTab.Content[BSSID_WCID], &pTable, &TableSize, &pAd->CommonCfg.TxRateIndex);
 		AsicUpdateAutoFallBackTable(pAd, pTable);
 	}
-	
+
 	NdisAcquireSpinLock(&pAd->MacTabLock);
     pEntry->HTPhyMode.word = pAd->StaCfg.HTPhyMode.word;
     pEntry->MaxHTPhyMode.word = pAd->StaCfg.HTPhyMode.word;
@@ -1782,7 +1782,7 @@ VOID LinkUp(
 		if ((pEntry->HTPhyMode.field.MCS > MCS_7) || (pEntry->HTPhyMode.field.MCS == 32))
 			pEntry->HTPhyMode.field.STBC = STBC_NONE;
 #endif // DOT11_N_SUPPORT //
-		// If the legacy mode is set, overwrite the transmit setting of this entry.  
+		// If the legacy mode is set, overwrite the transmit setting of this entry.
 		if (pEntry->HTPhyMode.field.MODE <= MODE_OFDM)
 			RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
 	}
@@ -1811,7 +1811,7 @@ VOID LinkUp(
 	}
 
 #ifdef DOT11_N_SUPPORT
-	if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) 
+	if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
 	{
 	}
 	else if (pEntry->MaxRAmpduFactor == 0)
@@ -1828,12 +1828,12 @@ VOID LinkUp(
 	// 2. Set EnTXWriteBackDDONE in register-WPDMA_GLO_CFG as zero
 	// 3. PBF_MAX_PCNT as 0x1F3FBF9F
 	// 4. kick per two packets when dequeue
-	// 
+	//
 	// Txop can only be modified when RDG is off, WMM is disable and TxBurst is enable
 	//
 	// if 1. Legacy AP WMM on,  or 2. 11n AP, AMPDU disable.  Force turn off burst no matter what bEnableTxBurst is.
 #ifdef DOT11_N_SUPPORT
-	if (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED))) 
+	if (((pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) && (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED)))
 		|| ((pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE) && (pAd->CommonCfg.BACapability.field.Policy == BA_NOTUSE)))
 	{
 		RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &Data);
@@ -1865,8 +1865,8 @@ VOID LinkUp(
 		RTMP_IO_WRITE32(pAd, PBF_MAX_PCNT, 0x1F3F7F9F);
 		DBGPRINT(RT_DEBUG_TRACE, ("Txburst 3\n"));
 	}
-	
-#ifdef DOT11_N_SUPPORT	
+
+#ifdef DOT11_N_SUPPORT
 	// Re-check to turn on TX burst or not.
 	if ((pAd->CommonCfg.IOTestParm.bLastAtheros == TRUE) && ((STA_WEP_ON(pAd))||(STA_TKIP_ON(pAd))))
 	{
@@ -1875,7 +1875,7 @@ VOID LinkUp(
 		{
 		    UINT32 MACValue = 0;
 			// Force disable  TXOP value in this case. The same action in MLMEUpdateProtect too.
-			// I didn't change PBF_MAX_PCNT setting. 
+			// I didn't change PBF_MAX_PCNT setting.
 			RTMP_IO_READ32(pAd, EDCA_AC0_CFG, &MACValue);
 			MACValue  &= 0xFFFFFF00;
 			RTMP_IO_WRITE32(pAd, EDCA_AC0_CFG, MACValue);
@@ -1940,10 +1940,10 @@ VOID LinkUp(
 	Arguments:
 		pAd				- Pointer to our adapter
 		IsReqFromAP		- Request from AP
-		
-	Return Value:		
+
+	Return Value:
 		None
-		
+
 	IRQL = DISPATCH_LEVEL
 
 	Note:
@@ -1951,7 +1951,7 @@ VOID LinkUp(
 		If yes! we need to do extra handling, for example, remove the WPA key.
 		Otherwise on 4-way handshaking will faied, since the WPA key didn't be
 		remove while auto reconnect.
-		Disconnect request from AP, it means we will start afresh 4-way handshaking 
+		Disconnect request from AP, it means we will start afresh 4-way handshaking
 		on WPA mode.
 
 	==========================================================================
@@ -1967,19 +1967,19 @@ VOID LinkDown(
 		return;
 
 #ifdef RALINK_ATE
-	// Nothing to do in ATE mode. 
+	// Nothing to do in ATE mode.
 	if (ATE_ON(pAd))
 		return;
-#endif // RALINK_ATE //    
+#endif // RALINK_ATE //
 
     if (pAd->CommonCfg.bWirelessEvent)
-	{				
-		RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); 
+	{
+		RTMPSendWirelessEvent(pAd, IW_STA_LINKDOWN_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
 	}
 
 	DBGPRINT(RT_DEBUG_TRACE, ("!!! LINK DOWN !!!\n"));
 	OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_AGGREGATION_INUSED);
-    
+
 #ifdef RT2860
     if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))
     {
@@ -1997,7 +1997,7 @@ VOID LinkDown(
         OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_DOZE);
     }
 
-    pAd->bPCIclkOff = FALSE;  
+    pAd->bPCIclkOff = FALSE;
 #endif // RT2860 //
 	if (ADHOC_ON(pAd))		// Adhoc mode link down
 	{
@@ -2042,8 +2042,8 @@ VOID LinkDown(
 		}
 #endif // QOS_DLS_SUPPORT //
 
-		OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON); 
-		OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); 
+		OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_INFRA_ON);
+		OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
 
 		// Saved last SSID for linkup comparison
 		pAd->CommonCfg.LastSsidLen = pAd->CommonCfg.SsidLen;
@@ -2061,14 +2061,14 @@ VOID LinkDown(
 		{
             //
 			// If disassociation request is from NDIS, then we don't need to delete BSSID from entry.
-			// Otherwise lost beacon or receive De-Authentication from AP, 
+			// Otherwise lost beacon or receive De-Authentication from AP,
 			// then we should delete BSSID from BssTable.
 			// If we don't delete from entry, roaming will fail.
 			//
 			BssTableDeleteEntry(&pAd->ScanTab, pAd->CommonCfg.Bssid, pAd->CommonCfg.Channel);
 		}
 
-		// restore back to - 
+		// restore back to -
 		//      1. long slot (20 us) or short slot (9 us) time
 		//      2. turn on/off RTS/CTS and/or CTS-to-self protection
 		//      3. short preamble
@@ -2083,9 +2083,9 @@ VOID LinkDown(
 			pAd->StaCfg.CCXAdjacentAPChannel = pAd->CommonCfg.Channel;
 			pAd->StaCfg.CCXAdjacentAPSsidLen = pAd->CommonCfg.SsidLen;
 			NdisMoveMemory(pAd->StaCfg.CCXAdjacentAPSsid, pAd->CommonCfg.Ssid, pAd->StaCfg.CCXAdjacentAPSsidLen);
-			COPY_MAC_ADDR(pAd->StaCfg.CCXAdjacentAPBssid, pAd->CommonCfg.Bssid);			
+			COPY_MAC_ADDR(pAd->StaCfg.CCXAdjacentAPBssid, pAd->CommonCfg.Bssid);
 		}
-		
+
 #ifdef EXT_BUILD_CHANNEL_LIST
 		// Country IE of the AP will be evaluated and will be used.
 		if (pAd->StaCfg.IEEE80211dClientMode != Rt802_11_D_None)
@@ -2095,7 +2095,7 @@ VOID LinkDown(
 			BuildChannelListEx(pAd);
 		}
 #endif // EXT_BUILD_CHANNEL_LIST //
-		
+
 	}
 
 	for (i=1; i<MAX_LEN_OF_MAC_TABLE; i++)
@@ -2103,10 +2103,10 @@ VOID LinkDown(
 		if (pAd->MacTab.Content[i].ValidAsCLI == TRUE)
 			MacTableDeleteEntry(pAd, pAd->MacTab.Content[i].Aid, pAd->MacTab.Content[i].Addr);
 	}
-	
+
 	pAd->StaCfg.CCXQosECWMin	= 4;
 	pAd->StaCfg.CCXQosECWMax	= 10;
-	
+
 	AsicSetSlotTime(pAd, TRUE); //FALSE);
 	AsicSetEdcaParm(pAd, NULL);
 
@@ -2133,7 +2133,7 @@ VOID LinkDown(
 	pAd->MlmeAux.HtCapabilityLen = 0;
 	pAd->MlmeAux.NewExtChannelOffset = 0xff;
 #endif // DOT11_N_SUPPORT //
-	
+
 	// Reset WPA-PSK state. Only reset when supplicant enabled
 	if (pAd->StaCfg.WpaState != SS_NOTUSE)
 	{
@@ -2146,18 +2146,18 @@ VOID LinkDown(
 			NdisZeroMemory(pAd->StaCfg.DlsReplayCounter, 8);
 #endif // QOS_DLS_SUPPORT //
 	}
-	
-	
+
+
 	//
 	// if link down come from AP, we need to remove all WPA keys on WPA mode.
 	// otherwise will cause 4-way handshaking failed, since the WPA key not empty.
 	//
 	if ((IsReqFromAP) && (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA))
 	{
-		// Remove all WPA keys 
+		// Remove all WPA keys
 		RTMPWPARemoveAllKeys(pAd);
 	}
-	
+
 	// 802.1x port control
 #ifdef WPA_SUPPLICANT_SUPPORT
 	// Prevent clear PortSecured here with static WEP
@@ -2178,7 +2178,7 @@ VOID LinkDown(
 	NdisAcquireSpinLock(&pAd->MacTabLock);
 	pAd->MacTab.Content[BSSID_WCID].PortSecured = pAd->StaCfg.PortSecured;
 	NdisReleaseSpinLock(&pAd->MacTabLock);
-	
+
 	pAd->StaCfg.MicErrCnt = 0;
 
 	// Turn off Ckip control flag
@@ -2201,7 +2201,7 @@ VOID LinkDown(
 	NdisZeroMemory(&pAd->StaCfg.AssocInfo, sizeof(NDIS_802_11_ASSOCIATION_INFORMATION));
 	pAd->StaCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
 	pAd->StaCfg.ReqVarIELen = 0;
-	pAd->StaCfg.ResVarIELen = 0;	
+	pAd->StaCfg.ResVarIELen = 0;
 
 	//
 	// Reset RSSI value after link down
@@ -2250,7 +2250,7 @@ VOID LinkDown(
 	AsicDisableRDG(pAd);
 	pAd->CommonCfg.IOTestParm.bCurrentAtheros = FALSE;
 	pAd->CommonCfg.IOTestParm.bNowAtherosBurstOn = FALSE;
-				
+
 #ifdef DOT11_N_SUPPORT
 #ifdef DOT11N_DRAFT3
 	OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SCAN_2040);
@@ -2265,7 +2265,7 @@ VOID LinkDown(
 
 	RTMP_IO_WRITE32(pAd, MAX_LEN_CFG, 0x1fff);
 	RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-	
+
 #ifdef WPA_SUPPLICANT_SUPPORT
 #ifndef NATIVE_WPA_SUPPLICANT_SUPPORT
 	if (pAd->StaCfg.WpaSupplicantUP) {
@@ -2274,17 +2274,17 @@ VOID LinkDown(
 		memset(&wrqu, 0, sizeof(wrqu));
 		wrqu.data.flags = RT_DISASSOC_EVENT_FLAG;
 		wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
-	} 
+	}
 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //            
-			
+#endif // WPA_SUPPLICANT_SUPPORT //
+
 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
 	{
 		union iwreq_data    wrqu;
 		memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
 		wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
 	}
-#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //        
+#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
 }
 
 /*
@@ -2292,11 +2292,11 @@ VOID LinkDown(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID IterateOnBssTab(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	MLME_START_REQ_STRUCT   StartReq;
 	MLME_JOIN_REQ_STRUCT    JoinReq;
@@ -2308,7 +2308,7 @@ VOID IterateOnBssTab(
 	pAd->StaCfg.GroupCipher = pAd->StaCfg.OrigWepStatus;
 
 	BssIdx = pAd->MlmeAux.BssIdx;
-	if (BssIdx < pAd->MlmeAux.SsidBssTab.BssNr) 
+	if (BssIdx < pAd->MlmeAux.SsidBssTab.BssNr)
 	{
 		// Check cipher suite, AP must have more secured cipher than station setting
 		// Set the Pairwise and Group cipher to match the intended AP setting
@@ -2316,34 +2316,34 @@ VOID IterateOnBssTab(
 		if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
 		{
 			pAd->StaCfg.GroupCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.GroupCipher;
-			
+
 			if (pAd->StaCfg.WepStatus == pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipher)
 				pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipher;
 			else if (pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipherAux != Ndis802_11WEPDisabled)
 				pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA.PairCipherAux;
 			else	// There is no PairCipher Aux, downgrade our capability to TKIP
-				pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;			
+				pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
 		}
 		else if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
 		{
 			pAd->StaCfg.GroupCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.GroupCipher;
-			
+
 			if (pAd->StaCfg.WepStatus == pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipher)
 				pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipher;
 			else if (pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipherAux != Ndis802_11WEPDisabled)
 				pAd->StaCfg.PairCipher = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.PairCipherAux;
 			else	// There is no PairCipher Aux, downgrade our capability to TKIP
-				pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;			
+				pAd->StaCfg.PairCipher = Ndis802_11Encryption2Enabled;
 
 			// RSN capability
 			pAd->StaCfg.RsnCapability = pAd->MlmeAux.SsidBssTab.BssEntry[BssIdx].WPA2.RsnCapability;
 		}
-		
+
 		// Set Mix cipher flag
 		pAd->StaCfg.bMixCipher = (pAd->StaCfg.PairCipher == pAd->StaCfg.GroupCipher) ? FALSE : TRUE;
 		if (pAd->StaCfg.bMixCipher == TRUE)
 		{
-			// If mix cipher, re-build RSNIE  
+			// If mix cipher, re-build RSNIE
 			RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
 		}
 
@@ -2366,13 +2366,13 @@ VOID IterateOnBssTab(
 		AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
 		AsicLockChannel(pAd, pAd->CommonCfg.Channel);
 		pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-	} 
+	}
 }
 
 // for re-association only
 // IRQL = DISPATCH_LEVEL
 VOID IterateOnBssTab2(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	MLME_REASSOC_REQ_STRUCT ReassocReq;
 	ULONG                   BssIdx;
@@ -2389,9 +2389,9 @@ VOID IterateOnBssTab2(
 		AsicLockChannel(pAd, pBss->Channel);
 
 		// reassociate message has the same structure as associate message
-		AssocParmFill(pAd, &ReassocReq, pBss->Bssid, pBss->CapabilityInfo, 
+		AssocParmFill(pAd, &ReassocReq, pBss->Bssid, pBss->CapabilityInfo,
 					  ASSOC_TIMEOUT, pAd->StaCfg.DefaultListenCount);
-		MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ, 
+		MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_REASSOC_REQ,
 					sizeof(MLME_REASSOC_REQ_STRUCT), &ReassocReq);
 
 		pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_REASSOC;
@@ -2402,7 +2402,7 @@ VOID IterateOnBssTab2(
 		AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
 		AsicLockChannel(pAd, pAd->CommonCfg.Channel);
 		pAd->Mlme.CntlMachine.CurrState = CNTL_IDLE;
-	} 
+	}
 }
 
 /*
@@ -2410,13 +2410,13 @@ VOID IterateOnBssTab2(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID JoinParmFill(
-	IN PRTMP_ADAPTER pAd, 
-	IN OUT MLME_JOIN_REQ_STRUCT *JoinReq, 
-	IN ULONG BssIdx) 
+	IN PRTMP_ADAPTER pAd,
+	IN OUT MLME_JOIN_REQ_STRUCT *JoinReq,
+	IN ULONG BssIdx)
 {
 	JoinReq->BssIdx = BssIdx;
 }
@@ -2426,16 +2426,16 @@ VOID JoinParmFill(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID ScanParmFill(
-	IN PRTMP_ADAPTER pAd, 
-	IN OUT MLME_SCAN_REQ_STRUCT *ScanReq, 
-	IN CHAR Ssid[], 
-	IN UCHAR SsidLen, 
-	IN UCHAR BssType, 
-	IN UCHAR ScanType) 
+	IN PRTMP_ADAPTER pAd,
+	IN OUT MLME_SCAN_REQ_STRUCT *ScanReq,
+	IN CHAR Ssid[],
+	IN UCHAR SsidLen,
+	IN UCHAR BssType,
+	IN UCHAR ScanType)
 {
     NdisZeroMemory(ScanReq->Ssid, MAX_LEN_OF_SSID);
 	ScanReq->SsidLen = SsidLen;
@@ -2450,14 +2450,14 @@ VOID ScanParmFill(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID DlsParmFill(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN OUT MLME_DLS_REQ_STRUCT *pDlsReq,
 	IN PRT_802_11_DLS pDls,
-	IN USHORT reason) 
+	IN USHORT reason)
 {
 	pDlsReq->pDLS = pDls;
 	pDlsReq->Reason = reason;
@@ -2469,17 +2469,17 @@ VOID DlsParmFill(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID StartParmFill(
-	IN PRTMP_ADAPTER pAd, 
-	IN OUT MLME_START_REQ_STRUCT *StartReq, 
-	IN CHAR Ssid[], 
-	IN UCHAR SsidLen) 
+	IN PRTMP_ADAPTER pAd,
+	IN OUT MLME_START_REQ_STRUCT *StartReq,
+	IN CHAR Ssid[],
+	IN UCHAR SsidLen)
 {
 	ASSERT(SsidLen <= MAX_LEN_OF_SSID);
-	NdisMoveMemory(StartReq->Ssid, Ssid, SsidLen); 
+	NdisMoveMemory(StartReq->Ssid, Ssid, SsidLen);
 	StartReq->SsidLen = SsidLen;
 }
 
@@ -2488,14 +2488,14 @@ VOID StartParmFill(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 VOID AuthParmFill(
-	IN PRTMP_ADAPTER pAd, 
-	IN OUT MLME_AUTH_REQ_STRUCT *AuthReq, 
-	IN PUCHAR pAddr, 
-	IN USHORT Alg) 
+	IN PRTMP_ADAPTER pAd,
+	IN OUT MLME_AUTH_REQ_STRUCT *AuthReq,
+	IN PUCHAR pAddr,
+	IN USHORT Alg)
 {
 	COPY_MAC_ADDR(AuthReq->Addr, pAddr);
 	AuthReq->Alg = Alg;
@@ -2507,7 +2507,7 @@ VOID AuthParmFill(
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 #ifdef RT2860
@@ -2546,11 +2546,11 @@ VOID ComposeNullFrame(
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
 */
 ULONG MakeIbssBeacon(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	UCHAR         DsLen = 1, IbssLen = 2;
 	UCHAR         LocalErpIe[3] = {IE_ERP, 1, 0x04};
@@ -2566,7 +2566,7 @@ ULONG MakeIbssBeacon(
 	UCHAR         ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
 	UCHAR         ExtRateLen = 0;
 	UCHAR         RSNIe = IE_WPA;
-	
+
 	if ((pAd->CommonCfg.PhyMode == PHY_11B) && (pAd->CommonCfg.Channel <= 14))
 	{
 		SupRate[0] = 0x82; // 1 mbps
@@ -2614,7 +2614,7 @@ ULONG MakeIbssBeacon(
 		ExtRate[4]  = 0x30;    // 24 mbps, in units of 0.5 Mbps,
 		ExtRate[5]  = 0x48;    // 36 mbps, in units of 0.5 Mbps
 		ExtRate[6]  = 0x60;    // 48 mbps, in units of 0.5 Mbps
-		ExtRate[7]  = 0x6c;    // 54 mbps, in units of 0.5 Mbps		
+		ExtRate[7]  = 0x6c;    // 54 mbps, in units of 0.5 Mbps
 		ExtRateLen  = 8;
 	}
 
@@ -2622,30 +2622,30 @@ ULONG MakeIbssBeacon(
 	NdisMoveMemory(pAd->StaActive.SupRate, SupRate, SupRateLen);
 	pAd->StaActive.ExtRateLen = ExtRateLen;
 	NdisMoveMemory(pAd->StaActive.ExtRate, ExtRate, ExtRateLen);
-	
+
 	// compose IBSS beacon frame
 	MgtMacHeaderInit(pAd, &BcnHdr, SUBTYPE_BEACON, 0, BROADCAST_ADDR, pAd->CommonCfg.Bssid);
-	Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) || 
-			  (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) || 
+	Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
+			  (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
 			  (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
 	CapabilityInfo = CAP_GENERATE(0, 1, Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 0, 0);
 
 	MakeOutgoingFrame(pBeaconFrame,                &FrameLen,
-					  sizeof(HEADER_802_11),           &BcnHdr, 
+					  sizeof(HEADER_802_11),           &BcnHdr,
 					  TIMESTAMP_LEN,                   &FakeTimestamp,
 					  2,                               &pAd->CommonCfg.BeaconPeriod,
 					  2,                               &CapabilityInfo,
-					  1,                               &SsidIe, 
-					  1,                               &pAd->CommonCfg.SsidLen, 
+					  1,                               &SsidIe,
+					  1,                               &pAd->CommonCfg.SsidLen,
 					  pAd->CommonCfg.SsidLen,          pAd->CommonCfg.Ssid,
-					  1,                               &SupRateIe, 
+					  1,                               &SupRateIe,
 					  1,                               &SupRateLen,
 					  SupRateLen,                      SupRate,
-					  1,                               &DsIe, 
-					  1,                               &DsLen, 
+					  1,                               &DsIe,
+					  1,                               &DsLen,
 					  1,                               &pAd->CommonCfg.Channel,
-					  1,                               &IbssIe, 
-					  1,                               &IbssLen, 
+					  1,                               &IbssIe,
+					  1,                               &IbssLen,
 					  2,                               &pAd->StaActive.AtimWin,
 					  END_OF_ARGS);
 
@@ -2668,13 +2668,13 @@ ULONG MakeIbssBeacon(
 	{
 		ULONG tmp;
         RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0);
-        
+
 		MakeOutgoingFrame(pBeaconFrame + FrameLen,        	&tmp,
 						  1,                              	&RSNIe,
 						  1,                            	&pAd->StaCfg.RSNIE_Len,
 						  pAd->StaCfg.RSNIE_Len,      		pAd->StaCfg.RSN_IE,
 						  END_OF_ARGS);
-		FrameLen += tmp;	
+		FrameLen += tmp;
 	}
 
 #ifdef DOT11_N_SUPPORT
@@ -2689,17 +2689,17 @@ ULONG MakeIbssBeacon(
 		USHORT	b2lTmp, b2lTmp2;
 #endif
 
-		// add HT Capability IE 
+		// add HT Capability IE
 		HtLen = sizeof(pAd->CommonCfg.HtCapability);
 		HtLen1 = sizeof(pAd->CommonCfg.AddHTInfo);
 #ifndef RT_BIG_ENDIAN
 		MakeOutgoingFrame(pBeaconFrame+FrameLen,	&TmpLen,
 						  1,						&HtCapIe,
 						  1,						&HtLen,
-						  HtLen,					&pAd->CommonCfg.HtCapability, 
+						  HtLen,					&pAd->CommonCfg.HtCapability,
 						  1,						&AddHtInfoIe,
 						  1,						&HtLen1,
-						  HtLen1,					&pAd->CommonCfg.AddHTInfo, 
+						  HtLen1,					&pAd->CommonCfg.AddHTInfo,
 						  END_OF_ARGS);
 #else
 		NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
@@ -2713,20 +2713,20 @@ ULONG MakeIbssBeacon(
 		MakeOutgoingFrame(pBeaconFrame+FrameLen,	&TmpLen,
 						  1,						&HtCapIe,
 						  1,						&HtLen,
-						  HtLen,					&HtCapabilityTmp, 
+						  HtLen,					&HtCapabilityTmp,
 						  1,						&AddHtInfoIe,
 						  1,						&HtLen1,
-						  HtLen1,					&addHTInfoTmp, 
+						  HtLen1,					&addHTInfoTmp,
 						  END_OF_ARGS);
 #endif
 		FrameLen += TmpLen;
 	}
-#endif // DOT11_N_SUPPORT //	
+#endif // DOT11_N_SUPPORT //
 
 	//beacon use reserved WCID 0xff
     if (pAd->CommonCfg.Channel > 14)
     {
-	RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE,  TRUE, FALSE, FALSE, TRUE, 0, 0xff, FrameLen, 
+	RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE,  TRUE, FALSE, FALSE, TRUE, 0, 0xff, FrameLen,
 		PID_MGMT, PID_BEACON, RATE_1, IFS_HTTXOP, FALSE, &pAd->CommonCfg.MlmeTransmit);
     }
     else
@@ -2734,16 +2734,16 @@ ULONG MakeIbssBeacon(
         // Set to use 1Mbps for Adhoc beacon.
 		HTTRANSMIT_SETTING Transmit;
         Transmit.word = 0;
-        RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE,  TRUE, FALSE, FALSE, TRUE, 0, 0xff, FrameLen, 
+        RTMPWriteTxWI(pAd, pTxWI, FALSE, FALSE,  TRUE, FALSE, FALSE, TRUE, 0, 0xff, FrameLen,
     		PID_MGMT, PID_BEACON, RATE_1, IFS_HTTXOP, FALSE, &Transmit);
     }
-	
+
 #ifdef RT_BIG_ENDIAN
 	RTMPFrameEndianChange(pAd, pBeaconFrame, DIR_WRITE, FALSE);
 	RTMPWIEndianChange((PUCHAR)pTxWI, TYPE_TXWI);
 #endif
 
-    DBGPRINT(RT_DEBUG_TRACE, ("MakeIbssBeacon (len=%ld), SupRateLen=%d, ExtRateLen=%d, Channel=%d, PhyMode=%d\n", 
+    DBGPRINT(RT_DEBUG_TRACE, ("MakeIbssBeacon (len=%ld), SupRateLen=%d, ExtRateLen=%d, Channel=%d, PhyMode=%d\n",
 					FrameLen, SupRateLen, ExtRateLen, pAd->CommonCfg.Channel, pAd->CommonCfg.PhyMode));
 	return FrameLen;
 }
diff --git a/sta/dls.c b/sta/dls.c
index ec05888..78fb289 100644
--- a/sta/dls.c
+++ b/sta/dls.c
@@ -7,29 +7,29 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
     Module Name:
     dls.c
- 
+
     Abstract:
     Handle WMM-DLS state machine
- 
+
     Revision History:
     Who         When          What
     --------    ----------    ----------------------------------------------
@@ -37,7 +37,7 @@
 	Arvin Tai	06-03-2008	  Modified for RT28xx
  */
 
-#include "rt_config.h"
+#include "../rt_config.h"
 
 /*
     ==========================================================================
@@ -47,27 +47,27 @@
         Sm - pointer to the dls state machine
     Note:
         The state machine looks like this
-        
+
                             DLS_IDLE
     MT2_MLME_DLS_REQUEST   MlmeDlsReqAction
     MT2_PEER_DLS_REQUEST   PeerDlsReqAction
     MT2_PEER_DLS_RESPONSE  PeerDlsRspAction
     MT2_MLME_DLS_TEARDOWN  MlmeTearDownAction
     MT2_PEER_DLS_TEARDOWN  PeerTearDownAction
-        
+
 	IRQL = PASSIVE_LEVEL
 
     ==========================================================================
  */
 void DlsStateMachineInit(
-    IN PRTMP_ADAPTER pAd, 
-    IN STATE_MACHINE *Sm, 
-    OUT STATE_MACHINE_FUNC Trans[]) 
+    IN PRTMP_ADAPTER pAd,
+    IN STATE_MACHINE *Sm,
+    OUT STATE_MACHINE_FUNC Trans[])
 {
 	UCHAR	i;
-	
+
     StateMachineInit(Sm, (STATE_MACHINE_FUNC*)Trans, MAX_DLS_STATE, MAX_DLS_MSG, (STATE_MACHINE_FUNC)Drop, DLS_IDLE, DLS_MACHINE_BASE);
-     
+
     // the first column
     StateMachineSetAction(Sm, DLS_IDLE, MT2_MLME_DLS_REQ, (STATE_MACHINE_FUNC)MlmeDlsReqAction);
     StateMachineSetAction(Sm, DLS_IDLE, MT2_PEER_DLS_REQ, (STATE_MACHINE_FUNC)PeerDlsReqAction);
@@ -85,14 +85,14 @@ void DlsStateMachineInit(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID MlmeDlsReqAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
 	PUCHAR			pOutBuffer = NULL;
 	NDIS_STATUS		NStatus;
@@ -110,16 +110,16 @@ VOID MlmeDlsReqAction(
 		return;
 
 	DBGPRINT(RT_DEBUG_TRACE,("DLS - MlmeDlsReqAction() \n"));
-	
+
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-	if (NStatus != NDIS_STATUS_SUCCESS) 
+	if (NStatus != NDIS_STATUS_SUCCESS)
 	{
 		DBGPRINT(RT_DEBUG_ERROR,("DLS - MlmeDlsReqAction() allocate memory failed \n"));
 		return;
 	}
 
 	ActHeaderInit(pAd, &DlsReqHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-		
+
 	// Build basic frame first
 	MakeOutgoingFrame(pOutBuffer,				&FrameLen,
 					sizeof(HEADER_802_11),		&DlsReqHdr,
@@ -153,13 +153,13 @@ VOID MlmeDlsReqAction(
 		HT_CAPABILITY_IE HtCapabilityTmp;
 #endif
 
-		// add HT Capability IE 
+		// add HT Capability IE
 		HtLen = sizeof(HT_CAPABILITY_IE);
 #ifndef RT_BIG_ENDIAN
 		MakeOutgoingFrame(pOutBuffer + FrameLen,	&tmp,
 							1,						&HtCapIe,
 							1,						&HtLen,
-							HtLen,					&pAd->CommonCfg.HtCapability, 
+							HtLen,					&pAd->CommonCfg.HtCapability,
 							END_OF_ARGS);
 #else
 		NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
@@ -169,7 +169,7 @@ VOID MlmeDlsReqAction(
 		MakeOutgoingFrame(pOutBuffer + FrameLen,	&tmp,
 							1,						&HtCapIe,
 							1,						&HtLen,
-							HtLen,					&HtCapabilityTmp, 
+							HtLen,					&HtCapabilityTmp,
 							END_OF_ARGS);
 #endif
 		FrameLen = FrameLen + tmp;
@@ -187,14 +187,14 @@ VOID MlmeDlsReqAction(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID PeerDlsReqAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
 	PUCHAR			pOutBuffer = NULL;
 	NDIS_STATUS		NStatus;
@@ -218,20 +218,20 @@ VOID PeerDlsReqAction(
 	HT_CAPABILITY_IE	HtCapability;
 
 	if (!PeerDlsReqSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &CapabilityInfo, &DLSTimeOut,
-							&SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability)) 
+							&SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability))
 		return;
 
     // supported rates array may not be sorted. sort it and find the maximum rate
     for (i = 0; i < SupportedRatesLen; i++)
     {
-        if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f)) 
+        if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f))
             MaxSupportedRateIn500Kbps = SupportedRates[i] & 0x7f;
     }
 
 	DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsReqAction() from %02x:%02x:%02x:%02x:%02x:%02x\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5]));
 
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-	if (NStatus != NDIS_STATUS_SUCCESS) 
+	if (NStatus != NDIS_STATUS_SUCCESS)
 	{
 		DBGPRINT(RT_DEBUG_ERROR,("DLS - PeerDlsReqAction() allocate memory failed \n"));
 		return;
@@ -350,11 +350,11 @@ VOID PeerDlsReqAction(
 					pEntry->MaxHTPhyMode.field.BW = BW_20;
 					pEntry->MinHTPhyMode.field.BW = BW_20;
 
-#ifdef DOT11_N_SUPPORT				
+#ifdef DOT11_N_SUPPORT
 					pEntry->HTCapability.MCSSet[0] = 0;
 					pEntry->HTCapability.MCSSet[1] = 0;
 
-					// If this Entry supports 802.11n, upgrade to HT rate. 
+					// If this Entry supports 802.11n, upgrade to HT rate.
 					if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
 					{
 						UCHAR	j, bitmask; //k,bitmask;
@@ -368,7 +368,7 @@ VOID PeerDlsReqAction(
 							pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
 						}
 						else
-						{	
+						{
 							pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
 							pAd->MacTab.fAnyStationNonGF = TRUE;
 							pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
@@ -380,7 +380,7 @@ VOID PeerDlsReqAction(
 							pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
 						}
 						else
-						{	
+						{
 							pEntry->MaxHTPhyMode.field.BW = BW_20;
 							pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
 							pAd->MacTab.fAnyStation20Only = TRUE;
@@ -388,8 +388,8 @@ VOID PeerDlsReqAction(
 
 						// find max fixed rate
 						for (ii=15; ii>=0; ii--)
-						{	
-							j = ii/8;	
+						{
+							j = ii/8;
 							bitmask = (1<<(ii-(j*8)));
 							if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
 							{
@@ -400,7 +400,7 @@ VOID PeerDlsReqAction(
 								break;
 						}
 
-						 
+
 						if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
 						{
 
@@ -417,7 +417,7 @@ VOID PeerDlsReqAction(
 							}
 							else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
 							{
-								// STA supports fixed MCS 
+								// STA supports fixed MCS
 								pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
 							}
 						}
@@ -426,7 +426,7 @@ VOID PeerDlsReqAction(
 						pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
 						pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
 						pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
-						pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;				
+						pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
 						pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
 
 						if (HtCapability.HtCapInfo.ShortGIfor20)
@@ -437,12 +437,12 @@ VOID PeerDlsReqAction(
 							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
 						if (HtCapability.HtCapInfo.RxSTBC)
 							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
-						if (HtCapability.ExtHtCapInfo.PlusHTC)				
+						if (HtCapability.ExtHtCapInfo.PlusHTC)
 							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
-						if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)				
-							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);	
+						if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
+							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
 						if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
-							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);		
+							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
 
 						NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
 					}
@@ -490,7 +490,7 @@ VOID PeerDlsReqAction(
 	}
 
 	ActHeaderInit(pAd, &DlsRspHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-		
+
 	// Build basic frame first
 	if (StatusCode == MLME_SUCCESS)
 	{
@@ -526,13 +526,13 @@ VOID PeerDlsReqAction(
 			HT_CAPABILITY_IE HtCapabilityTmp;
 #endif
 
-			// add HT Capability IE 
+			// add HT Capability IE
 			HtLen = sizeof(HT_CAPABILITY_IE);
 #ifndef RT_BIG_ENDIAN
 			MakeOutgoingFrame(pOutBuffer + FrameLen,	&tmp,
 								1,						&HtCapIe,
 								1,						&HtLen,
-								HtLen,					&pAd->CommonCfg.HtCapability, 
+								HtLen,					&pAd->CommonCfg.HtCapability,
 								END_OF_ARGS);
 #else
 			NdisMoveMemory(&HtCapabilityTmp, &pAd->CommonCfg.HtCapability, HtLen);
@@ -542,7 +542,7 @@ VOID PeerDlsReqAction(
 			MakeOutgoingFrame(pOutBuffer + FrameLen,	&tmp,
 								1,						&HtCapIe,
 								1,						&HtLen,
-								HtLen,					&HtCapabilityTmp, 
+								HtLen,					&HtCapabilityTmp,
 								END_OF_ARGS);
 #endif
 			FrameLen = FrameLen + tmp;
@@ -575,14 +575,14 @@ VOID PeerDlsReqAction(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID PeerDlsRspAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT		CapabilityInfo;
 	UCHAR		DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
@@ -602,13 +602,13 @@ VOID PeerDlsRspAction(
 		return;
 
 	if (!PeerDlsRspSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &CapabilityInfo, &StatusCode,
-							&SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability)) 
+							&SupportedRatesLen, &SupportedRates[0], &HtCapabilityLen, &HtCapability))
 		return;
 
     // supported rates array may not be sorted. sort it and find the maximum rate
     for (i=0; i<SupportedRatesLen; i++)
     {
-        if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f)) 
+        if (MaxSupportedRateIn500Kbps < (SupportedRates[i] & 0x7f))
             MaxSupportedRateIn500Kbps = SupportedRates[i] & 0x7f;
     }
 
@@ -666,12 +666,12 @@ VOID PeerDlsRspAction(
 
 				pEntry->MaxHTPhyMode.field.BW = BW_20;
 				pEntry->MinHTPhyMode.field.BW = BW_20;
-				
+
 #ifdef DOT11_N_SUPPORT
 				pEntry->HTCapability.MCSSet[0] = 0;
 				pEntry->HTCapability.MCSSet[1] = 0;
 
-				// If this Entry supports 802.11n, upgrade to HT rate. 
+				// If this Entry supports 802.11n, upgrade to HT rate.
 				if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
 				{
 					UCHAR	j, bitmask; //k,bitmask;
@@ -685,7 +685,7 @@ VOID PeerDlsRspAction(
 						pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
 					}
 					else
-					{	
+					{
 						pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
 						pAd->MacTab.fAnyStationNonGF = TRUE;
 						pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
@@ -697,7 +697,7 @@ VOID PeerDlsRspAction(
 						pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
 					}
 					else
-					{	
+					{
 						pEntry->MaxHTPhyMode.field.BW = BW_20;
 						pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
 						pAd->MacTab.fAnyStation20Only = TRUE;
@@ -705,8 +705,8 @@ VOID PeerDlsRspAction(
 
 					// find max fixed rate
 					for (ii=15; ii>=0; ii--)
-					{	
-						j = ii/8;	
+					{
+						j = ii/8;
 						bitmask = (1<<(ii-(j*8)));
 						if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
 						{
@@ -716,7 +716,7 @@ VOID PeerDlsRspAction(
 						if (ii==0)
 							break;
 					}
-	 
+
 					if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
 					{
 						if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
@@ -730,7 +730,7 @@ VOID PeerDlsRspAction(
 						}
 						else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
 						{
-							// STA supports fixed MCS 
+							// STA supports fixed MCS
 							pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
 						}
 					}
@@ -739,7 +739,7 @@ VOID PeerDlsRspAction(
 					pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
 					pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
 					pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
-					pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;				
+					pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
 					pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
 
 					if (HtCapability.HtCapInfo.ShortGIfor20)
@@ -750,12 +750,12 @@ VOID PeerDlsRspAction(
 						CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
 					if (HtCapability.HtCapInfo.RxSTBC)
 						CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
-					if (HtCapability.ExtHtCapInfo.PlusHTC)				
+					if (HtCapability.ExtHtCapInfo.PlusHTC)
 						CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
-					if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)				
-						CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);	
+					if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
+						CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
 					if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
-						CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);		
+						CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
 
 					NdisMoveMemory(&pEntry->HTCapability, &HtCapability, sizeof(HT_CAPABILITY_IE));
 				}
@@ -790,7 +790,7 @@ VOID PeerDlsRspAction(
 					{
 						MLME_DLS_REQ_STRUCT	MlmeDlsReq;
 						USHORT				reason = REASON_QOS_CIPHER_NOT_SUPPORT;
-						
+
 						DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
 						MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
 						pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
@@ -882,12 +882,12 @@ VOID PeerDlsRspAction(
 
 					pEntry->MaxHTPhyMode.field.BW = BW_20;
 					pEntry->MinHTPhyMode.field.BW = BW_20;
-					
+
 #ifdef DOT11_N_SUPPORT
 					pEntry->HTCapability.MCSSet[0] = 0;
 					pEntry->HTCapability.MCSSet[1] = 0;
 
-					// If this Entry supports 802.11n, upgrade to HT rate. 
+					// If this Entry supports 802.11n, upgrade to HT rate.
 					if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
 					{
 						UCHAR	j, bitmask; //k,bitmask;
@@ -901,7 +901,7 @@ VOID PeerDlsRspAction(
 							pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
 						}
 						else
-						{	
+						{
 							pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
 							pAd->MacTab.fAnyStationNonGF = TRUE;
 							pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
@@ -913,7 +913,7 @@ VOID PeerDlsRspAction(
 							pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(HtCapability.HtCapInfo.ShortGIfor40));
 						}
 						else
-						{	
+						{
 							pEntry->MaxHTPhyMode.field.BW = BW_20;
 							pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(HtCapability.HtCapInfo.ShortGIfor20));
 							pAd->MacTab.fAnyStation20Only = TRUE;
@@ -921,8 +921,8 @@ VOID PeerDlsRspAction(
 
 						// find max fixed rate
 						for (ii=15; ii>=0; ii--)
-						{	
-							j = ii/8;	
+						{
+							j = ii/8;
 							bitmask = (1<<(ii-(j*8)));
 							if ( (pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j]&bitmask) && (HtCapability.MCSSet[j]&bitmask))
 							{
@@ -932,7 +932,7 @@ VOID PeerDlsRspAction(
 							if (ii==0)
 								break;
 						}
-		 
+
 						if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
 						{
 							printk("@@@ pAd->CommonCfg.RegTransmitSetting.field.MCS = %d\n",
@@ -948,7 +948,7 @@ VOID PeerDlsRspAction(
 							}
 							else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
 							{
-								// STA supports fixed MCS 
+								// STA supports fixed MCS
 								pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
 							}
 						}
@@ -957,7 +957,7 @@ VOID PeerDlsRspAction(
 						pEntry->MpduDensity = HtCapability.HtCapParm.MpduDensity;
 						pEntry->MaxRAmpduFactor = HtCapability.HtCapParm.MaxRAmpduFactor;
 						pEntry->MmpsMode = (UCHAR)HtCapability.HtCapInfo.MimoPs;
-						pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;				
+						pEntry->AMsduSize = (UCHAR)HtCapability.HtCapInfo.AMsduSize;
 						pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
 
 						if (HtCapability.HtCapInfo.ShortGIfor20)
@@ -968,10 +968,10 @@ VOID PeerDlsRspAction(
 							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
 						if (HtCapability.HtCapInfo.RxSTBC)
 							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
-						if (HtCapability.ExtHtCapInfo.PlusHTC)				
+						if (HtCapability.ExtHtCapInfo.PlusHTC)
 							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
-						if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)				
-							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);	
+						if (pAd->CommonCfg.bRdg && HtCapability.ExtHtCapInfo.RDGSupport)
+							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
 						if (HtCapability.ExtHtCapInfo.MCSFeedback == 0x03)
 							CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
 
@@ -1009,7 +1009,7 @@ VOID PeerDlsRspAction(
 						{
 							MLME_DLS_REQ_STRUCT	MlmeDlsReq;
 							USHORT				reason = REASON_QOS_CIPHER_NOT_SUPPORT;
-							
+
 							DlsParmFill(pAd, &MlmeDlsReq, &pAd->StaCfg.DLSEntry[i], reason);
 							MlmeEnqueue(pAd, DLS_STATE_MACHINE, MT2_MLME_DLS_TEAR_DOWN, sizeof(MLME_DLS_REQ_STRUCT), &MlmeDlsReq);
 							pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;
@@ -1050,14 +1050,14 @@ VOID PeerDlsRspAction(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID MlmeDlsTearDownAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
 	PUCHAR			pOutBuffer = NULL;
 	NDIS_STATUS		NStatus;
@@ -1074,16 +1074,16 @@ VOID MlmeDlsTearDownAction(
 		return;
 
 	DBGPRINT(RT_DEBUG_TRACE,("DLS - MlmeDlsTearDownAction() with ReasonCode=%d \n", ReasonCode));
-	
+
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-	if (NStatus != NDIS_STATUS_SUCCESS) 
+	if (NStatus != NDIS_STATUS_SUCCESS)
 	{
 		DBGPRINT(RT_DEBUG_ERROR,("DLS - MlmeDlsTearDownAction() allocate memory failed \n"));
 		return;
 	}
 
 	ActHeaderInit(pAd, &DlsTearDownHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-		
+
 	// Build basic frame first
 	MakeOutgoingFrame(pOutBuffer,				&FrameLen,
 					sizeof(HEADER_802_11),		&DlsTearDownHdr,
@@ -1123,14 +1123,14 @@ VOID MlmeDlsTearDownAction(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 VOID PeerDlsTearDownAction(
-    IN PRTMP_ADAPTER pAd, 
-    IN MLME_QUEUE_ELEM *Elem) 
+    IN PRTMP_ADAPTER pAd,
+    IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR			DA[MAC_ADDR_LEN], SA[MAC_ADDR_LEN];
 	USHORT			ReasonCode;
@@ -1142,8 +1142,8 @@ VOID PeerDlsTearDownAction(
 
 	if (!INFRA_ON(pAd))
 		return;
-	
-	if (!PeerDlsTearDownSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &ReasonCode)) 
+
+	if (!PeerDlsTearDownSanity(pAd, Elem->Msg, Elem->MsgLen, DA, SA, &ReasonCode))
 		return;
 
 	DBGPRINT(RT_DEBUG_TRACE,("DLS - PeerDlsTearDownAction() from %02x:%02x:%02x:%02x:%02x:%02x with ReasonCode=%d\n", SA[0], SA[1], SA[2], SA[3], SA[4], SA[5], ReasonCode));
@@ -1180,7 +1180,7 @@ VOID PeerDlsTearDownAction(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
@@ -1191,7 +1191,7 @@ VOID RTMPCheckDLSTimeOut(
 	ULONG				i;
 	MLME_DLS_REQ_STRUCT	MlmeDlsReq;
 	USHORT				reason = REASON_QOS_UNSPECIFY;
-	
+
 	if (! pAd->CommonCfg.bDLSCapable)
 		return;
 
@@ -1242,7 +1242,7 @@ VOID RTMPCheckDLSTimeOut(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
@@ -1267,7 +1267,7 @@ BOOLEAN RTMPRcvFrameDLSCheck(
 	BOOLEAN			TimerCancelled;
 	CIPHER_KEY		PairwiseKey;
 
-	
+
 	if (! pAd->CommonCfg.bDLSCapable)
 		return bSTAKeyFrame;
 
@@ -1283,10 +1283,10 @@ BOOLEAN RTMPRcvFrameDLSCheck(
 	pProto	= (PUCHAR)pHeader + LENGTH_802_11 + 2 + 6;	// QOS Control field , 0xAA 0xAA 0xAA 0x00 0x00 0x00
 	pAddr	= pHeader->Addr2;
 
-	// L2PAD bit on will pad 2 bytes at LLC 
+	// L2PAD bit on will pad 2 bytes at LLC
 	if (pRxD->L2PAD)
 	{
-		pProto += 2;	
+		pProto += 2;
 	}
 
 	if (RTMPEqualMemory(EAPOL, pProto, 2) && (pAd->StaCfg.AuthMode >=  Ndis802_11AuthModeWPA))
@@ -1344,7 +1344,7 @@ BOOLEAN RTMPRcvFrameDLSCheck(
 			{
 				hmac_md5(DlsPTK, LEN_EAP_MICK, (PUCHAR) pEap, pEap->Body_Len[1] + 4, Mic);
 			}
-			
+
 			if (!NdisEqualMemory(OldMic, Mic, LEN_KEY_DESC_MIC))
 			{
 				DBGPRINT(RT_DEBUG_ERROR, ("MIC Different in Msg1 of STAKey handshake! \n"));
@@ -1377,7 +1377,7 @@ BOOLEAN RTMPRcvFrameDLSCheck(
 				bSTAKeyFrame = TRUE;
 			}
 #endif
-			
+
 		}
 		else if (Len >= (LENGTH_802_11 + 6 + 2 + 2 + sizeof(EAPOL_PACKET) - MAX_LEN_OF_RSNIE))
 		{
@@ -1407,7 +1407,7 @@ BOOLEAN RTMPRcvFrameDLSCheck(
 				// STAKey frame, add pairwise key table
 				pAd->StaCfg.DLSEntry[i].Status = DLS_FINISH;
 				RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &TimerCancelled);
-				
+
 				PairwiseKey.KeyLen = LEN_TKIP_EK;
 				NdisMoveMemory(PairwiseKey.Key, &pSTAKey[0], LEN_TKIP_EK);
 				NdisMoveMemory(PairwiseKey.TxMic, &pSTAKey[16], LEN_TKIP_RXMICK);
@@ -1421,14 +1421,14 @@ BOOLEAN RTMPRcvFrameDLSCheck(
 				// Add Pair-wise key to Asic
 #ifdef RT2860
             	AsicAddPairwiseKeyEntry(pAd,
-										pAd->StaCfg.DLSEntry[i].MacAddr, 
+										pAd->StaCfg.DLSEntry[i].MacAddr,
 										(UCHAR)pAd->StaCfg.DLSEntry[i].MacTabMatchWCID,
-										&PairwiseKey);															
+										&PairwiseKey);
 
-				RTMPAddWcidAttributeEntry(pAd, 
+				RTMPAddWcidAttributeEntry(pAd,
 										  BSS0,
-										  0, 
-										  PairwiseKey.CipherAlg, 
+										  0,
+										  PairwiseKey.CipherAlg,
 										  pEntry);
 
 #endif // RT2860 //
@@ -1436,7 +1436,7 @@ BOOLEAN RTMPRcvFrameDLSCheck(
 				DBGPRINT(RT_DEBUG_TRACE,("DLS - Receive STAKey Message-1 (Peer STA MAC Address STAKey) \n"));
 
 				RTMPSendSTAKeyHandShake(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);
-				
+
 				DBGPRINT(RT_DEBUG_TRACE,("DLS - Finish STAKey handshake procedure (Initiator side)\n"));
 			}
 			else
@@ -1479,14 +1479,14 @@ BOOLEAN RTMPRcvFrameDLSCheck(
 				// Add Pair-wise key to Asic
 #ifdef RT2860
             	AsicAddPairwiseKeyEntry(pAd,
-										pAd->StaCfg.DLSEntry[i].MacAddr, 
+										pAd->StaCfg.DLSEntry[i].MacAddr,
 										(UCHAR)pAd->StaCfg.DLSEntry[i].MacTabMatchWCID,
-										&PairwiseKey);															
+										&PairwiseKey);
 
-				RTMPAddWcidAttributeEntry(pAd, 
+				RTMPAddWcidAttributeEntry(pAd,
 										  BSS0,
-										  0, 
-										  PairwiseKey.CipherAlg, 
+										  0,
+										  PairwiseKey.CipherAlg,
 										  pEntry);
 #endif // RT2860 //
 				NdisMoveMemory(&pEntry->PairwiseKey, &PairwiseKey, sizeof(CIPHER_KEY));
@@ -1517,11 +1517,11 @@ BOOLEAN RTMPRcvFrameDLSCheck(
 					pAd->StaCfg.DLSEntry[i].CountDownTimer = pAd->StaCfg.DLSEntry[i].TimeOut;
 				}
 			}
-			
+
 			bFindEntry = TRUE;
 		}
 	}
-	
+
 
 	return bSTAKeyFrame;
 }
@@ -1531,15 +1531,15 @@ BOOLEAN RTMPRcvFrameDLSCheck(
 
 	Routine	Description:
 		Check if the frame can be sent through DLS direct link interface
-		
+
 	Arguments:
 		pAd		Pointer	to adapter
-		
+
 	Return Value:
 		DLS entry index
-		
+
 	Note:
-	
+
 	========================================================================
 */
 INT	RTMPCheckDLSFrame(
@@ -1578,14 +1578,14 @@ INT	RTMPCheckDLSFrame(
 			}
 		}
 	} while (FALSE);
-	
+
 	return rval;
 }
 
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
@@ -1610,15 +1610,15 @@ VOID RTMPSendDLSTearDownFrame(
 	DBGPRINT(RT_DEBUG_TRACE, ("Send DLS TearDown Frame \n"));
 
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-	if (NStatus != NDIS_STATUS_SUCCESS) 
+	if (NStatus != NDIS_STATUS_SUCCESS)
 	{
 		DBGPRINT(RT_DEBUG_ERROR,("ASSOC - RTMPSendDLSTearDownFrame() allocate memory failed \n"));
 		return;
 	}
 
 	ActHeaderInit(pAd, &DlsTearDownHdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
-	MakeOutgoingFrame(pOutBuffer,				&FrameLen, 
-					sizeof(HEADER_802_11),		&DlsTearDownHdr, 
+	MakeOutgoingFrame(pOutBuffer,				&FrameLen,
+					sizeof(HEADER_802_11),		&DlsTearDownHdr,
 					1,							&Category,
 					1,							&Action,
 					6,							pDA,
@@ -1655,7 +1655,7 @@ VOID RTMPSendDLSTearDownFrame(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
@@ -1676,7 +1676,7 @@ NDIS_STATUS RTMPSendSTAKeyRequest(
 	UCHAR				DlsPTK[80];
 
 	DBGPRINT(RT_DEBUG_TRACE,("DLS - RTMPSendSTAKeyRequest() to %02x:%02x:%02x:%02x:%02x:%02x\n", pDA[0], pDA[1], pDA[2], pDA[3], pDA[4], pDA[5]));
-	
+
 	pAd->Sequence ++;
 	MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
 
@@ -1685,7 +1685,7 @@ NDIS_STATUS RTMPSendSTAKeyRequest(
 	Packet.ProVer = EAPOL_VER;
 	Packet.ProType    = EAPOLKey;
 	Packet.Body_Len[1]  = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + 6 + MAC_ADDR_LEN;		// data field contain KDE andPeer MAC address
-	
+
 	// STAKey Message is as EAPOL-Key(1,1,0,0,G/0,0,0, MIC, 0,Peer MAC KDE)
 	if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
     {
@@ -1695,9 +1695,9 @@ NDIS_STATUS RTMPSendSTAKeyRequest(
     {
         Packet.KeyDesc.Type = WPA2_KEY_DESC;
     }
-	
+
 	// Key descriptor version
-	Packet.KeyDesc.KeyInfo.KeyDescVer = 
+	Packet.KeyDesc.KeyInfo.KeyDescVer =
 		(((pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) || (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
 
 	Packet.KeyDesc.KeyInfo.KeyMic	= 1;
@@ -1714,12 +1714,12 @@ NDIS_STATUS RTMPSendSTAKeyRequest(
 	Packet.KeyDesc.KeyData[4]		= 0x43;
 	Packet.KeyDesc.KeyData[5]		= 0x03;
 	NdisMoveMemory(&Packet.KeyDesc.KeyData[6], pDA, MAC_ADDR_LEN);
-	
+
 	NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.DlsReplayCounter, LEN_KEY_DESC_REPLAY);
 
 	// Allocate buffer for transmitting message
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
-	if (NStatus	!= NDIS_STATUS_SUCCESS)	
+	if (NStatus	!= NDIS_STATUS_SUCCESS)
 		return NStatus;
 
 	// Prepare EAPOL frame for MIC calculation
@@ -1748,7 +1748,7 @@ NDIS_STATUS RTMPSendSTAKeyRequest(
 		NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
 	}
 
-	MakeOutgoingFrame(pOutBuffer,           &FrameLen,	
+	MakeOutgoingFrame(pOutBuffer,           &FrameLen,
 	                  sizeof(Header802_3),	Header802_3,
 		              Packet.Body_Len[1] + 4,	&Packet,
 		              END_OF_ARGS);
@@ -1762,7 +1762,7 @@ NDIS_STATUS RTMPSendSTAKeyRequest(
 	}
 
 	MlmeFreeMemory(pAd, pOutBuffer);
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("RTMPSendSTAKeyRequest- Send STAKey request (NStatus=%x, FrameLen=%ld)\n", NStatus, FrameLen));
 
 	return NStatus;
@@ -1771,7 +1771,7 @@ NDIS_STATUS RTMPSendSTAKeyRequest(
 /*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
@@ -1792,7 +1792,7 @@ NDIS_STATUS RTMPSendSTAKeyHandShake(
 	UCHAR				DlsPTK[80];			// Due to dirver can not get PTK, use proprietary PTK
 
 	DBGPRINT(RT_DEBUG_TRACE,("DLS - RTMPSendSTAKeyHandShake() to %02x:%02x:%02x:%02x:%02x:%02x\n", pDA[0], pDA[1], pDA[2], pDA[3], pDA[4], pDA[5]));
-	
+
 	pAd->Sequence ++;
 	MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
 
@@ -1801,7 +1801,7 @@ NDIS_STATUS RTMPSendSTAKeyHandShake(
 	Packet.ProVer = EAPOL_VER;
 	Packet.ProType    = EAPOLKey;
 	Packet.Body_Len[1]  = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + 6 + MAC_ADDR_LEN;		// data field contain KDE and Peer MAC address
-	
+
 	// STAKey Message is as EAPOL-Key(1,1,0,0,G/0,0,0, MIC, 0,Peer MAC KDE)
 	if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
     {
@@ -1811,9 +1811,9 @@ NDIS_STATUS RTMPSendSTAKeyHandShake(
     {
         Packet.KeyDesc.Type = WPA2_KEY_DESC;
     }
-	
+
 	// Key descriptor version
-	Packet.KeyDesc.KeyInfo.KeyDescVer = 
+	Packet.KeyDesc.KeyInfo.KeyDescVer =
 		(((pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled) || (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)) ? (DESC_TYPE_AES) : (DESC_TYPE_TKIP));
 
 	Packet.KeyDesc.KeyInfo.KeyMic	= 1;
@@ -1829,12 +1829,12 @@ NDIS_STATUS RTMPSendSTAKeyHandShake(
 	Packet.KeyDesc.KeyData[4]		= 0x43;
 	Packet.KeyDesc.KeyData[5]		= 0x03;
 	NdisMoveMemory(&Packet.KeyDesc.KeyData[6], pDA, MAC_ADDR_LEN);
-	
+
 	NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.DlsReplayCounter, LEN_KEY_DESC_REPLAY);
 
 	// Allocate buffer for transmitting message
 	NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
-	if (NStatus	!= NDIS_STATUS_SUCCESS)	
+	if (NStatus	!= NDIS_STATUS_SUCCESS)
 		return NStatus;
 
 	// Prepare EAPOL frame for MIC calculation
@@ -1863,7 +1863,7 @@ NDIS_STATUS RTMPSendSTAKeyHandShake(
 		NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
 	}
 
-	MakeOutgoingFrame(pOutBuffer,           &FrameLen,	
+	MakeOutgoingFrame(pOutBuffer,           &FrameLen,
 	                  sizeof(Header802_3),	Header802_3,
 		              Packet.Body_Len[1] + 4,	&Packet,
 		              END_OF_ARGS);
@@ -1877,17 +1877,17 @@ NDIS_STATUS RTMPSendSTAKeyHandShake(
 	}
 
 	MlmeFreeMemory(pAd, pOutBuffer);
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("RTMPSendSTAKeyHandShake- Send STAKey Message-2 (NStatus=%x, FrameLen=%ld)\n", NStatus, FrameLen));
 
 	return NStatus;
 }
 
 VOID DlsTimeoutAction(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
-	IN PVOID SystemSpecific3) 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
+	IN PVOID SystemSpecific3)
 {
 	MLME_DLS_REQ_STRUCT		MlmeDlsReq;
 	USHORT					reason;
@@ -1910,7 +1910,7 @@ VOID DlsTimeoutAction(
 
 /*
 ================================================================
-Description : because DLS and CLI share the same WCID table in ASIC. 
+Description : because DLS and CLI share the same WCID table in ASIC.
 Mesh entry also insert to pAd->MacTab.content[].  Such is marked as ValidAsDls = TRUE.
 Also fills the pairwise key.
 Because front MAX_AID_BA entries have direct mapping to BAEntry, which is only used as CLI. So we insert Dls
@@ -1918,7 +1918,7 @@ from index MAX_AID_BA.
 ================================================================
 */
 MAC_TABLE_ENTRY *MacTableInsertDlsEntry(
-	IN  PRTMP_ADAPTER   pAd, 
+	IN  PRTMP_ADAPTER   pAd,
 	IN  PUCHAR	pAddr,
 	IN  UINT	DlsEntryIdx)
 {
@@ -1956,13 +1956,13 @@ MAC_TABLE_ENTRY *MacTableInsertDlsEntry(
 
 				CipherAlg 	= pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
 
-				RTMPAddWcidAttributeEntry(pAd, 
-											BSS0, 
-											pAd->StaCfg.DefaultKeyId, 
-											pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg, 
+				RTMPAddWcidAttributeEntry(pAd,
+											BSS0,
+											pAd->StaCfg.DefaultKeyId,
+											pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
 											pEntry);
 			}
-		
+
 			break;
 		}
 	} while(FALSE);
@@ -2068,7 +2068,7 @@ MAC_TABLE_ENTRY *DlsEntryTableLookupByWcid(
 }
 
 INT Set_DlsEntryInfo_Display_Proc(
-	IN PRTMP_ADAPTER pAd, 
+	IN PRTMP_ADAPTER pAd,
 	IN PUCHAR arg)
 {
 	INT i;
@@ -2104,7 +2104,7 @@ INT Set_DlsEntryInfo_Display_Proc(
 			printk("%-6d", pEntry->HTPhyMode.field.MCS);
 			printk("%-6d", pEntry->HTPhyMode.field.ShortGI);
 			printk("%-6d", pEntry->HTPhyMode.field.STBC);
-			printk("%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount, 
+			printk("%-10d, %d, %d%%\n", pEntry->DebugFIFOCount, pEntry->DebugTxCount,
 						(pEntry->DebugTxCount) ? ((pEntry->DebugTxCount-pEntry->DebugFIFOCount)*100/pEntry->DebugTxCount) : 0);
 			printk("\n");
 
@@ -2115,7 +2115,7 @@ INT Set_DlsEntryInfo_Display_Proc(
 }
 
 INT	Set_DlsAddEntry_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
     UCHAR	mac[MAC_ADDR_LEN];
@@ -2131,7 +2131,7 @@ INT	Set_DlsAddEntry_Proc(
 	if ((token != NULL) && (strlen(token)>1))
 	{
 		Timeout = simple_strtol((token+1), 0, 10);
-		
+
 		*token = '\0';
 		for (i = 0, token = rstrtok(arg, &sepValue[0]); token; token = rstrtok(NULL, &sepValue[0]), i++)
 		{
@@ -2150,10 +2150,10 @@ INT	Set_DlsAddEntry_Proc(
 		COPY_MAC_ADDR(Dls.MacAddr, mac);
 		Dls.Valid = 1;
 
-		MlmeEnqueue(pAd, 
-					MLME_CNTL_STATE_MACHINE, 
-					RT_OID_802_11_SET_DLS_PARAM, 
-					sizeof(RT_802_11_DLS), 
+		MlmeEnqueue(pAd,
+					MLME_CNTL_STATE_MACHINE,
+					RT_OID_802_11_SET_DLS_PARAM,
+					sizeof(RT_802_11_DLS),
 					&Dls);
 
 		return TRUE;
@@ -2164,7 +2164,7 @@ INT	Set_DlsAddEntry_Proc(
 }
 
 INT	Set_DlsTearDownEntry_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	UCHAR			macAddr[MAC_ADDR_LEN];
@@ -2175,9 +2175,9 @@ INT	Set_DlsTearDownEntry_Proc(
 	if(strlen(arg) != 17)  //Mac address acceptable format 01:02:03:04:05:06 length 17
 		return FALSE;
 
-	for (i=0, value = rstrtok(arg,":"); value; value = rstrtok(NULL,":")) 
+	for (i=0, value = rstrtok(arg,":"); value; value = rstrtok(NULL,":"))
 	{
-		if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) ) 
+		if((strlen(value) != 2) || (!isxdigit(*value)) || (!isxdigit(*(value+1))) )
 			return FALSE;  //Invalid
 
 		AtoH(value, &macAddr[i++], 2);
@@ -2190,10 +2190,10 @@ INT	Set_DlsTearDownEntry_Proc(
 	COPY_MAC_ADDR(Dls.MacAddr, macAddr);
 	Dls.Valid = 0;
 
-	MlmeEnqueue(pAd, 
-				MLME_CNTL_STATE_MACHINE, 
-				RT_OID_802_11_SET_DLS_PARAM, 
-				sizeof(RT_802_11_DLS), 
+	MlmeEnqueue(pAd,
+				MLME_CNTL_STATE_MACHINE,
+				RT_OID_802_11_SET_DLS_PARAM,
+				sizeof(RT_802_11_DLS),
 				&Dls);
 
 	return TRUE;
diff --git a/sta/rtmp_data.c b/sta/rtmp_data.c
index a186dc8..36aff24 100644
--- a/sta/rtmp_data.c
+++ b/sta/rtmp_data.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -36,7 +36,7 @@
 	John		      Aug/17/04		major modification for RT2561/2661
 	Jan Lee	      Mar/17/06		major modification for RT2860 New Ring Design
 */
-#include "rt_config.h"
+#include "../rt_config.h"
 
 
 
@@ -60,19 +60,19 @@ VOID STARxEAPOLFrameIndicate(
 			if ( pAd->StaCfg.IEEE8021X == TRUE &&
 				 (EAP_CODE_SUCCESS == WpaCheckEapCode(pAd, pRxBlk->pData, pRxBlk->DataSize, LENGTH_802_1_H)))
 			{
-				PUCHAR	Key; 			
+				PUCHAR	Key;
 				UCHAR 	CipherAlg;
 				int     idx = 0;
 
 				DBGPRINT_RAW(RT_DEBUG_TRACE, ("Receive EAP-SUCCESS Packet\n"));
 				STA_PORT_SECURED(pAd);
-				
+
                 if (pAd->StaCfg.IEEE8021x_required_keys == FALSE)
                 {
                     idx = pAd->StaCfg.DesireSharedKeyId;
                     CipherAlg = pAd->StaCfg.DesireSharedKey[idx].CipherAlg;
 					Key = pAd->StaCfg.DesireSharedKey[idx].Key;
-                    
+
                     if (pAd->StaCfg.DesireSharedKey[idx].KeyLen > 0)
     				{
 #ifdef RT2860
@@ -81,7 +81,7 @@ VOID STARxEAPOLFrameIndicate(
 						// Set key material and cipherAlg to Asic
 						AsicAddSharedKeyEntry(pAd, BSS0, idx, CipherAlg, Key, NULL, NULL);
 
-						// Assign group key info  
+						// Assign group key info
 						RTMPAddWcidAttributeEntry(pAd, BSS0, idx, CipherAlg, NULL);
 
 						// Assign pairwise key info
@@ -93,19 +93,19 @@ VOID STARxEAPOLFrameIndicate(
 						// For Preventing ShardKey Table is cleared by remove key procedure.
     					pAd->SharedKey[BSS0][idx].CipherAlg = CipherAlg;
 						pAd->SharedKey[BSS0][idx].KeyLen = pAd->StaCfg.DesireSharedKey[idx].KeyLen;
-						NdisMoveMemory(pAd->SharedKey[BSS0][idx].Key, 
-									   pAd->StaCfg.DesireSharedKey[idx].Key, 
+						NdisMoveMemory(pAd->SharedKey[BSS0][idx].Key,
+									   pAd->StaCfg.DesireSharedKey[idx].Key,
 									   pAd->StaCfg.DesireSharedKey[idx].KeyLen);
     				}
 				}
 			}
 
 			Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
-			return; 
+			return;
 		}
 	}
 	else
-#endif // WPA_SUPPLICANT_SUPPORT //                        
+#endif // WPA_SUPPLICANT_SUPPORT //
 	{
 		// Special DATA frame that has to pass to MLME
 		//	 1. Cisco Aironet frames for CCX2. We need pass it to MLME for special process
@@ -148,8 +148,8 @@ VOID STARxDataFrameAnnounce(
 			}
 			else
 			{
-				// encryption in-use but receive a non-EAPOL clear text frame, drop it 
-				if ((pAd->StaCfg.WepStatus != Ndis802_11EncryptionDisabled) && 
+				// encryption in-use but receive a non-EAPOL clear text frame, drop it
+				if ((pAd->StaCfg.WepStatus != Ndis802_11EncryptionDisabled) &&
 					(pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
 				{
 					// release packet
@@ -163,7 +163,7 @@ VOID STARxDataFrameAnnounce(
 		{
 			// Normal legacy, AMPDU or AMSDU
 			CmmRxnonRalinkFrameIndicate(pAd, pRxBlk, FromWhichBSSID);
-			
+
 		}
 		else
 		{
@@ -174,14 +174,14 @@ VOID STARxDataFrameAnnounce(
 		RX_BLK_CLEAR_FLAG(pRxBlk, fRX_DLS);
 #endif // QOS_DLS_SUPPORT //
 	}
-	else 
+	else
 	{
 		RX_BLK_SET_FLAG(pRxBlk, fRX_EAP);
 #ifdef DOT11_N_SUPPORT
-		if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU) && (pAd->CommonCfg.bDisableReordering == 0)) 
+		if (RX_BLK_TEST_FLAG(pRxBlk, fRX_AMPDU) && (pAd->CommonCfg.bDisableReordering == 0))
 		{
 			Indicate_AMPDU_Packet(pAd, pRxBlk, FromWhichBSSID);
-		} 
+		}
 		else
 #endif // DOT11_N_SUPPORT //
 		{
@@ -193,7 +193,7 @@ VOID STARxDataFrameAnnounce(
 }
 
 
-// For TKIP frame, calculate the MIC value						
+// For TKIP frame, calculate the MIC value
 BOOLEAN STACheckTkipMICValue(
 	IN	PRTMP_ADAPTER	pAd,
 	IN	MAC_TABLE_ENTRY	*pEntry,
@@ -213,7 +213,7 @@ BOOLEAN STACheckTkipMICValue(
 	{
 		pSA = pHeader->Addr3;
 	}
-	else 
+	else
 	{
 		pSA = pHeader->Addr2;
 	}
@@ -233,12 +233,12 @@ BOOLEAN STACheckTkipMICValue(
 		{
 			WpaSendMicFailureToWpaSupplicant(pAd, (pWpaKey->Type == PAIRWISEKEY) ? TRUE : FALSE);
 		}
-		else 
+		else
 #endif // WPA_SUPPLICANT_SUPPORT //
 		{
 			RTMPReportMicError(pAd, pWpaKey);
 		}
-		
+
 		// release packet
 		RELEASE_NDIS_PACKET(pAd, pRxBlk->pRxPacket, NDIS_STATUS_FAILURE);
 		return FALSE;
@@ -255,7 +255,7 @@ BOOLEAN STACheckTkipMICValue(
 //  2. pData pointer to payload including LLC (just skip Header)
 //  3. set payload size including LLC to DataSize
 //  4. set some flags with RX_BLK_SET_FLAG()
-// 
+//
 VOID STAHandleRxDataFrame(
 	IN	PRTMP_ADAPTER	pAd,
 	IN	RX_BLK			*pRxBlk)
@@ -289,7 +289,7 @@ VOID STAHandleRxDataFrame(
 		// Drop not my BSS frames
 		if (pRxD->MyBss == 0)
 		{
-			{	
+			{
 				// release packet
 				RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
 				return;
@@ -376,14 +376,14 @@ VOID STAHandleRxDataFrame(
 
 		//
 		// find pEntry
-		// 
+		//
 		if (pRxWI->WirelessCliID < MAX_LEN_OF_MAC_TABLE)
 		{
 			pEntry = &pAd->MacTab.Content[pRxWI->WirelessCliID];
 		}
-		else 
+		else
 		{
-			// 1. release packet if infra mode 
+			// 1. release packet if infra mode
 			// 2. new a pEntry if ad-hoc mode
 			RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
 			return;
@@ -419,7 +419,7 @@ VOID STAHandleRxDataFrame(
 	//
 	// update RxBlk->pData, DataSize
 	// 802.11 Header, QOS, HTC, Hw Padding
-	// 
+	//
 
 	// 1. skip 802.11 HEADER
 	{
@@ -431,7 +431,7 @@ VOID STAHandleRxDataFrame(
 	if (pHeader->FC.SubType & 0x08)
 	{
 		RX_BLK_SET_FLAG(pRxBlk, fRX_QOS);
-		UserPriority = *(pRxBlk->pData) & 0x0f;	
+		UserPriority = *(pRxBlk->pData) & 0x0f;
 		// bit 7 in QoS Control field signals the HT A-MSDU format
 		if ((*pRxBlk->pData) & 0x80)
 		{
@@ -464,11 +464,11 @@ VOID STAHandleRxDataFrame(
 		}
 	}
 
-	// 4. skip HW padding 
+	// 4. skip HW padding
 	if (pRxD->L2PAD)
 	{
-		// just move pData pointer 
-		// because DataSize excluding HW padding 
+		// just move pData pointer
+		// because DataSize excluding HW padding
 		RX_BLK_SET_FLAG(pRxBlk, fRX_PAD);
 		pRxBlk->pData += 2;
 	}
@@ -481,7 +481,7 @@ VOID STAHandleRxDataFrame(
 #endif // DOT11_N_SUPPORT //
 
 
-	// 
+	//
 	// Case I  Process Broadcast & Multicast data frame
 	//
 	if (pRxD->Bcast || pRxD->Mcast)
@@ -495,7 +495,7 @@ VOID STAHandleRxDataFrame(
 			RELEASE_NDIS_PACKET(pAd, pRxPacket, NDIS_STATUS_FAILURE);
 			return;
 		}
-				
+
 		// Filter out Bcast frame which AP relayed for us
 		if (pHeader->FC.FrDs && MAC_ADDR_EQUAL(pHeader->Addr3, pAd->CurrentAddress))
 		{
@@ -506,7 +506,7 @@ VOID STAHandleRxDataFrame(
 
 		Indicate_Legacy_Packet(pAd, pRxBlk, FromWhichBSSID);
 		return;
-	}					
+	}
 	else if (pRxD->U2M)
 	{
 		pAd->LastRxRate = (USHORT)((pRxWI->MCS) + (pRxWI->BW <<7) + (pRxWI->ShortGI <<8)+ (pRxWI->PHYMODE <<14)) ;
@@ -535,14 +535,14 @@ VOID STAHandleRxDataFrame(
 
 		pAd->StaCfg.LastSNR0 = (UCHAR)(pRxWI->SNR0);
 		pAd->StaCfg.LastSNR1 = (UCHAR)(pRxWI->SNR1);
-	
+
 		pAd->RalinkCounters.OneSecRxOkDataCnt++;
 
 
     	if (!((pHeader->Frag == 0) && (pHeader->FC.MoreFrag == 0)))
     	{
     		// re-assemble the fragmented packets
-    		// return complete frame (pRxPacket) or NULL   
+    		// return complete frame (pRxPacket) or NULL
     		bFragment = TRUE;
     		pRxPacket = RTMPDeFragmentDataFrame(pAd, pRxBlk);
     	}
@@ -556,8 +556,8 @@ VOID STAHandleRxDataFrame(
     		{
 				// Minus MIC length
 				pRxBlk->DataSize -= 8;
-			
-    			// For TKIP frame, calculate the MIC value						
+
+    			// For TKIP frame, calculate the MIC value
     			if (STACheckTkipMICValue(pAd, pEntry, pRxBlk) == FALSE)
     			{
     				return;
@@ -569,8 +569,8 @@ VOID STAHandleRxDataFrame(
     	}
     	else
     	{
-    		// just return 
-    		// because RTMPDeFragmentDataFrame() will release rx packet, 
+    		// just return
+    		// because RTMPDeFragmentDataFrame() will release rx packet,
     		// if packet is fragmented
     		return;
     	}
@@ -602,14 +602,14 @@ VOID STAHandleRxMgmtFrame(
 			pAd->StaCfg.LastSNR1 = (UCHAR)(pRxWI->SNR1);
 		}
 
-		// First check the size, it MUST not exceed the mlme queue size		
+		// First check the size, it MUST not exceed the mlme queue size
 		if (pRxWI->MPDUtotalByteCount > MGMT_DMA_BUFFER_SIZE)
 		{
 			DBGPRINT_ERR(("STAHandleRxMgmtFrame: frame too large, size = %d \n", pRxWI->MPDUtotalByteCount));
 			break;
 		}
 
-		REPORT_MGMT_FRAME_TO_MLME(pAd, pRxWI->WirelessCliID, pHeader, pRxWI->MPDUtotalByteCount, 
+		REPORT_MGMT_FRAME_TO_MLME(pAd, pRxWI->WirelessCliID, pHeader, pRxWI->MPDUtotalByteCount,
 									pRxWI->RSSI0, pRxWI->RSSI1, pRxWI->RSSI2, pRxD->PlcpSignal);
 	} while (FALSE);
 
@@ -658,7 +658,7 @@ VOID STAHandleRxControlFrame(
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
 		This routine has to maintain Rx ring read pointer.
 		Need to consider QOS DATA format when converting to 802.3
@@ -696,7 +696,7 @@ BOOLEAN STARxDoneInterruptHandle(
 #ifdef RT2860
 		if (RxProcessed++ > MAX_RX_PROCESS_CNT)
 		{
-			// need to reschedule rx handle 
+			// need to reschedule rx handle
 			bReschedule = TRUE;
 			break;
 		}
@@ -704,12 +704,12 @@ BOOLEAN STARxDoneInterruptHandle(
 
 		RxProcessed ++; // test
 
-		// 1. allocate a new data packet into rx ring to replace received packet 
+		// 1. allocate a new data packet into rx ring to replace received packet
 		//    then processing the received packet
 		// 2. the callee must take charge of release of packet
 		// 3. As far as driver is concerned ,
-		//    the rx packet must 
-		//      a. be indicated to upper layer or 
+		//    the rx packet must
+		//      a. be indicated to upper layer or
 		//      b. be released if it is discarded
 		pRxPacket = GetPacketFromRxRing(pAd, &(RxCell.RxD), &bReschedule, &RxPending);
 		if (pRxPacket == NULL)
@@ -746,7 +746,7 @@ BOOLEAN STARxDoneInterruptHandle(
 
 		if (pRxWI->MPDUtotalByteCount < 14)
 			Status = NDIS_STATUS_FAILURE;
-		
+
         if (MONITOR_ON(pAd))
 		{
             send_monitor_packets(pAd, &RxCell);
@@ -822,7 +822,7 @@ BOOLEAN STARxDoneInterruptHandle(
 		pAd 	Pointer to our adapter
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	========================================================================
 */
 VOID	RTMPHandleTwakeupInterrupt(
@@ -840,9 +840,9 @@ Arguments:
     NDIS_HANDLE 	MiniportAdapterContext	Pointer refer to the device handle, i.e., the pAd.
 	PPNDIS_PACKET	ppPacketArray			The packet array need to do transmission.
 	UINT			NumberOfPackets			Number of packet in packet array.
-	
+
 Return Value:
-	NONE					
+	NONE
 
 Note:
 	This function do early checking and classification for send-out packet.
@@ -880,7 +880,7 @@ VOID STASendPackets(
 			}
 			else
 			{
-				// Record that orignal packet source is from NDIS layer,so that 
+				// Record that orignal packet source is from NDIS layer,so that
 				// later on driver knows how to release this NDIS PACKET
 #ifdef QOS_DLS_SUPPORT
 				MAC_TABLE_ENTRY *pEntry;
@@ -907,7 +907,7 @@ VOID STASendPackets(
 		else
 			RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
 	}
-	
+
 	// Dequeue outgoing frames from TxSwQueue[] and process it
 	RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS);
 
@@ -917,10 +917,10 @@ VOID STASendPackets(
 /*
 ========================================================================
 Routine Description:
-	This routine is used to do packet parsing and classification for Tx packet 
-	to STA device, and it will en-queue packets to our TxSwQueue depends on AC 
+	This routine is used to do packet parsing and classification for Tx packet
+	to STA device, and it will en-queue packets to our TxSwQueue depends on AC
 	class.
-	
+
 Arguments:
 	pAd    		Pointer to our adapter
 	pPacket 	Pointer to send packet
@@ -947,8 +947,8 @@ NDIS_STATUS STASendPacket(
 	unsigned int 	IrqFlags;
 	UCHAR			FlgIsIP = 0;
 	UCHAR			Rate;
-	
-	// Prepare packet information structure for buffer descriptor 
+
+	// Prepare packet information structure for buffer descriptor
 	// chained within a single NDIS packet.
 	RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
 
@@ -961,16 +961,16 @@ NDIS_STATUS STASendPacket(
 		return NDIS_STATUS_FAILURE;
 	}
 
-	
+
 	if (SrcBufLen < 14)
 	{
 		DBGPRINT(RT_DEBUG_ERROR,("STASendPacket --> Ndis Packet buffer error !!!\n"));
 		RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
 		return (NDIS_STATUS_FAILURE);
 	}
-	
-	// In HT rate adhoc mode, A-MPDU is often used. So need to lookup BA Table and MAC Entry. 
-	// Note multicast packets in adhoc also use BSSID_WCID index. 
+
+	// In HT rate adhoc mode, A-MPDU is often used. So need to lookup BA Table and MAC Entry.
+	// Note multicast packets in adhoc also use BSSID_WCID index.
 	{
 		if(INFRA_ON(pAd))
 		{
@@ -999,7 +999,7 @@ NDIS_STATUS STASendPacket(
 				RTMP_SET_PACKET_WCID(pPacket, MCAST_WCID);
 				pEntry = &pAd->MacTab.Content[MCAST_WCID];
 			}
-			else 
+			else
 			{
 				pEntry = MacTableLookup(pAd, pSrcBufVA);
 			}
@@ -1021,24 +1021,24 @@ NDIS_STATUS STASendPacket(
 	{
 		RTMP_SET_PACKET_WCID(pPacket, (UCHAR)pEntry->Aid);
 	}
-		
+
 	//
 	// Check the Ethernet Frame type of this packet, and set the RTMP_SET_PACKET_SPECIFIC flags.
 	//		Here we set the PACKET_SPECIFIC flags(LLC, VLAN, DHCP/ARP, EAPOL).
 	RTMPCheckEtherType(pAd, pPacket);
 
-	
-	
+
+
 	//
 	// WPA 802.1x secured port control - drop all non-802.1x frame before port secured
 	//
-	if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || 
+	if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
 		 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
-		 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || 
+		 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
 		 (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
 #ifdef WPA_SUPPLICANT_SUPPORT
-		  || (pAd->StaCfg.IEEE8021X == TRUE) 
-#endif // WPA_SUPPLICANT_SUPPORT //     		 
+		  || (pAd->StaCfg.IEEE8021X == TRUE)
+#endif // WPA_SUPPLICANT_SUPPORT //
 #ifdef LEAP_SUPPORT
 		  || (pAd->StaCfg.LeapAuthMode == CISCO_AuthModeLEAP)
 #endif // LEAP_SUPPORT //
@@ -1046,7 +1046,7 @@ NDIS_STATUS STASendPacket(
 		  && ((pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED) || (pAd->StaCfg.MicErrCnt >= 2))
 		  && (RTMP_GET_PACKET_EAPOL(pPacket)== FALSE)
 		  )
-	{    
+	{
 		DBGPRINT(RT_DEBUG_TRACE,("STASendPacket --> Drop packet before port secured !!!\n"));
 		RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE);
 
@@ -1054,10 +1054,10 @@ NDIS_STATUS STASendPacket(
 	}
 
 
-	// STEP 1. Decide number of fragments required to deliver this MSDU. 
-	//	   The estimation here is not very accurate because difficult to 
-	//	   take encryption overhead into consideration here. The result 
-	//	   "NumberOfFrag" is then just used to pre-check if enough free 
+	// STEP 1. Decide number of fragments required to deliver this MSDU.
+	//	   The estimation here is not very accurate because difficult to
+	//	   take encryption overhead into consideration here. The result
+	//	   "NumberOfFrag" is then just used to pre-check if enough free
 	//	   TXD are available to hold this MSDU.
 
 
@@ -1073,13 +1073,13 @@ NDIS_STATUS STASendPacket(
 #endif // DOT11_N_SUPPORT //
 	else
 	{
-		// The calculated "NumberOfFrag" is a rough estimation because of various 
+		// The calculated "NumberOfFrag" is a rough estimation because of various
 		// encryption/encapsulation overhead not taken into consideration. This number is just
 		// used to make sure enough free TXD are available before fragmentation takes place.
-		// In case the actual required number of fragments of an NDIS packet 
+		// In case the actual required number of fragments of an NDIS packet
 		// excceeds "NumberOfFrag"caculated here and not enough free TXD available, the
-		// last fragment (i.e. last MPDU) will be dropped in RTMPHardTransmit() due to out of 
-		// resource, and the NDIS packet will be indicated NDIS_STATUS_FAILURE. This should 
+		// last fragment (i.e. last MPDU) will be dropped in RTMPHardTransmit() due to out of
+		// resource, and the NDIS packet will be indicated NDIS_STATUS_FAILURE. This should
 		// rarely happen and the penalty is just like a TX RETRY fail. Affordable.
 
 		AllowFragSize = (pAd->CommonCfg.FragmentThreshold) - LENGTH_802_11 - LENGTH_CRC;
@@ -1174,17 +1174,17 @@ NDIS_STATUS STASendPacket(
 	RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags);
 
 #ifdef DOT11_N_SUPPORT
-    if ((pAd->CommonCfg.BACapability.field.AutoBA == TRUE)&& 
+    if ((pAd->CommonCfg.BACapability.field.AutoBA == TRUE)&&
         (pAd->StaActive.SupportedPhyInfo.bHtEnable == TRUE))
 	{
-		if (((pEntry->TXBAbitmap & (1<<UserPriority)) == 0) && 
+		if (((pEntry->TXBAbitmap & (1<<UserPriority)) == 0) &&
             ((pEntry->BADeclineBitmap & (1<<UserPriority)) == 0) &&
             (pEntry->PortSecured == WPA_802_1X_PORT_SECURED)
-			 // For IOT compatibility, if  
-			 // 1. It is Ralink chip or 			  
-			 // 2. It is OPEN or AES mode, 
-			 // then BA session can be bulit.			 
-			 && ((pEntry->ValidAsCLI && pAd->MlmeAux.APRalinkIe != 0x0) || 
+			 // For IOT compatibility, if
+			 // 1. It is Ralink chip or
+			 // 2. It is OPEN or AES mode,
+			 // then BA session can be bulit.
+			 && ((pEntry->ValidAsCLI && pAd->MlmeAux.APRalinkIe != 0x0) ||
 			 	 (pEntry->WepStatus == Ndis802_11WEPDisabled || pEntry->WepStatus == Ndis802_11Encryption3Enabled))
 			)
 		{
@@ -1204,20 +1204,20 @@ NDIS_STATUS STASendPacket(
 	Routine Description:
 		This subroutine will scan through releative ring descriptor to find
 		out avaliable free ring descriptor and compare with request size.
-		
+
 	Arguments:
 		pAd Pointer to our adapter
 		QueIdx		Selected TX Ring
-		
+
 	Return Value:
 		NDIS_STATUS_FAILURE 	Not enough free descriptor
 		NDIS_STATUS_SUCCESS 	Enough free descriptor
 
 	IRQL = PASSIVE_LEVEL
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 #ifdef RT2860
@@ -1229,7 +1229,7 @@ NDIS_STATUS RTMPFreeTXDRequest(
 {
 	ULONG		FreeNumber = 0;
 	NDIS_STATUS 	Status = NDIS_STATUS_FAILURE;
-			
+
 	switch (QueIdx)
 	{
 		case QID_AC_BK:
@@ -1272,7 +1272,7 @@ VOID RTMPSendDisassociationFrame(
 	IN	PRTMP_ADAPTER	pAd)
 {
 }
-	
+
 VOID	RTMPSendNullFrame(
 	IN	PRTMP_ADAPTER	pAd,
 	IN	UCHAR			TxRate,
@@ -1291,15 +1291,15 @@ VOID	RTMPSendNullFrame(
 #endif // RALINK_ATE //
 
     // WPA 802.1x secured port control
-    if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || 
+    if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
          (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
-         (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) || 
+         (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
          (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
 #ifdef WPA_SUPPLICANT_SUPPORT
-			  || (pAd->StaCfg.IEEE8021X == TRUE)		
-#endif 		
+			  || (pAd->StaCfg.IEEE8021X == TRUE)
+#endif
         ) &&
-       (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)) 
+       (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
 	{
 		return;
 	}
@@ -1308,7 +1308,7 @@ VOID	RTMPSendNullFrame(
 	Length = sizeof(HEADER_802_11);
 
 	pHeader_802_11 = (PHEADER_802_11) NullFrame;
-	
+
 	pHeader_802_11->FC.Type = BTYPE_DATA;
 	pHeader_802_11->FC.SubType = SUBTYPE_NULL_FUNC;
 	pHeader_802_11->FC.ToDs = 1;
@@ -1333,13 +1333,13 @@ VOID	RTMPSendNullFrame(
 	if (bQosNull)
 	{
 		pHeader_802_11->FC.SubType = SUBTYPE_QOS_NULL;
-		
+
 		// copy QOS control bytes
 		NullFrame[Length]	=  0;
 		NullFrame[Length+1] =  0;
 		Length += 2;// if pad with 2 bytes for alignment, APSD will fail
 	}
-	
+
 	HAL_KickOutNullFrameTx(pAd, 0, NullFrame, Length);
 
 }
@@ -1375,11 +1375,11 @@ VOID STAFindCipherAlgorithm(
 	NDIS_802_11_ENCRYPTION_STATUS	Cipher;				// To indicate cipher used for this packet
 	UCHAR							CipherAlg = CIPHER_NONE;		// cipher alogrithm
 	UCHAR							KeyIdx = 0xff;
-	PUCHAR							pSrcBufVA; 
+	PUCHAR							pSrcBufVA;
 	PCIPHER_KEY						pKey = NULL;
 
 	pSrcBufVA = GET_OS_PKT_DATAPTR(pTxBlk->pPacket);
-	
+
 	{
 	    // Select Cipher
 	    if ((*pSrcBufVA & 0x01) && (ADHOC_ON(pAd)))
@@ -1390,7 +1390,7 @@ VOID STAFindCipherAlgorithm(
 		if (RTMP_GET_PACKET_EAPOL(pTxBlk->pPacket))
 		{
 			ASSERT(pAd->SharedKey[BSS0][0].CipherAlg <= CIPHER_CKIP128);
-			
+
 			// 4-way handshaking frame must be clear
 			if (!(TX_BLK_TEST_FLAG(pTxBlk, fTX_bClearEAPFrame)) && (pAd->SharedKey[BSS0][0].CipherAlg) &&
 				(pAd->SharedKey[BSS0][0].KeyLen))
@@ -1401,7 +1401,7 @@ VOID STAFindCipherAlgorithm(
 		}
 		else if (Cipher == Ndis802_11Encryption1Enabled)
 		{
-#ifdef LEAP_SUPPORT		
+#ifdef LEAP_SUPPORT
 			if (pAd->StaCfg.CkipFlag & 0x10) // Cisco CKIP KP is on
 			{
 				if (LEAP_CCKM_ON(pAd))
@@ -1424,7 +1424,7 @@ VOID STAFindCipherAlgorithm(
 					KeyIdx = 0;
 			}
 			else	// standard WEP64 or WEP128
-#endif // LEAP_SUPPORT //		
+#endif // LEAP_SUPPORT //
 				KeyIdx = pAd->StaCfg.DefaultKeyId;
 		}
 		else if ((Cipher == Ndis802_11Encryption2Enabled) ||
@@ -1443,7 +1443,7 @@ VOID STAFindCipherAlgorithm(
 		else if ((Cipher == Ndis802_11EncryptionDisabled) || (pAd->SharedKey[BSS0][KeyIdx].KeyLen == 0))
 			CipherAlg = CIPHER_NONE;
 #ifdef WPA_SUPPLICANT_SUPPORT
-	    else if ( pAd->StaCfg.WpaSupplicantUP && 
+	    else if ( pAd->StaCfg.WpaSupplicantUP &&
 	             (Cipher == Ndis802_11Encryption1Enabled) &&
 	             (pAd->StaCfg.IEEE8021X == TRUE) &&
 	             (pAd->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
@@ -1456,7 +1456,7 @@ VOID STAFindCipherAlgorithm(
 			pKey = &pAd->SharedKey[BSS0][KeyIdx];
 		}
 	}
-	
+
 	pTxBlk->CipherAlg = CipherAlg;
 	pTxBlk->pKey = pKey;
 }
@@ -1473,9 +1473,9 @@ VOID STABuildCommon802_11Header(
 	INT	DlsEntryIndex = 0;
 #endif // QOS_DLS_SUPPORT //
 
-	// 
+	//
 	// MAKE A COMMON 802.11 HEADER
-	// 
+	//
 
 	// normal wlan header size : 24 octets
 	pTxBlk->MpduHeaderLen = sizeof(HEADER_802_11);
@@ -1504,12 +1504,12 @@ VOID STABuildCommon802_11Header(
     if (pTxBlk->pMacEntry)
 	{
 		if (TX_BLK_TEST_FLAG(pTxBlk, fTX_bForceNonQoS))
-		{			
+		{
 			pHeader_802_11->Sequence = pTxBlk->pMacEntry->NonQosDataSeq;
 			pTxBlk->pMacEntry->NonQosDataSeq = (pTxBlk->pMacEntry->NonQosDataSeq+1) & MAXSEQ;
 		}
 		else
-		{		
+		{
 #ifdef QOS_DLS_SUPPORT
 			if (bDLSFrame)
 			{
@@ -1521,13 +1521,13 @@ VOID STABuildCommon802_11Header(
 			{
     	    pHeader_802_11->Sequence = pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority];
     	    pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority] = (pTxBlk->pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ;
-    	}		
+    	}
 	}
 	}
 	else
 	{
 		pHeader_802_11->Sequence = pAd->Sequence;
-		pAd->Sequence = (pAd->Sequence+1) & MAXSEQ; // next sequence  
+		pAd->Sequence = (pAd->Sequence+1) & MAXSEQ; // next sequence
 	}
 
 	pHeader_802_11->Frag = 0;
@@ -1561,18 +1561,18 @@ VOID STABuildCommon802_11Header(
 			COPY_MAC_ADDR(pHeader_802_11->Addr3, pAd->CommonCfg.Bssid);
 			pHeader_802_11->FC.ToDs = 0;
 		}
-	}	
-	
+	}
+
 	if (pTxBlk->CipherAlg != CIPHER_NONE)
 		pHeader_802_11->FC.Wep = 1;
 
 	// -----------------------------------------------------------------
-	// STEP 2. MAKE A COMMON 802.11 HEADER SHARED BY ENTIRE FRAGMENT BURST. Fill sequence later. 
+	// STEP 2. MAKE A COMMON 802.11 HEADER SHARED BY ENTIRE FRAGMENT BURST. Fill sequence later.
 	// -----------------------------------------------------------------
 	if (pAd->CommonCfg.bAPSDForcePowerSave)
     	pHeader_802_11->FC.PwrMgmt = PWR_SAVE;
 	else
-    	pHeader_802_11->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);		
+    	pHeader_802_11->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
 }
 
 #ifdef DOT11_N_SUPPORT
@@ -1587,20 +1587,20 @@ VOID STABuildCache802_11Header(
 	pHeader80211 = (PHEADER_802_11)pHeader;
 	pMacEntry = pTxBlk->pMacEntry;
 
-	// 
+	//
 	// Update the cached 802.11 HEADER
-	// 
-	
+	//
+
 	// normal wlan header size : 24 octets
 	pTxBlk->MpduHeaderLen = sizeof(HEADER_802_11);
-	
+
 	// More Bit
 	pHeader80211->FC.MoreData = TX_BLK_TEST_FLAG(pTxBlk, fTX_bMoreData);
-	
+
 	// Sequence
 	pHeader80211->Sequence = pMacEntry->TxSeq[pTxBlk->UserPriority];
     pMacEntry->TxSeq[pTxBlk->UserPriority] = (pMacEntry->TxSeq[pTxBlk->UserPriority]+1) & MAXSEQ;
-	
+
 	{
 		// Check if the frame can be sent through DLS direct link interface
 		// If packet can be sent through DLS, then force aggregation disable. (Hard to determine peer STA's capability)
@@ -1632,12 +1632,12 @@ VOID STABuildCache802_11Header(
 	}
 
 	// -----------------------------------------------------------------
-	// STEP 2. MAKE A COMMON 802.11 HEADER SHARED BY ENTIRE FRAGMENT BURST. Fill sequence later. 
+	// STEP 2. MAKE A COMMON 802.11 HEADER SHARED BY ENTIRE FRAGMENT BURST. Fill sequence later.
 	// -----------------------------------------------------------------
 	if (pAd->CommonCfg.bAPSDForcePowerSave)
     	pHeader80211->FC.PwrMgmt = PWR_SAVE;
 	else
-    	pHeader80211->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);	
+    	pHeader80211->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
 }
 #endif // DOT11_N_SUPPORT //
 
@@ -1650,7 +1650,7 @@ static inline PUCHAR STA_Build_ARalink_Frame_Header(
 	PNDIS_PACKET	pNextPacket;
 	UINT32			nextBufLen;
 	PQUEUE_ENTRY	pQEntry;
-		
+
 	STAFindCipherAlgorithm(pAd, pTxBlk);
 	STABuildCommon802_11Header(pAd, pTxBlk);
 
@@ -1660,7 +1660,7 @@ static inline PUCHAR STA_Build_ARalink_Frame_Header(
 
 	// steal "order" bit to mark "aggregation"
 	pHeader_802_11->FC.Order = 1;
-	
+
 	// skip common header
 	pHeaderBufPtr += pTxBlk->MpduHeaderLen;
 
@@ -1668,7 +1668,7 @@ static inline PUCHAR STA_Build_ARalink_Frame_Header(
 	{
 		//
 		// build QOS Control bytes
-		// 
+		//
 		*pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
 
 		*(pHeaderBufPtr+1) = 0;
@@ -1680,23 +1680,23 @@ static inline PUCHAR STA_Build_ARalink_Frame_Header(
 	pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
 	pHeaderBufPtr = (PCHAR)ROUND_UP(pHeaderBufPtr, 4);
 	pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-	
-	// For RA Aggregation, 
+
+	// For RA Aggregation,
 	// put the 2nd MSDU length(extra 2-byte field) after QOS_CONTROL in little endian format
 	pQEntry = pTxBlk->TxPacketList.Head;
 	pNextPacket = QUEUE_ENTRY_TO_PKT(pQEntry);
 	nextBufLen = GET_OS_PKT_LEN(pNextPacket);
 	if (RTMP_GET_PACKET_VLAN(pNextPacket))
 		nextBufLen -= LENGTH_802_1Q;
-	
+
 	*pHeaderBufPtr = (UCHAR)nextBufLen & 0xff;
 	*(pHeaderBufPtr+1) = (UCHAR)(nextBufLen >> 8);
 
 	pHeaderBufPtr += 2;
 	pTxBlk->MpduHeaderLen += 2;
-	
+
 	return pHeaderBufPtr;
-	
+
 }
 
 #ifdef DOT11_N_SUPPORT
@@ -1707,7 +1707,7 @@ static inline PUCHAR STA_Build_AMSDU_Frame_Header(
 	PUCHAR			pHeaderBufPtr;//, pSaveBufPtr;
 	HEADER_802_11	*pHeader_802_11;
 
-	
+
 	STAFindCipherAlgorithm(pAd, pTxBlk);
 	STABuildCommon802_11Header(pAd, pTxBlk);
 
@@ -1719,12 +1719,12 @@ static inline PUCHAR STA_Build_AMSDU_Frame_Header(
 
 	//
 	// build QOS Control bytes
-	// 
+	//
 	*pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
 
 	//
 	// A-MSDU packet
-	// 
+	//
 	*pHeaderBufPtr |= 0x80;
 
 	*(pHeaderBufPtr+1) = 0;
@@ -1736,13 +1736,13 @@ static inline PUCHAR STA_Build_AMSDU_Frame_Header(
 	//
 	// padding at front of LLC header
 	// LLC header should locate at 4-octets aligment
-	// 
+	//
 	// @@@ MpduHeaderLen excluding padding @@@
-	// 
+	//
 	pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
 	pHeaderBufPtr = (PCHAR) ROUND_UP(pHeaderBufPtr, 4);
 	pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
-		
+
 	return pHeaderBufPtr;
 
 }
@@ -1758,7 +1758,7 @@ VOID STA_AMPDU_Frame_Tx(
 	MAC_TABLE_ENTRY	*pMacEntry;
 	BOOLEAN			bVLANPkt;
 	PQUEUE_ENTRY	pQEntry;
-	
+
 	ASSERT(pTxBlk);
 
 	while(pTxBlk->TxPacketList.Head)
@@ -1772,7 +1772,7 @@ VOID STA_AMPDU_Frame_Tx(
 		}
 
 		bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-		
+
 		pMacEntry = pTxBlk->pMacEntry;
 		if (pMacEntry->isCached)
 		{
@@ -1781,37 +1781,37 @@ VOID STA_AMPDU_Frame_Tx(
 			pHeaderBufPtr = (PUCHAR)(&pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE]);
 			STABuildCache802_11Header(pAd, pTxBlk, pHeaderBufPtr);
 		}
-		else 
+		else
 		{
 			STAFindCipherAlgorithm(pAd, pTxBlk);
 			STABuildCommon802_11Header(pAd, pTxBlk);
-			
+
 			pHeaderBufPtr = &pTxBlk->HeaderBuf[TXINFO_SIZE + TXWI_SIZE];
 		}
 
 
 		pHeader_802_11 = (HEADER_802_11 *) pHeaderBufPtr;
-		
+
 		// skip common header
 		pHeaderBufPtr += pTxBlk->MpduHeaderLen;
 
 		//
 		// build QOS Control bytes
-		// 
+		//
 		*pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
 		*(pHeaderBufPtr+1) = 0;
 		pHeaderBufPtr +=2;
 		pTxBlk->MpduHeaderLen += 2;
 
 		//
-		// build HTC+ 
+		// build HTC+
 		// HTC control filed following QoS field
-		// 
+		//
 		if ((pAd->CommonCfg.bRdg == TRUE) && CLIENT_STATUS_TEST_FLAG(pTxBlk->pMacEntry, fCLIENT_STATUS_RDG_CAPABLE))
 		{
 			if (pMacEntry->isCached == FALSE)
 			{
-				// mark HTC bit 
+				// mark HTC bit
 				pHeader_802_11->FC.Order = 1;
 
 				NdisZeroMemory(pHeaderBufPtr, 4);
@@ -1838,9 +1838,9 @@ VOID STA_AMPDU_Frame_Tx(
 		//
 		// padding at front of LLC header
 		// LLC header should locate at 4-octets aligment
-		// 
+		//
 		// @@@ MpduHeaderLen excluding padding @@@
-		// 
+		//
 		pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
 		pHeaderBufPtr = (PCHAR) ROUND_UP(pHeaderBufPtr, 4);
 		pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
@@ -1876,10 +1876,10 @@ VOID STA_AMPDU_Frame_Tx(
 			pMacEntry->isCached = TRUE;
 		}
 
-		// calculate Transmitted AMPDU count and ByteCount 	
+		// calculate Transmitted AMPDU count and ByteCount
 		{
 			pAd->RalinkCounters.TransmittedMPDUsInAMPDUCount.u.LowPart ++;
-			pAd->RalinkCounters.TransmittedOctetsInAMPDUCount.QuadPart += pTxBlk->SrcBufLen;		
+			pAd->RalinkCounters.TransmittedOctetsInAMPDUCount.QuadPart += pTxBlk->SrcBufLen;
 		}
 
 		//FreeNumber = GET_TXRING_FREENO(pAd, QueIdx);
@@ -1888,13 +1888,13 @@ VOID STA_AMPDU_Frame_Tx(
 
 		//
 		// Kick out Tx
-		// 
+		//
 		HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
 
 		pAd->RalinkCounters.KickTxCount++;
 		pAd->RalinkCounters.OneSecTxDoneCount++;
 	}
-	
+
 }
 
 
@@ -1912,10 +1912,10 @@ VOID STA_AMSDU_Frame_Tx(
 	BOOLEAN			bVLANPkt;
 	int 			frameNum = 0;
 	PQUEUE_ENTRY	pQEntry;
-		
+
 
 	ASSERT(pTxBlk);
-	
+
 	ASSERT((pTxBlk->TxPacketList.Number > 1));
 
 	while(pTxBlk->TxPacketList.Head)
@@ -1929,7 +1929,7 @@ VOID STA_AMSDU_Frame_Tx(
 		}
 
 		bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-		
+
 		// skip 802.3 header
 		pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
 		pTxBlk->SrcBufLen  -= LENGTH_802_3;
@@ -1940,7 +1940,7 @@ VOID STA_AMSDU_Frame_Tx(
 			pTxBlk->pSrcBufData	+= LENGTH_802_1Q;
 			pTxBlk->SrcBufLen	-= LENGTH_802_1Q;
 		}
-		
+
 		if (frameNum == 0)
 		{
 			pHeaderBufPtr = STA_Build_AMSDU_Frame_Header(pAd, pTxBlk);
@@ -1960,7 +1960,7 @@ VOID STA_AMSDU_Frame_Tx(
 		//
 		// A-MSDU subframe
 		//   DA(6)+SA(6)+Length(2) + LLC/SNAP Encap
-		// 
+		//
 		subFrameHeader = pHeaderBufPtr;
 		subFramePayloadLen = pTxBlk->SrcBufLen;
 
@@ -1973,7 +1973,7 @@ VOID STA_AMSDU_Frame_Tx(
 
 		//
 		// Insert LLC-SNAP encapsulation - 8 octets
-		// 
+		//
 		EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->pSrcBufData-2, pTxBlk->pExtraLlcSnapEncap);
 
 		subFramePayloadLen = pTxBlk->SrcBufLen;
@@ -2003,22 +2003,22 @@ VOID STA_AMSDU_Frame_Tx(
 		frameNum++;
 
 		pAd->RalinkCounters.KickTxCount++;
-		pAd->RalinkCounters.OneSecTxDoneCount++;		
-		
+		pAd->RalinkCounters.OneSecTxDoneCount++;
+
 		// calculate Transmitted AMSDU Count and ByteCount
 		{
 			pAd->RalinkCounters.TransmittedAMSDUCount.u.LowPart ++;
-			pAd->RalinkCounters.TransmittedOctetsInAMSDU.QuadPart += totalMPDUSize;			
+			pAd->RalinkCounters.TransmittedOctetsInAMSDU.QuadPart += totalMPDUSize;
 		}
-		
+
 	}
 
 	HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, FirstTx);
 	HAL_LastTxIdx(pAd, pTxBlk->QueIdx, LastTxIdx);
-	
+
 	//
 	// Kick out Tx
-	// 
+	//
 	HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
 }
 #endif // DOT11_N_SUPPORT //
@@ -2032,7 +2032,7 @@ VOID STA_Legacy_Frame_Tx(
 	USHORT			FreeNumber;
 	BOOLEAN			bVLANPkt;
 	PQUEUE_ENTRY	pQEntry;
-	
+
 	ASSERT(pTxBlk);
 
 
@@ -2048,7 +2048,7 @@ VOID STA_Legacy_Frame_Tx(
 	{
 		INC_COUNTER64(pAd->WlanCounters.MulticastTransmittedFrameCount);
 	}
-	
+
 	if (RTMP_GET_PACKET_RTS(pTxBlk->pPacket))
 		TX_BLK_SET_FLAG(pTxBlk, fTX_bRtsRequired);
 	else
@@ -2058,7 +2058,7 @@ VOID STA_Legacy_Frame_Tx(
 
 	if (pTxBlk->TxRate < pAd->CommonCfg.MinTxRate)
 		pTxBlk->TxRate = pAd->CommonCfg.MinTxRate;
-	
+
 	STAFindCipherAlgorithm(pAd, pTxBlk);
 	STABuildCommon802_11Header(pAd, pTxBlk);
 
@@ -2084,14 +2084,14 @@ VOID STA_Legacy_Frame_Tx(
 	{
 		//
 		// build QOS Control bytes
-		// 
+		//
 		*pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
 		*(pHeaderBufPtr+1) = 0;
 		pHeaderBufPtr +=2;
 		pTxBlk->MpduHeaderLen += 2;
 	}
 
-	// The remaining content of MPDU header should locate at 4-octets aligment	
+	// The remaining content of MPDU header should locate at 4-octets aligment
 	pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
 	pHeaderBufPtr = (PCHAR) ROUND_UP(pHeaderBufPtr, 4);
 	pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
@@ -2100,16 +2100,16 @@ VOID STA_Legacy_Frame_Tx(
 
 		//
 		// Insert LLC-SNAP encapsulation - 8 octets
-		// 
 		//
-   		// if original Ethernet frame contains no LLC/SNAP, 
-		// then an extra LLC/SNAP encap is required 
+		//
+   		// if original Ethernet frame contains no LLC/SNAP,
+		// then an extra LLC/SNAP encap is required
 		//
 		EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(pTxBlk->pSrcBufHeader, pTxBlk->pExtraLlcSnapEncap);
 		if (pTxBlk->pExtraLlcSnapEncap)
 		{
 			UCHAR vlan_size;
-	
+
 			NdisMoveMemory(pHeaderBufPtr, pTxBlk->pExtraLlcSnapEncap, 6);
 			pHeaderBufPtr += 6;
 			// skip vlan tag
@@ -2132,13 +2132,13 @@ VOID STA_Legacy_Frame_Tx(
 	//FreeNumber = GET_TXRING_FREENO(pAd, QueIdx);
 
 	HAL_WriteTxResource(pAd, pTxBlk, TRUE, &FreeNumber);
-	
+
 	pAd->RalinkCounters.KickTxCount++;
 	pAd->RalinkCounters.OneSecTxDoneCount++;
 
 	//
 	// Kick out Tx
-	// 
+	//
 	HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
 }
 
@@ -2157,7 +2157,7 @@ VOID STA_ARalink_Frame_Tx(
 
 
 	ASSERT(pTxBlk);
-	
+
 	ASSERT((pTxBlk->TxPacketList.Number== 2));
 
 
@@ -2174,7 +2174,7 @@ VOID STA_ARalink_Frame_Tx(
 		}
 
 		bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-		
+
 		// skip 802.3 header
 		pTxBlk->pSrcBufData = pTxBlk->pSrcBufHeader + LENGTH_802_3;
 		pTxBlk->SrcBufLen  -= LENGTH_802_3;
@@ -2185,20 +2185,20 @@ VOID STA_ARalink_Frame_Tx(
 			pTxBlk->pSrcBufData	+= LENGTH_802_1Q;
 			pTxBlk->SrcBufLen	-= LENGTH_802_1Q;
 		}
-		
+
 		if (frameNum == 0)
 		{	// For first frame, we need to create the 802.11 header + padding(optional) + RA-AGG-LEN + SNAP Header
-		
+
 			pHeaderBufPtr = STA_Build_ARalink_Frame_Header(pAd, pTxBlk);
-			
-			// It's ok write the TxWI here, because the TxWI->MPDUtotalByteCount 
+
+			// It's ok write the TxWI here, because the TxWI->MPDUtotalByteCount
 			//	will be updated after final frame was handled.
 			RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
 
 
 			//
 			// Insert LLC-SNAP encapsulation - 8 octets
-			// 
+			//
 			EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(pTxBlk->pSrcBufData-2, pTxBlk->pExtraLlcSnapEncap);
 
 			if (pTxBlk->pExtraLlcSnapEncap)
@@ -2213,10 +2213,10 @@ VOID STA_ARalink_Frame_Tx(
 		}
 		else
 		{	// For second aggregated frame, we need create the 802.3 header to headerBuf, because PCI will copy it to SDPtr0.
-		
+
 			pHeaderBufPtr = &pTxBlk->HeaderBuf[0];
 			pTxBlk->MpduHeaderLen = 0;
-			
+
 			// A-Ralink sub-sequent frame header is the same as 802.3 header.
 			//   DA(6)+SA(6)+FrameType(2)
 			NdisMoveMemory(pHeaderBufPtr, pTxBlk->pSrcBufHeader, 12);
@@ -2228,7 +2228,7 @@ VOID STA_ARalink_Frame_Tx(
 		}
 
 		totalMPDUSize += pTxBlk->MpduHeaderLen + pTxBlk->SrcBufLen;
-		
+
 		//FreeNumber = GET_TXRING_FREENO(pAd, QueIdx);
 		if (frameNum ==0)
 			FirstTx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
@@ -2236,11 +2236,11 @@ VOID STA_ARalink_Frame_Tx(
 			LastTxIdx = HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, &FreeNumber);
 
 		frameNum++;
-		
+
 		pAd->RalinkCounters.OneSecTxAggregationCount++;
 		pAd->RalinkCounters.KickTxCount++;
 		pAd->RalinkCounters.OneSecTxDoneCount++;
-		
+
 	}
 
 	HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, FirstTx);
@@ -2248,7 +2248,7 @@ VOID STA_ARalink_Frame_Tx(
 
 	//
 	// Kick out Tx
-	// 
+	//
 	HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
 
 }
@@ -2263,14 +2263,14 @@ VOID STA_Fragment_Frame_Tx(
 	USHORT			FreeNumber;
 	UCHAR 			fragNum = 0;
 	PACKET_INFO		PacketInfo;
-	USHORT			EncryptionOverhead = 0;	
+	USHORT			EncryptionOverhead = 0;
 	UINT32			FreeMpduSize, SrcRemainingBytes;
 	USHORT			AckDuration;
 	UINT 			NextMpduSize;
 	BOOLEAN			bVLANPkt;
 	PQUEUE_ENTRY	pQEntry;
-	
-	
+
+
 	ASSERT(pTxBlk);
 
 	pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
@@ -2283,10 +2283,10 @@ VOID STA_Fragment_Frame_Tx(
 
 	ASSERT(TX_BLK_TEST_FLAG(pTxBlk, fTX_bAllowFrag));
 	bVLANPkt = (RTMP_GET_PACKET_VLAN(pTxBlk->pPacket) ? TRUE : FALSE);
-	
+
 	STAFindCipherAlgorithm(pAd, pTxBlk);
 	STABuildCommon802_11Header(pAd, pTxBlk);
-	
+
 	if (pTxBlk->CipherAlg == CIPHER_TKIP)
 	{
 		pTxBlk->pPacket = duplicate_pkt_with_TKIP_MIC(pAd, pTxBlk->pPacket);
@@ -2318,7 +2318,7 @@ VOID STA_Fragment_Frame_Tx(
 	{
 		//
 		// build QOS Control bytes
-		// 
+		//
 		*pHeaderBufPtr = (pTxBlk->UserPriority & 0x0F);
 
 		*(pHeaderBufPtr+1) = 0;
@@ -2329,7 +2329,7 @@ VOID STA_Fragment_Frame_Tx(
 	//
 	// padding at front of LLC header
 	// LLC header should locate at 4-octets aligment
-	// 
+	//
 	pTxBlk->HdrPadLen = (ULONG)pHeaderBufPtr;
 	pHeaderBufPtr = (PCHAR) ROUND_UP(pHeaderBufPtr, 4);
 	pTxBlk->HdrPadLen = (ULONG)(pHeaderBufPtr - pTxBlk->HdrPadLen);
@@ -2338,11 +2338,11 @@ VOID STA_Fragment_Frame_Tx(
 
 	//
 	// Insert LLC-SNAP encapsulation - 8 octets
-	// 
 	//
-   	// if original Ethernet frame contains no LLC/SNAP, 
-	// then an extra LLC/SNAP encap is required 
-	// 
+	//
+   	// if original Ethernet frame contains no LLC/SNAP,
+	// then an extra LLC/SNAP encap is required
+	//
 	EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(pTxBlk->pSrcBufHeader, pTxBlk->pExtraLlcSnapEncap);
 	if (pTxBlk->pExtraLlcSnapEncap)
 	{
@@ -2358,7 +2358,7 @@ VOID STA_Fragment_Frame_Tx(
 		pTxBlk->MpduHeaderLen += LENGTH_802_1_H;
 	}
 
-	
+
 	// If TKIP is used and fragmentation is required. Driver has to
 	//	append TKIP MIC at tail of the scatter buffer
 	//	MAC ASIC will only perform IV/EIV/ICV insertion but no TKIP MIC
@@ -2378,7 +2378,7 @@ VOID STA_Fragment_Frame_Tx(
 	// calcuate the overhead bytes that encryption algorithm may add. This
 	// affects the calculate of "duration" field
 	//
-	if ((pTxBlk->CipherAlg == CIPHER_WEP64) || (pTxBlk->CipherAlg == CIPHER_WEP128)) 
+	if ((pTxBlk->CipherAlg == CIPHER_WEP64) || (pTxBlk->CipherAlg == CIPHER_WEP128))
 		EncryptionOverhead = 8; //WEP: IV[4] + ICV[4];
 	else if (pTxBlk->CipherAlg == CIPHER_TKIP_NO_MIC)
 		EncryptionOverhead = 12;//TKIP: IV[4] + EIV[4] + ICV[4], MIC will be added to TotalPacketLength
@@ -2394,7 +2394,7 @@ VOID STA_Fragment_Frame_Tx(
 
 	// Init the total payload length of this frame.
 	SrcRemainingBytes = pTxBlk->SrcBufLen;
-	
+
 	pTxBlk->TotalFragNum = 0xff;
 
 	do {
@@ -2405,12 +2405,12 @@ VOID STA_Fragment_Frame_Tx(
 
 		if (SrcRemainingBytes <= FreeMpduSize)
 		{	// this is the last or only fragment
-		
+
 			pTxBlk->SrcBufLen = SrcRemainingBytes;
-			
+
 			pHeader_802_11->FC.MoreFrag = 0;
 			pHeader_802_11->Duration = pAd->CommonCfg.Dsifs + AckDuration;
-			
+
 			// Indicate the lower layer that this's the last fragment.
 			pTxBlk->TotalFragNum = fragNum;
 		}
@@ -2418,7 +2418,7 @@ VOID STA_Fragment_Frame_Tx(
 		{	// more fragment is required
 
 			pTxBlk->SrcBufLen = FreeMpduSize;
-			
+
 			NextMpduSize = min(((UINT)SrcRemainingBytes - pTxBlk->SrcBufLen), ((UINT)pAd->CommonCfg.FragmentThreshold));
 			pHeader_802_11->FC.MoreFrag = 1;
 			pHeader_802_11->Duration = (3 * pAd->CommonCfg.Dsifs) + (2 * AckDuration) + RTMPCalcDuration(pAd, pTxBlk->TxRate, NextMpduSize + EncryptionOverhead);
@@ -2428,11 +2428,11 @@ VOID STA_Fragment_Frame_Tx(
 			pTxBlk->FrameGap = IFS_HTTXOP;
 		else
 			pTxBlk->FrameGap = IFS_SIFS;
-		
+
 		RTMPWriteTxWI_Data(pAd, (PTXWI_STRUC)(&pTxBlk->HeaderBuf[TXINFO_SIZE]), pTxBlk);
 
 		HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, &FreeNumber);
-		
+
 		pAd->RalinkCounters.KickTxCount++;
 		pAd->RalinkCounters.OneSecTxDoneCount++;
 
@@ -2441,18 +2441,18 @@ VOID STA_Fragment_Frame_Tx(
 		// space for 802.11 header.
 		if (fragNum == 0 && pTxBlk->pExtraLlcSnapEncap)
 			pTxBlk->MpduHeaderLen -= LENGTH_802_1_H;
-		
+
 		fragNum++;
 		SrcRemainingBytes -= pTxBlk->SrcBufLen;
 		pTxBlk->pSrcBufData += pTxBlk->SrcBufLen;
-		
+
 		pHeader_802_11->Frag++;	 // increase Frag #
-		
+
 	}while(SrcRemainingBytes > 0);
 
 	//
 	// Kick out Tx
-	// 
+	//
 	HAL_KickOutTx(pAd, pTxBlk, pTxBlk->QueIdx);
 }
 
@@ -2469,35 +2469,35 @@ VOID STA_Fragment_Frame_Tx(
 	========================================================================
 
 	Routine Description:
-		Copy frame from waiting queue into relative ring buffer and set 
+		Copy frame from waiting queue into relative ring buffer and set
 	appropriate ASIC register to kick hardware encryption before really
 	sent out to air.
-		
+
 	Arguments:
 		pAd 	Pointer to our adapter
 		PNDIS_PACKET	Pointer to outgoing Ndis frame
 		NumberOfFrag	Number of fragment required
-		
+
 	Return Value:
 		None
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 NDIS_STATUS STAHardTransmit(
 	IN PRTMP_ADAPTER	pAd,
 	IN TX_BLK 			*pTxBlk,
 	IN	UCHAR			QueIdx)
-{	
+{
 	NDIS_PACKET		*pPacket;
 	PQUEUE_ENTRY	pQEntry;
-	
+
 	// ---------------------------------------------
 	// STEP 0. DO SANITY CHECK AND SOME EARLY PREPARATION.
-	// ---------------------------------------------	
+	// ---------------------------------------------
 	//
 	ASSERT(pTxBlk->TxPacketList.Number);
 	if (pTxBlk->TxPacketList.Head == NULL)
@@ -2519,7 +2519,7 @@ NDIS_STATUS STAHardTransmit(
 
 	// ------------------------------------------------------------------
 	// STEP 1. WAKE UP PHY
-	//		outgoing frame always wakeup PHY to prevent frame lost and 
+	//		outgoing frame always wakeup PHY to prevent frame lost and
 	//		turn off PSM bit to improve performance
 	// ------------------------------------------------------------------
 	// not to change PSM bit, just send this frame out?
@@ -2528,7 +2528,7 @@ NDIS_STATUS STAHardTransmit(
 	    DBGPRINT_RAW(RT_DEBUG_TRACE, ("AsicForceWakeup At HardTx\n"));
 		AsicForceWakeup(pAd, TRUE);
 	}
-	
+
 	// It should not change PSM bit, when APSD turn on.
 	if ((!(pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable) && (pAd->CommonCfg.bAPSDForcePowerSave == FALSE))
 		|| (RTMP_GET_PACKET_EAPOL(pTxBlk->pPacket))
@@ -2566,7 +2566,7 @@ NDIS_STATUS STAHardTransmit(
 				// It should not happened!
 				DBGPRINT(RT_DEBUG_ERROR, ("Send a pacekt was not classified!! It should not happen!\n"));
 				while(pTxBlk->TxPacketList.Number)
-				{	
+				{
 					pQEntry = RemoveHeadQueue(&pTxBlk->TxPacketList);
 					pPacket = QUEUE_ENTRY_TO_PACKET(pQEntry);
 					if (pPacket)
@@ -2577,15 +2577,15 @@ NDIS_STATUS STAHardTransmit(
 	}
 
 	return (NDIS_STATUS_SUCCESS);
-	
+
 }
 
 ULONG  HashBytesPolynomial(UCHAR *value, unsigned int len)
 {
    unsigned char *word = value;
-   unsigned int ret = 0; 
-   unsigned int i;	
-   
+   unsigned int ret = 0;
+   unsigned int i;
+
    for(i=0; i < len; i++)
    {
 	  int mod = i % 32;
diff --git a/sta/sanity.c b/sta/sanity.c
index 2b32676..2398724 100644
--- a/sta/sanity.c
+++ b/sta/sanity.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -34,7 +34,7 @@
 	--------	----------		----------------------------------------------
 	John Chang  2004-09-01      add WMM support
 */
-#include "rt_config.h"
+#include "../rt_config.h"
 
 extern UCHAR	CISCO_OUI[];
 
@@ -46,7 +46,7 @@ extern UCHAR	Ccx2QosInfo[];
 extern UCHAR	RALINK_OUI[];
 extern UCHAR	BROADCOM_OUI[];
 
-/* 
+/*
     ==========================================================================
     Description:
         MLME message sanity check
@@ -55,16 +55,16 @@ extern UCHAR	BROADCOM_OUI[];
     ==========================================================================
  */
 BOOLEAN MlmeStartReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
-    OUT CHAR Ssid[], 
-    OUT UCHAR *pSsidLen) 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
+    OUT CHAR Ssid[],
+    OUT UCHAR *pSsidLen)
 {
     MLME_START_REQ_STRUCT *Info;
 
     Info = (MLME_START_REQ_STRUCT *)(Msg);
-    
+
     if (Info->SsidLen > MAX_LEN_OF_SSID)
     {
         DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqSanity fail - wrong SSID length\n"));
@@ -77,49 +77,49 @@ BOOLEAN MlmeStartReqSanity(
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         MLME message sanity check
     Return:
         TRUE if all parameters are OK, FALSE otherwise
-        
+
     IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 BOOLEAN PeerAssocRspSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *pMsg, 
-    IN ULONG MsgLen, 
-    OUT PUCHAR pAddr2, 
-    OUT USHORT *pCapabilityInfo, 
-    OUT USHORT *pStatus, 
-    OUT USHORT *pAid, 
-    OUT UCHAR SupRate[], 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *pMsg,
+    IN ULONG MsgLen,
+    OUT PUCHAR pAddr2,
+    OUT USHORT *pCapabilityInfo,
+    OUT USHORT *pStatus,
+    OUT USHORT *pAid,
+    OUT UCHAR SupRate[],
     OUT UCHAR *pSupRateLen,
-    OUT UCHAR ExtRate[], 
+    OUT UCHAR ExtRate[],
     OUT UCHAR *pExtRateLen,
     OUT HT_CAPABILITY_IE		*pHtCapability,
-    OUT ADD_HT_INFO_IE		*pAddHtInfo,	// AP might use this additional ht info IE 
+    OUT ADD_HT_INFO_IE		*pAddHtInfo,	// AP might use this additional ht info IE
     OUT UCHAR			*pHtCapabilityLen,
     OUT UCHAR			*pAddHtInfoLen,
     OUT UCHAR			*pNewExtChannelOffset,
     OUT PEDCA_PARM pEdcaParm,
-    OUT UCHAR *pCkipFlag) 
+    OUT UCHAR *pCkipFlag)
 {
     CHAR          IeType, *Ptr;
     PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
     PEID_STRUCT   pEid;
     ULONG         Length = 0;
-    
+
 	*pNewExtChannelOffset = 0xff;
 	*pHtCapabilityLen = 0;
 	*pAddHtInfoLen = 0;
     COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
     Ptr = pFrame->Octet;
     Length += LENGTH_802_11;
-        
+
     NdisMoveMemory(pCapabilityInfo, &pFrame->Octet[0], 2);
     Length += 2;
     NdisMoveMemory(pStatus,         &pFrame->Octet[2], 2);
@@ -127,16 +127,16 @@ BOOLEAN PeerAssocRspSanity(
     *pCkipFlag = 0;
     *pExtRateLen = 0;
     pEdcaParm->bValid = FALSE;
-    
-    if (*pStatus != MLME_SUCCESS) 
+
+    if (*pStatus != MLME_SUCCESS)
         return TRUE;
-    
+
     NdisMoveMemory(pAid, &pFrame->Octet[4], 2);
     Length += 2;
-        
+
     // Aid already swaped byte order in RTMPFrameEndianChange() for big endian platform
     *pAid = (*pAid) & 0x3fff; // AID is low 14-bit
-        
+
     // -- get supported rates from payload and advance the pointer
     IeType = pFrame->Octet[6];
     *pSupRateLen = pFrame->Octet[7];
@@ -144,8 +144,8 @@ BOOLEAN PeerAssocRspSanity(
     {
         DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspSanity fail - wrong SupportedRates IE\n"));
         return FALSE;
-    } 
-    else 
+    }
+    else
         NdisMoveMemory(SupRate, &pFrame->Octet[8], *pSupRateLen);
 
     Length = Length + 2 + *pSupRateLen;
@@ -153,7 +153,7 @@ BOOLEAN PeerAssocRspSanity(
     // many AP implement proprietary IEs in non-standard order, we'd better
     // tolerate mis-ordered IEs to get best compatibility
     pEid = (PEID_STRUCT) &pFrame->Octet[8 + (*pSupRateLen)];
-            
+
     // get variable fields from payload and advance the pointer
     while ((Length + 2 + pEid->Len) <= MsgLen)
     {
@@ -182,17 +182,17 @@ BOOLEAN PeerAssocRspSanity(
 			{
 				DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_HT_CAP. \n"));
 			}
-				
+
 		break;
 #ifdef DOT11_N_SUPPORT
             case IE_ADD_HT:
             case IE_ADD_HT2:
-			if (pEid->Len >= sizeof(ADD_HT_INFO_IE))				
+			if (pEid->Len >= sizeof(ADD_HT_INFO_IE))
 			{
 				// This IE allows extension, but we can ignore extra bytes beyond our knowledge , so only
 				// copy first sizeof(ADD_HT_INFO_IE)
 				NdisMoveMemory(pAddHtInfo, pEid->Octet, sizeof(ADD_HT_INFO_IE));
-				
+
 				*(USHORT *)(&pAddHtInfo->AddHtInfo2) = cpu2le16(*(USHORT *)(&pAddHtInfo->AddHtInfo2));
 				*(USHORT *)(&pAddHtInfo->AddHtInfo3) = cpu2le16(*(USHORT *)(&pAddHtInfo->AddHtInfo3));
 
@@ -202,7 +202,7 @@ BOOLEAN PeerAssocRspSanity(
 			{
 				DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_ADD_HT. \n"));
 			}
-				
+
 		break;
             case IE_SECONDARY_CH_OFFSET:
 			if (pEid->Len == 1)
@@ -213,17 +213,17 @@ BOOLEAN PeerAssocRspSanity(
 			{
 				DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
 			}
-#endif // DOT11_N_SUPPORT //				
+#endif // DOT11_N_SUPPORT //
 		break;
             case IE_AIRONET_CKIP:
                 // 0. Check Aironet IE length, it must be larger or equal to 28
                 //    Cisco's AP VxWork version(will not be supported) used this IE length as 28
-                //    Cisco's AP IOS version used this IE length as 30 
+                //    Cisco's AP IOS version used this IE length as 30
                 if (pEid->Len < (CKIP_NEGOTIATION_LENGTH - 2))
                 break;
 
                 // 1. Copy CKIP flag byte to buffer for process
-                *pCkipFlag = *(pEid->Octet + 8);				
+                *pCkipFlag = *(pEid->Octet + 8);
                 break;
 
             case IE_AIRONET_IPADDRESS:
@@ -243,7 +243,7 @@ BOOLEAN PeerAssocRspSanity(
                 {
                     PUCHAR ptr;
                     int i;
-        
+
                     // parsing EDCA parameters
                     pEdcaParm->bValid          = TRUE;
                     pEdcaParm->bQAck           = FALSE; // pEid->Octet[0] & 0x10;
@@ -285,9 +285,9 @@ BOOLEAN PeerAssocRspSanity(
                 DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspSanity - ignore unrecognized EID = %d\n", pEid->Eid));
                 break;
         }
-                   
-        Length = Length + 2 + pEid->Len; 
-        pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);        
+
+        Length = Length + 2 + pEid->Len;
+        pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
     }
 
     // Force CCX2 enable to TRUE for those AP didn't replay CCX v2 IE, we still force it to be on
@@ -297,24 +297,24 @@ BOOLEAN PeerAssocRspSanity(
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         MLME message sanity check
     Return:
         TRUE if all parameters are OK, FALSE otherwise
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 BOOLEAN PeerProbeReqSanity(
-    IN PRTMP_ADAPTER pAd, 
-    IN VOID *Msg, 
-    IN ULONG MsgLen, 
+    IN PRTMP_ADAPTER pAd,
+    IN VOID *Msg,
+    IN ULONG MsgLen,
     OUT PUCHAR pAddr2,
-    OUT CHAR Ssid[], 
-    OUT UCHAR *pSsidLen) 
+    OUT CHAR Ssid[],
+    OUT UCHAR *pSsidLen)
 {
     UCHAR         Idx;
     UCHAR	      RateLen;
@@ -323,12 +323,12 @@ BOOLEAN PeerProbeReqSanity(
 
     COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
 
-    if ((pFrame->Octet[0] != IE_SSID) || (pFrame->Octet[1] > MAX_LEN_OF_SSID)) 
+    if ((pFrame->Octet[0] != IE_SSID) || (pFrame->Octet[1] > MAX_LEN_OF_SSID))
     {
         DBGPRINT(RT_DEBUG_TRACE, ("PeerProbeReqSanity fail - wrong SSID IE(Type=%d,Len=%d)\n",pFrame->Octet[0],pFrame->Octet[1]));
         return FALSE;
-    } 
-    
+    }
+
     *pSsidLen = pFrame->Octet[1];
     NdisMoveMemory(Ssid, &pFrame->Octet[2], *pSsidLen);
 
@@ -337,7 +337,7 @@ BOOLEAN PeerProbeReqSanity(
     // -- get supported rates from payload and advance the pointer
     IeType = pFrame->Octet[Idx];
     RateLen = pFrame->Octet[Idx + 1];
-    if (IeType != IE_SUPP_RATES) 
+    if (IeType != IE_SUPP_RATES)
     {
         DBGPRINT(RT_DEBUG_TRACE, ("PeerProbeReqSanity fail - wrong SupportRates IE(Type=%d,Len=%d)\n",pFrame->Octet[Idx],pFrame->Octet[Idx+1]));
         return FALSE;
@@ -351,52 +351,52 @@ BOOLEAN PeerProbeReqSanity(
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
-        
+
 	IRQL = DISPATCH_LEVEL
 
     ==========================================================================
  */
 BOOLEAN GetTimBit(
-    IN CHAR *Ptr, 
-    IN USHORT Aid, 
-    OUT UCHAR *TimLen, 
-    OUT UCHAR *BcastFlag, 
-    OUT UCHAR *DtimCount, 
+    IN CHAR *Ptr,
+    IN USHORT Aid,
+    OUT UCHAR *TimLen,
+    OUT UCHAR *BcastFlag,
+    OUT UCHAR *DtimCount,
     OUT UCHAR *DtimPeriod,
-    OUT UCHAR *MessageToMe) 
+    OUT UCHAR *MessageToMe)
 {
     UCHAR          BitCntl, N1, N2, MyByte, MyBit;
     CHAR          *IdxPtr;
 
     IdxPtr = Ptr;
-    
+
     IdxPtr ++;
     *TimLen = *IdxPtr;
-    
+
     // get DTIM Count from TIM element
     IdxPtr ++;
     *DtimCount = *IdxPtr;
-    
+
     // get DTIM Period from TIM element
     IdxPtr++;
     *DtimPeriod = *IdxPtr;
-        
+
     // get Bitmap Control from TIM element
     IdxPtr++;
     BitCntl = *IdxPtr;
 
-    if ((*DtimCount == 0) && (BitCntl & 0x01)) 
+    if ((*DtimCount == 0) && (BitCntl & 0x01))
         *BcastFlag = TRUE;
-    else 
+    else
         *BcastFlag = FALSE;
-    
+
     // Parse Partial Virtual Bitmap from TIM element
     N1 = BitCntl & 0xfe;    // N1 is the first bitmap byte#
     N2 = *TimLen - 4 + N1;  // N2 is the last bitmap byte#
-    
+
     if ((Aid < (N1 << 3)) || (Aid >= ((N2 + 1) << 3)))
         *MessageToMe = FALSE;
     else
@@ -408,10 +408,10 @@ BOOLEAN GetTimBit(
 
         //if (*IdxPtr)
         //    DBGPRINT(RT_DEBUG_WARN, ("TIM bitmap = 0x%02x\n", *IdxPtr));
-            
+
         if (*IdxPtr & (0x01 << MyBit))
             *MessageToMe = TRUE;
-        else 
+        else
             *MessageToMe = FALSE;
     }
 
diff --git a/sta/sync.c b/sta/sync.c
index 040307d..a94b4b7 100644
--- a/sta/sync.c
+++ b/sta/sync.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -35,7 +35,7 @@
 	John Chang	2004-09-01      modified for rt2561/2661
 	Jan Lee		2006-08-01      modified for rt2860 for 802.11n
 */
-#include "rt_config.h"
+#include "../rt_config.h"
 
 #define AC0_DEF_TXOP		0
 #define AC1_DEF_TXOP		0
@@ -75,7 +75,7 @@ VOID	AdhocTurnOnQos(
 /*
 	==========================================================================
 	Description:
-		The sync state machine, 
+		The sync state machine,
 	Parameters:
 		Sm - pointer to the state machine
 	Note:
@@ -84,9 +84,9 @@ VOID	AdhocTurnOnQos(
 	==========================================================================
  */
 VOID SyncStateMachineInit(
-	IN PRTMP_ADAPTER pAd, 
-	IN STATE_MACHINE *Sm, 
-	OUT STATE_MACHINE_FUNC Trans[]) 
+	IN PRTMP_ADAPTER pAd,
+	IN STATE_MACHINE *Sm,
+	OUT STATE_MACHINE_FUNC Trans[])
 {
 	StateMachineInit(Sm, Trans, MAX_SYNC_STATE, MAX_SYNC_MSG, (STATE_MACHINE_FUNC)Drop, SYNC_IDLE, SYNC_MACHINE_BASE);
 
@@ -95,7 +95,7 @@ VOID SyncStateMachineInit(
 	StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)MlmeJoinReqAction);
 	StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)MlmeStartReqAction);
 	StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeacon);
-	StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_PROBE_REQ, (STATE_MACHINE_FUNC)PeerProbeReqAction); 
+	StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_PROBE_REQ, (STATE_MACHINE_FUNC)PeerProbeReqAction);
 
 	//column 2
 	StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenScan);
@@ -117,7 +117,7 @@ VOID SyncStateMachineInit(
 	RTMPInitTimer(pAd, &pAd->MlmeAux.ScanTimer, GET_TIMER_FUNCTION(ScanTimeout), pAd, FALSE);
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 		Beacon timeout handler, executed in timer thread
@@ -127,15 +127,15 @@ VOID SyncStateMachineInit(
 	==========================================================================
  */
 VOID BeaconTimeout(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
-	IN PVOID SystemSpecific3) 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
+	IN PVOID SystemSpecific3)
 {
 	RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
 
 	DBGPRINT(RT_DEBUG_TRACE,("SYNC - BeaconTimeout\n"));
-	
+
 	// Do nothing if the driver is starting halt state.
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
@@ -160,7 +160,7 @@ VOID BeaconTimeout(
 	RT28XX_MLME_HANDLER(pAd);
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 		Scan timeout handler, executed in timer thread
@@ -170,19 +170,19 @@ VOID BeaconTimeout(
 	==========================================================================
  */
 VOID ScanTimeout(
-	IN PVOID SystemSpecific1, 
-	IN PVOID FunctionContext, 
-	IN PVOID SystemSpecific2, 
-	IN PVOID SystemSpecific3) 
+	IN PVOID SystemSpecific1,
+	IN PVOID FunctionContext,
+	IN PVOID SystemSpecific2,
+	IN PVOID SystemSpecific3)
 {
 	RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
-	
+
 
 	// Do nothing if the driver is starting halt state.
 	// This might happen when timer already been fired before cancel timer with mlmehalt
 	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
 		return;
-	
+
 	if (MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_SCAN_TIMEOUT, 0, NULL))
 	{
 		RT28XX_MLME_HANDLER(pAd);
@@ -193,28 +193,28 @@ VOID ScanTimeout(
 		pAd->MlmeAux.Channel = 0;
 		ScanNextChannel(pAd);
 		if (pAd->CommonCfg.bWirelessEvent)
-		{				
-			RTMPSendWirelessEvent(pAd, IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); 
+		{
+			RTMPSendWirelessEvent(pAd, IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
 		}
 	}
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 		MLME SCAN req state machine procedure
 	==========================================================================
  */
 VOID MlmeScanReqAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR          Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType, BBPValue = 0;
 	BOOLEAN        TimerCancelled;
 	ULONG		   Now;
 	USHORT         Status;
 	PHEADER_802_11 pHdr80211;
-	PUCHAR         pOutBuffer = NULL;	
+	PUCHAR         pOutBuffer = NULL;
 	NDIS_STATUS    NStatus;
 
 	// Check the total scan tries for one single OID command
@@ -227,9 +227,9 @@ VOID MlmeScanReqAction(
 
 	// Increase the scan retry counters.
 	pAd->StaCfg.ScanCnt++;
-	
+
 #ifdef RT2860
-    if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) && 
+    if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) &&
         (IDLE_ON(pAd)) &&
 		(pAd->StaCfg.bRadio == TRUE) &&
 		(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
@@ -239,13 +239,13 @@ VOID MlmeScanReqAction(
 #endif // RT2860 //
 
 	// first check the parameter sanity
-	if (MlmeScanReqSanity(pAd, 
-						  Elem->Msg, 
-						  Elem->MsgLen, 
-						  &BssType, 
-						  Ssid, 
-						  &SsidLen, 
-						  &ScanType)) 
+	if (MlmeScanReqSanity(pAd,
+						  Elem->Msg,
+						  Elem->MsgLen,
+						  &BssType,
+						  Ssid,
+						  &SsidLen,
+						  &ScanType))
 	{
 
 		// Check for channel load and noise hist request
@@ -259,12 +259,12 @@ VOID MlmeScanReqAction(
 		{
 			// Suspend MSDU transmission here
 			RTMPSuspendMsduTransmission(pAd);
-		}	
-		
+		}
+
 		//
-		// To prevent data lost.	
+		// To prevent data lost.
 		// Send an NULL data with turned PSM bit on to current associated AP before SCAN progress.
-		// And should send an NULL data with turned PSM bit off to AP, when scan progress done 
+		// And should send an NULL data with turned PSM bit off to AP, when scan progress done
 		//
 		if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && (INFRA_ON(pAd)))
 		{
@@ -284,7 +284,7 @@ VOID MlmeScanReqAction(
 				RTMPusecDelay(5000);
 			}
 		}
-		
+
 		NdisGetSystemUpTime(&Now);
 		pAd->StaCfg.LastScanTime = Now;
 		// reset all the timers
@@ -305,15 +305,15 @@ VOID MlmeScanReqAction(
 		if ((ScanType == SCAN_CISCO_PASSIVE) || (ScanType == SCAN_CISCO_ACTIVE) ||
 			(ScanType == SCAN_CISCO_CHANNEL_LOAD) || (ScanType == SCAN_CISCO_NOISE))
 			pAd->MlmeAux.Channel = pAd->StaCfg.CCXScanChannel;
-		
-		// Let BBP register at 20MHz to do scan		
+
+		// Let BBP register at 20MHz to do scan
 		RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
 		BBPValue &= (~0x18);
 		RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
 		DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BBP R4 to 20MHz.l\n"));
 		ScanNextChannel(pAd);
-	} 
-	else 
+	}
+	else
 	{
 		DBGPRINT_ERR(("SYNC - MlmeScanReqAction() sanity check fail\n"));
 		pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
@@ -322,35 +322,35 @@ VOID MlmeScanReqAction(
 	}
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 		MLME JOIN req state machine procedure
 	==========================================================================
  */
 VOID MlmeJoinReqAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR        BBPValue = 0;
 	BSS_ENTRY    *pBss;
 	BOOLEAN       TimerCancelled;
-	HEADER_802_11 Hdr80211;	
+	HEADER_802_11 Hdr80211;
 	NDIS_STATUS   NStatus;
-	ULONG         FrameLen = 0;	
+	ULONG         FrameLen = 0;
 	PUCHAR        pOutBuffer = NULL;
 	PUCHAR        pSupRate = NULL;
 	UCHAR         SupRateLen;
 	PUCHAR        pExtRate = NULL;
-	UCHAR         ExtRateLen;	
+	UCHAR         ExtRateLen;
 	UCHAR         ASupRate[] = {0x8C, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6C};
-	UCHAR         ASupRateLen = sizeof(ASupRate)/sizeof(UCHAR);	
+	UCHAR         ASupRateLen = sizeof(ASupRate)/sizeof(UCHAR);
 	MLME_JOIN_REQ_STRUCT *pInfo = (MLME_JOIN_REQ_STRUCT *)(Elem->Msg);
 
 	DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeJoinReqAction(BSS #%ld)\n", pInfo->BssIdx));
 
 #ifdef RT2860
-    if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) && 
+    if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)) &&
         (IDLE_ON(pAd)) &&
 		(pAd->StaCfg.bRadio == TRUE) &&
 		(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
@@ -367,18 +367,18 @@ VOID MlmeJoinReqAction(
 
 	// record the desired SSID & BSSID we're waiting for
 	COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pBss->Bssid);
-	
+
 	// If AP's SSID is not hidden, it is OK for updating ssid to MlmeAux again.
 	if (pBss->Hidden == 0)
 	{
-		NdisMoveMemory(pAd->MlmeAux.Ssid, pBss->Ssid, pBss->SsidLen);	
+		NdisMoveMemory(pAd->MlmeAux.Ssid, pBss->Ssid, pBss->SsidLen);
 		pAd->MlmeAux.SsidLen = pBss->SsidLen;
 	}
-	
+
 	pAd->MlmeAux.BssType = pBss->BssType;
 	pAd->MlmeAux.Channel = pBss->Channel;
 	pAd->MlmeAux.CentralChannel = pBss->CentralChannel;
-	
+
 #ifdef EXT_BUILD_CHANNEL_LIST
 	// Country IE of the AP will be evaluated and will be used.
 	if ((pAd->StaCfg.IEEE80211dClientMode != Rt802_11_D_None) &&
@@ -394,8 +394,8 @@ VOID MlmeJoinReqAction(
 		BuildChannelListEx(pAd);
 	}
 #endif // EXT_BUILD_CHANNEL_LIST //
-	
-	// Let BBP register at 20MHz to do scan		
+
+	// Let BBP register at 20MHz to do scan
 	RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
 	BBPValue &= (~0x18);
 	RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
@@ -408,10 +408,10 @@ VOID MlmeJoinReqAction(
 
     do
 	{
-		if (((pAd->CommonCfg.bIEEE80211H == 1) && 
-            (pAd->MlmeAux.Channel > 14) && 
+		if (((pAd->CommonCfg.bIEEE80211H == 1) &&
+            (pAd->MlmeAux.Channel > 14) &&
              RadarChannelCheck(pAd, pAd->MlmeAux.Channel))
-#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier             
+#ifdef CARRIER_DETECTION_SUPPORT // Roger sync Carrier
              || (pAd->CommonCfg.CarrierDetect.Enable == TRUE)
 #endif // CARRIER_DETECTION_SUPPORT //
             )
@@ -422,7 +422,7 @@ VOID MlmeJoinReqAction(
 			if (pBss->Hidden == 0)
 				break;
 		}
-                
+
 		//
 		// send probe request
 		//
@@ -467,34 +467,34 @@ VOID MlmeJoinReqAction(
 				MakeOutgoingFrame(pOutBuffer + FrameLen,            &Tmp,
 								  1,                                &ExtRateIe,
 								  1,                                &ExtRateLen,
-								  ExtRateLen,                       pExtRate, 
+								  ExtRateLen,                       pExtRate,
 								  END_OF_ARGS);
 				FrameLen += Tmp;
 			}
-			
+
 
 			MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
 			MlmeFreeMemory(pAd, pOutBuffer);
 		}
     } while (FALSE);
 
-	DBGPRINT(RT_DEBUG_TRACE, ("SYNC - Switch to ch %d, Wait BEACON from %02x:%02x:%02x:%02x:%02x:%02x\n", 
+	DBGPRINT(RT_DEBUG_TRACE, ("SYNC - Switch to ch %d, Wait BEACON from %02x:%02x:%02x:%02x:%02x:%02x\n",
 		pBss->Channel, pBss->Bssid[0], pBss->Bssid[1], pBss->Bssid[2], pBss->Bssid[3], pBss->Bssid[4], pBss->Bssid[5]));
 
 	pAd->Mlme.SyncMachine.CurrState = JOIN_WAIT_BEACON;
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 		MLME START Request state machine procedure, starting an IBSS
 	==========================================================================
  */
 VOID MlmeStartReqAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
-	UCHAR         Ssid[MAX_LEN_OF_SSID], SsidLen; 
+	UCHAR         Ssid[MAX_LEN_OF_SSID], SsidLen;
 	BOOLEAN       TimerCancelled;
 
 	// New for WPA security suites
@@ -509,8 +509,8 @@ VOID MlmeStartReqAction(
 	pVIE->Length = 0;
 	TimeStamp.u.LowPart  = 0;
 	TimeStamp.u.HighPart = 0;
-	
-	if (MlmeStartReqSanity(pAd, Elem->Msg, Elem->MsgLen, Ssid, &SsidLen)) 
+
+	if (MlmeStartReqSanity(pAd, Elem->Msg, Elem->MsgLen, Ssid, &SsidLen))
 	{
 		// reset all the timers
 		RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
@@ -521,15 +521,15 @@ VOID MlmeStartReqAction(
 		//
 		DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqAction - Start a new IBSS. All IBSS parameters are decided now.... \n"));
 		pAd->MlmeAux.BssType           = BSS_ADHOC;
-		NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen); 
+		NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
 		pAd->MlmeAux.SsidLen           = SsidLen;
 
 		// generate a radom number as BSSID
 		MacAddrRandomBssid(pAd, pAd->MlmeAux.Bssid);
 		DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqAction - generate a radom number as BSSID \n"));
 
-		Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) || 
-				  (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) || 
+		Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
+				  (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
 				  (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
 		pAd->MlmeAux.CapabilityInfo    = CAP_GENERATE(0,1,Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 1, 0);
 		pAd->MlmeAux.BeaconPeriod      = pAd->CommonCfg.BeaconPeriod;
@@ -573,8 +573,8 @@ VOID MlmeStartReqAction(
 		pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
 		Status = MLME_SUCCESS;
 		MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
-	} 
-	else 
+	}
+	else
 	{
 		DBGPRINT_ERR(("SYNC - MlmeStartReqAction() sanity check fail.\n"));
 		pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
@@ -583,15 +583,15 @@ VOID MlmeStartReqAction(
 	}
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 		peer sends beacon back when scanning
 	==========================================================================
  */
 VOID PeerBeaconAtScanAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR           Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
 	UCHAR           Ssid[MAX_LEN_OF_SSID], BssType, Channel, NewChannel,
@@ -613,11 +613,11 @@ VOID PeerBeaconAtScanAction(
 	UCHAR						VarIE[MAX_VIE_LEN];		// Total VIE length = MAX_VIE_LEN - -5
 	NDIS_802_11_VARIABLE_IEs	*pVIE = NULL;
 	HT_CAPABILITY_IE		HtCapability;
-	ADD_HT_INFO_IE		AddHtInfo;	// AP might use this additional ht info IE 
+	ADD_HT_INFO_IE		AddHtInfo;	// AP might use this additional ht info IE
 	UCHAR			HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
 	UCHAR			AddHtInfoLen;
 	UCHAR			NewExtChannelOffset = 0xff;
-	
+
 	pFrame = (PFRAME_802_11) Elem->Msg;
 	// Init Variable IE structure
 	pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
@@ -627,27 +627,27 @@ VOID PeerBeaconAtScanAction(
 	RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
 #endif // DOT11_N_SUPPORT //
 
-	if (PeerBeaconAndProbeRspSanity(pAd, 
-								Elem->Msg, 
-								Elem->MsgLen, 
+	if (PeerBeaconAndProbeRspSanity(pAd,
+								Elem->Msg,
+								Elem->MsgLen,
 								Elem->Channel,
-								Addr2, 
-								Bssid, 
-								Ssid, 
-								&SsidLen, 
-								&BssType, 
-								&BeaconPeriod, 
-								&Channel, 
+								Addr2,
+								Bssid,
+								Ssid,
+								&SsidLen,
+								&BssType,
+								&BeaconPeriod,
+								&Channel,
 								&NewChannel,
-								&TimeStamp, 
-								&CfParm, 
-								&AtimWin, 
-								&CapabilityInfo, 
+								&TimeStamp,
+								&CfParm,
+								&AtimWin,
+								&CapabilityInfo,
 								&Erp,
-								&DtimCount, 
-								&DtimPeriod, 
-								&BcastFlag, 
-								&MessageToMe, 
+								&DtimCount,
+								&DtimPeriod,
+								&BcastFlag,
+								&MessageToMe,
 								SupRate,
 								&SupRateLen,
 								ExtRate,
@@ -665,13 +665,13 @@ VOID PeerBeaconAtScanAction(
 								&AddHtInfo,
 								&NewExtChannelOffset,
 								&LenVIE,
-								pVIE)) 
+								pVIE))
 	{
 		ULONG Idx;
 		CHAR Rssi = 0;
 
 		Idx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
-		if (Idx != BSS_NOT_FOUND) 
+		if (Idx != BSS_NOT_FOUND)
 			Rssi = pAd->ScanTab.BssEntry[Idx].Rssi;
 
 		Rssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
@@ -683,9 +683,9 @@ VOID PeerBeaconAtScanAction(
 #endif // DOT11_N_SUPPORT //
 		if ((pAd->StaCfg.CCXReqType != MSRN_TYPE_UNUSED) && (Channel == pAd->StaCfg.CCXScanChannel))
 		{
-			Idx = BssTableSetEntry(pAd, &pAd->StaCfg.CCXBssTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod, 
+			Idx = BssTableSetEntry(pAd, &pAd->StaCfg.CCXBssTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
 						 &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen,ExtRate, ExtRateLen, &HtCapability,
-						 &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag, 
+						 &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag,
 						 &EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
 			if (Idx != BSS_NOT_FOUND)
 			{
@@ -700,7 +700,7 @@ VOID PeerBeaconAtScanAction(
 		{
 			Idx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
 						  &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,  &HtCapability,
-						 &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag, 
+						 &AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag,
 						 &EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
 #ifdef DOT11_N_SUPPORT
 #ifdef DOT11N_DRAFT3
@@ -723,19 +723,19 @@ VOID PeerBeaconAtScanAction(
 	// sanity check fail, ignored
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 		When waiting joining the (I)BSS, beacon received from external
 	==========================================================================
  */
 VOID PeerBeaconAtJoinAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR         Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
-	UCHAR         Ssid[MAX_LEN_OF_SSID], SsidLen, BssType, Channel, MessageToMe, 
-				  DtimCount, DtimPeriod, BcastFlag, NewChannel; 
+	UCHAR         Ssid[MAX_LEN_OF_SSID], SsidLen, BssType, Channel, MessageToMe,
+				  DtimCount, DtimPeriod, BcastFlag, NewChannel;
 	LARGE_INTEGER TimeStamp;
 	USHORT        BeaconPeriod, AtimWin, CapabilityInfo;
 	CF_PARM       Cf;
@@ -755,7 +755,7 @@ VOID PeerBeaconAtJoinAction(
 	ULONG           RalinkIe;
 	ULONG         Idx;
 	HT_CAPABILITY_IE		HtCapability;
-	ADD_HT_INFO_IE		AddHtInfo;	// AP might use this additional ht info IE 
+	ADD_HT_INFO_IE		AddHtInfo;	// AP might use this additional ht info IE
 	UCHAR				HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
 	UCHAR			AddHtInfoLen;
 	UCHAR			NewExtChannelOffset = 0xff;
@@ -768,29 +768,29 @@ VOID PeerBeaconAtJoinAction(
 	pVIE->Length = 0;
     RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
 	RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
-	
 
-	if (PeerBeaconAndProbeRspSanity(pAd, 
-								Elem->Msg, 
-								Elem->MsgLen, 
+
+	if (PeerBeaconAndProbeRspSanity(pAd,
+								Elem->Msg,
+								Elem->MsgLen,
 								Elem->Channel,
-								Addr2, 
-								Bssid, 
-								Ssid, 
-								&SsidLen, 
-								&BssType, 
-								&BeaconPeriod, 
-								&Channel, 
+								Addr2,
+								Bssid,
+								Ssid,
+								&SsidLen,
+								&BssType,
+								&BeaconPeriod,
+								&Channel,
 								&NewChannel,
-								&TimeStamp, 
-								&Cf, 
-								&AtimWin, 
-								&CapabilityInfo, 
+								&TimeStamp,
+								&Cf,
+								&AtimWin,
+								&CapabilityInfo,
 								&Erp,
-								&DtimCount, 
-								&DtimPeriod, 
-								&BcastFlag, 
-								&MessageToMe, 
+								&DtimCount,
+								&DtimPeriod,
+								&BcastFlag,
+								&MessageToMe,
 								SupRate,
 								&SupRateLen,
 								ExtRate,
@@ -808,7 +808,7 @@ VOID PeerBeaconAtJoinAction(
 								&AddHtInfo,
 								&NewExtChannelOffset,
 								&LenVIE,
-								pVIE)) 
+								pVIE))
 	{
 		// Disqualify 11b only adhoc when we are in 11g only adhoc mode
 		if ((BssType == BSS_ADHOC) && (pAd->CommonCfg.PhyMode == PHY_11G) && ((SupRateLen+ExtRateLen)< 12))
@@ -820,7 +820,7 @@ VOID PeerBeaconAtJoinAction(
 		//    Do we need to receover back all parameters belonging to previous BSS?
 		// A. Should be not. There's no back-door recover to previous AP. It still need
 		//    a new JOIN-AUTH-ASSOC sequence.
-		if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Bssid)) 
+		if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Bssid))
 		{
 			DBGPRINT(RT_DEBUG_TRACE, ("SYNC - receive desired BEACON at JoinWaitBeacon... Channel = %d\n", Channel));
 			RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
@@ -838,7 +838,7 @@ VOID PeerBeaconAtJoinAction(
 
 			//
 			// We need to check if SSID only set to any, then we can record the current SSID.
-			// Otherwise will cause hidden SSID association failed. 
+			// Otherwise will cause hidden SSID association failed.
 			//
 			if (pAd->MlmeAux.SsidLen == 0)
 			{
@@ -886,7 +886,7 @@ VOID PeerBeaconAtJoinAction(
 			{
 				RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
    				RTMPMoveMemory(&pAd->MlmeAux.AddHtInfo, &AddHtInfo, SIZE_ADD_HT_INFO_IE);
-				
+
 				// StaActive.SupportedHtPhy.MCSSet stores Peer AP's 11n Rx capability
 				NdisMoveMemory(pAd->StaActive.SupportedPhyInfo.MCSSet, HtCapability.MCSSet, 16);
 				pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset;
@@ -896,9 +896,9 @@ VOID PeerBeaconAtJoinAction(
 					pAd->StaActive.SupportedPhyInfo.bPreNHt = TRUE;
 				RTMPCheckHt(pAd, BSSID_WCID, &HtCapability, &AddHtInfo);
 				// Copy AP Parameter to StaActive.  This is also in LinkUp.
-				DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAtJoinAction! (MpduDensity=%d, MaxRAmpduFactor=%d, BW=%d)\n", 
+				DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAtJoinAction! (MpduDensity=%d, MaxRAmpduFactor=%d, BW=%d)\n",
 					pAd->StaActive.SupportedHtPhy.MpduDensity, pAd->StaActive.SupportedHtPhy.MaxRAmpduFactor, HtCapability.HtCapInfo.ChannelWidth));
-				
+
 				if (AddHtInfoLen > 0)
 				{
 					CentralChannel = AddHtInfo.ControlChan;
@@ -911,7 +911,7 @@ VOID PeerBeaconAtJoinAction(
 		 			{
 		 				CentralChannel = AddHtInfo.ControlChan + 2;
 		 			}
-                    
+
 					// Check Error .
 					if (pAd->MlmeAux.CentralChannel != CentralChannel)
 		 				DBGPRINT(RT_DEBUG_ERROR, ("PeerBeaconAtJoinAction HT===>Beacon Central Channel = %d, Control Channel = %d. Mlmeaux CentralChannel = %d\n", CentralChannel, AddHtInfo.ControlChan, pAd->MlmeAux.CentralChannel));
@@ -919,7 +919,7 @@ VOID PeerBeaconAtJoinAction(
 		 			DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAtJoinAction HT===>Central Channel = %d, Control Channel = %d,  .\n", CentralChannel, AddHtInfo.ControlChan));
 
 				}
-				
+
 			}
 			else
 #endif // DOT11_N_SUPPORT //
@@ -952,19 +952,19 @@ VOID PeerBeaconAtJoinAction(
 				NdisZeroMemory(&pAd->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));
 				NdisZeroMemory(&pAd->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));
 			}
-			
-			DBGPRINT(RT_DEBUG_TRACE, ("SYNC - after JOIN, SupRateLen=%d, ExtRateLen=%d\n", 
+
+			DBGPRINT(RT_DEBUG_TRACE, ("SYNC - after JOIN, SupRateLen=%d, ExtRateLen=%d\n",
 										pAd->MlmeAux.SupRateLen, pAd->MlmeAux.ExtRateLen));
 
 #ifdef LEAP_SUPPORT
 			// Update CkipFlag
 			pAd->StaCfg.CkipFlag = CkipFlag;
-			
+
 			// Keep TimeStamp for Re-Association used.
 			if (LEAP_CCKM_ON(pAd) && (pAd->StaCfg.CCKMLinkUpFlag == TRUE))
 				pAd->StaCfg.CCKMBeaconAtJoinTimeStamp = TimeStamp;
 #endif // LEAP_SUPPORT //
-				
+
 			if (AironetCellPowerLimit != 0xFF)
 			{
 				//We need to change our TxPower for CCX 2.0 AP Control of Client Transmit Power
@@ -978,11 +978,11 @@ VOID PeerBeaconAtJoinAction(
 			MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
 		}
 		// not to me BEACON, ignored
-	} 
+	}
 	// sanity check fail, ignore this frame
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 		receive BEACON from peer
@@ -992,8 +992,8 @@ VOID PeerBeaconAtJoinAction(
 	==========================================================================
  */
 VOID PeerBeacon(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR         Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
 	CHAR          Ssid[MAX_LEN_OF_SSID];
@@ -1017,7 +1017,7 @@ VOID PeerBeacon(
 	UCHAR						VarIE[MAX_VIE_LEN];		// Total VIE length = MAX_VIE_LEN - -5
 	NDIS_802_11_VARIABLE_IEs	*pVIE = NULL;
 	HT_CAPABILITY_IE		HtCapability;
-	ADD_HT_INFO_IE		AddHtInfo;	// AP might use this additional ht info IE 
+	ADD_HT_INFO_IE		AddHtInfo;	// AP might use this additional ht info IE
 	UCHAR			HtCapabilityLen, PreNHtCapabilityLen;
 	UCHAR			AddHtInfoLen;
 	UCHAR			NewExtChannelOffset = 0xff;
@@ -1040,27 +1040,27 @@ VOID PeerBeacon(
     RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
 	RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
 
-	if (PeerBeaconAndProbeRspSanity(pAd, 
-								Elem->Msg, 
-								Elem->MsgLen, 
+	if (PeerBeaconAndProbeRspSanity(pAd,
+								Elem->Msg,
+								Elem->MsgLen,
 								Elem->Channel,
-								Addr2, 
-								Bssid, 
-								Ssid, 
-								&SsidLen, 
-								&BssType, 
-								&BeaconPeriod, 
-								&Channel, 
+								Addr2,
+								Bssid,
+								Ssid,
+								&SsidLen,
+								&BssType,
+								&BeaconPeriod,
+								&Channel,
 								&NewChannel,
-								&TimeStamp, 
-								&CfParm, 
-								&AtimWin, 
-								&CapabilityInfo, 
+								&TimeStamp,
+								&CfParm,
+								&AtimWin,
+								&CapabilityInfo,
 								&Erp,
-								&DtimCount, 
-								&DtimPeriod, 
-								&BcastFlag, 
-								&MessageToMe, 
+								&DtimCount,
+								&DtimPeriod,
+								&BcastFlag,
+								&MessageToMe,
 								SupRate,
 								&SupRateLen,
 								ExtRate,
@@ -1078,7 +1078,7 @@ VOID PeerBeacon(
 								&AddHtInfo,
 								&NewExtChannelOffset,
 								&LenVIE,
-								pVIE)) 
+								pVIE))
 	{
 		BOOLEAN is_my_bssid, is_my_ssid;
 		ULONG   Bssidx, Now;
@@ -1096,9 +1096,9 @@ VOID PeerBeacon(
 		// It means STA waits disassoc completely from this AP, ignores this beacon.
 		if (pAd->Mlme.CntlMachine.CurrState == CNTL_WAIT_DISASSOC)
 			return;
-		
+
 #ifdef DOT11_N_SUPPORT
-		// Copy Control channel for this BSSID.		
+		// Copy Control channel for this BSSID.
 		if (AddHtInfoLen != 0)
 			Channel = AddHtInfo.ControlChan;
 
@@ -1107,26 +1107,26 @@ VOID PeerBeacon(
 #endif // DOT11_N_SUPPORT //
 
 		//
-		// Housekeeping "SsidBssTab" table for later-on ROAMing usage. 
+		// Housekeeping "SsidBssTab" table for later-on ROAMing usage.
 		//
 		Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
 		if (Bssidx == BSS_NOT_FOUND)
 		{
 			// discover new AP of this network, create BSS entry
 			Bssidx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
-						 &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, 
-						&HtCapability, &AddHtInfo,HtCapabilityLen,AddHtInfoLen,NewExtChannelOffset, Channel, 
-						RealRssi, TimeStamp, CkipFlag, &EdcaParm, &QosCapability, 
+						 &CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,
+						&HtCapability, &AddHtInfo,HtCapabilityLen,AddHtInfoLen,NewExtChannelOffset, Channel,
+						RealRssi, TimeStamp, CkipFlag, &EdcaParm, &QosCapability,
 						&QbssLoad, LenVIE, pVIE);
 			if (Bssidx == BSS_NOT_FOUND) // return if BSS table full
-				return;  
-			
+				return;
+
 			NdisMoveMemory(pAd->ScanTab.BssEntry[Bssidx].PTSF, &Elem->Msg[24], 4);
 			NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
 			NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
 
-			
-			
+
+
 		}
 
 		if ((pAd->CommonCfg.bIEEE80211H == 1) && (NewChannel != 0) && (Channel != NewChannel))
@@ -1139,7 +1139,7 @@ VOID PeerBeacon(
 			MlmeQueueInit(&pAd->Mlme.Queue);
 			BssTableInit(&pAd->ScanTab);
 		    RTMPusecDelay(1000000);		// use delay to prevent STA do reassoc
-					
+
 			// channel sanity check
 			for (index = 0 ; index < pAd->ChannelListNum; index++)
 			{
@@ -1171,17 +1171,17 @@ VOID PeerBeacon(
 			{
 				return;
 			}
-			
+
 			// collapse into the ADHOC network which has bigger BSSID value.
 			for (i = 0; i < 6; i++)
 			{
 				if (Bssid[i] > pAd->CommonCfg.Bssid[i])
 				{
-					DBGPRINT(RT_DEBUG_TRACE, ("SYNC - merge to the IBSS with bigger BSSID=%02x:%02x:%02x:%02x:%02x:%02x\n", 
+					DBGPRINT(RT_DEBUG_TRACE, ("SYNC - merge to the IBSS with bigger BSSID=%02x:%02x:%02x:%02x:%02x:%02x\n",
 						Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
 					AsicDisableSync(pAd);
 					COPY_MAC_ADDR(pAd->CommonCfg.Bssid, Bssid);
-					AsicSetBssid(pAd, pAd->CommonCfg.Bssid); 
+					AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
 					MakeIbssBeacon(pAd);        // re-build BEACON frame
 					AsicEnableIbssSync(pAd);    // copy BEACON frame to on-chip memory
 					is_my_bssid = TRUE;
@@ -1192,7 +1192,7 @@ VOID PeerBeacon(
 			}
 		}
 
-	
+
 		NdisGetSystemUpTime(&Now);
 		pBss = &pAd->ScanTab.BssEntry[Bssidx];
 		pBss->Rssi = RealRssi;       // lastest RSSI
@@ -1200,7 +1200,7 @@ VOID PeerBeacon(
 
 		//
 		// BEACON from my BSSID - either IBSS or INFRA network
-		// 
+		//
 		if (is_my_bssid)
 		{
 			RXWI_STRUC	RxWI;
@@ -1227,30 +1227,30 @@ VOID PeerBeacon(
 			{
 				//
 				// AironetCellPowerLimit equal to 0xFF means the Cisco (ccx) "TxPower Limit" not exist.
-				// Used the default TX Power Percentage, that set from UI.	
+				// Used the default TX Power Percentage, that set from UI.
 				//
-				pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;	
+				pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
 			}
 
 			// at least one 11b peer joined. downgrade the MaxTxRate to 11Mbps
 			// after last 11b peer left for several seconds, we'll auto switch back to 11G rate
 			// in MlmePeriodicExec()
-			if (ADHOC_ON(pAd) && (CAP_IS_IBSS_ON(CapabilityInfo)))   
+			if (ADHOC_ON(pAd) && (CAP_IS_IBSS_ON(CapabilityInfo)))
 			{
 				BOOLEAN	bRestart;
-                BOOLEAN	bnRestart;                					
-                
+                BOOLEAN	bnRestart;
+
 				bRestart = FALSE;
                 bnRestart = FALSE;
-	
-				do 
+
+				do
 				{
 					if ((SupRateLen+ExtRateLen <= 4) && (pAd->CommonCfg.MaxTxRate > RATE_11))
 					{
 						if (pAd->StaCfg.AdhocBOnlyJoined == FALSE)
 						{
 							DBGPRINT(RT_DEBUG_TRACE, ("SYNC - 11b peer joined. down-grade to 11b TX rates \n"));
-							bRestart = TRUE;											
+							bRestart = TRUE;
 							NdisMoveMemory(pAd->StaActive.SupRate, SupRate, MAX_LEN_OF_SUPPORTED_RATES);
 							pAd->StaActive.SupRateLen = SupRateLen;
 							NdisMoveMemory(pAd->StaActive.ExtRate, ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
@@ -1259,20 +1259,20 @@ VOID PeerBeacon(
 							pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
 							AsicSetEdcaParm(pAd, NULL);
 						}
-						
+
 						// this timestamp is for MlmePeriodicExec() to check if all 11B peers have left
 						pAd->StaCfg.Last11bBeaconRxTime = Now;
 						break;
 					}
-#ifdef DOT11_N_SUPPORT					
-					// Update Ht Phy. 
+#ifdef DOT11_N_SUPPORT
+					// Update Ht Phy.
 					if ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
-					{						
+					{
 						if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) &&
 							!pAd->StaCfg.AdhocBGJoined &&
 							!pAd->StaCfg.AdhocBOnlyJoined)
 							AdhocTurnOnQos(pAd);
-						
+
 						// Handle rate switch issue when Adhoc mode
 						if ((SupRateLen+ExtRateLen >= 8) && (HtCapability.MCSSet[0] == 0) && (HtCapability.MCSSet[1] == 0))
 						{
@@ -1288,9 +1288,9 @@ VOID PeerBeacon(
 								pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
 								AsicSetEdcaParm(pAd, NULL);
 							}
-							
+
 							// this timestamp is for MlmePeriodicExec() to check if all 11g peers have left
-							pAd->StaCfg.Last11gBeaconRxTime = Now;							
+							pAd->StaCfg.Last11gBeaconRxTime = Now;
 							break;
 						}
 						else if (!pAd->StaCfg.AdhocBGJoined &&
@@ -1301,9 +1301,9 @@ VOID PeerBeacon(
 							if (pAd->StaCfg.Adhoc20NJoined == FALSE)
 							{
 								UCHAR	ByteValue = 0;
-								
+
 								pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
-								
+
 								pAd->StaCfg.Adhoc20NJoined = TRUE;
 								NdisMoveMemory(&pAd->MlmeAux.HtCapability, &HtCapability, SIZE_HT_CAP_IE);
 								if (AddHtInfoLen != 0)
@@ -1319,7 +1319,7 @@ VOID PeerBeacon(
 							// this timestamp is for MlmePeriodicExec() to check if all 20MHz N peers have left
 							pAd->StaCfg.Last20NBeaconRxTime = Now;
 						}
-						
+
 					}
 					else
 #endif // DOT11_N_SUPPORT //
@@ -1349,27 +1349,27 @@ VOID PeerBeacon(
 				// At least another peer in this IBSS, declare MediaState as CONNECTED
 				if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
 				{
-					OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); 
+					OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
 
 					pAd->IndicateMediaState = NdisMediaStateConnected;
 					RTMP_IndicateMediaState(pAd);
 	                pAd->ExtraInfo = GENERAL_LINK_UP;
 					AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
-					
+
 					// 2003/03/12 - john
 					// Make sure this entry in "ScanTab" table, thus complies to Microsoft's policy that
-					// "site survey" result should always include the current connected network. 
+					// "site survey" result should always include the current connected network.
 					//
 					Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
 					if (Bssidx == BSS_NOT_FOUND)
 					{
-						Bssidx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod, 
+						Bssidx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
 									&CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability,
-									&AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, RealRssi, TimeStamp, 0, 
+									&AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, RealRssi, TimeStamp, 0,
 									&EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
 					}
 					DBGPRINT(RT_DEBUG_TRACE, ("ADHOC  fOP_STATUS_MEDIA_STATE_CONNECTED.\n"));
-				}	
+				}
 
 				// Ad-hoc mode is using MAC address as BA session. So we need to continuously find newly joined adhoc station by receiving beacon.
 				// To prevent always check this, we use wcid == RESERVED_WCID to recognize it as newly joined adhoc station.
@@ -1377,17 +1377,17 @@ VOID PeerBeacon(
 				{
 					UCHAR	idx;
 					MAC_TABLE_ENTRY *pEntry;
-					
+
 					// look up the existing table
-					pEntry = MacTableLookup(pAd, Addr2);				
+					pEntry = MacTableLookup(pAd, Addr2);
 					if (pEntry == NULL)
 					{
-						// Another adhoc joining, add to our MAC table. 
-						pEntry = MacTableInsertEntry(pAd, Addr2, BSS0, FALSE);	 			
+						// Another adhoc joining, add to our MAC table.
+						pEntry = MacTableInsertEntry(pAd, Addr2, BSS0, FALSE);
 						if (pEntry)
 						{
 							pEntry->Sst = SST_ASSOC;
-							idx = pAd->StaCfg.DefaultKeyId;	
+							idx = pAd->StaCfg.DefaultKeyId;
 							// After InsertEntry, Write to ASIC on-chip table.
 							RT28XX_STA_SECURITY_INFO_ADD(pAd, BSS0, idx, pEntry);
 							DBGPRINT(RT_DEBUG_TRACE, ("ADHOC %x:%x:%x:%x:%x:%x  join in.Entry=%d\n", Addr2[0],Addr2[1],Addr2[2],Addr2[3],Addr2[4],Addr2[5], pEntry->Aid));
@@ -1428,17 +1428,17 @@ VOID PeerBeacon(
 	                            wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL);
 	                        }
 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
-#endif // WPA_SUPPLICANT_SUPPORT //                    
+#endif // WPA_SUPPLICANT_SUPPORT //
 
 #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT
 	                        {
 	                            union iwreq_data    wrqu;
 	                            wext_notify_event_assoc(pAd);
-	                            
+
 	                            memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
 	                            memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
 	                            wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
-	                            
+
 	                        }
 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
 						}
@@ -1450,11 +1450,11 @@ VOID PeerBeacon(
 			{
 				BOOLEAN bUseShortSlot, bUseBGProtection;
 
-				// decide to use/change to - 
+				// decide to use/change to -
 				//      1. long slot (20 us) or short slot (9 us) time
 				//      2. turn on/off RTS/CTS and/or CTS-to-self protection
 				//      3. short preamble
-					
+
 				//bUseShortSlot = pAd->CommonCfg.bUseShortSlotTime && CAP_IS_SHORT_SLOT(CapabilityInfo);
 				bUseShortSlot = CAP_IS_SHORT_SLOT(CapabilityInfo);
 				if (bUseShortSlot != OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED))
@@ -1478,13 +1478,13 @@ VOID PeerBeacon(
 						OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
 						AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, (OFDMSETPROTECT|CCKSETPROTECT|ALLN_SETPROTECT),TRUE,(pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1));
 					}
-					
+
 					DBGPRINT(RT_DEBUG_WARN, ("SYNC - AP changed B/G protection to %d\n", bUseBGProtection));
 				}
-				
+
 #ifdef DOT11_N_SUPPORT
 				// check Ht protection mode. and adhere to the Non-GF device indication by AP.
-				if ((AddHtInfoLen != 0) && 
+				if ((AddHtInfoLen != 0) &&
 					((AddHtInfo.AddHtInfo2.OperaionMode != pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode) ||
 					(AddHtInfo.AddHtInfo2.NonGfPresent != pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent)))
 				{
@@ -1500,8 +1500,8 @@ VOID PeerBeacon(
 					DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP changed N OperaionMode to %d\n", pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode));
 				}
 #endif // DOT11_N_SUPPORT //
-				
-				if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED) && 
+
+				if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED) &&
 					ERP_IS_USE_BARKER_PREAMBLE(Erp))
 				{
 					MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
@@ -1512,7 +1512,7 @@ VOID PeerBeacon(
 					(EdcaParm.bValid == TRUE)                          &&
 					(EdcaParm.EdcaUpdateCount != pAd->CommonCfg.APEdcaParm.EdcaUpdateCount))
 				{
-					DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP change EDCA parameters(from %d to %d)\n", 
+					DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP change EDCA parameters(from %d to %d)\n",
 						pAd->CommonCfg.APEdcaParm.EdcaUpdateCount,
 						EdcaParm.EdcaUpdateCount));
 					AsicSetEdcaParm(pAd, &EdcaParm);
@@ -1557,7 +1557,7 @@ VOID PeerBeacon(
 						RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
 					}
 #endif // RT2860 //
-				} 
+				}
 				else if ((pAd->TxSwQueue[QID_AC_BK].Number != 0)													||
 						(pAd->TxSwQueue[QID_AC_BE].Number != 0)														||
 						(pAd->TxSwQueue[QID_AC_VI].Number != 0)														||
@@ -1566,7 +1566,7 @@ VOID PeerBeacon(
 						(RTMPFreeTXDRequest(pAd, QID_AC_BE, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS)	||
 						(RTMPFreeTXDRequest(pAd, QID_AC_VI, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS)	||
 						(RTMPFreeTXDRequest(pAd, QID_AC_VO, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS)	||
-						(RTMPFreeTXDRequest(pAd, QID_MGMT, MGMT_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS)) 
+						(RTMPFreeTXDRequest(pAd, QID_MGMT, MGMT_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS))
 				{
 					// TODO: consider scheduled HCCA. might not be proper to use traditional DTIM-based power-saving scheme
 					// can we cheat here (i.e. just check MGMT & AC_BE) for better performance?
@@ -1575,13 +1575,13 @@ VOID PeerBeacon(
 					{
 						RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
 					}
-#endif // RT2860 //                    
+#endif // RT2860 //
 				}
-				else 
+				else
 				{
 					USHORT NextDtim = DtimCount;
 
-					if (NextDtim == 0) 
+					if (NextDtim == 0)
 						NextDtim = DtimPeriod;
 
 					TbttNumToNextWakeUp = pAd->StaCfg.DefaultListenCount;
@@ -1600,15 +1600,15 @@ VOID PeerBeacon(
 	// sanity check fail, ignore this frame
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 		Receive PROBE REQ from remote peer when operating in IBSS mode
 	==========================================================================
  */
 VOID PeerProbeReqAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	UCHAR         Addr2[MAC_ADDR_LEN];
 	CHAR          Ssid[MAX_LEN_OF_SSID];
@@ -1633,7 +1633,7 @@ VOID PeerProbeReqAction(
 	if (PeerProbeReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, Ssid, &SsidLen))
 	{
 		if ((SsidLen == 0) || SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen))
-		{			
+		{
 			// allocate and send out ProbeRsp frame
 			NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
 			if (NStatus != NDIS_STATUS_SUCCESS)
@@ -1641,34 +1641,34 @@ VOID PeerProbeReqAction(
 
 			//pAd->StaCfg.AtimWin = 0;  // ??????
 
-			Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) || 
-					  (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) || 
+			Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
+					  (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
 					  (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
 			CapabilityInfo = CAP_GENERATE(0, 1, Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 0, 0);
 
-			MakeOutgoingFrame(pOutBuffer,                   &FrameLen, 
-							  sizeof(HEADER_802_11),        &ProbeRspHdr, 
+			MakeOutgoingFrame(pOutBuffer,                   &FrameLen,
+							  sizeof(HEADER_802_11),        &ProbeRspHdr,
 							  TIMESTAMP_LEN,                &FakeTimestamp,
 							  2,                            &pAd->CommonCfg.BeaconPeriod,
 							  2,                            &CapabilityInfo,
-							  1,                            &SsidIe, 
-							  1,                            &pAd->CommonCfg.SsidLen, 
+							  1,                            &SsidIe,
+							  1,                            &pAd->CommonCfg.SsidLen,
 							  pAd->CommonCfg.SsidLen,       pAd->CommonCfg.Ssid,
-							  1,                            &SupRateIe, 
+							  1,                            &SupRateIe,
 							  1,                            &pAd->StaActive.SupRateLen,
-							  pAd->StaActive.SupRateLen,    pAd->StaActive.SupRate, 
-							  1,                            &DsIe, 
-							  1,                            &DsLen, 
+							  pAd->StaActive.SupRateLen,    pAd->StaActive.SupRate,
+							  1,                            &DsIe,
+							  1,                            &DsLen,
 							  1,                            &pAd->CommonCfg.Channel,
-							  1,                            &IbssIe, 
-							  1,                            &IbssLen, 
+							  1,                            &IbssIe,
+							  1,                            &IbssLen,
 							  2,                            &pAd->StaActive.AtimWin,
 							  END_OF_ARGS);
 
 			if (pAd->StaActive.ExtRateLen)
 			{
 				ULONG tmp;
-				MakeOutgoingFrame(pOutBuffer + FrameLen,        &tmp, 
+				MakeOutgoingFrame(pOutBuffer + FrameLen,        &tmp,
 								  3,                            LocalErpIe,
 								  1,                            &ExtRateIe,
 								  1,                            &pAd->StaActive.ExtRateLen,
@@ -1702,21 +1702,21 @@ VOID PeerProbeReqAction(
 					MakeOutgoingFrame(pOutBuffer + FrameLen,            &TmpLen,
 								  1,                                &WpaIe,
 								  4,                                &BROADCOM[0],
-								 pAd->MlmeAux.HtCapabilityLen,          &pAd->MlmeAux.HtCapability, 
+								 pAd->MlmeAux.HtCapabilityLen,          &pAd->MlmeAux.HtCapability,
 								  END_OF_ARGS);
 				}
-				else				
+				else
 				{
 				MakeOutgoingFrame(pOutBuffer + FrameLen,            &TmpLen,
 								  1,                                &HtCapIe,
 								  1,                                &HtLen,
-								 sizeof(HT_CAPABILITY_IE),          &pAd->CommonCfg.HtCapability, 
+								 sizeof(HT_CAPABILITY_IE),          &pAd->CommonCfg.HtCapability,
 								  1,                                &AddHtInfoIe,
 								  1,                                &AddHtLen,
-								 sizeof(ADD_HT_INFO_IE),          &pAd->CommonCfg.AddHTInfo, 
+								 sizeof(ADD_HT_INFO_IE),          &pAd->CommonCfg.AddHTInfo,
 								  1,                                &NewExtChanIe,
 								  1,                                &NewExtLen,
-								 sizeof(NEW_EXT_CHAN_IE),          &pAd->CommonCfg.NewExtChanOffset, 
+								 sizeof(NEW_EXT_CHAN_IE),          &pAd->CommonCfg.NewExtChanOffset,
 								  END_OF_ARGS);
 				}
 				FrameLen += TmpLen;
@@ -1729,8 +1729,8 @@ VOID PeerProbeReqAction(
 }
 
 VOID BeaconTimeoutAtJoinAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT Status;
 	DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BeaconTimeoutAtJoinAction\n"));
@@ -1739,37 +1739,37 @@ VOID BeaconTimeoutAtJoinAction(
 	MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 		Scan timeout procedure. basically add channel index by 1 and rescan
 	==========================================================================
  */
 VOID ScanTimeoutAction(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	pAd->MlmeAux.Channel = NextChannel(pAd, pAd->MlmeAux.Channel);
 
 	// Only one channel scanned for CISCO beacon request
-	if ((pAd->MlmeAux.ScanType == SCAN_CISCO_ACTIVE) || 
+	if ((pAd->MlmeAux.ScanType == SCAN_CISCO_ACTIVE) ||
 		(pAd->MlmeAux.ScanType == SCAN_CISCO_PASSIVE) ||
 		(pAd->MlmeAux.ScanType == SCAN_CISCO_NOISE) ||
 		(pAd->MlmeAux.ScanType == SCAN_CISCO_CHANNEL_LOAD))
 		pAd->MlmeAux.Channel = 0;
 
 	// this routine will stop if pAd->MlmeAux.Channel == 0
-	ScanNextChannel(pAd); 
+	ScanNextChannel(pAd);
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 	==========================================================================
  */
 VOID InvalidStateWhenScan(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT Status;
 	DBGPRINT(RT_DEBUG_TRACE, ("AYNC - InvalidStateWhenScan(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
@@ -1778,14 +1778,14 @@ VOID InvalidStateWhenScan(
 	MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 	==========================================================================
  */
 VOID InvalidStateWhenJoin(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT Status;
 	DBGPRINT(RT_DEBUG_TRACE, ("InvalidStateWhenJoin(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
@@ -1794,14 +1794,14 @@ VOID InvalidStateWhenJoin(
 	MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 	==========================================================================
  */
 VOID InvalidStateWhenStart(
-	IN PRTMP_ADAPTER pAd, 
-	IN MLME_QUEUE_ELEM *Elem) 
+	IN PRTMP_ADAPTER pAd,
+	IN MLME_QUEUE_ELEM *Elem)
 {
 	USHORT Status;
 	DBGPRINT(RT_DEBUG_TRACE, ("InvalidStateWhenStart(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
@@ -1810,16 +1810,16 @@ VOID InvalidStateWhenStart(
 	MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
 }
 
-/* 
+/*
 	==========================================================================
 	Description:
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	==========================================================================
  */
 VOID EnqueuePsPoll(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 #ifdef RALINK_ATE
     if (ATE_ON(pAd))
@@ -1828,20 +1828,20 @@ VOID EnqueuePsPoll(
     }
 #endif // RALINK_ATE //
 
-	
+
 	if (pAd->StaCfg.WindowsPowerMode == Ndis802_11PowerModeLegacy_PSP)
     	pAd->PsPollFrame.FC.PwrMgmt = PWR_SAVE;
 	MiniportMMRequest(pAd, 0, (PUCHAR)&pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
 }
 
 
-/* 
+/*
 	==========================================================================
 	Description:
 	==========================================================================
  */
 VOID EnqueueProbeRequest(
-	IN PRTMP_ADAPTER pAd) 
+	IN PRTMP_ADAPTER pAd)
 {
 	NDIS_STATUS     NState;
 	PUCHAR          pOutBuffer;
@@ -1851,7 +1851,7 @@ VOID EnqueueProbeRequest(
 	DBGPRINT(RT_DEBUG_TRACE, ("force out a ProbeRequest ...\n"));
 
 	NState = MlmeAllocateMemory(pAd, &pOutBuffer);  //Get an unused nonpaged memory
-	if (NState == NDIS_STATUS_SUCCESS) 
+	if (NState == NDIS_STATUS_SUCCESS)
 	{
 		MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
 
@@ -1863,7 +1863,7 @@ VOID EnqueueProbeRequest(
 						  pAd->CommonCfg.SsidLen,		  pAd->CommonCfg.Ssid,
 						  1,                              &SupRateIe,
 						  1,                              &pAd->StaActive.SupRateLen,
-						  pAd->StaActive.SupRateLen,      pAd->StaActive.SupRate, 
+						  pAd->StaActive.SupRateLen,      pAd->StaActive.SupRate,
 						  END_OF_ARGS);
 		MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
 		MlmeFreeMemory(pAd, pOutBuffer);
@@ -1879,7 +1879,7 @@ VOID BuildEffectedChannelList(
 	UCHAR		EChannel[11];
 	UCHAR		i, j, k;
 	UCHAR		UpperChannel = 0, LowerChannel = 0;
-	
+
 	RTMPZeroMemory(EChannel, 11);
 	i = 0;
 	// Find upper channel and lower channel.
@@ -1936,7 +1936,7 @@ VOID BuildEffectedChannelList(
 			}
 		}
 	}
-	// 
+	//
 	for (j = 0;j < i;j++)
 	{
 		for (k = 0;k < pAd->ChannelListNum;k++)
diff --git a/sta/wpa.c b/sta/wpa.c
index 5933cb7..774c656 100644
--- a/sta/wpa.c
+++ b/sta/wpa.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -35,7 +35,7 @@
 	Jan	Lee		03-07-22		Initial
 	Paul Lin	03-11-28		Modify for supplicant
 */
-#include "rt_config.h"
+#include "../rt_config.h"
 
 #define		WPARSNIE	0xdd
 #define		WPA2RSNIE	0x30
@@ -111,36 +111,36 @@ UCHAR	EAPOL_FRAME[] = {0x88, 0x8E};
 BOOLEAN CheckRSNIE(
 	IN  PRTMP_ADAPTER   pAd,
 	IN  PUCHAR          pData,
-	IN  UCHAR           DataLen,	
+	IN  UCHAR           DataLen,
 	OUT	UCHAR			*Offset);
 
 void inc_byte_array(UCHAR *counter, int len);
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Classify WPA EAP message type
 
 	Arguments:
 		EAPType		Value of EAP message type
 		MsgType		Internal Message definition for MLME state machine
-		
+
 	Return Value:
 		TRUE		Found appropriate message type
 		FALSE		No appropriate message type
 
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
 		All these constants are defined in wpa.h
 		For supplicant, there is only EAPOL Key message avaliable
-		
+
 	========================================================================
 */
 BOOLEAN	WpaMsgTypeSubst(
 	IN	UCHAR	EAPType,
-	OUT	INT		*MsgType)	
+	OUT	INT		*MsgType)
 {
 	switch (EAPType)
 	{
@@ -160,23 +160,23 @@ BOOLEAN	WpaMsgTypeSubst(
 			*MsgType = MT2_EAPOLASFAlert;
 			break;
 		default:
-			return FALSE;		
-	}	
+			return FALSE;
+	}
 	return TRUE;
 }
 
-/*	
+/*
 	==========================================================================
-	Description: 
+	Description:
 		association	state machine init,	including state	transition and timer init
-	Parameters:	
+	Parameters:
 		S -	pointer	to the association state machine
 	==========================================================================
  */
 VOID WpaPskStateMachineInit(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	STATE_MACHINE *S, 
-	OUT	STATE_MACHINE_FUNC Trans[])	
+	IN	PRTMP_ADAPTER	pAd,
+	IN	STATE_MACHINE *S,
+	OUT	STATE_MACHINE_FUNC Trans[])
 {
 	StateMachineInit(S,	Trans, MAX_WPA_PSK_STATE, MAX_WPA_PSK_MSG, (STATE_MACHINE_FUNC)Drop, WPA_PSK_IDLE, WPA_MACHINE_BASE);
 	StateMachineSetAction(S, WPA_PSK_IDLE, MT2_EAPOLKey, (STATE_MACHINE_FUNC)WpaEAPOLKeyAction);
@@ -185,10 +185,10 @@ VOID WpaPskStateMachineInit(
 /*
 	==========================================================================
 	Description:
-		This is	state machine function.	
-		When receiving EAPOL packets which is  for 802.1x key management. 
-		Use	both in	WPA, and WPAPSK	case. 
-		In this	function, further dispatch to different	functions according	to the received	packet.	 3 categories are :	
+		This is	state machine function.
+		When receiving EAPOL packets which is  for 802.1x key management.
+		Use	both in	WPA, and WPAPSK	case.
+		In this	function, further dispatch to different	functions according	to the received	packet.	 3 categories are :
 		  1.  normal 4-way pairwisekey and 2-way groupkey handshake
 		  2.  MIC error	(Countermeasures attack)  report packet	from STA.
 		  3.  Request for pairwise/group key update	from STA
@@ -196,9 +196,9 @@ VOID WpaPskStateMachineInit(
 	==========================================================================
 */
 VOID WpaEAPOLKeyAction(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	MLME_QUEUE_ELEM	*Elem) 
-	
+	IN	PRTMP_ADAPTER	pAd,
+	IN	MLME_QUEUE_ELEM	*Elem)
+
 {
 	INT             MsgType = EAPOL_MSG_INVALID;
 	PKEY_DESCRIPTER pKeyDesc;
@@ -293,7 +293,7 @@ VOID WpaEAPOLKeyAction(
 			{
 				Wpa2PairMsg1Action(pAd, Elem);
 				pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
-			} 
+			}
 			else if(MsgType == EAPOL_PAIR_MSG_3)
 			{
 				Wpa2PairMsg3Action(pAd, Elem);
@@ -309,14 +309,14 @@ VOID WpaEAPOLKeyAction(
 				pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
 				Wpa2PairMsg1Action(pAd, Elem);
 				pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
-			} 
+			}
 			else if(MsgType == EAPOL_PAIR_MSG_3)
 			{
 			    // Reset port secured variable
 				pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
 				Wpa2PairMsg3Action(pAd, Elem);
 				pAd->StaCfg.WpaState = SS_WAIT_GROUP;
-			} 
+			}
 			else if(MsgType == EAPOL_GROUP_MSG_1)
 			{
 				WpaGroupMsg1Action(pAd, Elem);
@@ -325,8 +325,8 @@ VOID WpaEAPOLKeyAction(
 			break;
 
 		default:
-			break;              
-		} 
+			break;
+		}
 	}
 	// Process WPAPSK Frame
 	// Classify message Type, either pairwise message 1, 3, or group message 1 for supplicant
@@ -342,7 +342,7 @@ VOID WpaEAPOLKeyAction(
 		{
 			MsgType = EAPOL_PAIR_MSG_1;
 			DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Pairwise Message 1\n"));
-		} 
+		}
 		else if((peerKeyInfo.KeyType == PAIRWISEKEY) &&
 			(peerKeyInfo.KeyIndex == 0) &&
 			(peerKeyInfo.KeyAck == 1) &&
@@ -353,7 +353,7 @@ VOID WpaEAPOLKeyAction(
 		{
 			MsgType = EAPOL_PAIR_MSG_3;
 			DBGPRINT(RT_DEBUG_TRACE, ("Receive EAPOL Key Pairwise Message 3\n"));
-		} 
+		}
 		else if((peerKeyInfo.KeyType == GROUPKEY) &&
 			(peerKeyInfo.KeyIndex != 0) &&
 			(peerKeyInfo.KeyAck == 1) &&
@@ -383,7 +383,7 @@ VOID WpaEAPOLKeyAction(
 			{
 				WpaPairMsg1Action(pAd, Elem);
 				pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
-			} 
+			}
 			else if(MsgType == EAPOL_PAIR_MSG_3)
 			{
 				WpaPairMsg3Action(pAd, Elem);
@@ -399,14 +399,14 @@ VOID WpaEAPOLKeyAction(
 				pAd->StaCfg.WpaState = SS_WAIT_MSG_3;
 				// Reset port secured variable
 				pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-			} 
+			}
 			else if(MsgType == EAPOL_PAIR_MSG_3)
 			{
 				WpaPairMsg3Action(pAd, Elem);
 				pAd->StaCfg.WpaState = SS_WAIT_GROUP;
 				// Reset port secured variable
 				pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
-			} 
+			}
 			else if(MsgType == EAPOL_GROUP_MSG_1)
 			{
 				WpaGroupMsg1Action(pAd, Elem);
@@ -415,7 +415,7 @@ VOID WpaEAPOLKeyAction(
 			break;
 
 		default:
-			break;              
+			break;
 		}
 	}
 
@@ -424,24 +424,24 @@ VOID WpaEAPOLKeyAction(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Process Pairwise key 4-way handshaking
 
 	Arguments:
 		pAd	Pointer	to our adapter
 		Elem		Message body
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	WpaPairMsg1Action(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  MLME_QUEUE_ELEM *Elem) 
+	IN  PRTMP_ADAPTER   pAd,
+	IN  MLME_QUEUE_ELEM *Elem)
 {
 	PHEADER_802_11      pHeader;
 	UCHAR				*mpool, *PTK, *digest;
@@ -471,29 +471,29 @@ VOID	WpaPairMsg1Action(
 	pMsg1 = (PEAPOL_PACKET) &Elem->Msg[LENGTH_802_11 + LENGTH_802_1_H];
 
 	// 1. Save Replay counter, it will use to verify message 3 and construct message 2
-	NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg1->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);       
+	NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg1->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
 
 	// 2. Save ANonce
 	NdisMoveMemory(pAd->StaCfg.ANonce, pMsg1->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE);
 
 	// Generate random SNonce
-	GenRandom(pAd, pAd->CurrentAddress, pAd->StaCfg.SNonce); 
+	GenRandom(pAd, pAd->CurrentAddress, pAd->StaCfg.SNonce);
 
 	// Calc PTK(ANonce, SNonce)
 	WpaCountPTK(pAd,
 		pAd->StaCfg.PMK,
 		pAd->StaCfg.ANonce,
-		pAd->CommonCfg.Bssid, 
-		pAd->StaCfg.SNonce, 
-		pAd->CurrentAddress,     
-		PTK, 
+		pAd->CommonCfg.Bssid,
+		pAd->StaCfg.SNonce,
+		pAd->CurrentAddress,
+		PTK,
 		LEN_PTK);
 
 	// Save key to PTK entry
 	NdisMoveMemory(pAd->StaCfg.PTK, PTK, LEN_PTK);
 
 	// init 802.3 header and Fill Packet
-	MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);	
+	MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
 
 	// Zero Message 2 body
 	NdisZeroMemory(&Packet, sizeof(Packet));
@@ -507,7 +507,7 @@ VOID	WpaPairMsg1Action(
 	if(pAd->StaCfg.WepStatus  == Ndis802_11Encryption3Enabled)
 	{
 		Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
-	} 
+	}
 	else	  // TKIP
 	{
 		Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
@@ -522,9 +522,9 @@ VOID	WpaPairMsg1Action(
 	// Update packet length after decide Key data payload
 	Packet.Body_Len[1]  = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + Packet.KeyDesc.KeyDataLen[1];
 
-	// Update Key length 
+	// Update Key length
 	Packet.KeyDesc.KeyLength[0] = pMsg1->KeyDesc.KeyLength[0];
-	Packet.KeyDesc.KeyLength[1] = pMsg1->KeyDesc.KeyLength[1];  
+	Packet.KeyDesc.KeyLength[1] = pMsg1->KeyDesc.KeyLength[1];
 	// 2. Key Type PeerKey
 	Packet.KeyDesc.KeyInfo.KeyType = PAIRWISEKEY;
 
@@ -539,7 +539,7 @@ VOID	WpaPairMsg1Action(
 	NdisMoveMemory(Packet.KeyDesc.KeyNonce, pAd->StaCfg.SNonce, LEN_KEY_DESC_NONCE);
 
 	// 5. Key Replay Count
-	NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);      
+	NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
 
 	// Send EAPOL(0, 1, 0, 0, 0, P, 0, SNonce, MIC, RSN_IE)
 	// Out buffer for transmitting message 2
@@ -562,7 +562,7 @@ VOID	WpaPairMsg1Action(
 
 		HMAC_SHA1(pOutBuffer, FrameLen, PTK, LEN_EAP_MICK, digest);
 		NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
-	} 
+	}
 	else
 	{	// TKIP
 		hmac_md5(PTK,  LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
@@ -571,7 +571,7 @@ VOID	WpaPairMsg1Action(
 
 	//hex_dump("MIC", Mic, LEN_KEY_DESC_MIC);
 
-		MakeOutgoingFrame(pOutBuffer,           	&FrameLen,  
+		MakeOutgoingFrame(pOutBuffer,           	&FrameLen,
 			  			LENGTH_802_3,     			&Header802_3,
 						Packet.Body_Len[1] + 4,    &Packet,
 						END_OF_ARGS);
@@ -624,7 +624,7 @@ VOID Wpa2PairMsg1Action(
 	NdisMoveMemory(pAd->StaCfg.ANonce, pMsg1->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE);
 
 	// Generate random SNonce
-	GenRandom(pAd, pAd->CurrentAddress, pAd->StaCfg.SNonce); 
+	GenRandom(pAd, pAd->CurrentAddress, pAd->StaCfg.SNonce);
 
 	if(pMsg1->KeyDesc.KeyDataLen[1] > 0 )
 	{
@@ -633,19 +633,19 @@ VOID Wpa2PairMsg1Action(
 
 	// Calc PTK(ANonce, SNonce)
 	WpaCountPTK(pAd,
-		pAd->StaCfg.PMK,   
+		pAd->StaCfg.PMK,
 		pAd->StaCfg.ANonce,
-		pAd->CommonCfg.Bssid, 
-		pAd->StaCfg.SNonce, 
-		pAd->CurrentAddress,    
-		PTK, 
-		LEN_PTK);   
+		pAd->CommonCfg.Bssid,
+		pAd->StaCfg.SNonce,
+		pAd->CurrentAddress,
+		PTK,
+		LEN_PTK);
 
 	// Save key to PTK entry
 	NdisMoveMemory(pAd->StaCfg.PTK, PTK, LEN_PTK);
 
 	// init 802.3 header and Fill Packet
-	MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);	
+	MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
 
 	// Zero message 2 body
 	NdisZeroMemory(&Packet, sizeof(Packet));
@@ -660,18 +660,18 @@ VOID Wpa2PairMsg1Action(
 	if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
 	{
 		Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
-	} 
+	}
 	else	  // TKIP
 	{
 		Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
 	}
-	
+
 	// fill in Data Material and its length
 	Packet.KeyDesc.KeyData[0] = IE_WPA2;
 	Packet.KeyDesc.KeyData[1] = pAd->StaCfg.RSNIE_Len;
 	Packet.KeyDesc.KeyDataLen[1] = pAd->StaCfg.RSNIE_Len + 2;
 	NdisMoveMemory(&Packet.KeyDesc.KeyData[2], pAd->StaCfg.RSN_IE, pAd->StaCfg.RSNIE_Len);
-	
+
 	// Update packet length after decide Key data payload
 	Packet.Body_Len[1]  = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE + Packet.KeyDesc.KeyDataLen[1];
 
@@ -689,7 +689,7 @@ VOID Wpa2PairMsg1Action(
 	NdisMoveMemory(Packet.KeyDesc.KeyNonce, pAd->StaCfg.SNonce, LEN_KEY_DESC_NONCE);
 
 	// 5. Key Replay Count
-	NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);     
+	NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
 
 	// Convert to little-endian format.
 	*((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
@@ -716,7 +716,7 @@ VOID Wpa2PairMsg1Action(
 		// AES
 		HMAC_SHA1(pOutBuffer, FrameLen, PTK, LEN_EAP_MICK, digest);
 		NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
-	} 
+	}
 	else
 	{
 		hmac_md5(PTK,  LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
@@ -725,7 +725,7 @@ VOID Wpa2PairMsg1Action(
 
 
 	// Make  Transmitting frame
-	MakeOutgoingFrame(pOutBuffer,           	&FrameLen,  
+	MakeOutgoingFrame(pOutBuffer,           	&FrameLen,
 			  			LENGTH_802_3,     		&Header802_3,
 						Packet.Body_Len[1] + 4, &Packet,
 						END_OF_ARGS);
@@ -743,25 +743,25 @@ VOID Wpa2PairMsg1Action(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Process Pairwise key 4-way handshaking
 
 	Arguments:
 		pAd	Pointer	to our adapter
 		Elem		Message body
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	WpaPairMsg3Action(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	MLME_QUEUE_ELEM	*Elem) 
-	
+	IN	PRTMP_ADAPTER	pAd,
+	IN	MLME_QUEUE_ELEM	*Elem)
+
 {
 	PHEADER_802_11      pHeader;
 	PUCHAR          	pOutBuffer = NULL;
@@ -769,7 +769,7 @@ VOID	WpaPairMsg3Action(
 	ULONG           	FrameLen = 0;
 	EAPOL_PACKET        Packet;
 	PEAPOL_PACKET       pMsg3;
-	UCHAR           	Mic[16], OldMic[16];    
+	UCHAR           	Mic[16], OldMic[16];
 	MAC_TABLE_ENTRY 	*pEntry = NULL;
 	UCHAR				skip_offset;
 	KEY_INFO			peerKeyInfo;
@@ -790,7 +790,7 @@ VOID	WpaPairMsg3Action(
 	if (pAd->StaCfg.WepStatus  == Ndis802_11Encryption3Enabled && (peerKeyInfo.KeyDescVer != 2))
 	{
 		return;
-	} 
+	}
 	else if(pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled && (peerKeyInfo.KeyDescVer != 1))
 	{
 		return;
@@ -799,7 +799,7 @@ VOID	WpaPairMsg3Action(
 	// Verify RSN IE
 	//if (!RTMPEqualMemory(pMsg3->KeyDesc.KeyData, pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len))
 	if (!CheckRSNIE(pAd, pMsg3->KeyDesc.KeyData, pMsg3->KeyDesc.KeyDataLen[1], &skip_offset))
-	{       
+	{
 		DBGPRINT(RT_DEBUG_ERROR, ("RSN_IE Different in Msg 3 of WPA1 4-way handshake!! \n"));
 		hex_dump("The original RSN_IE", pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len);
 		hex_dump("The received RSN_IE", pMsg3->KeyDesc.KeyData, pMsg3->KeyDesc.KeyDataLen[1]);
@@ -820,7 +820,7 @@ VOID	WpaPairMsg3Action(
 
 		HMAC_SHA1((PUCHAR) pMsg3, pMsg3->Body_Len[1] + 4, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
 		NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
-	} 
+	}
 	else	// TKIP
 	{
 		hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, (PUCHAR) pMsg3, pMsg3->Body_Len[1] + 4, Mic);
@@ -830,7 +830,7 @@ VOID	WpaPairMsg3Action(
 	{
 		DBGPRINT(RT_DEBUG_ERROR, (" MIC Different in msg 3 of 4-way handshake!!!!!!!!!! \n"));
 		return;
-	} 
+	}
 	else
 		DBGPRINT(RT_DEBUG_TRACE, (" MIC VALID in msg 3 of 4-way handshake!!!!!!!!!! \n"));
 
@@ -839,14 +839,14 @@ VOID	WpaPairMsg3Action(
 		return;
 
 	// Update new replay counter
-	NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);      
+	NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
 
 	// 4. Double check ANonce
 	if(!NdisEqualMemory(pAd->StaCfg.ANonce, pMsg3->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE))
 		return;
 
 	// init 802.3 header and Fill Packet
-	MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);	
+	MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
 
 	// Zero Message 4 body
 	NdisZeroMemory(&Packet, sizeof(Packet));
@@ -879,8 +879,8 @@ VOID	WpaPairMsg3Action(
 	// Convert to little-endian format.
 	*((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
 
-	// Key Replay count	
-	NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);        
+	// Key Replay count
+	NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
 
 	// Out buffer for transmitting message 4
 	MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer);  // allocate memory
@@ -902,7 +902,7 @@ VOID	WpaPairMsg3Action(
 
 		HMAC_SHA1(pOutBuffer, FrameLen, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
 		NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
-	} 
+	}
 	else
 	{
 		hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
@@ -911,11 +911,11 @@ VOID	WpaPairMsg3Action(
 
 	// Update PTK
 	// Prepare pair-wise key information into shared key table
-	NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));  
+	NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
 	pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
     NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
 	NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
-	NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);            
+	NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
 
 	// Decide its ChiperAlg
 	if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
@@ -929,27 +929,27 @@ VOID	WpaPairMsg3Action(
 	pEntry = &pAd->MacTab.Content[BSSID_WCID];
 	NdisMoveMemory(pEntry->PairwiseKey.Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
 	NdisMoveMemory(pEntry->PairwiseKey.RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
-	NdisMoveMemory(pEntry->PairwiseKey.TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);            
+	NdisMoveMemory(pEntry->PairwiseKey.TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
 	pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
-	
-	// Update pairwise key information to ASIC Shared Key Table	   
-	AsicAddSharedKeyEntry(pAd, 
-						  BSS0, 
-						  0, 
+
+	// Update pairwise key information to ASIC Shared Key Table
+	AsicAddSharedKeyEntry(pAd,
+						  BSS0,
+						  0,
 						  pAd->SharedKey[BSS0][0].CipherAlg,
 						  pAd->SharedKey[BSS0][0].Key,
-						  pAd->SharedKey[BSS0][0].TxMic, 
+						  pAd->SharedKey[BSS0][0].TxMic,
 						  pAd->SharedKey[BSS0][0].RxMic);
 
 	// Update ASIC WCID attribute table and IVEIV table
-	RTMPAddWcidAttributeEntry(pAd, 
-							  BSS0, 
-							  0, 
-							  pAd->SharedKey[BSS0][0].CipherAlg, 
+	RTMPAddWcidAttributeEntry(pAd,
+							  BSS0,
+							  0,
+							  pAd->SharedKey[BSS0][0].CipherAlg,
 							  pEntry);
 
 	// Make transmitting frame
-	MakeOutgoingFrame(pOutBuffer,           	&FrameLen,  
+	MakeOutgoingFrame(pOutBuffer,           	&FrameLen,
 			  			LENGTH_802_3,     		&Header802_3,
 						Packet.Body_Len[1] + 4, &Packet,
 						END_OF_ARGS);
@@ -964,9 +964,9 @@ VOID	WpaPairMsg3Action(
 }
 
 VOID    Wpa2PairMsg3Action(
-	IN  PRTMP_ADAPTER   pAd, 
-	IN  MLME_QUEUE_ELEM *Elem) 
-	
+	IN  PRTMP_ADAPTER   pAd,
+	IN  MLME_QUEUE_ELEM *Elem)
+
 {
 	PHEADER_802_11      pHeader;
 	PUCHAR              pOutBuffer = NULL;
@@ -974,7 +974,7 @@ VOID    Wpa2PairMsg3Action(
 	ULONG               FrameLen = 0;
 	EAPOL_PACKET        Packet;
 	PEAPOL_PACKET       pMsg3;
-	UCHAR               Mic[16], OldMic[16];    
+	UCHAR               Mic[16], OldMic[16];
 	UCHAR               *mpool, *KEYDATA, *digest;
 	UCHAR               Key[32];
 	MAC_TABLE_ENTRY 	*pEntry = NULL;
@@ -986,7 +986,7 @@ VOID    Wpa2PairMsg3Action(
 	if(mpool == NULL)
 		return;
 
-	// KEYDATA Len = 512.	    
+	// KEYDATA Len = 512.
 	KEYDATA = (UCHAR *) ROUND_UP(mpool, 4);
 	// digest Len = 80.
 	digest = (UCHAR *) ROUND_UP(KEYDATA + 512, 4);
@@ -1008,7 +1008,7 @@ VOID    Wpa2PairMsg3Action(
 	{
 		os_free_mem(pAd, (PUCHAR)mpool);
 		return;
-	} 
+	}
 	else if(pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled && (peerKeyInfo.KeyDescVer != 1))
 	{
 		os_free_mem(pAd, (PUCHAR)mpool);
@@ -1024,7 +1024,7 @@ VOID    Wpa2PairMsg3Action(
 		// AES
 		HMAC_SHA1((PUCHAR) pMsg3, pMsg3->Body_Len[1] + 4, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
 		NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
-	} 
+	}
 	else
 	{
 		hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, (PUCHAR) pMsg3, pMsg3->Body_Len[1] + 4, Mic);
@@ -1035,7 +1035,7 @@ VOID    Wpa2PairMsg3Action(
 		DBGPRINT(RT_DEBUG_ERROR, (" MIC Different in msg 3 of 4-way handshake!!!!!!!!!! \n"));
 		os_free_mem(pAd, (PUCHAR)mpool);
 		return;
-	} 
+	}
 	else
 		DBGPRINT(RT_DEBUG_TRACE, (" MIC VALID in msg 3 of 4-way handshake!!!!!!!!!! \n"));
 
@@ -1047,7 +1047,7 @@ VOID    Wpa2PairMsg3Action(
 	}
 
 	// Update new replay counter
-	NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);     
+	NdisMoveMemory(pAd->StaCfg.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
 
 	// 4. Double check ANonce
 	if(!NdisEqualMemory(pAd->StaCfg.ANonce, pMsg3->KeyDesc.KeyNonce, LEN_KEY_DESC_NONCE))
@@ -1061,9 +1061,9 @@ VOID    Wpa2PairMsg3Action(
 	DBGPRINT_RAW(RT_DEBUG_TRACE, ("EKD = %d\n", peerKeyInfo.EKD_DL));
 	if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
 	{
-		// Decrypt AES GTK  
-		AES_GTK_KEY_UNWRAP(&pAd->StaCfg.PTK[16], KEYDATA, pMsg3->KeyDesc.KeyDataLen[1],pMsg3->KeyDesc.KeyData);       
-	} 
+		// Decrypt AES GTK
+		AES_GTK_KEY_UNWRAP(&pAd->StaCfg.PTK[16], KEYDATA, pMsg3->KeyDesc.KeyDataLen[1],pMsg3->KeyDesc.KeyData);
+	}
 	else	  // TKIP
 	{
 		INT i;
@@ -1076,30 +1076,30 @@ VOID    Wpa2PairMsg3Action(
 		for(i = 0; i < 256; i++)
 			ARCFOUR_BYTE(&pAd->PrivateInfo.WEPCONTEXT);
 		// Decrypt GTK. Becareful, there is no ICV to check the result is correct or not
-		ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pMsg3->KeyDesc.KeyData, pMsg3->KeyDesc.KeyDataLen[1]);       
+		ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pMsg3->KeyDesc.KeyData, pMsg3->KeyDesc.KeyDataLen[1]);
 	}
 
-	if (!ParseKeyData(pAd, KEYDATA, pMsg3->KeyDesc.KeyDataLen[1], 1)) 
+	if (!ParseKeyData(pAd, KEYDATA, pMsg3->KeyDesc.KeyDataLen[1], 1))
 	{
 		os_free_mem(pAd, (PUCHAR)mpool);
 		return;
 	}
 
 	// Update GTK to ASIC
-	// Update group key information to ASIC Shared Key Table	   
-	AsicAddSharedKeyEntry(pAd, 
-						  BSS0, 
-						  pAd->StaCfg.DefaultKeyId, 
+	// Update group key information to ASIC Shared Key Table
+	AsicAddSharedKeyEntry(pAd,
+						  BSS0,
+						  pAd->StaCfg.DefaultKeyId,
 						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
 						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
-						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, 
+						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
 						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
 
 	// Update ASIC WCID attribute table and IVEIV table
-	RTMPAddWcidAttributeEntry(pAd, 
-							  BSS0, 
-							  pAd->StaCfg.DefaultKeyId, 
-							  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg, 
+	RTMPAddWcidAttributeEntry(pAd,
+							  BSS0,
+							  pAd->StaCfg.DefaultKeyId,
+							  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
 							  NULL);
 
 	// init 802.3 header and Fill Packet
@@ -1133,8 +1133,8 @@ VOID    Wpa2PairMsg3Action(
 	// Convert to little-endian format.
 	*((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
 
-	// Key Replay count 
-	NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);        
+	// Key Replay count
+	NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pMsg3->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
 
 	// Out buffer for transmitting message 4
 	MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer);  // allocate memory
@@ -1157,7 +1157,7 @@ VOID    Wpa2PairMsg3Action(
 		// AES
 		HMAC_SHA1(pOutBuffer, FrameLen, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
 		NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
-	} 
+	}
 	else
 	{
 		hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
@@ -1166,11 +1166,11 @@ VOID    Wpa2PairMsg3Action(
 
 	// Update PTK
 	// Prepare pair-wise key information into shared key table
-	NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));  
+	NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
 	pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
     NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
 	NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
-	NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);            
+	NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
 
 	// Decide its ChiperAlg
 	if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
@@ -1184,27 +1184,27 @@ VOID    Wpa2PairMsg3Action(
 	pEntry = &pAd->MacTab.Content[BSSID_WCID];
 	NdisMoveMemory(&pEntry->PairwiseKey.Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
 	NdisMoveMemory(&pEntry->PairwiseKey.RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
-	NdisMoveMemory(&pEntry->PairwiseKey.TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);            
+	NdisMoveMemory(&pEntry->PairwiseKey.TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
 	pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
 
-	// Update pairwise key information to ASIC Shared Key Table	   
-	AsicAddSharedKeyEntry(pAd, 
-						  BSS0, 
-						  0, 
+	// Update pairwise key information to ASIC Shared Key Table
+	AsicAddSharedKeyEntry(pAd,
+						  BSS0,
+						  0,
 						  pAd->SharedKey[BSS0][0].CipherAlg,
 						  pAd->SharedKey[BSS0][0].Key,
-						  pAd->SharedKey[BSS0][0].TxMic, 
+						  pAd->SharedKey[BSS0][0].TxMic,
 						  pAd->SharedKey[BSS0][0].RxMic);
 
 	// Update ASIC WCID attribute table and IVEIV table
-	RTMPAddWcidAttributeEntry(pAd, 
-							  BSS0, 
-							  0, 
-							  pAd->SharedKey[BSS0][0].CipherAlg, 
+	RTMPAddWcidAttributeEntry(pAd,
+							  BSS0,
+							  0,
+							  pAd->SharedKey[BSS0][0].CipherAlg,
 							  pEntry);
 
 	// Make  Transmitting frame
-	MakeOutgoingFrame(pOutBuffer,           	&FrameLen,  
+	MakeOutgoingFrame(pOutBuffer,           	&FrameLen,
 			  			LENGTH_802_3,     		&Header802_3,
 						Packet.Body_Len[1] + 4, &Packet,
 						END_OF_ARGS);
@@ -1225,7 +1225,7 @@ VOID    Wpa2PairMsg3Action(
 
 	// send wireless event - for set key done WPA2
 	if (pAd->CommonCfg.bWirelessEvent)
-		RTMPSendWirelessEvent(pAd, IW_SET_KEY_DONE_WPA2_EVENT_FLAG, pEntry->Addr, BSS0, 0); 
+		RTMPSendWirelessEvent(pAd, IW_SET_KEY_DONE_WPA2_EVENT_FLAG, pEntry->Addr, BSS0, 0);
 
 	DBGPRINT(RT_DEBUG_ERROR, ("Wpa2PairMsg3Action <-----\n"));
 
@@ -1233,25 +1233,25 @@ VOID    Wpa2PairMsg3Action(
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Process Group key 2-way handshaking
 
 	Arguments:
 		pAd	Pointer	to our adapter
 		Elem		Message body
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	WpaGroupMsg1Action(
-	IN	PRTMP_ADAPTER	pAd, 
-	IN	MLME_QUEUE_ELEM	*Elem) 
-	
+	IN	PRTMP_ADAPTER	pAd,
+	IN	MLME_QUEUE_ELEM	*Elem)
+
 {
 	PUCHAR              pOutBuffer = NULL;
 	UCHAR               Header802_3[14];
@@ -1269,7 +1269,7 @@ VOID	WpaGroupMsg1Action(
 	if(mpool == NULL)
 		return;
 
-	// digest Len = 80.	    
+	// digest Len = 80.
 	digest = (UCHAR *) ROUND_UP(mpool, 4);
 	// KEYDATA Len = 512.
 	KEYDATA = (UCHAR *) ROUND_UP(digest + 80, 4);
@@ -1289,7 +1289,7 @@ VOID	WpaGroupMsg1Action(
 	{
 		os_free_mem(pAd, (PUCHAR)mpool);
 		return;
-	} 
+	}
 	else if (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled && (peerKeyInfo.KeyDescVer != 1))
 	{
 		os_free_mem(pAd, (PUCHAR)mpool);
@@ -1305,7 +1305,7 @@ VOID	WpaGroupMsg1Action(
 	}
 
 	// Update new replay counter
-	NdisMoveMemory(pAd->StaCfg.ReplayCounter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);     
+	NdisMoveMemory(pAd->StaCfg.ReplayCounter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
 
 	// 2. Verify MIC is valid
 	// Save the MIC and replace with zero
@@ -1313,10 +1313,10 @@ VOID	WpaGroupMsg1Action(
 	NdisZeroMemory(pGroup->KeyDesc.KeyMic, LEN_KEY_DESC_MIC);
 
 	if(pAd->StaCfg.WepStatus  == Ndis802_11Encryption3Enabled)
-	{	// AES		
+	{	// AES
 		HMAC_SHA1((PUCHAR) pGroup, pGroup->Body_Len[1] + 4, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
 		NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
-	} 
+	}
 	else
 	{	// TKIP
 		hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, (PUCHAR) pGroup, pGroup->Body_Len[1] + 4, Mic);
@@ -1327,7 +1327,7 @@ VOID	WpaGroupMsg1Action(
 		DBGPRINT(RT_DEBUG_ERROR, (" MIC Different in group msg 1 of 2-way handshake!!!!!!!!!! \n"));
 		MlmeFreeMemory(pAd, (PUCHAR)mpool);
 		return;
-	} 
+	}
 	else
 		DBGPRINT(RT_DEBUG_TRACE, (" MIC VALID in group msg 1 of 2-way handshake!!!!!!!!!! \n"));
 
@@ -1336,7 +1336,7 @@ VOID	WpaGroupMsg1Action(
 	if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
 	{
 		// Decrypt AES GTK
-		AES_GTK_KEY_UNWRAP(&pAd->StaCfg.PTK[16], KEYDATA,  pGroup->KeyDesc.KeyDataLen[1], pGroup->KeyDesc.KeyData);       
+		AES_GTK_KEY_UNWRAP(&pAd->StaCfg.PTK[16], KEYDATA,  pGroup->KeyDesc.KeyDataLen[1], pGroup->KeyDesc.KeyData);
 	}
 	else	// TKIP
 	{
@@ -1351,7 +1351,7 @@ VOID	WpaGroupMsg1Action(
 		for(i = 0; i < 256; i++)
 			ARCFOUR_BYTE(&pAd->PrivateInfo.WEPCONTEXT);
 		// Decrypt GTK. Becareful, there is no ICV to check the result is correct or not
-		ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pGroup->KeyDesc.KeyData, pGroup->KeyDesc.KeyDataLen[1]);        		
+		ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, KEYDATA, pGroup->KeyDesc.KeyData, pGroup->KeyDesc.KeyDataLen[1]);
 	}
 
 	// Process decrypted key data material
@@ -1372,7 +1372,7 @@ VOID	WpaGroupMsg1Action(
 		pAd->StaCfg.DefaultKeyId = peerKeyInfo.KeyIndex;
 
 		// Prepare pair-wise key information into shared key table
-		NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));  
+		NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
 		pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
 		NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, GTK, LEN_TKIP_EK);
 		NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, &GTK[16], LEN_TKIP_RXMICK);
@@ -1388,22 +1388,22 @@ VOID	WpaGroupMsg1Action(
     	//hex_dump("Group Key :", pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, LEN_TKIP_EK);
 	}
 
-	// Update group key information to ASIC Shared Key Table	   
-	AsicAddSharedKeyEntry(pAd, 
-						  BSS0, 
-						  pAd->StaCfg.DefaultKeyId, 
+	// Update group key information to ASIC Shared Key Table
+	AsicAddSharedKeyEntry(pAd,
+						  BSS0,
+						  pAd->StaCfg.DefaultKeyId,
 						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
 						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
-						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, 
+						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
 						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
 
 	// Update ASIC WCID attribute table and IVEIV table
-	RTMPAddWcidAttributeEntry(pAd, 
-							  BSS0, 
-							  pAd->StaCfg.DefaultKeyId, 
-							  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg, 
+	RTMPAddWcidAttributeEntry(pAd,
+							  BSS0,
+							  pAd->StaCfg.DefaultKeyId,
+							  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
 							  NULL);
-	 
+
 	// set 802.1x port control
 	STA_PORT_SECURED(pAd);
 
@@ -1411,7 +1411,7 @@ VOID	WpaGroupMsg1Action(
     pAd->IndicateMediaState = NdisMediaStateConnected;
 
 	// init header and Fill Packet
-	MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);		
+	MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
 
 	// Zero Group message 1 body
 	NdisZeroMemory(&Packet, sizeof(Packet));
@@ -1434,9 +1434,9 @@ VOID	WpaGroupMsg1Action(
 	// Key descriptor version and appropriate RSN IE
 	Packet.KeyDesc.KeyInfo.KeyDescVer = peerKeyInfo.KeyDescVer;
 
-	// Update Key Length	
+	// Update Key Length
 	Packet.KeyDesc.KeyLength[0] = pGroup->KeyDesc.KeyLength[0];
-	Packet.KeyDesc.KeyLength[1] = pGroup->KeyDesc.KeyLength[1]; 
+	Packet.KeyDesc.KeyLength[1] = pGroup->KeyDesc.KeyLength[1];
 
 	// Key Index as G-Msg 1
 	if(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
@@ -1454,15 +1454,15 @@ VOID	WpaGroupMsg1Action(
 	// Convert to little-endian format.
 	*((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
 
-	// Key Replay count	
-	NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);       
+	// Key Replay count
+	NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pGroup->KeyDesc.ReplayCounter, LEN_KEY_DESC_REPLAY);
 
 	// Out buffer for transmitting group message 2
 	MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer);  // allocate memory
 	if(pOutBuffer == NULL)
 	{
 		MlmeFreeMemory(pAd, (PUCHAR)mpool);
-		return;         
+		return;
 	}
 
 	// Prepare EAPOL frame for MIC calculation
@@ -1478,7 +1478,7 @@ VOID	WpaGroupMsg1Action(
 		// AES
 		HMAC_SHA1(pOutBuffer, FrameLen, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
 		NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
-	} 
+	}
 	else
 	{
 		hmac_md5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
@@ -1486,7 +1486,7 @@ VOID	WpaGroupMsg1Action(
 	NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
 
 
-	MakeOutgoingFrame(pOutBuffer,       		&FrameLen, 
+	MakeOutgoingFrame(pOutBuffer,       		&FrameLen,
 						LENGTH_802_3,     		&Header802_3,
 						Packet.Body_Len[1] + 4, &Packet,
 						END_OF_ARGS);
@@ -1501,64 +1501,64 @@ VOID	WpaGroupMsg1Action(
 
 	// send wireless event - for set key done WPA2
 	if (pAd->CommonCfg.bWirelessEvent)
-		RTMPSendWirelessEvent(pAd, IW_SET_KEY_DONE_WPA2_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); 
+		RTMPSendWirelessEvent(pAd, IW_SET_KEY_DONE_WPA2_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
 
 	DBGPRINT(RT_DEBUG_TRACE, ("WpaGroupMsg1Action <-----\n"));
 }
 
 /*
 	========================================================================
-	
+
 	Routine Description:
 		Init WPA MAC header
 
 	Arguments:
 		pAd	Pointer	to our adapter
-		
+
 	Return Value:
 		None
-		
+
 	Note:
-		
+
 	========================================================================
 */
 VOID	WpaMacHeaderInit(
-	IN		PRTMP_ADAPTER	pAd, 
-	IN OUT	PHEADER_802_11	pHdr80211, 
-	IN		UCHAR			wep, 
-	IN		PUCHAR		    pAddr1)	
+	IN		PRTMP_ADAPTER	pAd,
+	IN OUT	PHEADER_802_11	pHdr80211,
+	IN		UCHAR			wep,
+	IN		PUCHAR		    pAddr1)
 {
 	NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
-	pHdr80211->FC.Type	= BTYPE_DATA;	
+	pHdr80211->FC.Type	= BTYPE_DATA;
 	pHdr80211->FC.ToDs	= 1;
 	if (wep	== 1)
 		pHdr80211->FC.Wep = 1;
-	
+
 	 //	Addr1: BSSID, Addr2: SA, Addr3:	DA
 	COPY_MAC_ADDR(pHdr80211->Addr1, pAddr1);
 	COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
 	COPY_MAC_ADDR(pHdr80211->Addr3, pAd->CommonCfg.Bssid);
-	pHdr80211->Sequence =	pAd->Sequence;		
+	pHdr80211->Sequence =	pAd->Sequence;
 }
 
 /*
 	========================================================================
 
 	Routine	Description:
-		Copy frame from waiting queue into relative ring buffer and set 
+		Copy frame from waiting queue into relative ring buffer and set
 	appropriate ASIC register to kick hardware encryption before really
 	sent out to air.
-		
+
 	Arguments:
 		pAd		Pointer	to our adapter
 		PNDIS_PACKET	Pointer to outgoing Ndis frame
 		NumberOfFrag	Number of fragment required
-		
+
 	Return Value:
 		None
 
 	Note:
-	
+
 	========================================================================
 */
 VOID    RTMPToWirelessSta(
@@ -1568,7 +1568,7 @@ VOID    RTMPToWirelessSta(
 	IN  PUCHAR          pData,
     IN  UINT            DataLen,
     IN	BOOLEAN			is4wayFrame)
-	
+
 {
 	NDIS_STATUS     Status;
 	PNDIS_PACKET    pPacket;
@@ -1596,7 +1596,7 @@ VOID    RTMPToWirelessSta(
 			// 1. Here, right after queueing the frame.
 			// 2. At the end of TxRingTxDone service routine.
 			// 3. Upon NDIS call RTMPSendPackets
-			if((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) && 
+			if((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) &&
 				(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)))
 			{
 				for(Index = 0; Index < 5; Index ++)
@@ -1610,47 +1610,47 @@ VOID    RTMPToWirelessSta(
 
 /*
     ========================================================================
-    
+
     Routine Description:
     Check Sanity RSN IE form AP
 
     Arguments:
-        
+
     Return Value:
 
-		
+
     ========================================================================
 */
 BOOLEAN CheckRSNIE(
 	IN  PRTMP_ADAPTER   pAd,
 	IN  PUCHAR          pData,
-	IN  UCHAR           DataLen,	
+	IN  UCHAR           DataLen,
 	OUT	UCHAR			*Offset)
 {
 	PUCHAR              pVIE;
 	UCHAR               len;
 	PEID_STRUCT         pEid;
 	BOOLEAN				result = FALSE;
-		
+
 	pVIE = pData;
 	len	 = DataLen;
 	*Offset = 0;
 
 	while (len > sizeof(RSNIE2))
 	{
-		pEid = (PEID_STRUCT) pVIE;	
+		pEid = (PEID_STRUCT) pVIE;
 		// WPA RSN IE
 		if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4)))
-		{			
+		{
 			if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) &&
 				(NdisEqualMemory(pVIE, pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len)) &&
 				(pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == (pEid->Len + 2)))
-			{				
+			{
 					DBGPRINT(RT_DEBUG_TRACE, ("CheckRSNIE ==> WPA/WPAPSK RSN IE matched in Msg 3, Length(%d) \n", (pEid->Len + 2)));
-					result = TRUE;				
-			}		
-			
-			*Offset += (pEid->Len + 2);			
+					result = TRUE;
+			}
+
+			*Offset += (pEid->Len + 2);
 		}
 		// WPA2 RSN IE
 		else if ((pEid->Eid == IE_RSN) && (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3)))
@@ -1658,43 +1658,43 @@ BOOLEAN CheckRSNIE(
 			if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2 || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) &&
 				(NdisEqualMemory(pVIE, pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len)) &&
 				(pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == (pEid->Len + 2)))
-			{				
+			{
 					DBGPRINT(RT_DEBUG_TRACE, ("CheckRSNIE ==> WPA2/WPA2PSK RSN IE matched in Msg 3, Length(%d) \n", (pEid->Len + 2)));
-					result = TRUE;				
-			}				
+					result = TRUE;
+			}
 
 			*Offset += (pEid->Len + 2);
-		}		
+		}
 		else
-		{			
+		{
 			break;
 		}
 
 		pVIE += (pEid->Len + 2);
 		len  -= (pEid->Len + 2);
 	}
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("CheckRSNIE ==> skip_offset(%d) \n", *Offset));
-		
+
 	return result;
-	
+
 }
 
 
 /*
     ========================================================================
-    
+
     Routine Description:
-    Parse KEYDATA field.  KEYDATA[] May contain 2 RSN IE and optionally GTK.  
+    Parse KEYDATA field.  KEYDATA[] May contain 2 RSN IE and optionally GTK.
     GTK  is encaptulated in KDE format at  p.83 802.11i D10
 
     Arguments:
-        
+
     Return Value:
 
     Note:
-        802.11i D10  
-        
+        802.11i D10
+
     ========================================================================
 */
 BOOLEAN ParseKeyData(
@@ -1708,16 +1708,16 @@ BOOLEAN ParseKeyData(
     UCHAR               KeyDataLength = KeyDataLen;
     UCHAR               GTKLEN;
 	UCHAR				skip_offset;
-    
+
 	// Verify The RSN IE contained in Pairewise-Msg 3 and skip it
 	if (bPairewise)
     {
-		// Check RSN IE whether it is WPA2/WPA2PSK   		
+		// Check RSN IE whether it is WPA2/WPA2PSK
 		if (!CheckRSNIE(pAd, pKeyData, KeyDataLen, &skip_offset))
 		{
 			DBGPRINT(RT_DEBUG_ERROR, ("ParseKeyData ==> WPA2/WPA2PSK RSN IE mismatched \n"));
 			hex_dump("Get KEYDATA :", pKeyData, KeyDataLen);
-			return FALSE;			
+			return FALSE;
     	}
     	else
 		{
@@ -1741,20 +1741,20 @@ BOOLEAN ParseKeyData(
 		DBGPRINT(RT_DEBUG_ERROR, ("ERROR: KeyDataLength is too short \n"));
         return FALSE;
     }
-    
-    
+
+
 	// Sanity check - shared key index should not be 0
 	if (pKDE->GTKEncap.Kid == 0)
     {
         DBGPRINT(RT_DEBUG_ERROR, ("ERROR: GTK Key index zero \n"));
         return FALSE;
-    }   
-    
+    }
+
 	// Sanity check - KED length
 	if (KeyDataLength < (pKDE->Len + 2))
     {
         DBGPRINT(RT_DEBUG_ERROR, ("ERROR: The len from KDE is too short \n"));
-        return FALSE;			
+        return FALSE;
     }
 
 	// Get GTK length - refer to IEEE 802.11i-2004 p.82
@@ -1769,12 +1769,12 @@ BOOLEAN ParseKeyData(
 		DBGPRINT(RT_DEBUG_TRACE, ("GTK Key with KDE formet got index=%d, len=%d \n", pKDE->GTKEncap.Kid, GTKLEN));
 
 	// Update GTK
-	// set key material, TxMic and RxMic for WPAPSK	
+	// set key material, TxMic and RxMic for WPAPSK
 	NdisMoveMemory(pAd->StaCfg.GTK, pKDE->GTKEncap.GTK, 32);
 	pAd->StaCfg.DefaultKeyId = pKDE->GTKEncap.Kid;
 
 	// Update shared key table
-	NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));  
+	NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
 	pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
 	NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKDE->GTKEncap.GTK, LEN_TKIP_EK);
 	NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, &pKDE->GTKEncap.GTK[16], LEN_TKIP_RXMICK);
@@ -1788,14 +1788,14 @@ BOOLEAN ParseKeyData(
 		pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
 
 	return TRUE;
- 
+
 }
 
 /*
 	========================================================================
 
 	Routine Description:
-		Cisco CCKM PRF function 
+		Cisco CCKM PRF function
 
 	Arguments:
 		key				Cisco Base Transient Key (BTK)
@@ -1809,7 +1809,7 @@ BOOLEAN ParseKeyData(
 
 	Note:
 		802.1i	Annex F.9
-		
+
 	========================================================================
 */
 VOID CCKMPRF(
@@ -1824,7 +1824,7 @@ VOID CCKMPRF(
 	UCHAR	input[1024];
 	INT		currentindex = 0;
 	INT		total_len;
-	
+
 	NdisMoveMemory(input, data, data_len);
 	total_len = data_len;
 	input[total_len] = 0;
@@ -1834,7 +1834,7 @@ VOID CCKMPRF(
 		HMAC_SHA1(input, total_len,	key, key_len, &output[currentindex]);
 		currentindex +=	20;
 		input[total_len - 1]++;
-	}	
+	}
 }
 
 /*
@@ -1842,22 +1842,22 @@ VOID CCKMPRF(
 
 	Routine Description:
 		Process MIC error indication and record MIC error timer.
-		
+
 	Arguments:
 		pAd 	Pointer to our adapter
 		pWpaKey 		Pointer to the WPA key structure
-		
+
 	Return Value:
 		None
-		
+
 	IRQL = DISPATCH_LEVEL
-	
+
 	Note:
-	
+
 	========================================================================
 */
 VOID	RTMPReportMicError(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PCIPHER_KEY 	pWpaKey)
 {
 	ULONG	Now;
@@ -1869,24 +1869,24 @@ VOID	RTMPReportMicError(
 	{
 		pAd->StaCfg.MicErrCnt++;
 		pAd->StaCfg.LastMicErrorTime = Now;
-        NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);        
+        NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
 	}
 	else if (pAd->StaCfg.MicErrCnt == 1)
 	{
 		if ((pAd->StaCfg.LastMicErrorTime + (60 * OS_HZ)) < Now)
 		{
 			// Update Last MIC error time, this did not violate two MIC errors within 60 seconds
-			pAd->StaCfg.LastMicErrorTime = Now; 		
+			pAd->StaCfg.LastMicErrorTime = Now;
 		}
 		else
 		{
 
 			if (pAd->CommonCfg.bWirelessEvent)
-				RTMPSendWirelessEvent(pAd, IW_COUNTER_MEASURES_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0); 
+				RTMPSendWirelessEvent(pAd, IW_COUNTER_MEASURES_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
 
-			pAd->StaCfg.LastMicErrorTime = Now; 		
+			pAd->StaCfg.LastMicErrorTime = Now;
 			// Violate MIC error counts, MIC countermeasures kicks in
-			pAd->StaCfg.MicErrCnt++;			
+			pAd->StaCfg.MicErrCnt++;
 		}
 	}
 	else
@@ -1895,7 +1895,7 @@ VOID	RTMPReportMicError(
 		// This should not happen
 		;
 	}
-    MlmeEnqueue(pAd, 
+    MlmeEnqueue(pAd,
 				MLME_CNTL_STATE_MACHINE,
 				OID_802_11_MIC_FAILURE_REPORT_FRAME,
 				1,
@@ -1917,15 +1917,15 @@ INT	    WpaCheckEapCode(
 	IN  USHORT				FrameLen,
 	IN  USHORT				OffSet)
 {
-	
+
 	PUCHAR	pData;
 	INT	result = 0;
-		
-	if( FrameLen < OffSet + LENGTH_EAPOL_H + LENGTH_EAP_H ) 
+
+	if( FrameLen < OffSet + LENGTH_EAPOL_H + LENGTH_EAP_H )
 		return result;
-		
+
 	pData = pFrame + OffSet; // skip offset bytes
- 	
+
 	if(*(pData+1) == EAPPacket) 	// 802.1x header - Packet Type
 	{
 		 result = *(pData+4);		// EAP header - Code
@@ -1937,10 +1937,10 @@ INT	    WpaCheckEapCode(
 VOID    WpaSendMicFailureToWpaSupplicant(
     IN  PRTMP_ADAPTER    pAd,
     IN  BOOLEAN          bUnicast)
-{    
+{
     union iwreq_data    wrqu;
     char custom[IW_CUSTOM_MAX] = {0};
-    
+
     sprintf(custom, "MLME-MICHAELMICFAILURE.indication");
     if (bUnicast)
         sprintf(custom, "%s unicast", custom);
@@ -1961,28 +1961,28 @@ VOID	WpaMicFailureReportFrame(
 	EAPOL_PACKET        Packet;
 	UCHAR               Mic[16];
     BOOLEAN             bUnicast;
-        
+
 	DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame ----->\n"));
 
     bUnicast = (Elem->Msg[0] == 1 ? TRUE:FALSE);
 	pAd->Sequence = ((pAd->Sequence) + 1) & (MAX_SEQ_NUMBER);
 
 	// init 802.3 header and Fill Packet
-	MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);	
+	MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
 
 	NdisZeroMemory(&Packet, sizeof(Packet));
 	Packet.ProVer	= EAPOL_VER;
 	Packet.ProType	= EAPOLKey;
-	
+
 	Packet.KeyDesc.Type = WPA1_KEY_DESC;
 
     // Request field presented
     Packet.KeyDesc.KeyInfo.Request = 1;
-    
+
 	if(pAd->StaCfg.WepStatus  == Ndis802_11Encryption3Enabled)
 	{
 		Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
-	} 
+	}
 	else	  // TKIP
 	{
 		Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
@@ -1995,7 +1995,7 @@ VOID	WpaMicFailureReportFrame(
 
     // Error field presented
 	Packet.KeyDesc.KeyInfo.Error  = 1;
-    
+
 	// Update packet length after decide Key data payload
 	Packet.Body_Len[1]  = sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE;
 
@@ -2012,7 +2012,7 @@ VOID	WpaMicFailureReportFrame(
 	{
 		return;
 	}
-    
+
 	// Prepare EAPOL frame for MIC calculation
 	// Be careful, only EAPOL frame is counted for MIC calculation
 	MakeOutgoingFrame(pOutBuffer,               &FrameLen,
@@ -2026,14 +2026,14 @@ VOID	WpaMicFailureReportFrame(
         UCHAR digest[20] = {0};
 		HMAC_SHA1(pOutBuffer, FrameLen, pAd->StaCfg.PTK, LEN_EAP_MICK, digest);
 		NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
-	} 
+	}
 	else
 	{	// TKIP
 		hmac_md5(pAd->StaCfg.PTK,  LEN_EAP_MICK, pOutBuffer, FrameLen, Mic);
 	}
 	NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
 
-    MakeOutgoingFrame(pOutBuffer,           	&FrameLen,  
+    MakeOutgoingFrame(pOutBuffer,           	&FrameLen,
     	  			LENGTH_802_3,     			&Header802_3,
     				Packet.Body_Len[1] + 4,     &Packet,
     				END_OF_ARGS);
@@ -2067,10 +2067,10 @@ void inc_byte_array(UCHAR *counter, int len)
 }
 
 VOID WpaDisassocApAndBlockAssoc(
-    IN PVOID SystemSpecific1, 
-    IN PVOID FunctionContext, 
-    IN PVOID SystemSpecific2, 
-    IN PVOID SystemSpecific3) 
+    IN PVOID SystemSpecific1,
+    IN PVOID FunctionContext,
+    IN PVOID SystemSpecific2,
+    IN PVOID SystemSpecific3)
 {
     RTMP_ADAPTER                *pAd = (PRTMP_ADAPTER)FunctionContext;
     MLME_DISASSOC_REQ_STRUCT    DisassocReq;
diff --git a/os/linux/sta_ioctl.c b/sta_ioctl.c
similarity index 92%
rename from os/linux/sta_ioctl.c
rename to sta_ioctl.c
index 5f555e7..87bf505 100644
--- a/os/linux/sta_ioctl.c
+++ b/sta_ioctl.c
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
     Module Name:
@@ -74,7 +74,7 @@ typedef struct PACKED _RT_VERSION_INFO{
 } RT_VERSION_INFO, *PRT_VERSION_INFO;
 
 struct iw_priv_args privtab[] = {
-{ RTPRIV_IOCTL_SET, 
+{ RTPRIV_IOCTL_SET,
   IW_PRIV_TYPE_CHAR | 1024, 0,
   "set"},
 
@@ -82,7 +82,7 @@ struct iw_priv_args privtab[] = {
   ""},
 { RTPRIV_IOCTL_SHOW, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
   ""},
-/* --- sub-ioctls definitions --- */   
+/* --- sub-ioctls definitions --- */
     { SHOW_CONN_STATUS,
 	  0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "connStatus" },
 	{ SHOW_DRVIER_VERION,
@@ -109,7 +109,7 @@ struct iw_priv_args privtab[] = {
   "bbp"},
 { RTPRIV_IOCTL_MAC,
   IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
-  "mac"},  
+  "mac"},
 { RTPRIV_IOCTL_E2P,
   IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024,
   "e2p"},
@@ -117,66 +117,66 @@ struct iw_priv_args privtab[] = {
 
 { RTPRIV_IOCTL_STATISTICS,
   0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK,
-  "stat"}, 
+  "stat"},
 { RTPRIV_IOCTL_GSITESURVEY,
   0, IW_PRIV_TYPE_CHAR | 1024,
   "get_site_survey"},
 };
 
 INT Set_SSID_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
 
 #ifdef WMM_SUPPORT
 INT	Set_WmmCapable_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 #endif
 
 INT Set_NetworkType_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
 
 INT Set_AuthMode_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
 
 INT Set_EncrypType_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
 
 INT Set_DefaultKeyID_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
 
 INT Set_Key1_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
 
 INT Set_Key2_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
 
 INT Set_Key3_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
 
 INT Set_Key4_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
 
 INT Set_WPAPSK_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
 
 
 INT Set_PSMode_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
 
 #ifdef WPA_SUPPLICANT_SUPPORT
 INT Set_Wpa_Support(
-    IN	PRTMP_ADAPTER	pAd, 
+    IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg);
 #endif // WPA_SUPPLICANT_SUPPORT //
 
@@ -186,7 +186,7 @@ VOID RTMPIoctlBBP(
 	IN	struct iwreq	*wrq);
 
 VOID RTMPIoctlMAC(
-	IN	PRTMP_ADAPTER	pAdapter, 
+	IN	PRTMP_ADAPTER	pAdapter,
 	IN	struct iwreq	*wrq);
 
 VOID RTMPIoctlE2PROM(
@@ -198,34 +198,34 @@ VOID RTMPIoctlE2PROM(
 NDIS_STATUS RTMPWPANoneAddKeyProc(
     IN  PRTMP_ADAPTER   pAd,
     IN	PVOID			pBuf);
-	
+
 INT Set_FragTest_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
-	
-#ifdef DOT11_N_SUPPORT	
+
+#ifdef DOT11_N_SUPPORT
 INT Set_TGnWifiTest_Proc(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
     IN  PUCHAR          arg);
 #endif // DOT11_N_SUPPORT //
 
 INT Set_LongRetryLimit_Proc(
-	IN	PRTMP_ADAPTER	pAdapter, 
+	IN	PRTMP_ADAPTER	pAdapter,
 	IN	PUCHAR			arg);
 
 INT Set_ShortRetryLimit_Proc(
-	IN	PRTMP_ADAPTER	pAdapter, 
+	IN	PRTMP_ADAPTER	pAdapter,
 	IN	PUCHAR			arg);
 
 #ifdef EXT_BUILD_CHANNEL_LIST
 INT Set_Ieee80211dClientMode_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg);
 #endif // EXT_BUILD_CHANNEL_LIST //
 
 #ifdef CARRIER_DETECTION_SUPPORT
 INT Set_CarrierDetect_Proc(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
     IN  PUCHAR          arg);
 #endif // CARRIER_DETECTION_SUPPORT //
 
@@ -234,17 +234,17 @@ static struct {
 	INT (*set_proc)(PRTMP_ADAPTER pAdapter, PUCHAR arg);
 } *PRTMP_PRIVATE_SET_PROC, RTMP_PRIVATE_SUPPORT_PROC[] = {
 	{"DriverVersion",				Set_DriverVersion_Proc},
-	{"CountryRegion",				Set_CountryRegion_Proc},	
-	{"CountryRegionABand",			Set_CountryRegionABand_Proc},      
-	{"SSID",						Set_SSID_Proc}, 
-	{"WirelessMode",				Set_WirelessMode_Proc},       
+	{"CountryRegion",				Set_CountryRegion_Proc},
+	{"CountryRegionABand",			Set_CountryRegionABand_Proc},
+	{"SSID",						Set_SSID_Proc},
+	{"WirelessMode",				Set_WirelessMode_Proc},
 	{"TxBurst",					Set_TxBurst_Proc},
 	{"TxPreamble",				Set_TxPreamble_Proc},
 	{"TxPower",					Set_TxPower_Proc},
-	{"Channel",					Set_Channel_Proc},            
+	{"Channel",					Set_Channel_Proc},
 	{"BGProtection",				Set_BGProtection_Proc},
-	{"RTSThreshold",				Set_RTSThreshold_Proc},       
-	{"FragThreshold",				Set_FragThreshold_Proc},      
+	{"RTSThreshold",				Set_RTSThreshold_Proc},
+	{"FragThreshold",				Set_FragThreshold_Proc},
 #ifdef DOT11_N_SUPPORT
 	{"HtBw",		                Set_HtBw_Proc},
 	{"HtMcs",		                Set_HtMcs_Proc},
@@ -260,29 +260,29 @@ static struct {
 	{"HtProtect",		        	Set_HtProtect_Proc},
 	{"HtMimoPs",		        	Set_HtMimoPs_Proc},
 #endif // DOT11_N_SUPPORT //
-	
+
 #ifdef AGGREGATION_SUPPORT
-	{"PktAggregate",				Set_PktAggregate_Proc},       
+	{"PktAggregate",				Set_PktAggregate_Proc},
 #endif
 
 #ifdef WMM_SUPPORT
-	{"WmmCapable",					Set_WmmCapable_Proc},         
-#endif         
+	{"WmmCapable",					Set_WmmCapable_Proc},
+#endif
 	{"IEEE80211H",					Set_IEEE80211H_Proc},
-    {"NetworkType",                 Set_NetworkType_Proc},        
-	{"AuthMode",					Set_AuthMode_Proc},           
-	{"EncrypType",					Set_EncrypType_Proc},         
-	{"DefaultKeyID",				Set_DefaultKeyID_Proc},       
-	{"Key1",						Set_Key1_Proc},               
-	{"Key2",						Set_Key2_Proc},               
-	{"Key3",						Set_Key3_Proc},               
-	{"Key4",						Set_Key4_Proc},               
+    {"NetworkType",                 Set_NetworkType_Proc},
+	{"AuthMode",					Set_AuthMode_Proc},
+	{"EncrypType",					Set_EncrypType_Proc},
+	{"DefaultKeyID",				Set_DefaultKeyID_Proc},
+	{"Key1",						Set_Key1_Proc},
+	{"Key2",						Set_Key2_Proc},
+	{"Key3",						Set_Key3_Proc},
+	{"Key4",						Set_Key4_Proc},
 	{"WPAPSK",						Set_WPAPSK_Proc},
 	{"ResetCounter",				Set_ResetStatCounter_Proc},
 	{"PSMode",                      Set_PSMode_Proc},
 #ifdef DBG
-	{"Debug",						Set_Debug_Proc},             
-#endif          
+	{"Debug",						Set_Debug_Proc},
+#endif
 
 #ifdef RALINK_ATE
 	{"ATE",							Set_ATE_Proc},
@@ -314,7 +314,7 @@ static struct {
 
 #ifdef RALINK_28xx_QA
 	{"TxStop",						Set_TxStop_Proc},
-	{"RxStop",						Set_RxStop_Proc},	
+	{"RxStop",						Set_RxStop_Proc},
 #endif // RALINK_28xx_QA //
 #endif // RALINK_ATE //
 
@@ -350,12 +350,12 @@ static struct {
 
 
 VOID RTMPAddKey(
-	IN	PRTMP_ADAPTER	    pAd, 
+	IN	PRTMP_ADAPTER	    pAd,
 	IN	PNDIS_802_11_KEY    pKey)
 {
 	ULONG				KeyIdx;
 	MAC_TABLE_ENTRY  	*pEntry;
-		
+
     DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey ------>\n"));
 
 	if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
@@ -369,19 +369,19 @@ VOID RTMPAddKey(
                 goto end;
             }
 		    // Update PTK
-		    NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));  
+		    NdisZeroMemory(&pAd->SharedKey[BSS0][0], sizeof(CIPHER_KEY));
             pAd->SharedKey[BSS0][0].KeyLen = LEN_TKIP_EK;
             NdisMoveMemory(pAd->SharedKey[BSS0][0].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-#ifdef WPA_SUPPLICANT_SUPPORT            
+#ifdef WPA_SUPPLICANT_SUPPORT
             if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
             {
-                NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);            
+                NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
                 NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
             }
             else
 #endif // WPA_SUPPLICANT_SUPPORT //
             {
-            	NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);            
+            	NdisMoveMemory(pAd->SharedKey[BSS0][0].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
                 NdisMoveMemory(pAd->SharedKey[BSS0][0].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
             }
 
@@ -391,58 +391,58 @@ VOID RTMPAddKey(
         	else if (pAd->StaCfg.PairCipher == Ndis802_11Encryption3Enabled)
         		pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_AES;
         	else
-        		pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE; 
+        		pAd->SharedKey[BSS0][0].CipherAlg = CIPHER_NONE;
 
             // Update these related information to MAC_TABLE_ENTRY
         	pEntry = &pAd->MacTab.Content[BSSID_WCID];
-            NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);            
+            NdisMoveMemory(pEntry->PairwiseKey.Key, pAd->SharedKey[BSS0][0].Key, LEN_TKIP_EK);
         	NdisMoveMemory(pEntry->PairwiseKey.RxMic, pAd->SharedKey[BSS0][0].RxMic, LEN_TKIP_RXMICK);
         	NdisMoveMemory(pEntry->PairwiseKey.TxMic, pAd->SharedKey[BSS0][0].TxMic, LEN_TKIP_TXMICK);
         	pEntry->PairwiseKey.CipherAlg = pAd->SharedKey[BSS0][0].CipherAlg;
 
-        	// Update pairwise key information to ASIC Shared Key Table	   
-        	AsicAddSharedKeyEntry(pAd, 
-        						  BSS0, 
-        						  0, 
+        	// Update pairwise key information to ASIC Shared Key Table
+        	AsicAddSharedKeyEntry(pAd,
+        						  BSS0,
+        						  0,
         						  pAd->SharedKey[BSS0][0].CipherAlg,
         						  pAd->SharedKey[BSS0][0].Key,
-        						  pAd->SharedKey[BSS0][0].TxMic, 
+        						  pAd->SharedKey[BSS0][0].TxMic,
         						  pAd->SharedKey[BSS0][0].RxMic);
 
         	// Update ASIC WCID attribute table and IVEIV table
-        	RTMPAddWcidAttributeEntry(pAd, 
-        							  BSS0, 
-        							  0, 
-        							  pAd->SharedKey[BSS0][0].CipherAlg, 
+        	RTMPAddWcidAttributeEntry(pAd,
+        							  BSS0,
+        							  0,
+        							  pAd->SharedKey[BSS0][0].CipherAlg,
         							  pEntry);
 
             if (pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA2)
             {
                 // set 802.1x port control
 				STA_PORT_SECURED(pAd);
-                
+
                 // Indicate Connected for GUI
                 pAd->IndicateMediaState = NdisMediaStateConnected;
             }
 		}
         else
         {
-            // Update GTK            
+            // Update GTK
             pAd->StaCfg.DefaultKeyId = (pKey->KeyIndex & 0xFF);
-            NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));  
+            NdisZeroMemory(&pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId], sizeof(CIPHER_KEY));
             pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen = LEN_TKIP_EK;
             NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key, pKey->KeyMaterial, LEN_TKIP_EK);
-#ifdef WPA_SUPPLICANT_SUPPORT            
+#ifdef WPA_SUPPLICANT_SUPPORT
             if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption2Enabled)
             {
-                NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);            
-                NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);        	
+                NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
+                NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
             }
             else
-#endif // WPA_SUPPLICANT_SUPPORT //                
+#endif // WPA_SUPPLICANT_SUPPORT //
             {
-            	NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);            
-                NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);        	
+            	NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, pKey->KeyMaterial + LEN_TKIP_EK, LEN_TKIP_TXMICK);
+                NdisMoveMemory(pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic, pKey->KeyMaterial + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
             }
 
             // Update Shared Key CipherAlg
@@ -452,20 +452,20 @@ VOID RTMPAddKey(
     		else if (pAd->StaCfg.GroupCipher == Ndis802_11Encryption3Enabled)
     			pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg = CIPHER_AES;
 
-            // Update group key information to ASIC Shared Key Table	   
-        	AsicAddSharedKeyEntry(pAd, 
-        						  BSS0, 
-        						  pAd->StaCfg.DefaultKeyId, 
+            // Update group key information to ASIC Shared Key Table
+        	AsicAddSharedKeyEntry(pAd,
+        						  BSS0,
+        						  pAd->StaCfg.DefaultKeyId,
         						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
         						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
-        						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic, 
+        						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].TxMic,
         						  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].RxMic);
 
         	// Update ASIC WCID attribute table and IVEIV table
-        	RTMPAddWcidAttributeEntry(pAd, 
-        							  BSS0, 
-        							  pAd->StaCfg.DefaultKeyId, 
-        							  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg, 
+        	RTMPAddWcidAttributeEntry(pAd,
+        							  BSS0,
+        							  pAd->StaCfg.DefaultKeyId,
+        							  pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].CipherAlg,
         							  NULL);
 
             // set 802.1x port control
@@ -482,7 +482,7 @@ VOID RTMPAddKey(
 
 		if(pKey->KeyLength == 32)
 			goto end;
-		
+
 		KeyIdx = pKey->KeyIndex & 0x0fffffff;
 
 		if (KeyIdx < 4)
@@ -495,58 +495,58 @@ VOID RTMPAddKey(
 				if (pEntry)
 				{
 					DBGPRINT(RT_DEBUG_TRACE, ("RTMPAddKey: Set Pair-wise Key\n"));
-		
+
 					// set key material and key length
  					pEntry->PairwiseKey.KeyLen = (UCHAR)pKey->KeyLength;
 					NdisMoveMemory(pEntry->PairwiseKey.Key, &pKey->KeyMaterial, pKey->KeyLength);
-					
+
 					// set Cipher type
 					if (pKey->KeyLength == 5)
 						pEntry->PairwiseKey.CipherAlg = CIPHER_WEP64;
 					else
 						pEntry->PairwiseKey.CipherAlg = CIPHER_WEP128;
-						
+
 					// Add Pair-wise key to Asic
 					AsicAddPairwiseKeyEntry(
-						pAd, 
-						pEntry->Addr, 
+						pAd,
+						pEntry->Addr,
 						(UCHAR)pEntry->Aid,
                 		&pEntry->PairwiseKey);
 
 					// update WCID attribute table and IVEIV table for this entry
 					RTMPAddWcidAttributeEntry(
-						pAd, 
-						BSS0, 
+						pAd,
+						BSS0,
 						KeyIdx, // The value may be not zero
-						pEntry->PairwiseKey.CipherAlg, 
+						pEntry->PairwiseKey.CipherAlg,
 						pEntry);
 
-				}	
+				}
 			}
-			else	
+			else
             {
 				// Default key for tx (shared key)
 				pAd->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
-                     
+
 				// set key material and key length
 				pAd->SharedKey[BSS0][KeyIdx].KeyLen = (UCHAR) pKey->KeyLength;
 				NdisMoveMemory(pAd->SharedKey[BSS0][KeyIdx].Key, &pKey->KeyMaterial, pKey->KeyLength);
-				
+
 				// Set Ciper type
 				if (pKey->KeyLength == 5)
 					pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP64;
 				else
 					pAd->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_WEP128;
-			
+
     			CipherAlg = pAd->SharedKey[BSS0][KeyIdx].CipherAlg;
     			Key = pAd->SharedKey[BSS0][KeyIdx].Key;
 
 				// Set Group key material to Asic
     			AsicAddSharedKeyEntry(pAd, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
-		
-				// Update WCID attribute table and IVEIV table for this group key table  
+
+				// Update WCID attribute table and IVEIV table for this group key table
 				RTMPAddWcidAttributeEntry(pAd, BSS0, KeyIdx, CipherAlg, NULL);
-												
+
 			}
 		}
 	}
@@ -590,7 +590,7 @@ int rt_ioctl_siwfreq(struct net_device *dev,
     if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
     {
         DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-        return -ENETDOWN;   
+        return -ENETDOWN;
     }
 
 
@@ -598,9 +598,9 @@ int rt_ioctl_siwfreq(struct net_device *dev,
 		return -EINVAL;
 
 	if((freq->e == 0) && (freq->m <= 1000))
-		chan = freq->m;	// Setting by channel number 
+		chan = freq->m;	// Setting by channel number
 	else
-		MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G, 
+		MAP_KHZ_TO_CHANNEL_ID( (freq->m /100) , chan); // Setting by frequency - search the table , like 2.412G, 2.422G,
 
     if (ChannelSanity(pAdapter, chan) == TRUE)
     {
@@ -609,7 +609,7 @@ int rt_ioctl_siwfreq(struct net_device *dev,
     }
     else
         return -EINVAL;
-    
+
 	return 0;
 }
 int rt_ioctl_giwfreq(struct net_device *dev,
@@ -659,7 +659,7 @@ int rt_ioctl_siwmode(struct net_device *dev,
     if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
     {
     	DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-       	return -ENETDOWN;   
+       	return -ENETDOWN;
     }
 
 	switch (*mode)
@@ -674,12 +674,12 @@ int rt_ioctl_siwmode(struct net_device *dev,
         case IW_MODE_MONITOR:
 			Set_NetworkType_Proc(pAdapter, "Monitor");
 			break;
-#endif            
+#endif
 		default:
 			DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_siwmode::SIOCSIWMODE (unknown %d)\n", *mode));
 			return -EINVAL;
 	}
-	
+
 	// Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
 	pAdapter->StaCfg.WpaState = SS_NOTUSE;
 
@@ -692,7 +692,7 @@ int rt_ioctl_giwmode(struct net_device *dev,
 {
 	PRTMP_ADAPTER 	pAdapter = NULL;
 	VIRTUAL_ADAPTER *pVirtualAd = NULL;
-	
+
 	if (dev->priv_flags == INT_MAIN)
 	{
 		pAdapter = dev->priv;
@@ -720,7 +720,7 @@ int rt_ioctl_giwmode(struct net_device *dev,
     {
         *mode = IW_MODE_MONITOR;
     }
-#endif         
+#endif
     else
         *mode = IW_MODE_AUTO;
 
@@ -738,7 +738,7 @@ int rt_ioctl_siwsens(struct net_device *dev,
     	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
     	{
         	DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-        	return -ENETDOWN;   
+        	return -ENETDOWN;
     	}
 
 	return 0;
@@ -808,13 +808,13 @@ int rt_ioctl_giwrange(struct net_device *dev,
 	range->num_channels =  pAdapter->ChannelListNum;
 
 	val = 0;
-	for (i = 1; i <= range->num_channels; i++) 
+	for (i = 1; i <= range->num_channels; i++)
 	{
 		u32 m;
 		range->freq[val].i = pAdapter->ChannelList[i-1].Channel;
 		MAP_CHANNEL_ID_TO_KHZ(pAdapter->ChannelList[i-1].Channel, m);
 		range->freq[val].m = m * 100; /* HZ */
-		
+
 		range->freq[val].e = 1;
 		val++;
 		if (val == IW_MAX_FREQUENCIES)
@@ -846,7 +846,7 @@ int rt_ioctl_giwrange(struct net_device *dev,
 
 #if WIRELESS_EXT > 17
 	/* IW_ENC_CAPA_* bit field */
-	range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | 
+	range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
 					IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
 #endif
 
@@ -864,7 +864,7 @@ int rt_ioctl_siwap(struct net_device *dev,
 	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
 	{
        	DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-       	return -ENETDOWN;   
+       	return -ENETDOWN;
     }
 
 	if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
@@ -875,18 +875,18 @@ int rt_ioctl_siwap(struct net_device *dev,
 
     // tell CNTL state machine to call NdisMSetInformationComplete() after completing
     // this request, because this request is initiated by NDIS.
-    pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE; 
+    pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
 	// Prevent to connect AP again in STAMlmePeriodicExec
 	pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
 
     memset(Bssid, 0, MAC_ADDR_LEN);
     memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN);
-    MlmeEnqueue(pAdapter, 
-                MLME_CNTL_STATE_MACHINE, 
-                OID_802_11_BSSID, 
+    MlmeEnqueue(pAdapter,
+                MLME_CNTL_STATE_MACHINE,
+                OID_802_11_BSSID,
                 sizeof(NDIS_802_11_MAC_ADDRESS),
                 (VOID *)&Bssid);
-    
+
     DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCSIWAP %02x:%02x:%02x:%02x:%02x:%02x\n",
         Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
 
@@ -899,7 +899,7 @@ int rt_ioctl_giwap(struct net_device *dev,
 {
 	PRTMP_ADAPTER 	pAdapter = NULL;
 	VIRTUAL_ADAPTER *pVirtualAd = NULL;
-	
+
 	if (dev->priv_flags == INT_MAIN)
 	{
 		pAdapter = dev->priv;
@@ -923,14 +923,14 @@ int rt_ioctl_giwap(struct net_device *dev,
 		ap_addr->sa_family = ARPHRD_ETHER;
 		memcpy(ap_addr->sa_data, &pAdapter->CommonCfg.Bssid, ETH_ALEN);
 	}
-#ifdef WPA_SUPPLICANT_SUPPORT    
+#ifdef WPA_SUPPLICANT_SUPPORT
     // Add for RT2870
     else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE)
     {
         ap_addr->sa_family = ARPHRD_ETHER;
         memcpy(ap_addr->sa_data, &pAdapter->MlmeAux.Bssid, ETH_ALEN);
     }
-#endif // WPA_SUPPLICANT_SUPPORT //    
+#endif // WPA_SUPPLICANT_SUPPORT //
 	else
 	{
 		DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIWAP(=EMPTY)\n"));
@@ -947,7 +947,7 @@ int rt_ioctl_giwap(struct net_device *dev,
  *
  * If you assume that the noise floor is -95, which is an
  * excellent assumption 99.5 % of the time, then you can
- * derive the absolute signal level (i.e. -95 + rssi). 
+ * derive the absolute signal level (i.e. -95 + rssi).
  * There are some other slight factors to take into account
  * depending on whether the rssi measurement is from 11b,
  * 11g, or 11a.   These differences are at most 2db and
@@ -957,7 +957,7 @@ int rt_ioctl_giwap(struct net_device *dev,
  *     drivers for compatibility
  */
 static void set_quality(PRTMP_ADAPTER pAdapter,
-                        struct iw_quality *iq, 
+                        struct iw_quality *iq,
                         signed char rssi)
 {
 	__u8 ChannelQuality;
@@ -968,15 +968,15 @@ static void set_quality(PRTMP_ADAPTER pAdapter,
 	else if (rssi >= -80) // between -50 ~ -80dbm
 		ChannelQuality = (__u8)(24 + ((rssi + 80) * 26)/10);
 	else if (rssi >= -90)   // between -80 ~ -90dbm
-        ChannelQuality = (__u8)((rssi + 90) * 26)/10;   
+        ChannelQuality = (__u8)((rssi + 90) * 26)/10;
 	else
 		ChannelQuality = 0;
-        
+
     iq->qual = (__u8)ChannelQuality;
-    
+
     iq->level = (__u8)(rssi);
     iq->noise = (pAdapter->BbpWriteLatch[66] > pAdapter->BbpTuning.FalseCcaUpperThreshold) ? ((__u8)pAdapter->BbpTuning.FalseCcaUpperThreshold) : ((__u8) pAdapter->BbpWriteLatch[66]); 	// noise level (dBm)
-    iq->noise += 256 - 143;		
+    iq->noise += 256 - 143;
     iq->updated = pAdapter->iw_stats.qual.updated;
 }
 
@@ -996,7 +996,7 @@ int rt_ioctl_iwaplist(struct net_device *dev,
        	DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
 		data->length = 0;
 		return 0;
-        //return -ENETDOWN;   
+        //return -ENETDOWN;
 	}
 
 	for (i = 0; i <IW_MAX_AP ; i++)
@@ -1005,7 +1005,7 @@ int rt_ioctl_iwaplist(struct net_device *dev,
 			break;
 		addr[i].sa_family = ARPHRD_ETHER;
 			memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
-		set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);	
+		set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
 	}
 	data->length = i;
 	memcpy(extra, &addr, i*sizeof(addr[0]));
@@ -1029,7 +1029,7 @@ int rt_ioctl_siwscan(struct net_device *dev,
 	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
 	{
 		DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-		return -ENETDOWN;   
+		return -ENETDOWN;
 	}
 
 	if (MONITOR_ON(pAdapter))
@@ -1063,8 +1063,8 @@ int rt_ioctl_siwscan(struct net_device *dev,
 #endif // WPA_SUPPLICANT_SUPPORT //
 
 		if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
-			((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || 
-			(pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&	
+			((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
+			(pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)) &&
 			(pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED))
 		{
 			DBGPRINT(RT_DEBUG_TRACE, ("!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n"));
@@ -1085,9 +1085,9 @@ int rt_ioctl_siwscan(struct net_device *dev,
 		pAdapter->StaCfg.ScanCnt = 0;
 		pAdapter->StaCfg.LastScanTime = Now;
 
-		MlmeEnqueue(pAdapter, 
-			MLME_CNTL_STATE_MACHINE, 
-			OID_802_11_BSSID_LIST_SCAN, 
+		MlmeEnqueue(pAdapter,
+			MLME_CNTL_STATE_MACHINE,
+			OID_802_11_BSSID_LIST_SCAN,
 			0,
 			NULL);
 
@@ -1133,7 +1133,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
 		data->length = 0;
 		return 0;
 	}
-	
+
 #if WIRELESS_EXT >= 17
     if (data->length > 0)
         end_buf = extra + data->length;
@@ -1143,7 +1143,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
     end_buf = extra + IW_SCAN_MAX_DATA;
 #endif
 
-	for (i = 0; i < pAdapter->ScanTab.BssNr; i++) 
+	for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
 	{
 		if (current_ev >= end_buf)
         {
@@ -1153,7 +1153,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
 			break;
 #endif
         }
-		
+
 		//MAC address
 		//================================
 		memset(&iwe, 0, sizeof(iwe));
@@ -1170,13 +1170,13 @@ int rt_ioctl_giwscan(struct net_device *dev,
 			break;
 #endif
 
-		//ESSID	
+		//ESSID
 		//================================
 		memset(&iwe, 0, sizeof(iwe));
 		iwe.cmd = SIOCGIWESSID;
 		iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
 		iwe.u.data.flags = 1;
- 
+
         previous_ev = current_ev;
 		current_ev = IWE_STREAM_ADD_POINT(info, current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
         if (current_ev == previous_ev)
@@ -1185,8 +1185,8 @@ int rt_ioctl_giwscan(struct net_device *dev,
 #else
 			break;
 #endif
-		
-		//Network Type 
+
+		//Network Type
 		//================================
 		memset(&iwe, 0, sizeof(iwe));
 		iwe.cmd = SIOCGIWMODE;
@@ -1223,7 +1223,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
 			iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel;
 		iwe.u.freq.e = 0;
 		iwe.u.freq.i = 0;
-		
+
 		previous_ev = current_ev;
 		current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
         if (current_ev == previous_ev)
@@ -1257,7 +1257,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
 		else
 			iwe.u.data.flags = IW_ENCODE_DISABLED;
 
-        previous_ev = current_ev;		
+        previous_ev = current_ev;
         current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key);
         if (current_ev == previous_ev)
 #if WIRELESS_EXT >= 17
@@ -1273,7 +1273,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
             UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1];
 			memset(&iwe, 0, sizeof(iwe));
 			iwe.cmd = SIOCGIWRATE;
-    		current_val = current_ev + IW_EV_LCP_LEN;            
+    		current_val = current_ev + IW_EV_LCP_LEN;
             if (tmpRate == 0x82)
                 iwe.u.bitrate.value =  1 * 1000000;
             else if (tmpRate == 0x84)
@@ -1284,11 +1284,11 @@ int rt_ioctl_giwscan(struct net_device *dev,
                 iwe.u.bitrate.value =  11 * 1000000;
             else
     		    iwe.u.bitrate.value =  (tmpRate/2) * 1000000;
-            
+
 			iwe.u.bitrate.disabled = 0;
 			current_val = IWE_STREAM_ADD_VALUE(info, current_ev,
 				current_val, end_buf, &iwe,
-    			IW_EV_PARAM_LEN);            
+    			IW_EV_PARAM_LEN);
 
         	if((current_val-current_ev)>IW_EV_LCP_LEN)
             	current_ev = current_val;
@@ -1299,14 +1299,14 @@ int rt_ioctl_giwscan(struct net_device *dev,
 			    break;
 #endif
         }
-            
+
 #ifdef IWEVGENIE
 		//WPA IE
 		if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0)
 		{
 			memset(&iwe, 0, sizeof(iwe));
 			memset(&custom[0], 0, MAX_CUSTOM_LEN);
-			memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]), 
+			memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]),
 						   pAdapter->ScanTab.BssEntry[i].WpaIE.IELen);
 			iwe.cmd = IWEVGENIE;
 			iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen;
@@ -1324,7 +1324,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
         {
         	memset(&iwe, 0, sizeof(iwe));
 			memset(&custom[0], 0, MAX_CUSTOM_LEN);
-			memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]), 
+			memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]),
 						   pAdapter->ScanTab.BssEntry[i].RsnIE.IELen);
 			iwe.cmd = IWEVGENIE;
 			iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen;
@@ -1397,15 +1397,15 @@ int rt_ioctl_siwessid(struct net_device *dev,
     if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
     {
        	DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-       	return -ENETDOWN;   
+       	return -ENETDOWN;
     }
 
 	if (data->flags)
 	{
 		PCHAR	pSsidString = NULL;
-		
+
 		// Includes null character.
-		if (data->length > (IW_ESSID_MAX_SIZE + 1)) 
+		if (data->length > (IW_ESSID_MAX_SIZE + 1))
 			return -E2BIG;
 
 		pSsidString = (CHAR *) kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG);
@@ -1434,7 +1434,7 @@ int rt_ioctl_giwessid(struct net_device *dev,
 {
 	PRTMP_ADAPTER 	pAdapter = NULL;
 	VIRTUAL_ADAPTER *pVirtualAd = NULL;
-	
+
 	if (dev->priv_flags == INT_MAIN)
 	{
 		pAdapter = dev->priv;
@@ -1452,8 +1452,8 @@ int rt_ioctl_giwessid(struct net_device *dev,
 		   So the net_dev->priv will be NULL in 2rd open */
 		return -ENETDOWN;
 	}
-	
-	data->flags = 1;		
+
+	data->flags = 1;
     if (MONITOR_ON(pAdapter))
     {
         data->length  = 0;
@@ -1486,7 +1486,7 @@ int rt_ioctl_siwnickn(struct net_device *dev,
     if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
     {
         DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n"));
-        return -ENETDOWN;   
+        return -ENETDOWN;
     }
 
 	if (data->length > IW_ESSID_MAX_SIZE)
@@ -1505,7 +1505,7 @@ int rt_ioctl_giwnickn(struct net_device *dev,
 {
 	PRTMP_ADAPTER 	pAdapter = NULL;
 	VIRTUAL_ADAPTER *pVirtualAd = NULL;
-	
+
 	if (dev->priv_flags == INT_MAIN)
 	{
 		pAdapter = dev->priv;
@@ -1544,9 +1544,9 @@ int rt_ioctl_siwrts(struct net_device *dev,
     if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
     {
         DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-        return -ENETDOWN;   
+        return -ENETDOWN;
     }
-	
+
 	if (rts->disabled)
 		val = MAX_RTS_THRESHOLD;
 	else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD)
@@ -1555,7 +1555,7 @@ int rt_ioctl_siwrts(struct net_device *dev,
 	    val = MAX_RTS_THRESHOLD;
 	else
 		val = rts->value;
-	
+
 	if (val != pAdapter->CommonCfg.RtsThreshold)
 		pAdapter->CommonCfg.RtsThreshold = val;
 
@@ -1591,7 +1591,7 @@ int rt_ioctl_giwrts(struct net_device *dev,
     	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
     	{
       		DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-        	return -ENETDOWN;   
+        	return -ENETDOWN;
     	}
 
 	rts->value = pAdapter->CommonCfg.RtsThreshold;
@@ -1612,7 +1612,7 @@ int rt_ioctl_siwfrag(struct net_device *dev,
     	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
     	{
       		DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-        	return -ENETDOWN;   
+        	return -ENETDOWN;
     	}
 
 	if (frag->disabled)
@@ -1634,7 +1634,7 @@ int rt_ioctl_giwfrag(struct net_device *dev,
 {
 	PRTMP_ADAPTER 	pAdapter = NULL;
 	VIRTUAL_ADAPTER *pVirtualAd = NULL;
-	
+
 	if (dev->priv_flags == INT_MAIN)
 	{
 		pAdapter = dev->priv;
@@ -1657,9 +1657,9 @@ int rt_ioctl_giwfrag(struct net_device *dev,
     	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
     	{
       		DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-        	return -ENETDOWN;   
+        	return -ENETDOWN;
     	}
-		
+
 	frag->value = pAdapter->CommonCfg.FragmentThreshold;
 	frag->disabled = (frag->value == MAX_FRAG_THRESHOLD);
 	frag->fixed = 1;
@@ -1679,7 +1679,7 @@ int rt_ioctl_siwencode(struct net_device *dev,
     	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
     	{
       		DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-        	return -ENETDOWN;   
+        	return -ENETDOWN;
     	}
 
 	if ((erq->length == 0) &&
@@ -1706,8 +1706,8 @@ int rt_ioctl_siwencode(struct net_device *dev,
 			pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
         goto done;
 	}
-    
-    if (erq->length > 0) 
+
+    if (erq->length > 0)
 	{
 		int keyIdx = (erq->flags & IW_ENCODE_INDEX) - 1;
 		/* Check the size of the key */
@@ -1717,22 +1717,22 @@ int rt_ioctl_siwencode(struct net_device *dev,
 		/* Check key index */
 		if ((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
         {
-            DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n", 
+            DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::Wrong keyIdx=%d! Using default key instead (%d)\n",
                                         keyIdx, pAdapter->StaCfg.DefaultKeyId));
-            
+
             //Using default key
-			keyIdx = pAdapter->StaCfg.DefaultKeyId;   
+			keyIdx = pAdapter->StaCfg.DefaultKeyId;
         }
 
         NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key,  16);
-		
+
 		if (erq->length == MAX_WEP_KEY_SIZE)
-        {      
+        {
 			pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
             pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
 		}
 		else if (erq->length == MIN_WEP_KEY_SIZE)
-        {      
+        {
             pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
             pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
 		}
@@ -1745,13 +1745,13 @@ int rt_ioctl_siwencode(struct net_device *dev,
 			/* Copy the key in the driver */
 			NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, extra, erq->length);
         }
-	} 
-    else 
+	}
+    else
 			{
 		/* Do we want to just set the transmit key index ? */
 		int index = (erq->flags & IW_ENCODE_INDEX) - 1;
-		if ((index >= 0) && (index < 4)) 
-        {      
+		if ((index >= 0) && (index < 4))
+        {
 			pAdapter->StaCfg.DefaultKeyId = index;
             }
         else
@@ -1760,7 +1760,7 @@ int rt_ioctl_siwencode(struct net_device *dev,
 				return -EINVAL;
 		}
 	}
-		
+
 done:
     DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::erq->flags=%x\n",erq->flags));
 	DBGPRINT(RT_DEBUG_TRACE ,("==>rt_ioctl_siwencode::AuthMode=%x\n",pAdapter->StaCfg.AuthMode));
@@ -1777,7 +1777,7 @@ rt_ioctl_giwencode(struct net_device *dev,
 	int kid;
 	PRTMP_ADAPTER 	pAdapter = NULL;
 	VIRTUAL_ADAPTER *pVirtualAd = NULL;
-	
+
 	if (dev->priv_flags == INT_MAIN)
 	{
 		pAdapter = dev->priv;
@@ -1800,9 +1800,9 @@ rt_ioctl_giwencode(struct net_device *dev,
 	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
 	{
   		DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-    	return -ENETDOWN;   
+    	return -ENETDOWN;
 	}
-		
+
 	kid = erq->flags & IW_ENCODE_INDEX;
 	DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_giwencode %d\n", erq->flags & IW_ENCODE_INDEX));
 
@@ -1810,7 +1810,7 @@ rt_ioctl_giwencode(struct net_device *dev,
 	{
 		erq->length = 0;
 		erq->flags = IW_ENCODE_DISABLED;
-	} 
+	}
 	else if ((kid > 0) && (kid <=4))
 	{
 		// copy wep key
@@ -1824,7 +1824,7 @@ rt_ioctl_giwencode(struct net_device *dev,
 			erq->flags |= IW_ENCODE_RESTRICTED;		/* XXX */
 		else
 			erq->flags |= IW_ENCODE_OPEN;		/* XXX */
-		
+
 	}
 	else if (kid == 0)
 	{
@@ -1842,7 +1842,7 @@ rt_ioctl_giwencode(struct net_device *dev,
 		erq->flags = pAdapter->StaCfg.DefaultKeyId + 1;			/* NB: base 1 */
 		erq->flags |= IW_ENCODE_ENABLED;	/* XXX */
 	}
-		
+
 	return 0;
 
 }
@@ -1857,7 +1857,7 @@ rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
 	char *this_char = extra;
 	char *value;
 	int  Status=0;
-	
+
 	if (dev->priv_flags == INT_MAIN)
 	{
 		pAdapter = dev->priv;
@@ -1880,7 +1880,7 @@ rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
 		pObj->ioctl_if_type = INT_MAIN;
         pObj->ioctl_if = MAIN_MBSSID;
 	}
-	
+
 	//check if the interface is down
     	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
     	{
@@ -1890,35 +1890,35 @@ rt_ioctl_setparam(struct net_device *dev, struct iw_request_info *info,
 
 	if (!*this_char)
 		return -EINVAL;
-	                                                                                                                            
-	if ((value = rtstrchr(this_char, '=')) != NULL)                                                                             
-	    *value++ = 0;                                                                                                           
-	                                                                                                                            
-	if (!value)                                                                                                      
-	    return -EINVAL;                                                                                                                  
+
+	if ((value = rtstrchr(this_char, '=')) != NULL)
+	    *value++ = 0;
+
+	if (!value)
+	    return -EINVAL;
 
 	// reject setting nothing besides ANY ssid(ssidLen=0)
     if (!*value && (strcmp(this_char, "SSID") != 0))
-        return -EINVAL; 
-        
-	for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)            
-	{                                                                                                                           
-	    if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)                                                               
-	    {						                                                                                                
-	        if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))                                                              
-	        {	//FALSE:Set private failed then return Invalid argument                                                         
-			    Status = -EINVAL;                                                                                               
-	        }                                                                                                                   
-		    break;	//Exit for loop.                                                                                        
-	    }                                                                                                                       
-	}                                                                                                                           
-	                                                                                                                            
-	if(PRTMP_PRIVATE_SET_PROC->name == NULL)                                                                                    
-	{  //Not found argument                                                                                                     
-	    Status = -EINVAL;                                                                                                       
+        return -EINVAL;
+
+	for (PRTMP_PRIVATE_SET_PROC = RTMP_PRIVATE_SUPPORT_PROC; PRTMP_PRIVATE_SET_PROC->name; PRTMP_PRIVATE_SET_PROC++)
+	{
+	    if (strcmp(this_char, PRTMP_PRIVATE_SET_PROC->name) == 0)
+	    {
+	        if(!PRTMP_PRIVATE_SET_PROC->set_proc(pAdapter, value))
+	        {	//FALSE:Set private failed then return Invalid argument
+			    Status = -EINVAL;
+	        }
+		    break;	//Exit for loop.
+	    }
+	}
+
+	if(PRTMP_PRIVATE_SET_PROC->name == NULL)
+	{  //Not found argument
+	    Status = -EINVAL;
 	    DBGPRINT(RT_DEBUG_TRACE, ("===>rt_ioctl_setparam:: (iwpriv) Not Support Set Command [%s=%s]\n", this_char, value));
-	}                                                                                                                           
-  
+	}
+
     return Status;
 }
 
@@ -1935,7 +1935,7 @@ rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
         wrq->length = 0;
         return -EIO;
     }
-    
+
     memset(extra, 0x00, IW_PRIV_SIZE_MASK);
     sprintf(extra, "\n\n");
 
@@ -1982,12 +1982,12 @@ rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
     	sprintf(extra+strlen(extra), "RSSI-A                          = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi0 - pAd->BbpRssiToDbmDelta));
         sprintf(extra+strlen(extra), "RSSI-B (if available)           = %ld\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi1 - pAd->BbpRssiToDbmDelta));
         sprintf(extra+strlen(extra), "RSSI-C (if available)           = %ld\n\n", (LONG)(pAd->StaCfg.RssiSample.LastRssi2 - pAd->BbpRssiToDbmDelta));
-	}   
+	}
 #ifdef WPA_SUPPLICANT_SUPPORT
     sprintf(extra+strlen(extra), "WpaSupplicantUP                 = %d\n\n", pAd->StaCfg.WpaSupplicantUP);
 #endif // WPA_SUPPLICANT_SUPPORT //
 
-        
+
     wrq->length = strlen(extra) + 1; // 1: size of '\0'
     DBGPRINT(RT_DEBUG_TRACE, ("<== rt_private_get_statistics, wrq->length = %d\n", wrq->length));
 
@@ -1996,7 +1996,7 @@ rt_private_get_statistics(struct net_device *dev, struct iw_request_info *info,
 
 #ifdef DOT11_N_SUPPORT
 void	getBaInfo(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			pOutBuf)
 {
 	INT i, j;
@@ -2008,12 +2008,12 @@ void	getBaInfo(
 		PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[i];
 		if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
 			|| (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
-		{		
+		{
 			sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
                 pOutBuf,
 				pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
 				pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
-			
+
 			sprintf(pOutBuf, "%s[Recipient]\n", pOutBuf);
 			for (j=0; j < NUM_OF_TID; j++)
 			{
@@ -2076,12 +2076,12 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
         return -EIO;
     }
     memset(extra, 0x00, IW_PRIV_SIZE_MASK);
-    
+
 	{
 		pObj->ioctl_if_type = INT_MAIN;
         pObj->ioctl_if = MAIN_MBSSID;
 	}
-    
+
     switch(subcmd)
     {
 
@@ -2099,11 +2099,11 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
             else
             {
                 if (pAd->IndicateMediaState == NdisMediaStateConnected)
-            	{        	    
+            	{
             	    if (INFRA_ON(pAd))
-                    {   
-                    sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n", 
-                                    pAd->CommonCfg.Ssid, 
+                    {
+                    sprintf(extra, "Connected(AP: %s[%02X:%02X:%02X:%02X:%02X:%02X])\n",
+                                    pAd->CommonCfg.Ssid,
                                     pAd->CommonCfg.Bssid[0],
                                     pAd->CommonCfg.Bssid[1],
                                     pAd->CommonCfg.Bssid[2],
@@ -2136,7 +2136,7 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
 		case SHOW_DESC_INFO:
 			{
 				Show_DescInfo_Proc(pAd, NULL);
-				wrq->length = 0; // 1: size of '\0'				
+				wrq->length = 0; // 1: size of '\0'
 			}
 			break;
         case RAIO_OFF:
@@ -2155,7 +2155,7 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
                     MlmeRadioOff(pAd);
                     // Update extra information
 					pAd->ExtraInfo = SW_RADIO_OFF;
-                } 
+                }
             }
             sprintf(extra, "Radio Off\n");
             wrq->length = strlen(extra) + 1; // 1: size of '\0'
@@ -2203,7 +2203,7 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
             DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __FUNCTION__, subcmd));
             break;
     }
-    
+
     return Status;
 }
 
@@ -2226,9 +2226,9 @@ int rt_ioctl_siwmlme(struct net_device *dev,
 
 	switch(pMlme->cmd)
 	{
-#ifdef IW_MLME_DEAUTH	
+#ifdef IW_MLME_DEAUTH
 		case IW_MLME_DEAUTH:
-			DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __FUNCTION__));			                
+			DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __FUNCTION__));
 			COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
 			DeAuthReq.Reason = pMlme->reason_code;
 			MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
@@ -2260,7 +2260,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
 			DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __FUNCTION__));
 			break;
 	}
-	
+
 	return 0;
 }
 #endif // SIOCSIWMLME //
@@ -2277,19 +2277,19 @@ int rt_ioctl_siwauth(struct net_device *dev,
 	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
 	{
   		DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-    	return -ENETDOWN;   
+    	return -ENETDOWN;
 	}
 	switch (param->flags & IW_AUTH_INDEX) {
     	case IW_AUTH_WPA_VERSION:
             if (param->value == IW_AUTH_WPA_VERSION_WPA)
-            {            
+            {
                 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
 				if (pAdapter->StaCfg.BssType == BSS_ADHOC)
 					pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
             }
             else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
                 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
-			
+
             DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value));
             break;
     	case IW_AUTH_CIPHER_PAIRWISE:
@@ -2305,7 +2305,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
                 pAdapter->StaCfg.WepStatus = Ndis802_11WEPEnabled;
                 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
                 pAdapter->StaCfg.PairCipher = Ndis802_11WEPEnabled;
-#ifdef WPA_SUPPLICANT_SUPPORT                
+#ifdef WPA_SUPPLICANT_SUPPORT
                 pAdapter->StaCfg.IEEE8021X = FALSE;
 #endif // WPA_SUPPLICANT_SUPPORT //
             }
@@ -2345,11 +2345,11 @@ int rt_ioctl_siwauth(struct net_device *dev,
             break;
     	case IW_AUTH_KEY_MGMT:
             if (param->value == IW_AUTH_KEY_MGMT_802_1X)
-            { 
+            {
                 if (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK)
                 {
                     pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
-#ifdef WPA_SUPPLICANT_SUPPORT                    
+#ifdef WPA_SUPPLICANT_SUPPORT
                     pAdapter->StaCfg.IEEE8021X = FALSE;
 #endif // WPA_SUPPLICANT_SUPPORT //
                 }
@@ -2360,11 +2360,11 @@ int rt_ioctl_siwauth(struct net_device *dev,
                     pAdapter->StaCfg.IEEE8021X = FALSE;
 #endif // WPA_SUPPLICANT_SUPPORT //
                 }
-#ifdef WPA_SUPPLICANT_SUPPORT                
+#ifdef WPA_SUPPLICANT_SUPPORT
                 else
                     // WEP 1x
                     pAdapter->StaCfg.IEEE8021X = TRUE;
-#endif // WPA_SUPPLICANT_SUPPORT //                
+#endif // WPA_SUPPLICANT_SUPPORT //
             }
             else if (param->value == 0)
             {
@@ -2386,15 +2386,15 @@ int rt_ioctl_siwauth(struct net_device *dev,
 			}
             DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value));
     		break;
-    	case IW_AUTH_80211_AUTH_ALG: 
-			if (param->value & IW_AUTH_ALG_SHARED_KEY) 
+    	case IW_AUTH_80211_AUTH_ALG:
+			if (param->value & IW_AUTH_ALG_SHARED_KEY)
             {
 				pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeShared;
-			} 
-            else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) 
+			}
+            else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
             {
 				pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-			} 
+			}
             else
 				return -EINVAL;
             DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __FUNCTION__, param->value));
@@ -2420,7 +2420,7 @@ int rt_ioctl_giwauth(struct net_device *dev,
 	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
     {
   		DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-    	return -ENETDOWN;   
+    	return -ENETDOWN;
     }
 
 	switch (param->flags & IW_AUTH_INDEX) {
@@ -2445,7 +2445,7 @@ int rt_ioctl_giwauth(struct net_device *dev,
 
 void fnSetCipherKey(
     IN  PRTMP_ADAPTER   pAdapter,
-    IN  INT             keyIdx,    
+    IN  INT             keyIdx,
     IN  UCHAR           CipherAlg,
     IN  BOOLEAN         bGTK,
     IN  struct iw_encode_ext *ext)
@@ -2457,28 +2457,28 @@ void fnSetCipherKey(
     NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].RxMic, ext->key + LEN_TKIP_EK + LEN_TKIP_TXMICK, LEN_TKIP_RXMICK);
     pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CipherAlg;
 
-    // Update group key information to ASIC Shared Key Table	   
-	AsicAddSharedKeyEntry(pAdapter, 
-						  BSS0, 
-						  keyIdx, 
+    // Update group key information to ASIC Shared Key Table
+	AsicAddSharedKeyEntry(pAdapter,
+						  BSS0,
+						  keyIdx,
 						  pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
 						  pAdapter->SharedKey[BSS0][keyIdx].Key,
-						  pAdapter->SharedKey[BSS0][keyIdx].TxMic, 
+						  pAdapter->SharedKey[BSS0][keyIdx].TxMic,
 						  pAdapter->SharedKey[BSS0][keyIdx].RxMic);
-			
+
     if (bGTK)
         // Update ASIC WCID attribute table and IVEIV table
-    	RTMPAddWcidAttributeEntry(pAdapter, 
-    							  BSS0, 
-    							  keyIdx, 
+    	RTMPAddWcidAttributeEntry(pAdapter,
+    							  BSS0,
+    							  keyIdx,
     							  pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
     							  NULL);
     else
         // Update ASIC WCID attribute table and IVEIV table
-    	RTMPAddWcidAttributeEntry(pAdapter, 
-    							  BSS0, 
-    							  keyIdx, 
-    							  pAdapter->SharedKey[BSS0][keyIdx].CipherAlg, 
+    	RTMPAddWcidAttributeEntry(pAdapter,
+    							  BSS0,
+    							  keyIdx,
+    							  pAdapter->SharedKey[BSS0][keyIdx].CipherAlg,
     							  &pAdapter->MacTab.Content[BSSID_WCID]);
 }
 
@@ -2491,12 +2491,12 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
 	struct iw_point *encoding = &wrqu->encoding;
 	struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
     int keyIdx, alg = ext->alg;
-	
+
     //check if the interface is down
 	if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE))
 	{
   		DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-    	return -ENETDOWN;   
+    	return -ENETDOWN;
 	}
 
     if (encoding->flags & IW_ENCODE_DISABLED)
@@ -2515,8 +2515,8 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
         // Get Key Index and convet to our own defined key index
     	keyIdx = (encoding->flags & IW_ENCODE_INDEX) - 1;
     	if((keyIdx < 0) || (keyIdx >= NR_WEP_KEYS))
-    		return -EINVAL;               
-					
+    		return -EINVAL;
+
         if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
         {
             pAdapter->StaCfg.DefaultKeyId = keyIdx;
@@ -2530,18 +2530,18 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
     		case IW_ENCODE_ALG_WEP:
                 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __FUNCTION__, ext->key_len, keyIdx));
     			if (ext->key_len == MAX_WEP_KEY_SIZE)
-                {      
+                {
         			pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
                     pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP128;
 				}
         		else if (ext->key_len == MIN_WEP_KEY_SIZE)
-                {      
+                {
                     pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MIN_WEP_KEY_SIZE;
                     pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_WEP64;
 			}
         		else
                     return -EINVAL;
-                                
+
                 NdisZeroMemory(pAdapter->SharedKey[BSS0][keyIdx].Key,  16);
 			    NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
     			break;
@@ -2560,7 +2560,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
                     else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
                     {
                         fnSetCipherKey(pAdapter, keyIdx, CIPHER_TKIP, TRUE, ext);
-		
+
                         // set 802.1x port control
             	        STA_PORT_SECURED(pAdapter);
                     }
@@ -2578,7 +2578,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
                 else if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
                 {
                     fnSetCipherKey(pAdapter, keyIdx, CIPHER_AES, TRUE, ext);
-                    
+
                     // set 802.1x port control
         	        STA_PORT_SECURED(pAdapter);
                 }
@@ -2587,7 +2587,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
     			return -EINVAL;
 		}
     }
-			
+
     return 0;
 }
 
@@ -2609,7 +2609,7 @@ rt_ioctl_giwencodeext(struct net_device *dev,
 		return -EINVAL;
 
 	idx = encoding->flags & IW_ENCODE_INDEX;
-	if (idx) 
+	if (idx)
 	{
 		if (idx < 1 || idx > 4)
 			return -EINVAL;
@@ -2624,7 +2624,7 @@ rt_ioctl_giwencodeext(struct net_device *dev,
 				return 0;
 			}
 		}
-	} 
+	}
 	else
 		idx = pAd->StaCfg.DefaultKeyId;
 
@@ -2635,7 +2635,7 @@ rt_ioctl_giwencodeext(struct net_device *dev,
 	switch(pAd->StaCfg.WepStatus) {
 		case Ndis802_11WEPDisabled:
 			ext->alg = IW_ENCODE_ALG_NONE;
-			encoding->flags |= IW_ENCODE_DISABLED;		
+			encoding->flags |= IW_ENCODE_DISABLED;
 			break;
 		case Ndis802_11WEPEnabled:
 			ext->alg = IW_ENCODE_ALG_WEP;
@@ -2643,7 +2643,7 @@ rt_ioctl_giwencodeext(struct net_device *dev,
 				return -E2BIG;
 			else
 			{
-				ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;				
+				ext->key_len = pAd->SharedKey[BSS0][idx].KeyLen;
 				pKey = &(pAd->SharedKey[BSS0][idx].Key[0]);
 			}
 			break;
@@ -2653,7 +2653,7 @@ rt_ioctl_giwencodeext(struct net_device *dev,
 				ext->alg = IW_ENCODE_ALG_TKIP;
 			else
 				ext->alg = IW_ENCODE_ALG_CCMP;
-			
+
 			if (max_key_len < 32)
 				return -E2BIG;
 			else
@@ -2671,7 +2671,7 @@ rt_ioctl_giwencodeext(struct net_device *dev,
 		encoding->flags |= IW_ENCODE_ENABLED;
 		memcpy(ext->key, pKey, ext->key_len);
 	}
-	
+
 	return 0;
 }
 
@@ -2681,22 +2681,22 @@ int rt_ioctl_siwgenie(struct net_device *dev,
 			  union iwreq_data *wrqu, char *extra)
 {
 	PRTMP_ADAPTER   pAd = (PRTMP_ADAPTER) dev->priv;
-	
+
 	if (wrqu->data.length > MAX_LEN_OF_RSNIE ||
 	    (wrqu->data.length && extra == NULL))
 		return -EINVAL;
 
-	if (wrqu->data.length) 
+	if (wrqu->data.length)
 	{
 		pAd->StaCfg.RSNIE_Len = wrqu->data.length;
 		NdisMoveMemory(&pAd->StaCfg.RSN_IE[0], extra, pAd->StaCfg.RSNIE_Len);
-	} 
-	else 
+	}
+	else
 	{
 		pAd->StaCfg.RSNIE_Len = 0;
 		NdisZeroMemory(&pAd->StaCfg.RSN_IE[0], MAX_LEN_OF_RSNIE);
 	}
-	
+
 	return 0;
 }
 #endif // SIOCSIWGENIE //
@@ -2706,7 +2706,7 @@ int rt_ioctl_giwgenie(struct net_device *dev,
 			       union iwreq_data *wrqu, char *extra)
 {
 	PRTMP_ADAPTER   pAd = (PRTMP_ADAPTER) dev->priv;
-	
+
 	if ((pAd->StaCfg.RSNIE_Len == 0) ||
 		(pAd->StaCfg.AuthMode < Ndis802_11AuthModeWPA))
 	{
@@ -2729,20 +2729,20 @@ int rt_ioctl_giwgenie(struct net_device *dev,
 #endif // NATIVE_WPA_SUPPLICANT_SUPPORT //
 	{
 		UCHAR RSNIe = IE_WPA;
-		
+
 		if (wrqu->data.length < (pAd->StaCfg.RSNIE_Len + 2)) // ID, Len
 			return -E2BIG;
 		wrqu->data.length = pAd->StaCfg.RSNIE_Len + 2;
-		
+
 		if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
             (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
 			RSNIe = IE_RSN;
-		
+
 		extra[0] = (char)RSNIe;
 		extra[1] = pAd->StaCfg.RSNIE_Len;
 		memcpy(extra+2, &pAd->StaCfg.RSN_IE[0], pAd->StaCfg.RSNIE_Len);
 	}
-	
+
 	return 0;
 }
 
@@ -2782,7 +2782,7 @@ int rt_ioctl_siwpmksa(struct net_device *dev,
 			        break;
 		        }
 	        }
-			
+
 			DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_REMOVE\n"));
 			break;
 		case IW_PMKSA_ADD:
@@ -2790,7 +2790,7 @@ int rt_ioctl_siwpmksa(struct net_device *dev,
 			{
 		        // compare the BSSID
 		        if (NdisEqualMemory(pPmksa->bssid.sa_data, pAd->StaCfg.SavedPMK[CachedIdx].BSSID, MAC_ADDR_LEN))
-			        break;			
+			        break;
 	        }
 
 	        // Found, replace it
@@ -2810,7 +2810,7 @@ int rt_ioctl_siwpmksa(struct net_device *dev,
 		        NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].BSSID[0], pPmksa->bssid.sa_data, MAC_ADDR_LEN);
 				NdisMoveMemory(&pAd->StaCfg.SavedPMK[CachedIdx].PMKID[0], pPmksa->pmkid, 16);
 	        }
-			
+
 			DBGPRINT(RT_DEBUG_TRACE ,("rt_ioctl_siwpmksa - IW_PMKSA_ADD\n"));
 			break;
 		default:
@@ -2842,23 +2842,23 @@ rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
 	if (wrq->length > 1) //No parameters.
 				{
 		sprintf(extra, "\n");
-					
+
 		//Parsing Read or Write
 		this_char = wrq->pointer;
 		DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s\n", this_char));
-		if (!*this_char)                                                                            
+		if (!*this_char)
 			goto next;
 
 		if ((value = rtstrchr(this_char, '=')) != NULL)
-			*value++ = 0;		
-		
+			*value++ = 0;
+
 		if (!value || !*value)
-		{ //Read                                                                                    
+		{ //Read
 			DBGPRINT(RT_DEBUG_TRACE, ("this_char=%s, value=%s\n", this_char, value));
-			if (sscanf(this_char, "%d", &(bbpId)) == 1)                                             
-			{  
-				if (bbpId <= 136)                                                                   
-				{                                                                                   
+			if (sscanf(this_char, "%d", &(bbpId)) == 1)
+			{
+				if (bbpId <= 136)
+				{
 #ifdef RALINK_ATE
 					if (ATE_ON(pAdapter))
 					{
@@ -2867,67 +2867,67 @@ rt_private_ioctl_bbp(struct net_device *dev, struct iw_request_info *info,
 					else
 #endif // RALINK_ATE //
 					{
-					RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);                          
+					RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
 					}
 					sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
                     wrq->length = strlen(extra) + 1; // 1: size of '\0'
 					DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
-				}                                                                                   
-				else                                                                                
-				{//Invalid parametes, so default printk all bbp                                     
+				}
+				else
+				{//Invalid parametes, so default printk all bbp
 					bIsPrintAllBBP = TRUE;
-					goto next;                                                                          
-				}                                                                                   
-			}                                                                                       
-			else                                                                                    
-			{ //Invalid parametes, so default printk all bbp                                        
+					goto next;
+				}
+			}
+			else
+			{ //Invalid parametes, so default printk all bbp
 				bIsPrintAllBBP = TRUE;
-				goto next;                                                                              
-			}                                                                                       
-		}                                                                                           
-		else                                                                                        
-		{ //Write                                
+				goto next;
+			}
+		}
+		else
+		{ //Write
 			if ((sscanf(this_char, "%d", &(bbpId)) == 1) && (sscanf(value, "%x", &(bbpValue)) == 1))
 			{
-				if (bbpId <= 136)                                                                   
-				{                                                                                   
+				if (bbpId <= 136)
+				{
 #ifdef RALINK_ATE
 					if (ATE_ON(pAdapter))
 					{
-						ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);          
-						//Read it back for showing                                                      
-						ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);  
+						ATE_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
+						//Read it back for showing
+						ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
 					}
 					else
 #endif // RALINK_ATE //
 					{
-					    RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);          
-    					//Read it back for showing                                                      
-    					RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);                          
+					    RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, bbpId, bbpValue);
+    					//Read it back for showing
+    					RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
 			}
 					sprintf(extra+strlen(extra), "R%02d[0x%02X]:%02X\n", bbpId, bbpId*2, regBBP);
                     wrq->length = strlen(extra) + 1; // 1: size of '\0'
-					DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));                                       
-				}                                                                                   
-				else                                                                                
-				{//Invalid parametes, so default printk all bbp                                     
-					bIsPrintAllBBP = TRUE;                                                          
-					goto next;                                                                          
-				}                                                                                   
-			}                                                                                       
-			else                                                                                    
-			{ //Invalid parametes, so default printk all bbp                                        
-				bIsPrintAllBBP = TRUE;                                                              
-				goto next;                                                                              
-			}                                                                                       
-		}                             
+					DBGPRINT(RT_DEBUG_TRACE, ("msg=%s\n", extra));
+				}
+				else
+				{//Invalid parametes, so default printk all bbp
+					bIsPrintAllBBP = TRUE;
+					goto next;
+				}
+			}
+			else
+			{ //Invalid parametes, so default printk all bbp
+				bIsPrintAllBBP = TRUE;
+				goto next;
+			}
+		}
 		}
 	else
 		bIsPrintAllBBP = TRUE;
 
-next:    
+next:
 	if (bIsPrintAllBBP)
-	{   
+	{
 		memset(extra, 0x00, IW_PRIV_SIZE_MASK);
 		sprintf(extra, "\n");
 		for (bbpId = 0; bbpId <= 136; bbpId++)
@@ -2937,7 +2937,7 @@ next:
 #ifdef RALINK_ATE
 			if (ATE_ON(pAdapter))
 			{
-				ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP); 
+				ATE_BBP_IO_READ8_BY_REG_ID(pAdapter, bbpId, &regBBP);
 			}
 			else
 #endif // RALINK_ATE //
@@ -2946,13 +2946,13 @@ next:
 			if (bbpId%5 == 4)
 				sprintf(extra+strlen(extra), "\n");
 		}
-		
+
         wrq->length = strlen(extra) + 1; // 1: size of '\0'
         DBGPRINT(RT_DEBUG_TRACE, ("wrq->length = %d\n", wrq->length));
 	}
-	
-	DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));	
-    
+
+	DBGPRINT(RT_DEBUG_TRACE, ("<==rt_private_ioctl_bbp\n\n"));
+
     return Status;
 }
 #endif // DBG //
@@ -2968,28 +2968,28 @@ int rt_ioctl_siwrate(struct net_device *dev,
 	if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
 	{
   		DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::Network is down!\n"));
-    	return -ENETDOWN;   
-	}    
+    	return -ENETDOWN;
+	}
 
     DBGPRINT(RT_DEBUG_TRACE, ("rt_ioctl_siwrate::(rate = %d, fixed = %d)\n", rate, fixed));
     /* rate = -1 => auto rate
-       rate = X, fixed = 1 => (fixed rate X)       
+       rate = X, fixed = 1 => (fixed rate X)
     */
     if (rate == -1)
     {
 		//Auto Rate
-		pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;	
+		pAd->StaCfg.DesiredTransmitSetting.field.MCS = MCS_AUTO;
 		pAd->StaCfg.bAutoTxRateSwitch = TRUE;
 		if ((pAd->CommonCfg.PhyMode <= PHY_11G) ||
 		    (pAd->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE <= MODE_OFDM))
 			RTMPSetDesiredRates(pAd, -1);
-			
+
 #ifdef DOT11_N_SUPPORT
 		SetCommonHT(pAd);
 #endif // DOT11_N_SUPPORT //
     }
     else
-    {        
+    {
         if (fixed)
         {
         	pAd->StaCfg.bAutoTxRateSwitch = FALSE;
@@ -3021,7 +3021,7 @@ int rt_ioctl_giwrate(struct net_device *dev,
 {
     PRTMP_ADAPTER   pAd = (PRTMP_ADAPTER) dev->priv;
     int rate_index = 0, rate_count = 0;
-    HTTRANSMIT_SETTING ht_setting; 
+    HTTRANSMIT_SETTING ht_setting;
     __s32 ralinkrate[] =
 	{2,  4,   11,  22, // CCK
 	12, 18,   24,  36, 48, 72, 96, 108, // OFDM
@@ -3039,7 +3039,7 @@ int rt_ioctl_giwrate(struct net_device *dev,
 	if(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))
 	{
   		DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-    	return -ENETDOWN;   
+    	return -ENETDOWN;
 	}
 
     if ((pAd->StaCfg.bAutoTxRateSwitch == FALSE) &&
@@ -3054,16 +3054,16 @@ int rt_ioctl_giwrate(struct net_device *dev,
     {
     	rate_index = 12 + ((UCHAR)ht_setting.field.BW *24) + ((UCHAR)ht_setting.field.ShortGI *48) + ((UCHAR)ht_setting.field.MCS);
     }
-    else 
+    else
 #endif // DOT11_N_SUPPORT //
-    if (ht_setting.field.MODE == MODE_OFDM)                
+    if (ht_setting.field.MODE == MODE_OFDM)
     	rate_index = (UCHAR)(ht_setting.field.MCS) + 4;
-    else if (ht_setting.field.MODE == MODE_CCK)   
+    else if (ht_setting.field.MODE == MODE_CCK)
     	rate_index = (UCHAR)(ht_setting.field.MCS);
 
     if (rate_index < 0)
         rate_index = 0;
-    
+
     if (rate_index > rate_count)
         rate_index = rate_count;
 
@@ -3130,9 +3130,9 @@ static const iw_handler rt_handler[] =
 	(iw_handler) rt_ioctl_giwencode,		/* SIOCGIWENCODE */
 	(iw_handler) NULL,		                /* SIOCSIWPOWER  */
 	(iw_handler) NULL,		                /* SIOCGIWPOWER  */
-	(iw_handler) NULL,						/* -- hole -- */	
 	(iw_handler) NULL,						/* -- hole -- */
-#if WIRELESS_EXT > 17	
+	(iw_handler) NULL,						/* -- hole -- */
+#if WIRELESS_EXT > 17
     (iw_handler) rt_ioctl_siwgenie,         /* SIOCSIWGENIE  */
 	(iw_handler) rt_ioctl_giwgenie,         /* SIOCGIWGENIE  */
 	(iw_handler) rt_ioctl_siwauth,		    /* SIOCSIWAUTH   */
@@ -3151,8 +3151,8 @@ static const iw_handler rt_priv_handlers[] = {
 #else
 	(iw_handler) NULL, /* + 0x02 */
 #endif // CONFIG_AP_SUPPORT //
-#ifdef DBG	
-	(iw_handler) rt_private_ioctl_bbp, /* + 0x03 */	
+#ifdef DBG
+	(iw_handler) rt_private_ioctl_bbp, /* + 0x03 */
 #else
 	(iw_handler) NULL, /* + 0x03 */
 #endif
@@ -3188,7 +3188,7 @@ const struct iw_handler_def rt28xx_iw_handler_def =
 	.num_private_args	= N(privtab),
 #if IW_HANDLER_VERSION >= 7
     .get_wireless_stats = rt28xx_get_wireless_stats,
-#endif 
+#endif
 };
 
 INT RTMPSetInformation(
@@ -3223,14 +3223,14 @@ INT RTMPSetInformation(
 #ifdef DOT11_N_SUPPORT
 	OID_SET_HT_PHYMODE					HT_PhyMode;	//11n ,kathy
 #endif // DOT11_N_SUPPORT //
-#ifdef WPA_SUPPLICANT_SUPPORT    
+#ifdef WPA_SUPPLICANT_SUPPORT
     PNDIS_802_11_PMKID                  pPmkId = NULL;
     BOOLEAN				                IEEE8021xState = FALSE;
     BOOLEAN				                IEEE8021x_required_keys = FALSE;
     UCHAR                               wpa_supplicant_enable = 0;
 #endif // WPA_SUPPLICANT_SUPPORT //
 
-#ifdef SNMP_SUPPORT	
+#ifdef SNMP_SUPPORT
 	TX_RTY_CFG_STRUC			tx_rty_cfg;
 	ULONG						ShortRetryLimit, LongRetryLimit;
 	UCHAR						ctmp;
@@ -3287,7 +3287,7 @@ INT RTMPSetInformation(
 			//Benson add 20080527, when radio off, sta don't need to scan
 			if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_RADIO_OFF))
 				break;
-				
+
 			if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
 			{
                 DBGPRINT(RT_DEBUG_TRACE, ("!!! Driver is scanning now !!!\n"));
@@ -3303,9 +3303,9 @@ INT RTMPSetInformation(
 				pAdapter->StaCfg.ScanCnt = 99;		// Prevent auto scan triggered by this OID
 				break;
             }
-            
+
             if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
-				((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) || 
+				((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
 				(pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
 				(pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
 				(pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
@@ -3333,10 +3333,10 @@ INT RTMPSetInformation(
 
 			pAdapter->StaCfg.bScanReqIsFromWebUI = TRUE;
             RTMP_SET_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
-            MlmeEnqueue(pAdapter, 
-                        MLME_CNTL_STATE_MACHINE, 
-                        OID_802_11_BSSID_LIST_SCAN, 
-                        0, 
+            MlmeEnqueue(pAdapter,
+                        MLME_CNTL_STATE_MACHINE,
+                        OID_802_11_BSSID_LIST_SCAN,
+                        0,
                         NULL);
 
             Status = NDIS_STATUS_SUCCESS;
@@ -3376,12 +3376,12 @@ INT RTMPSetInformation(
             }
             break;
         case OID_802_11_BSSID:
-#ifdef RALINK_ATE			
+#ifdef RALINK_ATE
 			if (ATE_ON(pAdapter))
 			{
 				DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
 				break;
-			}	
+			}
 #endif // RALINK_ATE //
             if (wrq->u.data.length != sizeof(NDIS_802_11_MAC_ADDRESS))
                 Status  = -EINVAL;
@@ -3391,7 +3391,7 @@ INT RTMPSetInformation(
 
                 // tell CNTL state machine to call NdisMSetInformationComplete() after completing
                 // this request, because this request is initiated by NDIS.
-                pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE; 
+                pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
 
 				// Prevent to connect AP again in STAMlmePeriodicExec
 				pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
@@ -3404,9 +3404,9 @@ INT RTMPSetInformation(
                     RT28XX_MLME_RESET_STATE_MACHINE(pAdapter);
                     DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME busy, reset MLME state machine !!!\n"));
                 }
-                MlmeEnqueue(pAdapter, 
-                            MLME_CNTL_STATE_MACHINE, 
-                            OID_802_11_BSSID, 
+                MlmeEnqueue(pAdapter,
+                            MLME_CNTL_STATE_MACHINE,
+                            OID_802_11_BSSID,
                             sizeof(NDIS_802_11_MAC_ADDRESS),
                             (VOID *)&Bssid);
                 Status = NDIS_STATUS_SUCCESS;
@@ -3561,7 +3561,7 @@ INT RTMPSetInformation(
             }
             break;
         case OID_802_11_AUTHENTICATION_MODE:
-            if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE)) 
+            if (wrq->u.data.length != sizeof(NDIS_802_11_AUTHENTICATION_MODE))
                 Status  = -EINVAL;
             else
             {
@@ -3610,7 +3610,7 @@ INT RTMPSetInformation(
             {
 				Status = -EINVAL;
             }
-            else 
+            else
             {
 				KeyIdx = *(NDIS_802_11_KEY_INDEX *) wrq->u.data.pointer;
 
@@ -3684,13 +3684,13 @@ INT RTMPSetInformation(
             else
             {
                 Status = copy_from_user(&PowerMode, wrq->u.data.pointer, wrq->u.data.length);
-                if (PowerMode == Ndis802_11PowerModeCAM) 
+                if (PowerMode == Ndis802_11PowerModeCAM)
                 	Set_PSMode_Proc(pAdapter, "CAM");
-                else if (PowerMode == Ndis802_11PowerModeMAX_PSP) 
+                else if (PowerMode == Ndis802_11PowerModeMAX_PSP)
                 	Set_PSMode_Proc(pAdapter, "Max_PSP");
-                else if (PowerMode == Ndis802_11PowerModeFast_PSP) 
+                else if (PowerMode == Ndis802_11PowerModeFast_PSP)
 					Set_PSMode_Proc(pAdapter, "Fast_PSP");
-                else if (PowerMode == Ndis802_11PowerModeLegacy_PSP) 
+                else if (PowerMode == Ndis802_11PowerModeLegacy_PSP)
 					Set_PSMode_Proc(pAdapter, "Legacy_PSP");
                 else
                     Status = -EINVAL;
@@ -3706,14 +3706,14 @@ INT RTMPSetInformation(
 				if (PowerTemp > 100)
 					PowerTemp = 0xffffffff;  // AUTO
 				pAdapter->CommonCfg.TxPowerDefault = PowerTemp; //keep current setting.
-					pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;			
+					pAdapter->CommonCfg.TxPowerPercentage = pAdapter->CommonCfg.TxPowerDefault;
                 DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
-			}	
+			}
 	        break;
-		case OID_802_11_NETWORK_TYPE_IN_USE: 
+		case OID_802_11_NETWORK_TYPE_IN_USE:
 			if (wrq->u.data.length != sizeof(NDIS_802_11_NETWORK_TYPE))
 				Status = -EINVAL;
-			else 
+			else
 			{
 				Status = copy_from_user(&NetType, wrq->u.data.pointer, wrq->u.data.length);
 
@@ -3723,14 +3723,14 @@ INT RTMPSetInformation(
 					RTMPSetPhyMode(pAdapter, PHY_11BG_MIXED);
 				else if (NetType == Ndis802_11OFDM5)
 					RTMPSetPhyMode(pAdapter, PHY_11A);
-				else 
+				else
 					Status = -EINVAL;
 #ifdef DOT11_N_SUPPORT
 				if (Status == NDIS_STATUS_SUCCESS)
 					SetCommonHT(pAdapter);
 #endif // DOT11_N_SUPPORT //
                 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_NETWORK_TYPE_IN_USE (=%d)\n",NetType));
-		    }	    
+		    }
 			break;
         // For WPA PSK PMK key
         case RT_OID_802_11_ADD_WPA:
@@ -3740,7 +3740,7 @@ INT RTMPSetInformation(
                 Status = -ENOMEM;
                 break;
             }
-            
+
             Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
             if (pKey->Length != wrq->u.data.length)
             {
@@ -3759,7 +3759,7 @@ INT RTMPSetInformation(
                 else if ((pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
 						 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
 						 (pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) )     // Only for WPA PSK mode
-				{		
+				{
                     NdisMoveMemory(pAdapter->StaCfg.PMK, &pKey->KeyMaterial, pKey->KeyLength);
                     // Use RaConfig as PSK agent.
                     // Start STA supplicant state machine
@@ -3769,7 +3769,7 @@ INT RTMPSetInformation(
                     DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
                 }
                 else
-                {   
+                {
                     pAdapter->StaCfg.WpaState = SS_NOTUSE;
                     DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_ADD_WPA (id=0x%x, Len=%d-byte)\n", pKey->KeyIndex, pKey->KeyLength));
                 }
@@ -3783,7 +3783,7 @@ INT RTMPSetInformation(
                 Status = -ENOMEM;
                 break;
             }
-            
+
             Status = copy_from_user(pRemoveKey, wrq->u.data.pointer, wrq->u.data.length);
             if (pRemoveKey->Length != wrq->u.data.length)
             {
@@ -3819,14 +3819,14 @@ INT RTMPSetInformation(
                         {
                             pAdapter->SharedKey[BSS0][KeyIdx].KeyLen = 0;
                             pAdapter->SharedKey[BSS0][KeyIdx].CipherAlg = CIPHER_NONE;
-                            AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx); 
+                            AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)KeyIdx);
                             DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_REMOVE_KEY (id=0x%x, Len=%d-byte)\n", pRemoveKey->KeyIndex, pRemoveKey->Length));
                         }
                     }
                 }
             }
             kfree(pRemoveKey);
-            break;        
+            break;
         // New for WPA
         case OID_802_11_ADD_KEY:
             pKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
@@ -3858,14 +3858,14 @@ INT RTMPSetInformation(
 
                 if ((pConfig->BeaconPeriod >= 20) && (pConfig->BeaconPeriod <=400))
                      pAdapter->CommonCfg.BeaconPeriod = (USHORT) pConfig->BeaconPeriod;
-                
+
                 pAdapter->StaActive.AtimWin = (USHORT) pConfig->ATIMWindow;
                 MAP_KHZ_TO_CHANNEL_ID(pConfig->DSConfig, pAdapter->CommonCfg.Channel);
                 //
 				// Save the channel on MlmeAux for CntlOidRTBssidProc used.
 				//
 				pAdapter->MlmeAux.Channel = pAdapter->CommonCfg.Channel;
-				
+
                 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_CONFIGURATION (BeacnPeriod=%ld,AtimW=%ld,Ch=%d)\n",
                     pConfig->BeaconPeriod, pConfig->ATIMWindow, pAdapter->CommonCfg.Channel));
                 // Config has changed
@@ -3876,18 +3876,18 @@ INT RTMPSetInformation(
 		case RT_OID_802_11_SET_HT_PHYMODE:
 			if (wrq->u.data.length	!= sizeof(OID_SET_HT_PHYMODE))
 				Status = -EINVAL;
-			else 
+			else
 			{
 			    POID_SET_HT_PHYMODE	pHTPhyMode = &HT_PhyMode;
-                
-				Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);				
-				DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode	(PhyMode = %d,TransmitNo = %d, HtMode =	%d,	ExtOffset =	%d , MCS = %d, BW =	%d,	STBC = %d, SHORTGI = %d) \n", 
+
+				Status = copy_from_user(&HT_PhyMode, wrq->u.data.pointer, wrq->u.data.length);
+				DBGPRINT(RT_DEBUG_TRACE, ("Set::pHTPhyMode	(PhyMode = %d,TransmitNo = %d, HtMode =	%d,	ExtOffset =	%d , MCS = %d, BW =	%d,	STBC = %d, SHORTGI = %d) \n",
 				pHTPhyMode->PhyMode, pHTPhyMode->TransmitNo,pHTPhyMode->HtMode,pHTPhyMode->ExtOffset,
 				pHTPhyMode->MCS, pHTPhyMode->BW, pHTPhyMode->STBC,	pHTPhyMode->SHORTGI));
 				if (pAdapter->CommonCfg.PhyMode	>= PHY_11ABGN_MIXED)
 					RTMPSetHT(pAdapter,	pHTPhyMode);
 			}
-			DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n", 
+			DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_HT_PHYMODE(MCS=%d,BW=%d,SGI=%d,STBC=%d)\n",
 				pAdapter->StaCfg.HTPhyMode.field.MCS, pAdapter->StaCfg.HTPhyMode.field.BW, pAdapter->StaCfg.HTPhyMode.field.ShortGI,
 				pAdapter->StaCfg.HTPhyMode.field.STBC));
 			break;
@@ -3895,7 +3895,7 @@ INT RTMPSetInformation(
 		case RT_OID_802_11_SET_APSD_SETTING:
 			if (wrq->u.data.length != sizeof(ULONG))
 				Status = -EINVAL;
-			else 
+			else
 			{
 				ULONG apsd ;
 				Status = copy_from_user(&apsd, wrq->u.data.pointer,	wrq->u.data.length);
@@ -3920,7 +3920,7 @@ INT RTMPSetInformation(
 		case RT_OID_802_11_SET_APSD_PSM:
 			if (wrq->u.data.length	!= sizeof(ULONG))
 				Status = -EINVAL;
-			else 
+			else
 			{
 				// Driver needs	to notify AP when PSM changes
 				Status = copy_from_user(&pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.pointer, wrq->u.data.length);
@@ -3936,7 +3936,7 @@ INT RTMPSetInformation(
 		case RT_OID_802_11_SET_DLS:
 			if (wrq->u.data.length != sizeof(ULONG))
 				Status = -EINVAL;
-			else 
+			else
 			{
 				BOOLEAN	oldvalue = pAdapter->CommonCfg.bDLSCapable;
 				Status = copy_from_user(&pAdapter->CommonCfg.bDLSCapable, wrq->u.data.pointer, wrq->u.data.length);
@@ -3973,16 +3973,16 @@ INT RTMPSetInformation(
 		case RT_OID_802_11_SET_DLS_PARAM:
 			if (wrq->u.data.length	!= sizeof(RT_802_11_DLS_UI))
 				Status = -EINVAL;
-			else 
+			else
 			{
 				RT_802_11_DLS	Dls;
 
 				NdisZeroMemory(&Dls, sizeof(RT_802_11_DLS));
 				RTMPMoveMemory(&Dls, wrq->u.data.pointer, sizeof(RT_802_11_DLS_UI));
-				MlmeEnqueue(pAdapter, 
-							MLME_CNTL_STATE_MACHINE, 
-							RT_OID_802_11_SET_DLS_PARAM, 
-							sizeof(RT_802_11_DLS), 
+				MlmeEnqueue(pAdapter,
+							MLME_CNTL_STATE_MACHINE,
+							RT_OID_802_11_SET_DLS_PARAM,
+							sizeof(RT_802_11_DLS),
 							&Dls);
 				DBGPRINT(RT_DEBUG_TRACE,("Set::RT_OID_802_11_SET_DLS_PARAM \n"));
 			}
@@ -3991,7 +3991,7 @@ INT RTMPSetInformation(
 		case RT_OID_802_11_SET_WMM:
 			if (wrq->u.data.length	!= sizeof(BOOLEAN))
 				Status = -EINVAL;
-			else 
+			else
 			{
 				Status = copy_from_user(&pAdapter->CommonCfg.bWmmCapable, wrq->u.data.pointer, wrq->u.data.length);
 				DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_802_11_SET_WMM (=%d)	\n", pAdapter->CommonCfg.bWmmCapable));
@@ -3999,24 +3999,24 @@ INT RTMPSetInformation(
 			break;
 
 		case OID_802_11_DISASSOCIATE:
-#ifdef RALINK_ATE			
+#ifdef RALINK_ATE
 			if (ATE_ON(pAdapter))
 			{
 				DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
 				break;
-			}	
+			}
 #endif // RALINK_ATE //
 			//
 			// Set NdisRadioStateOff to	TRUE, instead of called	MlmeRadioOff.
-			// Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be	0 
+			// Later on, NDIS_802_11_BSSID_LIST_EX->NumberOfItems should be	0
 			// when	query OID_802_11_BSSID_LIST.
 			//
 			// TRUE:  NumberOfItems	will set to	0.
 			// FALSE: NumberOfItems	no change.
-			//			
+			//
 			pAdapter->CommonCfg.NdisRadioStateOff =	TRUE;
 			// Set to immediately send the media disconnect	event
-			pAdapter->MlmeAux.CurrReqIsFromNdis	= TRUE;			
+			pAdapter->MlmeAux.CurrReqIsFromNdis	= TRUE;
 			DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_DISASSOCIATE	\n"));
 
 			if (INFRA_ON(pAdapter))
@@ -4027,7 +4027,7 @@ INT RTMPSetInformation(
 					DBGPRINT(RT_DEBUG_TRACE, ("!!! MLME	busy, reset	MLME state machine !!!\n"));
 				}
 
-				MlmeEnqueue(pAdapter, 
+				MlmeEnqueue(pAdapter,
 					MLME_CNTL_STATE_MACHINE,
 					OID_802_11_DISASSOCIATE,
 					0,
@@ -4073,12 +4073,12 @@ INT RTMPSetInformation(
 						pAdapter->CommonCfg.DesiredHtPhy.AmsduSize= Orde.AmsduSize;
 						pAdapter->CommonCfg.DesiredHtPhy.MimoPs = Orde.MMPSmode;
 						pAdapter->CommonCfg.BACapability.field.MMPSmode = Orde.MMPSmode;
-							
+
 						// UPdata to HT IE
 						pAdapter->CommonCfg.HtCapability.HtCapInfo.MimoPs = Orde.MMPSmode;
 						pAdapter->CommonCfg.HtCapability.HtCapInfo.AMsduSize = Orde.AmsduSize;
 						pAdapter->CommonCfg.HtCapability.HtCapParm.MpduDensity = Orde.MpduDensity;
-						
+
 						if (pAdapter->CommonCfg.BACapability.field.RxBAWinLimit > MAX_RX_REORDERBUF)
 							pAdapter->CommonCfg.BACapability.field.RxBAWinLimit = MAX_RX_REORDERBUF;
 
@@ -4096,7 +4096,7 @@ INT RTMPSetInformation(
 			DBGPRINT(RT_DEBUG_TRACE, (" Set :: RT_OID_802_11_ADD_IMME_BA \n"));
 			if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
 					Status = -EINVAL;
-			else 
+			else
 			{
 				UCHAR		        index;
 				OID_ADD_BA_ENTRY    BA;
@@ -4111,7 +4111,7 @@ INT RTMPSetInformation(
 				else
 				{
 					//BATableInsertEntry
-					//As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID. 
+					//As ad-hoc mode, BA pair is not limited to only BSSID. so add via OID.
 					index = BA.TID;
 					// in ad hoc mode, when adding BA pair, we should insert this entry into MACEntry too
 					pEntry = MacTableLookup(pAdapter, BA.MACAddr);
@@ -4127,7 +4127,7 @@ INT RTMPSetInformation(
 
 						BAOriSessionSetUp(pAdapter, pEntry, index, 0, 100, TRUE);
 					}
-					else 
+					else
 					{
 						//BATableInsertEntry(pAdapter, pEntry->Aid, BA.MACAddr, 0, 0xffff, BA.TID, BA.nMSDU, BA.IsRecipient);
 					}
@@ -4143,11 +4143,11 @@ INT RTMPSetInformation(
 			DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA \n"));
 			if (wrq->u.data.length != sizeof(OID_ADD_BA_ENTRY))
 					Status = -EINVAL;
-			else 
+			else
 			{
 				POID_ADD_BA_ENTRY	pBA;
 				MAC_TABLE_ENTRY *pEntry;
-				
+
 				pBA = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
 
 				if (pBA == NULL)
@@ -4159,13 +4159,13 @@ INT RTMPSetInformation(
 				{
 					Status = copy_from_user(pBA, wrq->u.data.pointer, wrq->u.data.length);
 					DBGPRINT(RT_DEBUG_TRACE, ("Set :: RT_OID_802_11_TEAR_IMME_BA(TID=%d, bAllTid=%d)\n", pBA->TID, pBA->bAllTid));
-					
+
 					if (!pBA->bAllTid && (pBA->TID > NUM_OF_TID))
 					{
 						Status = NDIS_STATUS_INVALID_DATA;
 						break;
 					}
-					
+
 					if (pBA->IsRecipient == FALSE)
 					{
 						pEntry = MacTableLookup(pAdapter, pBA->MACAddr);
@@ -4194,7 +4194,7 @@ INT RTMPSetInformation(
             break;
 #endif // DOT11_N_SUPPORT //
 
-        // For WPA_SUPPLICANT to set static wep key	  
+        // For WPA_SUPPLICANT to set static wep key
     	case OID_802_11_ADD_WEP:
     	    pWepKey = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
 
@@ -4254,10 +4254,10 @@ INT RTMPSetInformation(
                         NdisMoveMemory(pAdapter->StaCfg.DesireSharedKey[KeyIdx].Key, &pWepKey->KeyMaterial, pWepKey->KeyLength);
                         pAdapter->StaCfg.DesireSharedKeyId = KeyIdx;
                         pAdapter->StaCfg.DesireSharedKey[KeyIdx].CipherAlg = CipherAlg;
-#endif // WPA_SUPPLICANT_SUPPORT //                    
+#endif // WPA_SUPPLICANT_SUPPORT //
                         pAdapter->StaCfg.DefaultKeyId = (UCHAR) KeyIdx;
                     }
-                    
+
 #ifdef WPA_SUPPLICANT_SUPPORT
                     if (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED)
 #endif // WPA_SUPPLICANT_SUPPORT
@@ -4265,15 +4265,15 @@ INT RTMPSetInformation(
                         Key = pAdapter->SharedKey[BSS0][KeyIdx].Key;
 
                         // Set key material and cipherAlg to Asic
-        				AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);	
-                        
+        				AsicAddSharedKeyEntry(pAdapter, BSS0, KeyIdx, CipherAlg, Key, NULL, NULL);
+
                         if (pWepKey->KeyIndex & 0x80000000)
                         {
-                            PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];                            
-                            // Assign group key info  
+                            PMAC_TABLE_ENTRY pEntry = &pAdapter->MacTab.Content[BSSID_WCID];
+                            // Assign group key info
     						RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, NULL);
     						// Assign pairwise key info
-    						RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);	
+    						RTMPAddWcidAttributeEntry(pAdapter, BSS0, KeyIdx, CipherAlg, pEntry);
                         }
                     }
 					DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_ADD_WEP (id=0x%x, Len=%d-byte), %s\n", pWepKey->KeyIndex, pWepKey->KeyLength, (pAdapter->StaCfg.PortSecured == WPA_802_1X_PORT_SECURED) ? "Port Secured":"Port NOT Secured"));
@@ -4302,24 +4302,24 @@ INT RTMPSetInformation(
                 Status  = -EINVAL;
             else
             {
-                Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);                				
-    			pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;									
+                Status = copy_from_user(&wpa_supplicant_enable, wrq->u.data.pointer, wrq->u.data.length);
+    			pAdapter->StaCfg.WpaSupplicantUP = wpa_supplicant_enable;
     			DBGPRINT(RT_DEBUG_TRACE, ("Set::RT_OID_WPA_SUPPLICANT_SUPPORT (=%d)\n", pAdapter->StaCfg.WpaSupplicantUP));
 			}
-            break;	   
+            break;
         case OID_802_11_DEAUTHENTICATION:
             if (wrq->u.data.length != sizeof(MLME_DEAUTH_REQ_STRUCT))
                 Status  = -EINVAL;
             else
             {
                 MLME_DEAUTH_REQ_STRUCT      *pInfo;
-				MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);                
-                
+				MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);
+
                 pInfo = (MLME_DEAUTH_REQ_STRUCT *) MsgElem->Msg;
                 Status = copy_from_user(pInfo, wrq->u.data.pointer, wrq->u.data.length);
                 MlmeDeauthReqAction(pAdapter, MsgElem);
 				kfree(MsgElem);
-				
+
                 if (INFRA_ON(pAdapter))
                 {
                     LinkDown(pAdapter, FALSE);
@@ -4350,20 +4350,20 @@ INT RTMPSetInformation(
                 Status  = -EINVAL;
             else
             {
-                Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);                				
+                Status = copy_from_user(&IEEE8021xState, wrq->u.data.pointer, wrq->u.data.length);
 		        pAdapter->StaCfg.IEEE8021X = IEEE8021xState;
                 DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X (=%d)\n", IEEE8021xState));
             }
             break;
-        case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:	
+        case OID_802_11_SET_IEEE8021X_REQUIRE_KEY:
 			if (wrq->u.data.length != sizeof(BOOLEAN))
 				 Status  = -EINVAL;
             else
             {
-                Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);                				
-				pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;				
+                Status = copy_from_user(&IEEE8021x_required_keys, wrq->u.data.pointer, wrq->u.data.length);
+				pAdapter->StaCfg.IEEE8021x_required_keys = IEEE8021x_required_keys;
 				DBGPRINT(RT_DEBUG_TRACE, ("Set::OID_802_11_SET_IEEE8021X_REQUIRE_KEY (%d)\n", IEEE8021x_required_keys));
-			}	
+			}
 			break;
         case OID_802_11_PMKID:
 	        pPmkId = kmalloc(wrq->u.data.length, MEM_ALLOC_FLAG);
@@ -4373,7 +4373,7 @@ INT RTMPSetInformation(
                 break;
             }
             Status = copy_from_user(pPmkId, wrq->u.data.pointer, wrq->u.data.length);
-	  	  
+
 	        // check the PMKID information
 	        if (pPmkId->BSSIDInfoCount == 0)
                 NdisZeroMemory(pAdapter->StaCfg.SavedPMK, sizeof(BSSID_INFO)*PMKID_NO);
@@ -4392,7 +4392,7 @@ INT RTMPSetInformation(
 			        {
 				        // compare the BSSID
 				        if (NdisEqualMemory(pBssIdInfo->BSSID, pAdapter->StaCfg.SavedPMK[CachedIdx].BSSID, sizeof(NDIS_802_11_MAC_ADDRESS)))
-					        break;			
+					        break;
 			        }
 
 			        // Found, replace it
@@ -4409,10 +4409,10 @@ INT RTMPSetInformation(
 				        CachedIdx = (pBssIdInfo->BSSID[5] % PMKID_NO);
 				        DBGPRINT(RT_DEBUG_OFF, ("Update OID_802_11_PMKID, idx = %d\n", CachedIdx));
 				        NdisMoveMemory(&pAdapter->StaCfg.SavedPMK[CachedIdx], pBssIdInfo, sizeof(BSSID_INFO));
-			        }				
+			        }
 		        }
 			}
-			if(pPmkId) 
+			if(pPmkId)
 				kfree(pPmkId);
 	        break;
 #endif // WPA_SUPPLICANT_SUPPORT //
@@ -4452,7 +4452,7 @@ INT RTMPSetInformation(
 			pKey = kmalloc(wrq->u.data.length, GFP_KERNEL);
 			Status = copy_from_user(pKey, wrq->u.data.pointer, wrq->u.data.length);
 			//pKey = &WepKey;
-			
+
 			if ( pKey->Length != wrq->u.data.length)
 			{
 				Status = -EINVAL;
@@ -4544,9 +4544,9 @@ INT RTMPQueryInformation(
     BOOLEAN                             RadioState;
 	UCHAR	driverVersion[8];
     OID_SET_HT_PHYMODE			        *pHTPhyMode = NULL;
-	
 
-#ifdef SNMP_SUPPORT	
+
+#ifdef SNMP_SUPPORT
 	//for snmp, kathy
 	DefaultKeyIdxValue			*pKeyIdxValue;
 	INT							valueLen;
@@ -4555,12 +4555,12 @@ INT RTMPQueryInformation(
 	UCHAR						tmp[64];
 #endif //SNMP
 
-    switch(cmd) 
+    switch(cmd)
     {
         case RT_OID_DEVICE_NAME:
             wrq->u.data.length = sizeof(STA_NIC_DEVICE_NAME);
             Status = copy_to_user(wrq->u.data.pointer, STA_NIC_DEVICE_NAME, wrq->u.data.length);
-            break;        
+            break;
         case RT_OID_VERSION_INFO:
 			DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_VERSION_INFO \n"));
 			wrq->u.data.length = 8*sizeof(UCHAR);
@@ -4577,7 +4577,7 @@ INT RTMPQueryInformation(
 			wrq->u.data.length = sizeof(UINT32);
 			if (copy_to_user(wrq->u.data.pointer, &pAdapter->ate.TxDoneCount, wrq->u.data.length))
 			{
-				Status = -EFAULT; 	
+				Status = -EFAULT;
 			}
 			break;
 #endif // RALINK_ATE //
@@ -4594,8 +4594,8 @@ INT RTMPQueryInformation(
 			pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
             // Claculate total buffer size required
             BssBufSize = sizeof(ULONG);
-            
-            for (i = 0; i < pAdapter->ScanTab.BssNr; i++) 
+
+            for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
             {
                 // Align pointer to 4 bytes boundary.
                 //Padding = 4 - (pAdapter->ScanTab.BssEntry[i].VarIELen & 0x0003);
@@ -4617,13 +4617,13 @@ INT RTMPQueryInformation(
             NdisZeroMemory(pBuf, BssBufSize);
             pBssidList = (PNDIS_802_11_BSSID_LIST_EX) pBuf;
             pBssidList->NumberOfItems = pAdapter->ScanTab.BssNr;
-            
+
             // Calculate total buffer length
             BssLen = 4; // Consist of NumberOfItems
             // Point to start of NDIS_WLAN_BSSID_EX
             // pPtr = pBuf + sizeof(ULONG);
             pPtr = (PUCHAR) &pBssidList->Bssid[0];
-            for (i = 0; i < pAdapter->ScanTab.BssNr; i++) 
+            for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
             {
                 pBss = (PNDIS_WLAN_BSSID_EX) pPtr;
                 NdisMoveMemory(&pBss->MacAddress, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
@@ -4650,12 +4650,12 @@ INT RTMPQueryInformation(
                 pBss->Rssi = pAdapter->ScanTab.BssEntry[i].Rssi - pAdapter->BbpRssiToDbmDelta;
                 pBss->NetworkTypeInUse = NetworkTypeInUseSanity(&pAdapter->ScanTab.BssEntry[i]);
                 pBss->Configuration.Length = sizeof(NDIS_802_11_CONFIGURATION);
-                pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;  
+                pBss->Configuration.BeaconPeriod = pAdapter->ScanTab.BssEntry[i].BeaconPeriod;
                 pBss->Configuration.ATIMWindow = pAdapter->ScanTab.BssEntry[i].AtimWin;
 
                 MAP_CHANNEL_ID_TO_KHZ(pAdapter->ScanTab.BssEntry[i].Channel, pBss->Configuration.DSConfig);
 
-                if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA) 
+                if (pAdapter->ScanTab.BssEntry[i].BssType == BSS_INFRA)
                     pBss->InfrastructureMode = Ndis802_11Infrastructure;
                 else
                     pBss->InfrastructureMode = Ndis802_11IBSS;
@@ -4681,7 +4681,7 @@ INT RTMPQueryInformation(
                 }
                 pBss->Length = (ULONG)(sizeof(NDIS_WLAN_BSSID_EX) - 1 + sizeof(NDIS_802_11_FIXED_IEs) + pAdapter->ScanTab.BssEntry[i].VarIELen + Padding);
 
-#if WIRELESS_EXT < 17                
+#if WIRELESS_EXT < 17
                 if ((BssLen + pBss->Length) < wrq->u.data.length)
                 BssLen += pBss->Length;
                 else
@@ -4694,7 +4694,7 @@ INT RTMPQueryInformation(
 #endif
             }
 
-#if WIRELESS_EXT < 17            
+#if WIRELESS_EXT < 17
             wrq->u.data.length = BssLen;
 #else
             if (BssLen > wrq->u.data.length)
@@ -4717,18 +4717,18 @@ INT RTMPQueryInformation(
                 MediaState = NdisMediaStateConnected;
             else
                 MediaState = NdisMediaStateDisconnected;
-                
+
             wrq->u.data.length = sizeof(NDIS_MEDIA_STATE);
             Status = copy_to_user(wrq->u.data.pointer, &MediaState, wrq->u.data.length);
-            break;   
+            break;
         case OID_802_11_BSSID:
-#ifdef RALINK_ATE			
+#ifdef RALINK_ATE
 			if (ATE_ON(pAdapter))
 			{
 				DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
 				Status = NDIS_STATUS_RESOURCES;
 				break;
-			}	
+			}
 #endif // RALINK_ATE //
             if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
             {
@@ -4780,7 +4780,7 @@ INT RTMPQueryInformation(
                 MAP_CHANNEL_ID_TO_KHZ(pAdapter->CommonCfg.Channel, pConfiguration->DSConfig);
                 wrq->u.data.length = sizeof(NDIS_802_11_CONFIGURATION);
                 Status = copy_to_user(wrq->u.data.pointer, pConfiguration, wrq->u.data.length);
-                DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n", 
+                DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_CONFIGURATION(BeaconPeriod=%ld,AtimW=%ld,Channel=%d) \n",
                                         pConfiguration->BeaconPeriod, pConfiguration->ATIMWindow, pAdapter->CommonCfg.Channel));
 				kfree(pConfiguration);
             }
@@ -4802,7 +4802,7 @@ INT RTMPQueryInformation(
 			    Status = -EFAULT;
 			break;
 		case RT_OID_802_11_SNR_1:
-			if ((pAdapter->Antenna.field.RxPath	> 1) && 
+			if ((pAdapter->Antenna.field.RxPath	> 1) &&
                 (pAdapter->StaCfg.LastSNR1 > 0))
 			{
 				ulInfo = ((0xeb	- pAdapter->StaCfg.LastSNR1) * 3) /	16 ;
@@ -4843,7 +4843,7 @@ INT RTMPQueryInformation(
                 DBGPRINT(RT_DEBUG_TRACE, ("Query::OID_802_11_STATISTICS \n"));
                 // add the most up-to-date h/w raw counters into software counters
 			    NICUpdateRawCounters(pAdapter);
-                
+
                 // Sanity check for calculation of sucessful count
                 if (pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart < pAdapter->WlanCounters.RetryCount.QuadPart)
                     pAdapter->WlanCounters.TransmittedFragmentCount.QuadPart = pAdapter->WlanCounters.RetryCount.QuadPart;
@@ -4859,7 +4859,7 @@ INT RTMPQueryInformation(
                 pStatistics->FrameDuplicateCount.QuadPart = pAdapter->WlanCounters.FrameDuplicateCount.QuadPart;
                 pStatistics->ReceivedFragmentCount.QuadPart = pAdapter->WlanCounters.ReceivedFragmentCount.QuadPart;
                 pStatistics->MulticastReceivedFrameCount.QuadPart = pAdapter->WlanCounters.MulticastReceivedFrameCount.QuadPart;
-#ifdef DBG	
+#ifdef DBG
                 pStatistics->FCSErrorCount = pAdapter->RalinkCounters.RealFcsErrCount;
 #else
                 pStatistics->FCSErrorCount.QuadPart = pAdapter->WlanCounters.FCSErrorCount.QuadPart;
@@ -4983,7 +4983,7 @@ INT RTMPQueryInformation(
 			DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_TX_POWER_LEVEL_1 (=%ld)\n", pAdapter->CommonCfg.TxPowerPercentage));
 			break;
         case OID_802_11_NETWORK_TYPES_SUPPORTED:
-			if ((pAdapter->RfIcType	== RFIC_2850) || (pAdapter->RfIcType ==	RFIC_2750))		
+			if ((pAdapter->RfIcType	== RFIC_2850) || (pAdapter->RfIcType ==	RFIC_2750))
 			{
 				NetworkTypeList[0] = 3;                 // NumberOfItems = 3
 				NetworkTypeList[1] = Ndis802_11DS;      // NetworkType[1] = 11b
@@ -5054,13 +5054,13 @@ INT RTMPQueryInformation(
 
 			wrq->u.data.length = sizeof(ULONG);
 			Status = copy_to_user(wrq->u.data.pointer, &apsd, wrq->u.data.length);
-			DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_SETTING (=0x%lx,APSDCap=%d,AC_BE=%d,AC_BK=%d,AC_VI=%d,AC_VO=%d,MAXSPLen=%d)\n", 
+			DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_SETTING (=0x%lx,APSDCap=%d,AC_BE=%d,AC_BK=%d,AC_VI=%d,AC_VO=%d,MAXSPLen=%d)\n",
 				apsd,pAdapter->CommonCfg.bAPSDCapable,pAdapter->CommonCfg.bAPSDAC_BE,pAdapter->CommonCfg.bAPSDAC_BK,pAdapter->CommonCfg.bAPSDAC_VI,pAdapter->CommonCfg.bAPSDAC_VO,pAdapter->CommonCfg.MaxSPLength));
 			break;
 		case RT_OID_802_11_QUERY_APSD_PSM:
 			wrq->u.data.length = sizeof(ULONG);
 			Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.bAPSDForcePowerSave, wrq->u.data.length);
-			DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));			
+			DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_QUERY_APSD_PSM (=%d)\n", pAdapter->CommonCfg.bAPSDForcePowerSave));
 			break;
 		case RT_OID_802_11_QUERY_WMM:
 			wrq->u.data.length = sizeof(BOOLEAN);
@@ -5094,14 +5094,14 @@ INT RTMPQueryInformation(
         case RT_OID_802_11_QUERY_HT_PHYMODE:
             pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
             if (pHTPhyMode)
-            {           
+            {
                 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
     			pHTPhyMode->HtMode = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MODE;
     			pHTPhyMode->BW = (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.BW;
     			pHTPhyMode->MCS= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.MCS;
     			pHTPhyMode->SHORTGI= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.ShortGI;
     			pHTPhyMode->STBC= (UCHAR)pAdapter->MacTab.Content[BSSID_WCID].HTPhyMode.field.STBC;
-    	
+
     			pHTPhyMode->ExtOffset = ((pAdapter->CommonCfg.CentralChannel < pAdapter->CommonCfg.Channel) ? (EXTCHA_BELOW) : (EXTCHA_ABOVE));
                 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
                 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
@@ -5131,14 +5131,14 @@ INT RTMPQueryInformation(
         case RT_OID_802_11_QUERY_DAT_HT_PHYMODE:
             pHTPhyMode = (OID_SET_HT_PHYMODE *) kmalloc(sizeof(OID_SET_HT_PHYMODE), MEM_ALLOC_FLAG);
             if (pHTPhyMode)
-            {           
+            {
                 pHTPhyMode->PhyMode = pAdapter->CommonCfg.PhyMode;
     			pHTPhyMode->HtMode = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.HTMODE;
     			pHTPhyMode->BW = (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.BW;
     			pHTPhyMode->MCS= (UCHAR)pAdapter->StaCfg.DesiredTransmitSetting.field.MCS;
     			pHTPhyMode->SHORTGI= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.ShortGI;
     			pHTPhyMode->STBC= (UCHAR)pAdapter->CommonCfg.RegTransmitSetting.field.STBC;
-    	
+
                 wrq->u.data.length = sizeof(OID_SET_HT_PHYMODE);
                 if (copy_to_user(wrq->u.data.pointer, pHTPhyMode, wrq->u.data.length))
     			{
@@ -5154,7 +5154,7 @@ INT RTMPQueryInformation(
                 Status = -EFAULT;
             }
             break;
-        case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:            
+        case RT_OID_QUERY_MULTIPLE_CARD_SUPPORT:
 			wrq->u.data.length = sizeof(UCHAR);
             i = 0;
 #ifdef MULTIPLE_CARD_SUPPORT
@@ -5203,7 +5203,7 @@ INT RTMPQueryInformation(
 				ulInfo = 1; // 1 is power active else 2 is power save.
 			else
 				ulInfo = 2;
-			
+
 			wrq->u.data.length = sizeof(ulInfo);
 			Status = copy_to_user(wrq->u.data.pointer, &ulInfo, wrq->u.data.length);
 			break;
@@ -5261,17 +5261,17 @@ INT RTMPQueryInformation(
 			DBGPRINT(RT_DEBUG_TRACE, ("LongRetryLimit =%ld,  tx_rty_cfg.field.LongRtyLimit=%d\n", LongRetryLimit, tx_rty_cfg.field.LongRtyLimit));
 			Status = copy_to_user(wrq->u.data.pointer, &LongRetryLimit, wrq->u.data.length);
 			break;
-			
+
 		case RT_OID_802_11_PRODUCTID:
 			DBGPRINT(RT_DEBUG_TRACE, ("Query::RT_OID_802_11_PRODUCTID \n"));
-		
+
 #ifdef RT2860
 			{
-			
+
 				USHORT  device_id;
 				if (((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev != NULL)
 			    	pci_read_config_word(((POS_COOKIE)pAdapter->OS_Cookie)->pci_dev, PCI_DEVICE_ID, &device_id);
-				else 
+				else
 					DBGPRINT(RT_DEBUG_TRACE, (" pci_dev = NULL\n"));
 				sprintf(tmp, "%04x %04x\n", NIC_PCI_VENDOR_ID, device_id);
 			}
@@ -5294,7 +5294,7 @@ INT RTMPQueryInformation(
 			DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
 			break;
 #endif //SNMP_SUPPORT
-		
+
 		case OID_802_11_BUILD_CHANNEL_EX:
 			{
 				UCHAR value;
@@ -5355,7 +5355,7 @@ INT RTMPQueryInformation(
 			wrq->u.data.length = 1;
 			Status = copy_to_user(wrq->u.data.pointer, &pAdapter->CommonCfg.Geography, 1);
 			DBGPRINT(RT_DEBUG_TRACE, ("Status=%d\n", Status));
-			break;			
+			break;
 
 
 #ifdef QOS_DLS_SUPPORT
@@ -5395,8 +5395,8 @@ INT RTMPQueryInformation(
 }
 
 INT rt28xx_sta_ioctl(
-	IN	struct net_device	*net_dev, 
-	IN	OUT	struct ifreq	*rq, 
+	IN	struct net_device	*net_dev,
+	IN	OUT	struct ifreq	*rq,
 	IN	INT					cmd)
 {
 	POS_COOKIE			pObj;
@@ -5438,7 +5438,7 @@ INT rt28xx_sta_ioctl(
 #endif // CONFIG_APSTA_MIXED_SUPPORT //
         {
             DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n"));
-		    return -ENETDOWN;  
+		    return -ENETDOWN;
         }
     }
 
@@ -5448,7 +5448,7 @@ INT rt28xx_sta_ioctl(
 	}
 
 	switch(cmd)
-	{			
+	{
 #ifdef RALINK_ATE
 #ifdef RALINK_28xx_QA
 		case RTPRIV_IOCTL_ATE:
@@ -5456,12 +5456,12 @@ INT rt28xx_sta_ioctl(
 				RtmpDoAte(pAd, wrq);
 			}
 			break;
-#endif // RALINK_28xx_QA // 
+#endif // RALINK_28xx_QA //
 #endif // RALINK_ATE //
         case SIOCGIFHWADDR:
 			DBGPRINT(RT_DEBUG_TRACE, ("IOCTL::SIOCGIFHWADDR\n"));
 			memcpy(wrq->u.name, pAd->CurrentAddress, ETH_ALEN);
-			break;	
+			break;
 		case SIOCGIWNAME:
         {
         	char *name=&wrq->u.name[0];
@@ -5478,7 +5478,7 @@ INT rt28xx_sta_ioctl(
         {
         	struct iw_point	*essid=&wrq->u.essid;
         	rt_ioctl_siwessid(net_dev, NULL, essid, essid->pointer);
-			break;  
+			break;
 		}
 		case SIOCSIWNWID:   // set network id (the cell)
 		case SIOCGIWNWID:   // get network id
@@ -5586,16 +5586,16 @@ INT rt28xx_sta_ioctl(
 		case SIOCGIWRETRY:	//get retry limits and lifetime
 		case SIOCSIWRETRY:	//set retry limits and lifetime
 			Status = -EOPNOTSUPP;
-			break;			
+			break;
 		case RT_PRIV_IOCTL:
 			subcmd = wrq->u.data.flags;
 			if( subcmd & OID_GET_SET_TOGGLE)
 				Status = RTMPSetInformation(pAd, rq, subcmd);
 			else
 				Status = RTMPQueryInformation(pAd, rq, subcmd);
-			break;		
+			break;
 		case SIOCGIWPRIV:
-			if (wrq->u.data.pointer) 
+			if (wrq->u.data.pointer)
 			{
 				if ( access_ok(VERIFY_WRITE, wrq->u.data.pointer, sizeof(privtab)) != TRUE)
 					break;
@@ -5605,13 +5605,13 @@ INT rt28xx_sta_ioctl(
 			}
 			break;
 		case RTPRIV_IOCTL_SET:
-			if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)   
+			if(access_ok(VERIFY_READ, wrq->u.data.pointer, wrq->u.data.length) != TRUE)
 				break;
 			rt_ioctl_setparam(net_dev, NULL, NULL, wrq->u.data.pointer);
 			break;
 		case RTPRIV_IOCTL_GSITESURVEY:
 			RTMPIoctlGetSiteSurvey(pAd, wrq);
-		    break;			
+		    break;
 #ifdef DBG
 		case RTPRIV_IOCTL_MAC:
 			RTMPIoctlMAC(pAd, wrq);
@@ -5634,7 +5634,7 @@ INT rt28xx_sta_ioctl(
 	return Status;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set SSID
@@ -5643,7 +5643,7 @@ INT rt28xx_sta_ioctl(
     ==========================================================================
 */
 INT Set_SSID_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg)
 {
     NDIS_802_11_SSID                    Ssid, *pSsid=NULL;
@@ -5659,13 +5659,13 @@ INT Set_SSID_Proc(
             Ssid.SsidLength = strlen(arg);
         }
         else   //ANY ssid
-        {    
-            Ssid.SsidLength = 0; 
+        {
+            Ssid.SsidLength = 0;
 		    memcpy(Ssid.Ssid, "", 0);
-			pAdapter->StaCfg.BssType = BSS_INFRA;	
+			pAdapter->StaCfg.BssType = BSS_INFRA;
 			pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeOpen;
-	        pAdapter->StaCfg.WepStatus  = Ndis802_11EncryptionDisabled;		    
-		}	 
+	        pAdapter->StaCfg.WepStatus  = Ndis802_11EncryptionDisabled;
+		}
         pSsid = &Ssid;
 
         if (pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE)
@@ -5678,8 +5678,8 @@ INT Set_SSID_Proc(
         pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE;
 		pAdapter->bConfigChanged = TRUE;
 
-        MlmeEnqueue(pAdapter, 
-                    MLME_CNTL_STATE_MACHINE, 
+        MlmeEnqueue(pAdapter,
+                    MLME_CNTL_STATE_MACHINE,
                     OID_802_11_SSID,
                     sizeof(NDIS_802_11_SSID),
                     (VOID *)pSsid);
@@ -5697,7 +5697,7 @@ INT Set_SSID_Proc(
 }
 
 #ifdef WMM_SUPPORT
-/* 
+/*
     ==========================================================================
     Description:
         Set WmmCapable Enable or Disable
@@ -5706,7 +5706,7 @@ INT Set_SSID_Proc(
     ==========================================================================
 */
 INT	Set_WmmCapable_Proc(
-	IN	PRTMP_ADAPTER	pAd, 
+	IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 	BOOLEAN	bWmmCapable;
@@ -5719,16 +5719,16 @@ INT	Set_WmmCapable_Proc(
 	else if (bWmmCapable == 0)
 		pAd->CommonCfg.bWmmCapable = FALSE;
 	else
-		return FALSE;  //Invalid argument 
-	
-	DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n", 
+		return FALSE;  //Invalid argument
+
+	DBGPRINT(RT_DEBUG_TRACE, ("Set_WmmCapable_Proc::(bWmmCapable=%d)\n",
 		pAd->CommonCfg.bWmmCapable));
 
 	return TRUE;
 }
 #endif // WMM_SUPPORT //
 
-/* 
+/*
     ==========================================================================
     Description:
         Set Network Type(Infrastructure/Adhoc mode)
@@ -5737,7 +5737,7 @@ INT	Set_WmmCapable_Proc(
     ==========================================================================
 */
 INT Set_NetworkType_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg)
 {
     UINT32	Value = 0;
@@ -5745,7 +5745,7 @@ INT Set_NetworkType_Proc(
     if (strcmp(arg, "Adhoc") == 0)
 	{
 		if (pAdapter->StaCfg.BssType != BSS_ADHOC)
-		{				    
+		{
 			// Config has changed
 			pAdapter->bConfigChanged = TRUE;
             if (MONITOR_ON(pAdapter))
@@ -5764,13 +5764,13 @@ INT Set_NetworkType_Proc(
 				// Set the AutoReconnectSsid to prevent it reconnect to old SSID
 				// Since calling this indicate user don't want to connect to that SSID anymore.
 				pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-				NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);		
-				
+				NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
+
 				LinkDown(pAdapter, FALSE);
 
 				DBGPRINT(RT_DEBUG_TRACE, ("NDIS_STATUS_MEDIA_DISCONNECT Event BB!\n"));
 			}
-		}			
+		}
 		pAdapter->StaCfg.BssType = BSS_ADHOC;
         pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
 		DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(AD-HOC)\n"));
@@ -5778,7 +5778,7 @@ INT Set_NetworkType_Proc(
     else if (strcmp(arg, "Infra") == 0)
 	{
 		if (pAdapter->StaCfg.BssType != BSS_INFRA)
-		{			    
+		{
 			// Config has changed
 			pAdapter->bConfigChanged = TRUE;
             if (MONITOR_ON(pAdapter))
@@ -5796,15 +5796,15 @@ INT Set_NetworkType_Proc(
 				// Set the AutoReconnectSsid to prevent it reconnect to old SSID
 				// Since calling this indicate user don't want to connect to that SSID anymore.
 				pAdapter->MlmeAux.AutoReconnectSsidLen= 32;
-				NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);			
-			
+				NdisZeroMemory(pAdapter->MlmeAux.AutoReconnectSsid, pAdapter->MlmeAux.AutoReconnectSsidLen);
+
 				LinkDown(pAdapter, FALSE);
 			}
-		}			
+		}
 		pAdapter->StaCfg.BssType = BSS_INFRA;
         pAdapter->net_dev->type = pAdapter->StaCfg.OriDevType;
 		DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(INFRA)\n"));
-            
+
         pAdapter->StaCfg.BssType = BSS_INFRA;
 	}
     else if (strcmp(arg, "Monitor") == 0)
@@ -5844,7 +5844,7 @@ INT Set_NetworkType_Proc(
 			bbpValue |= 0x10;
 			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R4, bbpValue);
 			pAdapter->CommonCfg.BBPCurrentBW = BW_40;
-			//  RX : control channel at lower 
+			//  RX : control channel at lower
 			RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
 			bbpValue &= (~0x20);
 			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
@@ -5855,7 +5855,7 @@ INT Set_NetworkType_Proc(
 			pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel + 2;
             AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
 		    AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
-            DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n", 
+            DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
                                        pAdapter->CommonCfg.Channel,
                                        pAdapter->CommonCfg.CentralChannel));
 		}
@@ -5872,14 +5872,14 @@ INT Set_NetworkType_Proc(
 			RTMP_IO_READ32(pAdapter, TX_BAND_CFG, &Value);
 			Value |= 0x1;
 			RTMP_IO_WRITE32(pAdapter, TX_BAND_CFG, Value);
-			
+
 			RTMP_BBP_IO_READ8_BY_REG_ID(pAdapter, BBP_R3, &bbpValue);
 			bbpValue |= (0x20);
 			RTMP_BBP_IO_WRITE8_BY_REG_ID(pAdapter, BBP_R3, bbpValue);
 			pAdapter->CommonCfg.CentralChannel = pAdapter->CommonCfg.Channel - 2;
             AsicSwitchChannel(pAdapter, pAdapter->CommonCfg.CentralChannel, FALSE);
 		    AsicLockChannel(pAdapter, pAdapter->CommonCfg.CentralChannel);
-            DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n", 
+            DBGPRINT(RT_DEBUG_TRACE, ("BW_40 ,control_channel(%d), CentralChannel(%d) \n",
                                        pAdapter->CommonCfg.Channel,
                                        pAdapter->CommonCfg.CentralChannel));
 		}
@@ -5907,7 +5907,7 @@ INT Set_NetworkType_Proc(
 		csr.field.bTBTTEnable = 0;
 		csr.field.TsfSyncMode = 0;
 		RTMP_IO_WRITE32(pAdapter, BCN_TIME_CFG, csr.word);
-        
+
 		pAdapter->StaCfg.BssType = BSS_MONITOR;
         pAdapter->net_dev->type = ARPHRD_IEEE80211_PRISM; //ARPHRD_IEEE80211; // IEEE80211
 		DBGPRINT(RT_DEBUG_TRACE, ("===>Set_NetworkType_Proc::(MONITOR)\n"));
@@ -5921,7 +5921,7 @@ INT Set_NetworkType_Proc(
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set Authentication mode
@@ -5930,7 +5930,7 @@ INT Set_NetworkType_Proc(
     ==========================================================================
 */
 INT Set_AuthMode_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg)
 {
     if ((strcmp(arg, "WEPAUTO") == 0) || (strcmp(arg, "wepauto") == 0))
@@ -5944,15 +5944,15 @@ INT Set_AuthMode_Proc(
     else if ((strcmp(arg, "WPANONE") == 0) || (strcmp(arg, "wpanone") == 0))
         pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPANone;
     else if ((strcmp(arg, "WPA2PSK") == 0) || (strcmp(arg, "wpa2psk") == 0))
-        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;    
-#ifdef WPA_SUPPLICANT_SUPPORT    
+        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
+#ifdef WPA_SUPPLICANT_SUPPORT
     else if ((strcmp(arg, "WPA") == 0) || (strcmp(arg, "wpa") == 0))
-        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;    
+        pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA;
     else if ((strcmp(arg, "WPA2") == 0) || (strcmp(arg, "wpa2") == 0))
         pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2;
 #endif // WPA_SUPPLICANT_SUPPORT //
     else
-        return FALSE;  
+        return FALSE;
 
     pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
 
@@ -5961,7 +5961,7 @@ INT Set_AuthMode_Proc(
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set Encryption Type
@@ -5970,14 +5970,14 @@ INT Set_AuthMode_Proc(
     ==========================================================================
 */
 INT Set_EncrypType_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg)
 {
     if ((strcmp(arg, "NONE") == 0) || (strcmp(arg, "none") == 0))
     {
         if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
             return TRUE;    // do nothing
-            
+
         pAdapter->StaCfg.WepStatus     = Ndis802_11WEPDisabled;
         pAdapter->StaCfg.PairCipher    = Ndis802_11WEPDisabled;
 	    pAdapter->StaCfg.GroupCipher   = Ndis802_11WEPDisabled;
@@ -5986,7 +5986,7 @@ INT Set_EncrypType_Proc(
     {
         if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
             return TRUE;    // do nothing
-            
+
         pAdapter->StaCfg.WepStatus     = Ndis802_11WEPEnabled;
         pAdapter->StaCfg.PairCipher    = Ndis802_11WEPEnabled;
 	    pAdapter->StaCfg.GroupCipher   = Ndis802_11WEPEnabled;
@@ -5995,7 +5995,7 @@ INT Set_EncrypType_Proc(
     {
         if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
             return TRUE;    // do nothing
-            
+
         pAdapter->StaCfg.WepStatus     = Ndis802_11Encryption2Enabled;
         pAdapter->StaCfg.PairCipher    = Ndis802_11Encryption2Enabled;
 	    pAdapter->StaCfg.GroupCipher   = Ndis802_11Encryption2Enabled;
@@ -6004,7 +6004,7 @@ INT Set_EncrypType_Proc(
     {
         if (pAdapter->StaCfg.AuthMode < Ndis802_11AuthModeWPA)
             return TRUE;    // do nothing
-            
+
         pAdapter->StaCfg.WepStatus     = Ndis802_11Encryption3Enabled;
         pAdapter->StaCfg.PairCipher    = Ndis802_11Encryption3Enabled;
 	    pAdapter->StaCfg.GroupCipher   = Ndis802_11Encryption3Enabled;
@@ -6019,7 +6019,7 @@ INT Set_EncrypType_Proc(
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set Default Key ID
@@ -6028,7 +6028,7 @@ INT Set_EncrypType_Proc(
     ==========================================================================
 */
 INT Set_DefaultKeyID_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg)
 {
     ULONG                               KeyIdx;
@@ -6037,14 +6037,14 @@ INT Set_DefaultKeyID_Proc(
     if((KeyIdx >= 1 ) && (KeyIdx <= 4))
         pAdapter->StaCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
     else
-        return FALSE;  //Invalid argument 
+        return FALSE;  //Invalid argument
 
     DBGPRINT(RT_DEBUG_TRACE, ("Set_DefaultKeyID_Proc::(DefaultKeyID=%d)\n", pAdapter->StaCfg.DefaultKeyId));
 
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set WEP KEY1
@@ -6053,7 +6053,7 @@ INT Set_DefaultKeyID_Proc(
     ==========================================================================
 */
 INT Set_Key1_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg)
 {
     int                                 KeyLen;
@@ -6062,7 +6062,7 @@ INT Set_Key1_Proc(
 
     if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
         return TRUE;    // do nothing
-    
+
     KeyLen = strlen(arg);
 
     switch (KeyLen)
@@ -6071,7 +6071,7 @@ INT Set_Key1_Proc(
             pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
             memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
             CipherAlg = CIPHER_WEP64;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));       
+            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
             break;
         case 10: //wep 40 Hex type
             for(i=0; i < KeyLen; i++)
@@ -6082,13 +6082,13 @@ INT Set_Key1_Proc(
             pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
             AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
             CipherAlg = CIPHER_WEP64;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));     
+            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
             break;
         case 13: //wep 104 Ascii type
             pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen;
             memcpy(pAdapter->SharedKey[BSS0][0].Key, arg, KeyLen);
             CipherAlg = CIPHER_WEP128;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));       
+            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Ascii"));
             break;
         case 26: //wep 104 Hex type
             for(i=0; i < KeyLen; i++)
@@ -6099,13 +6099,13 @@ INT Set_Key1_Proc(
             pAdapter->SharedKey[BSS0][0].KeyLen = KeyLen / 2 ;
             AtoH(arg, pAdapter->SharedKey[BSS0][0].Key, KeyLen / 2);
             CipherAlg = CIPHER_WEP128;
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));     
+            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::(Key1=%s and type=%s)\n", arg, "Hex"));
             break;
-        default: //Invalid argument 
-            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));       
+        default: //Invalid argument
+            DBGPRINT(RT_DEBUG_TRACE, ("Set_Key1_Proc::Invalid argument (=%s)\n", arg));
             return FALSE;
     }
-    
+
     pAdapter->SharedKey[BSS0][0].CipherAlg = CipherAlg;
 
     // Set keys (into ASIC)
@@ -6113,18 +6113,18 @@ INT Set_Key1_Proc(
         ;   // not support
     else    // Old WEP stuff
     {
-        AsicAddSharedKeyEntry(pAdapter, 
-                              0, 
-                              0, 
-                              pAdapter->SharedKey[BSS0][0].CipherAlg, 
-                              pAdapter->SharedKey[BSS0][0].Key, 
+        AsicAddSharedKeyEntry(pAdapter,
+                              0,
+                              0,
+                              pAdapter->SharedKey[BSS0][0].CipherAlg,
+                              pAdapter->SharedKey[BSS0][0].Key,
                               NULL,
                               NULL);
     }
-    
+
     return TRUE;
 }
-/* 
+/*
     ==========================================================================
 
     Description:
@@ -6134,7 +6134,7 @@ INT Set_Key1_Proc(
     ==========================================================================
 */
 INT Set_Key2_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg)
 {
     int                                 KeyLen;
@@ -6143,7 +6143,7 @@ INT Set_Key2_Proc(
 
     if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
         return TRUE;    // do nothing
-    
+
     KeyLen = strlen(arg);
 
     switch (KeyLen)
@@ -6182,7 +6182,7 @@ INT Set_Key2_Proc(
             CipherAlg = CIPHER_WEP128;
             DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::(Key2=%s and type=%s)\n", arg, "Hex"));
             break;
-        default: //Invalid argument 
+        default: //Invalid argument
             DBGPRINT(RT_DEBUG_TRACE, ("Set_Key2_Proc::Invalid argument (=%s)\n", arg));
             return FALSE;
     }
@@ -6193,18 +6193,18 @@ INT Set_Key2_Proc(
         ;   // not support
     else    // Old WEP stuff
     {
-        AsicAddSharedKeyEntry(pAdapter, 
-                              0, 
-                              1, 
-                              pAdapter->SharedKey[BSS0][1].CipherAlg, 
-                              pAdapter->SharedKey[BSS0][1].Key, 
+        AsicAddSharedKeyEntry(pAdapter,
+                              0,
+                              1,
+                              pAdapter->SharedKey[BSS0][1].CipherAlg,
+                              pAdapter->SharedKey[BSS0][1].Key,
                               NULL,
                               NULL);
-    }        
-    
+    }
+
     return TRUE;
 }
-/* 
+/*
     ==========================================================================
     Description:
         Set WEP KEY3
@@ -6213,7 +6213,7 @@ INT Set_Key2_Proc(
     ==========================================================================
 */
 INT Set_Key3_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg)
 {
     int                                 KeyLen;
@@ -6222,7 +6222,7 @@ INT Set_Key3_Proc(
 
     if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
         return TRUE;    // do nothing
-    
+
     KeyLen = strlen(arg);
 
     switch (KeyLen)
@@ -6261,29 +6261,29 @@ INT Set_Key3_Proc(
             CipherAlg = CIPHER_WEP128;
             DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::(Key3=%s and type=Hex)\n", arg));
             break;
-        default: //Invalid argument 
+        default: //Invalid argument
             DBGPRINT(RT_DEBUG_TRACE, ("Set_Key3_Proc::Invalid argument (=%s)\n", arg));
             return FALSE;
     }
     pAdapter->SharedKey[BSS0][2].CipherAlg = CipherAlg;
-    
+
     // Set keys (into ASIC)
     if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
         ;   // not support
     else    // Old WEP stuff
     {
-        AsicAddSharedKeyEntry(pAdapter, 
-                              0, 
-                              2, 
-                              pAdapter->SharedKey[BSS0][2].CipherAlg, 
-                              pAdapter->SharedKey[BSS0][2].Key, 
+        AsicAddSharedKeyEntry(pAdapter,
+                              0,
+                              2,
+                              pAdapter->SharedKey[BSS0][2].CipherAlg,
+                              pAdapter->SharedKey[BSS0][2].Key,
                               NULL,
                               NULL);
     }
-    
+
     return TRUE;
 }
-/* 
+/*
     ==========================================================================
     Description:
         Set WEP KEY4
@@ -6292,7 +6292,7 @@ INT Set_Key3_Proc(
     ==========================================================================
 */
 INT Set_Key4_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg)
 {
     int                                 KeyLen;
@@ -6301,7 +6301,7 @@ INT Set_Key4_Proc(
 
     if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
         return TRUE;    // do nothing
-    
+
     KeyLen = strlen(arg);
 
     switch (KeyLen)
@@ -6340,30 +6340,30 @@ INT Set_Key4_Proc(
             CipherAlg = CIPHER_WEP128;
             DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::(Key4=%s and type=%s)\n", arg, "Hex"));
             break;
-        default: //Invalid argument 
+        default: //Invalid argument
             DBGPRINT(RT_DEBUG_TRACE, ("Set_Key4_Proc::Invalid argument (=%s)\n", arg));
             return FALSE;
-    } 
+    }
     pAdapter->SharedKey[BSS0][3].CipherAlg = CipherAlg;
-    
+
     // Set keys (into ASIC)
     if (pAdapter->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
         ;   // not support
     else    // Old WEP stuff
     {
-        AsicAddSharedKeyEntry(pAdapter, 
-                              0, 
-                              3, 
-                              pAdapter->SharedKey[BSS0][3].CipherAlg, 
-                              pAdapter->SharedKey[BSS0][3].Key, 
+        AsicAddSharedKeyEntry(pAdapter,
+                              0,
+                              3,
+                              pAdapter->SharedKey[BSS0][3].CipherAlg,
+                              pAdapter->SharedKey[BSS0][3].Key,
                               NULL,
                               NULL);
     }
-    
+
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set WPA PSK key
@@ -6372,17 +6372,17 @@ INT Set_Key4_Proc(
     ==========================================================================
 */
 INT Set_WPAPSK_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg)
 {
     UCHAR                   keyMaterial[40];
-    
-    if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) && 
+
+    if ((pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&
         (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&
 	    (pAdapter->StaCfg.AuthMode != Ndis802_11AuthModeWPANone)
 		)
         return TRUE;    // do nothing
-        
+
     DBGPRINT(RT_DEBUG_TRACE, ("Set_WPAPSK_Proc::(WPAPSK=%s)\n", arg));
 
     NdisZeroMemory(keyMaterial, 40);
@@ -6397,10 +6397,10 @@ INT Set_WPAPSK_Proc(
     {
         AtoH(arg, keyMaterial, 32);
         NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
-        
+
     }
     else
-    {   
+    {
         PasswordHash((char *)arg, pAdapter->MlmeAux.Ssid, pAdapter->MlmeAux.SsidLen, keyMaterial);
         NdisMoveMemory(pAdapter->StaCfg.PMK, keyMaterial, 32);
     }
@@ -6410,18 +6410,18 @@ INT Set_WPAPSK_Proc(
     if(pAdapter->StaCfg.BssType == BSS_ADHOC &&
        pAdapter->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
     {
-         pAdapter->StaCfg.WpaState = SS_NOTUSE;     
+         pAdapter->StaCfg.WpaState = SS_NOTUSE;
     }
     else
     {
         // Start STA supplicant state machine
         pAdapter->StaCfg.WpaState = SS_START;
-    }    
+    }
 
     return TRUE;
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Set Power Saving mode
@@ -6430,12 +6430,12 @@ INT Set_WPAPSK_Proc(
     ==========================================================================
 */
 INT Set_PSMode_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg)
 {
     if (pAdapter->StaCfg.BssType == BSS_INFRA)
     {
-        if ((strcmp(arg, "Max_PSP") == 0) || 
+        if ((strcmp(arg, "Max_PSP") == 0) ||
 			(strcmp(arg, "max_psp") == 0) ||
 			(strcmp(arg, "MAX_PSP") == 0))
         {
@@ -6446,9 +6446,9 @@ INT Set_PSMode_Proc(
             pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
             OPSTATUS_SET_FLAG(pAdapter, fOP_STATUS_RECEIVE_DTIM);
             pAdapter->StaCfg.DefaultListenCount = 5;
-        
+
         }
-        else if ((strcmp(arg, "Fast_PSP") == 0) || 
+        else if ((strcmp(arg, "Fast_PSP") == 0) ||
 				 (strcmp(arg, "fast_psp") == 0) ||
                  (strcmp(arg, "FAST_PSP") == 0))
         {
@@ -6460,8 +6460,8 @@ INT Set_PSMode_Proc(
             pAdapter->StaCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
             pAdapter->StaCfg.DefaultListenCount = 3;
         }
-        else if ((strcmp(arg, "Legacy_PSP") == 0) || 
-                 (strcmp(arg, "legacy_psp") == 0) || 
+        else if ((strcmp(arg, "Legacy_PSP") == 0) ||
+                 (strcmp(arg, "legacy_psp") == 0) ||
                  (strcmp(arg, "LEGACY_PSP") == 0))
         {
             // do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
@@ -6488,12 +6488,12 @@ INT Set_PSMode_Proc(
     else
         return FALSE;
 
-        
+
     return TRUE;
 }
 
 #ifdef WPA_SUPPLICANT_SUPPORT
-/* 
+/*
     ==========================================================================
     Description:
         Set WpaSupport flag.
@@ -6506,7 +6506,7 @@ INT Set_PSMode_Proc(
     ==========================================================================
 */
 INT Set_Wpa_Support(
-    IN	PRTMP_ADAPTER	pAd, 
+    IN	PRTMP_ADAPTER	pAd,
 	IN	PUCHAR			arg)
 {
 
@@ -6520,13 +6520,13 @@ INT Set_Wpa_Support(
         pAd->StaCfg.WpaSupplicantUP = WPA_SUPPLICANT_DISABLE;
 
     DBGPRINT(RT_DEBUG_TRACE, ("Set_Wpa_Support::(WpaSupplicantUP=%d)\n", pAd->StaCfg.WpaSupplicantUP));
-    
-    return TRUE;    
+
+    return TRUE;
 }
 #endif // WPA_SUPPLICANT_SUPPORT //
 
 #ifdef DBG
-/* 
+/*
     ==========================================================================
     Description:
         Read / Write MAC
@@ -6538,13 +6538,13 @@ INT Set_Wpa_Support(
         None
 
     Note:
-        Usage: 
+        Usage:
                1.) iwpriv ra0 mac 0        ==> read MAC where Addr=0x0
                2.) iwpriv ra0 mac 0=12     ==> write MAC where Addr=0x0, value=12
     ==========================================================================
 */
 VOID RTMPIoctlMAC(
-	IN	PRTMP_ADAPTER	pAdapter, 
+	IN	PRTMP_ADAPTER	pAdapter,
 	IN	struct iwreq	*wrq)
 {
 	CHAR				*this_char;
@@ -6556,14 +6556,14 @@ VOID RTMPIoctlMAC(
 	UCHAR				temp[16], temp2[16];
 	UINT32				macValue = 0;
 	INT					Status;
-	
+
 
 	memset(msg, 0x00, 1024);
 	if (wrq->u.data.length > 1) //No parameters.
-	{   
+	{
 	    Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
 		sprintf(msg, "\n");
-		
+
 		//Parsing Read or Write
 	    this_char = arg;
 		if (!*this_char)
@@ -6591,7 +6591,7 @@ VOID RTMPIoctlMAC(
 			{
 				this_char[4-k+j] = this_char[j];
 			}
-			
+
 			while(k < 4)
 				this_char[3-k++]='0';
 			this_char[4]='\0';
@@ -6599,7 +6599,7 @@ VOID RTMPIoctlMAC(
 			if(strlen(this_char) == 4)
 			{
 				AtoH(this_char, temp, 2);
-				macAddr = *temp*256 + temp[1];					
+				macAddr = *temp*256 + temp[1];
 				if (macAddr < 0xFFFF)
 				{
 					RTMP_IO_READ32(pAdapter, macAddr, &macValue);
@@ -6652,7 +6652,7 @@ VOID RTMPIoctlMAC(
 			{
 				temp2[8-k+j] = temp2[j];
 			}
-			
+
 			while(k < 8)
 				temp2[7-k++]='0';
 			temp2[8]='\0';
@@ -6668,7 +6668,7 @@ VOID RTMPIoctlMAC(
 				if (macAddr == (HW_DEBUG_SETTING_BASE + 4))
 				{
 					// 0x2bf4: byte0 non-zero: enable R17 tuning, 0: disable R17 tuning
-                    if (macValue & 0x000000ff) 
+                    if (macValue & 0x000000ff)
                     {
                         pAdapter->BbpTuning.bEnable = TRUE;
                         DBGPRINT(RT_DEBUG_TRACE,("turn on R17 tuning\n"));
@@ -6692,7 +6692,7 @@ VOID RTMPIoctlMAC(
 				}
 
 				DBGPRINT(RT_DEBUG_TRACE, ("MacAddr=%02lx, MacValue=0x%x\n", macAddr, macValue));
-				
+
 				RTMP_IO_WRITE32(pAdapter, macAddr, macValue);
 				sprintf(msg+strlen(msg), "[0x%08lX]:%08X  ", macAddr, macValue);
 			}
@@ -6705,11 +6705,11 @@ next:
 	// Copy the information into the user buffer
 	wrq->u.data.length = strlen(msg);
 	Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-	
+
 	DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlMAC\n\n"));
 }
 
-/* 
+/*
     ==========================================================================
     Description:
         Read / Write E2PROM
@@ -6721,13 +6721,13 @@ next:
         None
 
     Note:
-        Usage: 
+        Usage:
                1.) iwpriv ra0 e2p 0     	==> read E2PROM where Addr=0x0
                2.) iwpriv ra0 e2p 0=1234    ==> write E2PROM where Addr=0x0, value=1234
     ==========================================================================
 */
 VOID RTMPIoctlE2PROM(
-	IN	PRTMP_ADAPTER	pAdapter, 
+	IN	PRTMP_ADAPTER	pAdapter,
 	IN	struct iwreq	*wrq)
 {
 	CHAR				*this_char;
@@ -6740,17 +6740,17 @@ VOID RTMPIoctlE2PROM(
 	USHORT				eepValue;
 	int					Status;
 
-	
+
 	memset(msg, 0x00, 1024);
 	if (wrq->u.data.length > 1) //No parameters.
-	{   
+	{
 	    Status = copy_from_user(arg, wrq->u.data.pointer, (wrq->u.data.length > 255) ? 255 : wrq->u.data.length);
 		sprintf(msg, "\n");
 
 	    //Parsing Read or Write
 		this_char = arg;
-		
-			
+
+
 		if (!*this_char)
 			goto next;
 
@@ -6759,7 +6759,7 @@ VOID RTMPIoctlE2PROM(
 
 		if (!value || !*value)
 		{ //Read
-			
+
 			// Sanity check
 			if(strlen(this_char) > 4)
 				goto next;
@@ -6777,7 +6777,7 @@ VOID RTMPIoctlE2PROM(
 			{
 				this_char[4-k+j] = this_char[j];
 			}
-			
+
 			while(k < 4)
 				this_char[3-k++]='0';
 			this_char[4]='\0';
@@ -6785,7 +6785,7 @@ VOID RTMPIoctlE2PROM(
 			if(strlen(this_char) == 4)
 			{
 				AtoH(this_char, temp, 2);
-				eepAddr = *temp*256 + temp[1];					
+				eepAddr = *temp*256 + temp[1];
 				if (eepAddr < 0xFFFF)
 				{
 					RT28xx_EEPROM_READ16(pAdapter, eepAddr, eepValue);
@@ -6836,7 +6836,7 @@ VOID RTMPIoctlE2PROM(
 			{
 				temp2[4-k+j] = temp2[j];
 			}
-			
+
 			while(k < 4)
 				temp2[3-k++]='0';
 			temp2[4]='\0';
@@ -6859,8 +6859,8 @@ next:
 	// Copy the information into the user buffer
 	wrq->u.data.length = strlen(msg);
 	Status = copy_to_user(wrq->u.data.pointer, msg, wrq->u.data.length);
-	
-	DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));	
+
+	DBGPRINT(RT_DEBUG_TRACE, ("<==RTMPIoctlE2PROM\n"));
 }
 #endif // DBG //
 
@@ -6868,7 +6868,7 @@ next:
 
 
 INT Set_TGnWifiTest_Proc(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
     IN  PUCHAR          arg)
 {
     if (simple_strtol(arg, 0, 10) == 0)
@@ -6881,7 +6881,7 @@ INT Set_TGnWifiTest_Proc(
 }
 
 INT Set_LongRetryLimit_Proc(
-	IN	PRTMP_ADAPTER	pAdapter, 
+	IN	PRTMP_ADAPTER	pAdapter,
 	IN	PUCHAR			arg)
 {
 	TX_RTY_CFG_STRUC	tx_rty_cfg;
@@ -6895,7 +6895,7 @@ INT Set_LongRetryLimit_Proc(
 }
 
 INT Set_ShortRetryLimit_Proc(
-	IN	PRTMP_ADAPTER	pAdapter, 
+	IN	PRTMP_ADAPTER	pAdapter,
 	IN	PUCHAR			arg)
 {
 	TX_RTY_CFG_STRUC	tx_rty_cfg;
@@ -6903,14 +6903,14 @@ INT Set_ShortRetryLimit_Proc(
 
 	RTMP_IO_READ32(pAdapter, TX_RTY_CFG, &tx_rty_cfg.word);
 	tx_rty_cfg.field.ShortRtyLimit = ShortRetryLimit;
-	RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);	
+	RTMP_IO_WRITE32(pAdapter, TX_RTY_CFG, tx_rty_cfg.word);
 	DBGPRINT(RT_DEBUG_TRACE, ("IF Set_ShortRetryLimit_Proc::(tx_rty_cfg=0x%x)\n", tx_rty_cfg.word));
 	return TRUE;
 }
 
 #ifdef EXT_BUILD_CHANNEL_LIST
 INT Set_Ieee80211dClientMode_Proc(
-    IN  PRTMP_ADAPTER   pAdapter, 
+    IN  PRTMP_ADAPTER   pAdapter,
     IN  PUCHAR          arg)
 {
     if (simple_strtol(arg, 0, 10) == 0)
@@ -6920,7 +6920,7 @@ INT Set_Ieee80211dClientMode_Proc(
     else if (simple_strtol(arg, 0, 10) == 2)
         pAdapter->StaCfg.IEEE80211dClientMode = Rt802_11_D_Strict;
     else
-        return FALSE;  
+        return FALSE;
 
     DBGPRINT(RT_DEBUG_TRACE, ("Set_Ieee802dMode_Proc::(IEEEE0211dMode=%d)\n", pAdapter->StaCfg.IEEE80211dClientMode));
     return TRUE;
@@ -6929,7 +6929,7 @@ INT Set_Ieee80211dClientMode_Proc(
 
 #ifdef CARRIER_DETECTION_SUPPORT
 INT Set_CarrierDetect_Proc(
-    IN  PRTMP_ADAPTER   pAd, 
+    IN  PRTMP_ADAPTER   pAd,
     IN  PUCHAR          arg)
 {
     if (simple_strtol(arg, 0, 10) == 0)
diff --git a/tools/Makefile b/tools/Makefile
deleted file mode 100644
index ce4a422..0000000
--- a/tools/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-all:
-	gcc -g bin2h.c -o bin2h
-clean:
-	rm -f *.o bin2h
-
-	
diff --git a/tools/bin2h.c b/tools/bin2h.c
deleted file mode 100644
index ec2c6d9..0000000
--- a/tools/bin2h.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- *************************************************************************
- * Ralink Tech Inc.
- * 5F., No.36, Taiyuan St., Jhubei City,
- * Hsinchu County 302,
- * Taiwan, R.O.C.
- *
- * (c) Copyright 2002-2007, Ralink Technology, Inc.
- *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
- *************************************************************************
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-int main(int argc ,char *argv[])
-{
-    FILE *infile, *outfile;	
-    char infname[1024];
-    char outfname[1024];
-    char *rt28xxdir;
-    char *chipset;
-    int i=0,n=0;
-    unsigned char c;
-   
-    memset(infname,0,1024);
-    memset(outfname,0,1024);
-    
-    rt28xxdir = (char *)getenv("RT28xx_DIR");
-    chipset = (char *)getenv("CHIPSET");
-    if(!rt28xxdir)
-    {
-         printf("Environment value \"RT28xx_DIR\" not export \n");
-	 return -1;
-    }
-    if(!chipset)
-    {
-	 printf("Environment value \"CHIPSET\" not export \n");
-	 return -1;
-    }	    
-    strcat(infname,rt28xxdir);
-    if(strncmp(chipset, "2860",4)==0)
-	    strcat(infname,"/common/rt2860.bin");
-    else if(strncmp(chipset, "2870",4)==0)
-	    strcat(infname,"/common/rt2870.bin");
-    else
-    	strcat(infname,"/common/rt2860.bin");
-	    
-    strcat(outfname,rt28xxdir);
-    strcat(outfname,"/include/firmware.h");
-     
-    infile = fopen(infname,"r");
-    if (infile == (FILE *) NULL)
-    {
-         printf("Can't read file %s \n",infname);
-	 return -1;
-    }
-    outfile = fopen(outfname,"w");
-    
-    if (outfile == (FILE *) NULL)
-    {
-         printf("Can't open write file %s \n",outfname);
-        return -1;
-    }
-    
-    fputs("/*\n",outfile); 
-    fputs(" Copyright (c) 2007, Ralink Technology Corporation \n",outfile); 
-    fputs(" All rights reserved. \n\n",outfile);
-
-    fputs(" Redistribution.  Redistribution and use in binary form, without \n",outfile); 
-    fputs(" modification, are permitted provided that the following conditions are \n",outfile); 
-    fputs(" met: \n\n",outfile);
-
-    fputs(" \t* Redistributions must reproduce the above copyright notice and the \n",outfile);
-    fputs(" \tfollowing disclaimer in the documentation and/or other materials \n",outfile);
-    fputs(" \tprovided with the distribution. \n",outfile);
-    fputs(" \t* Neither the name of Ralink Technology Corporation nor the names of its \n",outfile);
-    fputs(" \tsuppliers may be used to endorse or promote products derived from this \n",outfile);
-    fputs(" \tsoftware without specific prior written permission. \n",outfile);
-    fputs(" \t* No reverse engineering, decompilation, or disassembly of this software \n",outfile);
-    fputs(" \tis permitted. \n\n",outfile);
-
-    fputs(" Limited patent license. Ralink Technology Corporation grants a world-wide, \n",outfile);
-    fputs(" royalty-free, non-exclusive license under patents it now or hereafter \n",outfile);
-    fputs(" owns or controls to make, have made, use, import, offer to sell and \n",outfile);
-    fputs(" sell (\"Utilize\") this software, but solely to the extent that any \n",outfile);
-    fputs(" such patent is necessary to Utilize the software alone, or in \n",outfile);
-    fputs(" combination with an operating system licensed under an approved Open \n",outfile);
-    fputs(" Source license as listed by the Open Source Initiative at \n",outfile);
-    fputs(" http://opensource.org/licenses.  The patent license shall not apply to \n",outfile);
-    fputs(" any other combinations which include this software.  No hardware per \n",outfile);
-    fputs(" se is licensed hereunder. \n\n",outfile);
-
-    fputs(" DISCLAIMER.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \n",outfile);
-    fputs(" CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, \n",outfile);
-    fputs(" BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \n",outfile);
-    fputs(" FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \n",outfile);
-    fputs(" COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \n",outfile);
-    fputs(" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \n",outfile);
-    fputs(" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS \n",outfile);
-    fputs(" OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND \n",outfile);
-    fputs(" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR \n",outfile);
-    fputs(" TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE \n",outfile);
-    fputs(" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH \n",outfile);
-    fputs(" DAMAGE. \n",outfile);
-    fputs("*/ \n",outfile);
-
-    fputs("/* AUTO GEN PLEASE DO NOT MODIFY IT */ \n",outfile);
-    fputs("/* AUTO GEN PLEASE DO NOT MODIFY IT */ \n",outfile);
-    fputs("\n",outfile);
-    fputs("\n",outfile);
-    fputs("UCHAR FirmwareImage [] = { \n",outfile);
-    while(1)
-    {
-	char cc[2];    
-
-	c = getc(infile);
-	
-	if (feof(infile))
-	    break;
-	
-	memset(cc,0,2);
-	
-	if (i>=16)
-	{	
-	    fputs("\n", outfile);	
-	    i = 0;
-	}    
-	fputs("0x", outfile); 
-	sprintf(cc,"%02x",c);
-	fputs(cc, outfile);
-	fputs(", ", outfile);
-	i++;
-    } 
-    
-    fputs("} ;\n", outfile);
-    fclose(infile);
-    fclose(outfile);
-    exit(0);
-}	
diff --git a/include/wpa.h b/wpa.h
similarity index 92%
rename from include/wpa.h
rename to wpa.h
index 013e6e8..88c7c8b 100644
--- a/include/wpa.h
+++ b/wpa.h
@@ -7,21 +7,21 @@
  *
  * (c) Copyright 2002-2007, Ralink Technology, Inc.
  *
- * This program is free software; you can redistribute it and/or modify  * 
- * it under the terms of the GNU General Public License as published by  * 
- * the Free Software Foundation; either version 2 of the License, or     * 
- * (at your option) any later version.                                   * 
- *                                                                       * 
- * This program is distributed in the hope that it will be useful,       * 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of        * 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * 
- * GNU General Public License for more details.                          * 
- *                                                                       * 
- * You should have received a copy of the GNU General Public License     * 
- * along with this program; if not, write to the                         * 
- * Free Software Foundation, Inc.,                                       * 
- * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
- *                                                                       * 
+ * This program is free software; you can redistribute it and/or modify  *
+ * it under the terms of the GNU General Public License as published by  *
+ * the Free Software Foundation; either version 2 of the License, or     *
+ * (at your option) any later version.                                   *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program; if not, write to the                         *
+ * Free Software Foundation, Inc.,                                       *
+ * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *                                                                       *
  *************************************************************************
 
 	Module Name:
@@ -46,9 +46,9 @@
 #define LEN_KEY_DESC_REPLAY			8
 #define LEN_KEY_DESC_MIC			16
 
-// The length is the EAPoL-Key frame except key data field. 
+// The length is the EAPoL-Key frame except key data field.
 // Please refer to 802.11i-2004 ,Figure 43u in p.78
-#define LEN_EAPOL_KEY_MSG			(sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE)	
+#define LEN_EAPOL_KEY_MSG			(sizeof(KEY_DESCRIPTER) - MAX_LEN_OF_RSNIE)
 
 // EAP Code Type.
 #define EAP_CODE_REQUEST	1
@@ -72,7 +72,7 @@
 #define LEN_MSG1_2WAY               0x7f
 #define MAX_LEN_OF_EAP_HS           256
 
-#define LEN_MASTER_KEY				32  
+#define LEN_MASTER_KEY				32
 
 // EAPOL EK, MK
 #define LEN_EAP_EK					16
@@ -173,7 +173,7 @@ typedef	struct PACKED _KEY_INFO
 	UCHAR	KeyIndex:2;
 	UCHAR	Install:1;
 	UCHAR	KeyAck:1;
-#endif	
+#endif
 }	KEY_INFO, *PKEY_INFO;
 
 // EAPOL Key descriptor format
@@ -188,7 +188,7 @@ typedef	struct PACKED _KEY_DESCRIPTER
 	UCHAR		KeyRsc[LEN_KEY_DESC_RSC];
 	UCHAR		KeyId[LEN_KEY_DESC_ID];
 	UCHAR		KeyMic[LEN_KEY_DESC_MIC];
-	UCHAR		KeyDataLen[2];	   
+	UCHAR		KeyDataLen[2];
 	UCHAR		KeyData[MAX_LEN_OF_RSNIE];
 }	KEY_DESCRIPTER, *PKEY_DESCRIPTER;
 
@@ -212,7 +212,7 @@ typedef struct PACKED _GTK_ENCAP
     UCHAR               rsv:5;
     UCHAR               tx:1;
     UCHAR               Kid:2;
-    UCHAR               rsv1;    	
+    UCHAR               rsv1;
 #endif
     UCHAR               GTK[TKIP_GTK_LENGTH];
 }   GTK_ENCAP, *PGTK_ENCAP;
@@ -295,11 +295,11 @@ typedef	enum	_WpaState
 	SS_KEYUPDATE,			// 5
 }	WPA_STATE;
 
-// 
+//
 //	The definition of the cipher combination
 //
 // 	 bit3	bit2  bit1   bit0
-//	+------------+------------+ 
+//	+------------+------------+
 // 	|	  WPA	 |	   WPA2   |
 //	+------+-----+------+-----+
 //	| TKIP | AES | TKIP | AES |
@@ -308,22 +308,22 @@ typedef	enum	_WpaState
 //	|	1  |  0  |   0  |  1  | -> 0x09
 //	|	1  |  0  |   1  |  1  | -> 0x0B
 //	|	1  |  1  |   0  |  1  | -> 0x0D
-//	|	1  |  1  |   1  |  0  | -> 0x0E									
-//	|	1  |  1  |   1  |  1  |	-> 0x0F																												
-//	+------+-----+------+-----+	
+//	|	1  |  1  |   1  |  0  | -> 0x0E
+//	|	1  |  1  |   1  |  1  |	-> 0x0F
+//	+------+-----+------+-----+
 //
 typedef	enum	_WpaMixPairCipher
 {
-	MIX_CIPHER_NOTUSE 			= 0x00,	
+	MIX_CIPHER_NOTUSE 			= 0x00,
 	WPA_NONE_WPA2_TKIPAES		= 0x03,		// WPA2-TKIPAES
-	WPA_AES_WPA2_TKIP 			= 0x06,				
-	WPA_AES_WPA2_TKIPAES		= 0x07,			
-	WPA_TKIP_WPA2_AES			= 0x09,			
-	WPA_TKIP_WPA2_TKIPAES		= 0x0B,  	
+	WPA_AES_WPA2_TKIP 			= 0x06,
+	WPA_AES_WPA2_TKIPAES		= 0x07,
+	WPA_TKIP_WPA2_AES			= 0x09,
+	WPA_TKIP_WPA2_TKIPAES		= 0x0B,
 	WPA_TKIPAES_WPA2_NONE		= 0x0C,		// WPA-TKIPAES
 	WPA_TKIPAES_WPA2_AES		= 0x0D,
-	WPA_TKIPAES_WPA2_TKIP		= 0x0E,  			
-	WPA_TKIPAES_WPA2_TKIPAES	= 0x0F,	
+	WPA_TKIPAES_WPA2_TKIP		= 0x0E,
+	WPA_TKIPAES_WPA2_TKIPAES	= 0x0F,
 }	WPA_MIX_PAIR_CIPHER;
 
 typedef struct PACKED _RSN_IE_HEADER_STRUCT	{

-- 
Packaging of rt2860-source



More information about the Debian-eeepc-devel mailing list