Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
[safe/jmp/linux-2.6] / drivers / staging / rtl8192e / r8192E_core.c
index abb6b49..0ca5d8b 100644 (file)
  * Jerry chuang <wlanfae@realtek.com>
  */
 
-#ifndef CONFIG_FORCE_HARD_FLOAT
-double __floatsidf (int i) { return i; }
-unsigned int __fixunsdfsi (double d) { return d; }
-double __adddf3(double a, double b) { return a+b; }
-double __addsf3(float a, float b) { return a+b; }
-double __subdf3(double a, double b) { return a-b; }
-double __extendsfdf2(float a) {return a;}
-#endif
 
 #undef LOOP_TEST
 #undef RX_DONT_PASS_UL
@@ -54,6 +46,7 @@ double __extendsfdf2(float a) {return a;}
 #undef DEBUG_TX_DESC
 
 //#define CONFIG_RTL8192_IO_MAP
+#include <linux/vmalloc.h>
 #include <asm/uaccess.h>
 #include "r8192E_hw.h"
 #include "r8192E.h"
@@ -123,46 +116,20 @@ static struct pci_device_id rtl8192_pci_id_tbl[] __devinitdata = {
 };
 
 static char* ifname = "wlan%d";
-#if 0
-static int hwseqnum = 0;
-static int hwwep = 0;
-#endif
 static int hwwep = 1; //default use hw. set 0 to use software security
 static int channels = 0x3fff;
 
 MODULE_LICENSE("GPL");
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
 MODULE_VERSION("V 1.1");
-#endif
 MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl);
 //MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>");
 MODULE_DESCRIPTION("Linux driver for Realtek RTL819x WiFi cards");
 
-#if 0
-MODULE_PARM(ifname,"s");
-MODULE_PARM_DESC(devname," Net interface name, wlan%d=default");
-
-MODULE_PARM(hwseqnum,"i");
-MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default");
 
-MODULE_PARM(hwwep,"i");
-MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards");
-
-MODULE_PARM(channels,"i");
-MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI");
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9)
 module_param(ifname, charp, S_IRUGO|S_IWUSR );
 //module_param(hwseqnum,int, S_IRUGO|S_IWUSR);
 module_param(hwwep,int, S_IRUGO|S_IWUSR);
 module_param(channels,int, S_IRUGO|S_IWUSR);
-#else
-MODULE_PARM(ifname, "s");
-//MODULE_PARM(hwseqnum,"i");
-MODULE_PARM(hwwep,"i");
-MODULE_PARM(channels,"i");
-#endif
 
 MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default");
 //MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default");
@@ -178,7 +145,6 @@ static struct pci_driver rtl8192_pci_driver = {
        .id_table       = rtl8192_pci_id_tbl,             /* PCI_ID table  */
        .probe          = rtl8192_pci_probe,              /* probe fn      */
        .remove         = __devexit_p(rtl8192_pci_disconnect),    /* remove fn     */
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)
 #ifdef CONFIG_PM_RTL
        .suspend        = rtl8192E_suspend,               /* PM suspend fn */
        .resume         = rtl8192E_resume,                 /* PM resume fn  */
@@ -186,7 +152,6 @@ static struct pci_driver rtl8192_pci_driver = {
        .suspend        = NULL,                           /* PM suspend fn */
        .resume         = NULL,                           /* PM resume fn  */
 #endif
-#endif
 };
 
 #ifdef ENABLE_DOT11D
@@ -269,7 +234,7 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv)
 
 #define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
 /* 2007/07/25 MH Defien temp tx fw info. */
-TX_FWINFO_T    Tmp_TxFwInfo;
+static TX_FWINFO_T Tmp_TxFwInfo;
 
 
 #define        rx_hal_is_cck_rate(_pdrvinfo)\
@@ -392,25 +357,12 @@ inline void force_pci_posting(struct net_device *dev)
 
 
 //warning message WB
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-void rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs);
-#else
-irqreturn_t rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs);
-#endif
-#else
 irqreturn_t rtl8192_interrupt(int irq, void *netdev);
-#endif
 //static struct net_device_stats *rtl8192_stats(struct net_device *dev);
 void rtl8192_commit(struct net_device *dev);
 //void rtl8192_restart(struct net_device *dev);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
 void rtl8192_restart(struct work_struct *work);
 //void rtl8192_rq_tx_ack(struct work_struct *work);
-#else
- void rtl8192_restart(struct net_device *dev);
-// //void rtl8192_rq_tx_ack(struct net_device *dev);
- #endif
 
 void watch_dog_timer_callback(unsigned long data);
 #ifdef ENABLE_IPS
@@ -523,99 +475,6 @@ static int proc_get_registers(char *page, char **start,
 }
 
 
-#if 0
-static int proc_get_cck_reg(char *page, char **start,
-                         off_t offset, int count,
-                         int *eof, void *data)
-{
-       struct net_device *dev = data;
-//     struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
-       int len = 0;
-       int i,n;
-
-       int max = 0x5F;
-
-       /* This dump the current register page */
-       for(n=0;n<=max;)
-       {
-               //printk( "\nD: %2x> ", n);
-               len += snprintf(page + len, count - len,
-                       "\nD:  %2x > ",n);
-
-               for(i=0;i<16 && n<=max;i++,n++)
-               len += snprintf(page + len, count - len,
-                       "%2x ",read_phy_cck(dev,n));
-
-               //      printk("%2x ",read_nic_byte(dev,n));
-       }
-       len += snprintf(page + len, count - len,"\n");
-
-
-       *eof = 1;
-       return len;
-}
-
-#endif
-
-#if 0
-static int proc_get_ofdm_reg(char *page, char **start,
-                         off_t offset, int count,
-                         int *eof, void *data)
-{
-
-       struct net_device *dev = data;
-//     struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
-       int len = 0;
-       int i,n;
-
-       //int max=0xff;
-       int max = 0x40;
-
-       /* This dump the current register page */
-       for(n=0;n<=max;)
-       {
-               //printk( "\nD: %2x> ", n);
-               len += snprintf(page + len, count - len,
-                       "\nD:  %2x > ",n);
-
-               for(i=0;i<16 && n<=max;i++,n++)
-               len += snprintf(page + len, count - len,
-                       "%2x ",read_phy_ofdm(dev,n));
-
-               //      printk("%2x ",read_nic_byte(dev,n));
-       }
-       len += snprintf(page + len, count - len,"\n");
-
-
-
-       *eof = 1;
-       return len;
-}
-
-#endif
-
-#if 0
-static int proc_get_stats_hw(char *page, char **start,
-                         off_t offset, int count,
-                         int *eof, void *data)
-{
-       struct net_device *dev = data;
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
-       int len = 0;
-
-       len += snprintf(page + len, count - len,
-               "NIC int: %lu\n"
-               "Total int: %lu\n",
-               priv->stats.ints,
-               priv->stats.shints);
-
-       *eof = 1;
-       return len;
-}
-#endif
 
 static int proc_get_stats_tx(char *page, char **start,
                          off_t offset, int count,
@@ -723,28 +582,20 @@ static int proc_get_stats_rx(char *page, char **start,
        return len;
 }
 
-void rtl8192_proc_module_init(void)
+static void rtl8192_proc_module_init(void)
 {
        RT_TRACE(COMP_INIT, "Initializing proc filesystem");
-#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
-       rtl8192_proc=create_proc_entry(RTL819xE_MODULE_NAME, S_IFDIR, proc_net);
-#else
        rtl8192_proc=create_proc_entry(RTL819xE_MODULE_NAME, S_IFDIR, init_net.proc_net);
-#endif
 }
 
 
-void rtl8192_proc_module_remove(void)
+static void rtl8192_proc_module_remove(void)
 {
-#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
-       remove_proc_entry(RTL819xE_MODULE_NAME, proc_net);
-#else
        remove_proc_entry(RTL819xE_MODULE_NAME, init_net.proc_net);
-#endif
 }
 
 
-void rtl8192_proc_remove_one(struct net_device *dev)
+static void rtl8192_proc_remove_one(struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
 
@@ -766,7 +617,7 @@ void rtl8192_proc_remove_one(struct net_device *dev)
 }
 
 
-void rtl8192_proc_init_one(struct net_device *dev)
+static void rtl8192_proc_init_one(struct net_device *dev)
 {
        struct proc_dir_entry *e;
        struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
@@ -778,16 +629,6 @@ void rtl8192_proc_init_one(struct net_device *dev)
                      dev->name);
                return;
        }
-       #if 0
-       e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO,
-                                  priv->dir_dev, proc_get_stats_hw, dev);
-
-       if (!e) {
-               DMESGE("Unable to initialize "
-                     "/proc/net/rtl8192/%s/stats-hw\n",
-                     dev->name);
-       }
-       #endif
        e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
                                   priv->dir_dev, proc_get_stats_rx, dev);
 
@@ -806,17 +647,6 @@ void rtl8192_proc_init_one(struct net_device *dev)
                      "/proc/net/rtl8192/%s/stats-tx\n",
                      dev->name);
        }
-       #if 0
-       e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO,
-                                  priv->dir_dev, proc_get_stats_ieee, dev);
-
-       if (!e) {
-               DMESGE("Unable to initialize "
-                     "/proc/net/rtl8192/%s/stats-ieee\n",
-                     dev->name);
-       }
-
-       #endif
 
        e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
                                   priv->dir_dev, proc_get_stats_ap, dev);
@@ -834,47 +664,11 @@ void rtl8192_proc_init_one(struct net_device *dev)
                      "/proc/net/rtl8192/%s/registers\n",
                      dev->name);
        }
-#if 0
-       e = create_proc_read_entry("cck-registers", S_IFREG | S_IRUGO,
-                                  priv->dir_dev, proc_get_cck_reg, dev);
-       if (!e) {
-               RT_TRACE(COMP_ERR, "Unable to initialize "
-                     "/proc/net/rtl8192/%s/cck-registers\n",
-                     dev->name);
-       }
-
-       e = create_proc_read_entry("ofdm-registers", S_IFREG | S_IRUGO,
-                                  priv->dir_dev, proc_get_ofdm_reg, dev);
-       if (!e) {
-               RT_TRACE(COMP_ERR, "Unable to initialize "
-                     "/proc/net/rtl8192/%s/ofdm-registers\n",
-                     dev->name);
-       }
-#endif
 }
 /****************************************************************************
    -----------------------------MISC STUFF-------------------------
 *****************************************************************************/
 
-/* this is only for debugging */
-void print_buffer(u32 *buffer, int len)
-{
-       int i;
-       u8 *buf =(u8*)buffer;
-
-       printk("ASCII BUFFER DUMP (len: %x):\n",len);
-
-       for(i=0;i<len;i++)
-               printk("%c",buf[i]);
-
-       printk("\nBINARY BUFFER DUMP (len: %x):\n",len);
-
-       for(i=0;i<len;i++)
-               printk("%x",buf[i]);
-
-       printk("\n");
-}
-
 short check_nic_enough_desc(struct net_device *dev, int prio)
 {
     struct r8192_priv *priv = ieee80211_priv(dev);
@@ -890,52 +684,22 @@ short check_nic_enough_desc(struct net_device *dev, int prio)
     }
 }
 
-void tx_timeout(struct net_device *dev)
+static void tx_timeout(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        //rtl8192_commit(dev);
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
        schedule_work(&priv->reset_wq);
-#else
-       schedule_task(&priv->reset_wq);
-#endif
        printk("TXTIMEOUT");
 }
 
 
-/* this is only for debug */
-void dump_eprom(struct net_device *dev)
-{
-       int i;
-       for(i=0; i<0xff; i++)
-               RT_TRACE(COMP_INIT, "EEPROM addr %x : %x", i, eprom_read(dev,i));
-}
-
-/* this is only for debug */
-void rtl8192_dump_reg(struct net_device *dev)
-{
-       int i;
-       int n;
-       int max=0x5ff;
-
-       RT_TRACE(COMP_INIT, "Dumping NIC register map");
-
-       for(n=0;n<=max;)
-       {
-               printk( "\nD: %2x> ", n);
-               for(i=0;i<16 && n<=max;i++,n++)
-                       printk("%2x ",read_nic_byte(dev,n));
-       }
-       printk("\n");
-}
-
 /****************************************************************************
       ------------------------------HW STUFF---------------------------
 *****************************************************************************/
 
 
-void rtl8192_irq_enable(struct net_device *dev)
+static void rtl8192_irq_enable(struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
        priv->irq_enabled = 1;
@@ -943,7 +707,7 @@ void rtl8192_irq_enable(struct net_device *dev)
 }
 
 
-void rtl8192_irq_disable(struct net_device *dev)
+static void rtl8192_irq_disable(struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
 
@@ -953,7 +717,7 @@ void rtl8192_irq_disable(struct net_device *dev)
 }
 
 
-void rtl8192_set_mode(struct net_device *dev,int mode)
+static void rtl8192_set_mode(struct net_device *dev,int mode)
 {
        u8 ecmd;
        ecmd=read_nic_byte(dev, EPROM_CMD);
@@ -1044,7 +808,7 @@ void rtl8192_rx_enable(struct net_device *dev)
  *  HIGH_QUEUE     ===>                        7
  *  BEACON_QUEUE   ===>                        8
  *  */
-u32 TX_DESC_BASE[] = {BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA};
+static u32 TX_DESC_BASE[] = {BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA};
 void rtl8192_tx_enable(struct net_device *dev)
 {
     struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
@@ -1055,19 +819,6 @@ void rtl8192_tx_enable(struct net_device *dev)
     ieee80211_reset_queue(priv->ieee80211);
 }
 
-#if 0
-void rtl8192_beacon_tx_enable(struct net_device *dev)
-{
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-       u32 reg;
-
-       reg = read_nic_dword(priv->ieee80211->dev,INTA_MASK);
-
-       /* enable Beacon realted interrupt signal */
-       reg |= (IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER);
-       write_nic_byte(dev,reg);
-}
-#endif
 
 static void rtl8192_free_rx_ring(struct net_device *dev)
 {
@@ -1111,7 +862,7 @@ static void rtl8192_free_tx_ring(struct net_device *dev, unsigned int prio)
 }
 
 
-void rtl8192_beacon_disable(struct net_device *dev)
+static void rtl8192_beacon_disable(struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
        u32 reg;
@@ -1149,7 +900,7 @@ void rtl8192_rtx_disable(struct net_device *dev)
        return;
 }
 
-void rtl8192_reset(struct net_device *dev)
+static void rtl8192_reset(struct net_device *dev)
 {
     rtl8192_irq_disable(dev);
     printk("This is RTL819xP Reset procedure\n");
@@ -1164,47 +915,8 @@ inline u16 rtl8192_rate2rate(short rate)
 
 
 
-u32
-rtl819xusb_rx_command_packet(
-       struct net_device *dev,
-       struct ieee80211_rx_stats *pstats
-       )
-{
-       u32     status;
-
-       //RT_TRACE(COMP_RECV, DBG_TRACE, ("---> RxCommandPacketHandle819xUsb()\n"));
-
-       RT_TRACE(COMP_EVENTS, "---->rtl819xusb_rx_command_packet()\n");
-       status = cmpk_message_handle_rx(dev, pstats);
-       if (status)
-       {
-               DMESG("rxcommandpackethandle819xusb: It is a command packet\n");
-       }
-       else
-       {
-               //RT_TRACE(COMP_RECV, DBG_TRACE, ("RxCommandPacketHandle819xUsb: It is not a command packet\n"));
-       }
-
-       //RT_TRACE(COMP_RECV, DBG_TRACE, ("<--- RxCommandPacketHandle819xUsb()\n"));
-       return status;
-}
-
-#if 0
-void rtl8192_tx_queues_stop(struct net_device *dev)
-{
-       //struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-       u8 dma_poll_mask = (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
-       dma_poll_mask |= (1<<TX_DMA_STOP_HIPRIORITY_SHIFT);
-       dma_poll_mask |= (1<<TX_DMA_STOP_NORMPRIORITY_SHIFT);
-       dma_poll_mask |= (1<<TX_DMA_STOP_BEACON_SHIFT);
-
-       rtl8192_set_mode(dev,EPROM_CMD_CONFIG);
-       write_nic_byte(dev,TX_DMA_POLLING,dma_poll_mask);
-       rtl8192_set_mode(dev,EPROM_CMD_NORMAL);
-}
-#endif
 
-void rtl8192_data_hard_stop(struct net_device *dev)
+static void rtl8192_data_hard_stop(struct net_device *dev)
 {
        //FIXME !!
        #if 0
@@ -1217,7 +929,7 @@ void rtl8192_data_hard_stop(struct net_device *dev)
 }
 
 
-void rtl8192_data_hard_resume(struct net_device *dev)
+static void rtl8192_data_hard_resume(struct net_device *dev)
 {
        // FIXME !!
        #if 0
@@ -1232,7 +944,7 @@ void rtl8192_data_hard_resume(struct net_device *dev)
 /* this function TX data frames when the ieee80211 stack requires this.
  * It checks also if we need to stop the ieee tx queue, eventually do it
  */
-void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
+static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
 {
        struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
        int ret;
@@ -1274,7 +986,7 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rat
  * If the ring is full packet are dropped (for data frame the queue
  * is stopped before this can happen).
  */
-int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
+static int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
 
@@ -1319,7 +1031,7 @@ int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
 
 void rtl8192_try_wake_queue(struct net_device *dev, int pri);
 
-void rtl8192_tx_isr(struct net_device *dev, int prio)
+static void rtl8192_tx_isr(struct net_device *dev, int prio)
 {
     struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
 
@@ -1329,7 +1041,7 @@ void rtl8192_tx_isr(struct net_device *dev, int prio)
         tx_desc_819x_pci *entry = &ring->desc[ring->idx];
         struct sk_buff *skb;
 
-        /* beacon packet will only use the first descriptor defautly,
+        /* beacon packet will only use the first descriptor defaultly,
          * and the OWN may not be cleared by the hardware
          * */
         if(prio != BEACON_QUEUE) {
@@ -1360,12 +1072,12 @@ void rtl8192_tx_isr(struct net_device *dev, int prio)
 
 }
 
-void rtl8192_stop_beacon(struct net_device *dev)
+static void rtl8192_stop_beacon(struct net_device *dev)
 {
        //rtl8192_beacon_disable(dev);
 }
 
-void rtl8192_config_rate(struct net_device* dev, u16* rate_config)
+static void rtl8192_config_rate(struct net_device* dev, u16* rate_config)
 {
         struct r8192_priv *priv = ieee80211_priv(dev);
         struct ieee80211_network *net;
@@ -1416,7 +1128,7 @@ void rtl8192_config_rate(struct net_device* dev, u16* rate_config)
 #define SHORT_SLOT_TIME 9
 #define NON_SHORT_SLOT_TIME 20
 
-void rtl8192_update_cap(struct net_device* dev, u16 cap)
+static void rtl8192_update_cap(struct net_device* dev, u16 cap)
 {
        u32 tmp = 0;
        struct r8192_priv *priv = ieee80211_priv(dev);
@@ -1441,7 +1153,8 @@ void rtl8192_update_cap(struct net_device* dev, u16 cap)
        }
 
 }
-void rtl8192_net_update(struct net_device *dev)
+
+static void rtl8192_net_update(struct net_device *dev)
 {
 
        struct r8192_priv *priv = ieee80211_priv(dev);
@@ -1486,140 +1199,6 @@ void rtl8192_net_update(struct net_device *dev)
 
 }
 
-inline u8 rtl8192_IsWirelessBMode(u16 rate)
-{
-       if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) )
-               return 1;
-       else return 0;
-}
-
-u16 N_DBPSOfRate(u16 DataRate);
-
-u16 ComputeTxTime(
-       u16             FrameLength,
-       u16             DataRate,
-       u8              bManagementFrame,
-       u8              bShortPreamble
-)
-{
-       u16     FrameTime;
-       u16     N_DBPS;
-       u16     Ceiling;
-
-       if( rtl8192_IsWirelessBMode(DataRate) )
-       {
-               if( bManagementFrame || !bShortPreamble || DataRate == 10 )
-               {       // long preamble
-                       FrameTime = (u16)(144+48+(FrameLength*8/(DataRate/10)));
-               }
-               else
-               {       // Short preamble
-                       FrameTime = (u16)(72+24+(FrameLength*8/(DataRate/10)));
-               }
-               if( ( FrameLength*8 % (DataRate/10) ) != 0 ) //Get the Ceilling
-                               FrameTime ++;
-       } else {        //802.11g DSSS-OFDM PLCP length field calculation.
-               N_DBPS = N_DBPSOfRate(DataRate);
-               Ceiling = (16 + 8*FrameLength + 6) / N_DBPS
-                               + (((16 + 8*FrameLength + 6) % N_DBPS) ? 1 : 0);
-               FrameTime = (u16)(16 + 4 + 4*Ceiling + 6);
-       }
-       return FrameTime;
-}
-
-u16 N_DBPSOfRate(u16 DataRate)
-{
-        u16 N_DBPS = 24;
-
-        switch(DataRate)
-        {
-        case 60:
-         N_DBPS = 24;
-         break;
-
-        case 90:
-         N_DBPS = 36;
-         break;
-
-        case 120:
-         N_DBPS = 48;
-         break;
-
-        case 180:
-         N_DBPS = 72;
-         break;
-
-        case 240:
-         N_DBPS = 96;
-         break;
-
-        case 360:
-         N_DBPS = 144;
-         break;
-
-        case 480:
-         N_DBPS = 192;
-         break;
-
-        case 540:
-         N_DBPS = 216;
-         break;
-
-        default:
-         break;
-        }
-
-        return N_DBPS;
-}
-
-unsigned int txqueue2outpipe(unsigned int tx_queue) {
-       unsigned int outpipe = 0x04;
-
-       switch (tx_queue) {
-               case VO_QUEUE://EP4
-                  outpipe = 0x04;
-               break;
-
-               case VI_QUEUE://EP5
-                  outpipe = 0x05;
-               break;
-
-               case BE_QUEUE://EP6
-                  outpipe = 0x06;
-               break;
-
-               case BK_QUEUE://EP7
-                  outpipe = 0x07;
-               break;
-
-               case HCCA_QUEUE://EP8
-                  outpipe = 0x08;
-               break;
-
-               case BEACON_QUEUE://EPA
-                  outpipe = 0x0A;
-               break;
-
-               case HIGH_QUEUE://EPB
-                  outpipe = 0x0B;
-               break;
-
-               case MGNT_QUEUE://EPC
-                  outpipe = 0x0C;
-               break;
-
-               case TXCMD_QUEUE://EPD
-                  outpipe = 0x0D;
-               break;
-
-               default:
-                 printk("Unknow queue index!\n");
-               break;
-       }
-
-       return outpipe;
-}
-
 void rtl819xE_tx_cmd(struct net_device *dev, struct sk_buff *skb)
 {
     struct r8192_priv *priv = ieee80211_priv(dev);
@@ -1681,7 +1260,7 @@ void rtl819xE_tx_cmd(struct net_device *dev, struct sk_buff *skb)
  *
  * \param QUEUEID       Software Queue
 */
-u8 MapHwQueueToFirmwareQueue(u8 QueueID)
+static u8 MapHwQueueToFirmwareQueue(u8 QueueID)
 {
        u8 QueueSelect = 0x0;       //defualt set to
 
@@ -1727,7 +1306,7 @@ u8 MapHwQueueToFirmwareQueue(u8 QueueID)
        return QueueSelect;
 }
 
-u8 MRateToHwRate8190Pci(u8 rate)
+static u8 MRateToHwRate8190Pci(u8 rate)
 {
        u8  ret = DESC90_RATE1M;
 
@@ -1770,7 +1349,7 @@ u8 MRateToHwRate8190Pci(u8 rate)
 }
 
 
-u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc)
+static u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc)
 {
        u8   tmp_Short;
 
@@ -1971,7 +1550,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb)
     return 0;
 }
 
-short rtl8192_alloc_rx_desc_ring(struct net_device *dev)
+static short rtl8192_alloc_rx_desc_ring(struct net_device *dev)
 {
     struct r8192_priv *priv = ieee80211_priv(dev);
     rx_desc_819x_pci *entry = NULL;
@@ -2038,7 +1617,7 @@ static int rtl8192_alloc_tx_desc_ring(struct net_device *dev,
 }
 
 
-short rtl8192_pci_initdescring(struct net_device *dev)
+static short rtl8192_pci_initdescring(struct net_device *dev)
 {
     u32 ret;
     int i;
@@ -2072,7 +1651,7 @@ err_free_rings:
     return 1;
 }
 
-void rtl8192_pci_resetdescring(struct net_device *dev)
+static void rtl8192_pci_resetdescring(struct net_device *dev)
 {
     struct r8192_priv *priv = ieee80211_priv(dev);
     int i;
@@ -2109,7 +1688,7 @@ void rtl8192_pci_resetdescring(struct net_device *dev)
 
 #if 1
 extern void rtl8192_update_ratr_table(struct net_device* dev);
-void rtl8192_link_change(struct net_device *dev)
+static void rtl8192_link_change(struct net_device *dev)
 {
 //     int i;
 
@@ -2159,16 +1738,10 @@ static struct ieee80211_qos_parameters def_qos_parameters = {
         {0,0,0,0} /* tx_op_limit */
 };
 
-#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20)
-void rtl8192_update_beacon(struct work_struct * work)
+static void rtl8192_update_beacon(struct work_struct * work)
 {
         struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work);
         struct net_device *dev = priv->ieee80211->dev;
-#else
-void rtl8192_update_beacon(struct net_device *dev)
-{
-        struct r8192_priv *priv = ieee80211_priv(dev);
-#endif
        struct ieee80211_device* ieee = priv->ieee80211;
        struct ieee80211_network* net = &ieee->current_network;
 
@@ -2180,31 +1753,19 @@ void rtl8192_update_beacon(struct net_device *dev)
 /*
 * background support to run QoS activate functionality
 */
-int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO};
-#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,20)
-void rtl8192_qos_activate(struct work_struct * work)
+static int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO};
+static void rtl8192_qos_activate(struct work_struct * work)
 {
         struct r8192_priv *priv = container_of(work, struct r8192_priv, qos_activate);
         struct net_device *dev = priv->ieee80211->dev;
-#else
-void rtl8192_qos_activate(struct net_device *dev)
-{
-        struct r8192_priv *priv = ieee80211_priv(dev);
-#endif
         struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters;
         u8 mode = priv->ieee80211->current_network.mode;
 //        u32 size = sizeof(struct ieee80211_qos_parameters);
        u8  u1bAIFS;
        u32 u4bAcParam;
         int i;
-        if (priv == NULL)
-                return;
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16))
-       down(&priv->mutex);
-#else
         mutex_lock(&priv->mutex);
-#endif
         if(priv->ieee80211->state != IEEE80211_LINKED)
                goto success;
        RT_TRACE(COMP_QOS,"qos active process with associate response received\n");
@@ -2224,11 +1785,7 @@ void rtl8192_qos_activate(struct net_device *dev)
        }
 
 success:
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16))
-       up(&priv->mutex);
-#else
         mutex_unlock(&priv->mutex);
-#endif
 }
 
 static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
@@ -2255,11 +1812,7 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
                                 network->qos_data.param_count)) {
                        network->qos_data.old_param_count =
                                network->qos_data.param_count;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
                        queue_work(priv->priv_wq, &priv->qos_activate);
-#else
-                       schedule_task(&priv->qos_activate);
-#endif
                        RT_TRACE (COMP_QOS, "QoS parameters change call "
                                        "qos_activate\n");
                }
@@ -2268,11 +1821,7 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
                       &def_qos_parameters, size);
 
                if ((network->qos_data.active == 1) && (active_network == 1)) {
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
                        queue_work(priv->priv_wq, &priv->qos_activate);
-#else
-                       schedule_task(&priv->qos_activate);
-#endif
                        RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate \n");
                }
                network->qos_data.active = 0;
@@ -2291,15 +1840,7 @@ static int rtl8192_handle_beacon(struct net_device * dev,
 
        rtl8192_qos_handle_probe_response(priv,1,network);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
        queue_delayed_work(priv->priv_wq, &priv->update_beacon_wq, 0);
-#else
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-       schedule_task(&priv->update_beacon_wq);
-#else
-       queue_work(priv->priv_wq, &priv->update_beacon_wq);
-#endif
-#endif
        return 0;
 
 }
@@ -2356,12 +1897,7 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv,
 
        RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n",__FUNCTION__,network->flags ,priv->ieee80211->current_network.qos_data.active);
        if (set_qos_param == 1)
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
                queue_work(priv->priv_wq, &priv->qos_activate);
-#else
-               schedule_task(&priv->qos_activate);
-#endif
-
 
         return ret;
 }
@@ -2430,7 +1966,7 @@ void rtl8192_update_ratr_table(struct net_device* dev)
 
 static u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04};
 static u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04};
-bool GetNmodeSupportBySecCfg8190Pci(struct net_device*dev)
+static bool GetNmodeSupportBySecCfg8190Pci(struct net_device*dev)
 {
 #if 1
        struct r8192_priv* priv = ieee80211_priv(dev);
@@ -2475,7 +2011,7 @@ bool GetNmodeSupportBySecCfg8190Pci(struct net_device*dev)
 #endif
 }
 
-void rtl8192_refresh_supportrate(struct r8192_priv* priv)
+static void rtl8192_refresh_supportrate(struct r8192_priv* priv)
 {
        struct ieee80211_device* ieee = priv->ieee80211;
        //we donot consider set support rate for ABG mode, only HT MCS rate is set here.
@@ -2490,7 +2026,7 @@ void rtl8192_refresh_supportrate(struct r8192_priv* priv)
        return;
 }
 
-u8 rtl8192_getSupportedWireleeMode(struct net_device*dev)
+static u8 rtl8192_getSupportedWireleeMode(struct net_device*dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        u8 ret = 0;
@@ -2510,7 +2046,8 @@ u8 rtl8192_getSupportedWireleeMode(struct net_device*dev)
        }
        return ret;
 }
-void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode)
+
+static void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        u8 bSupportMode = rtl8192_getSupportedWireleeMode(dev);
@@ -2559,7 +2096,7 @@ void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode)
 }
 //init priv variables here
 
-bool GetHalfNmodeSupportByAPs819xPci(struct net_device* dev)
+static bool GetHalfNmodeSupportByAPs819xPci(struct net_device* dev)
 {
        bool                    Reval;
        struct r8192_priv* priv = ieee80211_priv(dev);
@@ -2588,20 +2125,12 @@ short rtl8192_is_tx_queue_empty(struct net_device *dev)
        }
        return 1;
 }
-#if 0
-void rtl8192_rq_tx_ack(struct net_device *dev)
-{
-       struct r8192_priv *priv = ieee80211_priv(dev);
-       priv->ieee80211->ack_tx_to_ieee = 1;
-}
-#endif
-void rtl8192_hw_sleep_down(struct net_device *dev)
+static void rtl8192_hw_sleep_down(struct net_device *dev)
 {
        RT_TRACE(COMP_POWER, "%s()============>come to sleep down\n", __FUNCTION__);
        MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS);
 }
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
-void rtl8192_hw_sleep_wq (struct work_struct *work)
+static void rtl8192_hw_sleep_wq (struct work_struct *work)
 {
 //      struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
 //      struct ieee80211_device * ieee = (struct ieee80211_device*)
@@ -2609,16 +2138,12 @@ void rtl8192_hw_sleep_wq (struct work_struct *work)
         struct delayed_work *dwork = container_of(work,struct delayed_work,work);
         struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_sleep_wq);
         struct net_device *dev = ieee->dev;
-#else
-void rtl8192_hw_sleep_wq(struct net_device* dev)
-{
-#endif
        //printk("=========>%s()\n", __FUNCTION__);
         rtl8192_hw_sleep_down(dev);
 }
 //     printk("dev is %d\n",dev);
 //     printk("&*&(^*(&(&=========>%s()\n", __FUNCTION__);
-void rtl8192_hw_wakeup(struct net_device* dev)
+static void rtl8192_hw_wakeup(struct net_device* dev)
 {
 //     u32 flags = 0;
 
@@ -2628,7 +2153,6 @@ void rtl8192_hw_wakeup(struct net_device* dev)
        //FIXME: will we send package stored while nic is sleep?
 //     spin_unlock_irqrestore(&priv->ps_lock,flags);
 }
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
 void rtl8192_hw_wakeup_wq (struct work_struct *work)
 {
 //     struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
@@ -2637,17 +2161,13 @@ void rtl8192_hw_wakeup_wq (struct work_struct *work)
        struct delayed_work *dwork = container_of(work,struct delayed_work,work);
        struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq);
        struct net_device *dev = ieee->dev;
-#else
-void rtl8192_hw_wakeup_wq(struct net_device* dev)
-{
-#endif
        rtl8192_hw_wakeup(dev);
 
 }
 
 #define MIN_SLEEP_TIME 50
 #define MAX_SLEEP_TIME 10000
-void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl)
+static void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl)
 {
 
        struct r8192_priv *priv = ieee80211_priv(dev);
@@ -2860,18 +2380,10 @@ static void rtl8192_init_priv_lock(struct r8192_priv* priv)
        //spin_lock_init(&priv->rf_lock);
        sema_init(&priv->wx_sem,1);
        sema_init(&priv->rf_sem,1);
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16))
-       sema_init(&priv->mutex, 1);
-#else
        mutex_init(&priv->mutex);
-#endif
 }
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
 extern  void    rtl819x_watchdog_wqcallback(struct work_struct *work);
-#else
-extern  void    rtl819x_watchdog_wqcallback(struct net_device *dev);
-#endif
 
 void rtl8192_irq_rx_tasklet(struct r8192_priv *priv);
 void rtl8192_irq_tx_tasklet(struct r8192_priv *priv);
@@ -2882,15 +2394,12 @@ static void rtl8192_init_priv_task(struct net_device* dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
 #ifdef PF_SYNCTHREAD
        priv->priv_wq = create_workqueue(DRV_NAME,0);
 #else
        priv->priv_wq = create_workqueue(DRV_NAME);
 #endif
-#endif
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
 //     INIT_WORK(&priv->reset_wq, (void(*)(void*)) rtl8192_restart);
        INIT_WORK(&priv->reset_wq,  rtl8192_restart);
 //     INIT_DELAYED_WORK(&priv->watch_dog_wq, hal_dm_watchdog);
@@ -2904,34 +2413,6 @@ static void rtl8192_init_priv_task(struct net_device* dev)
        INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq,(void*) rtl8192_hw_wakeup_wq);
        INIT_DELAYED_WORK(&priv->ieee80211->hw_sleep_wq,(void*) rtl8192_hw_sleep_wq);
 
-#else
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-       tq_init(&priv->reset_wq, (void*)rtl8192_restart, dev);
-       tq_init(&priv->watch_dog_wq, (void*)rtl819x_watchdog_wqcallback, dev);
-       tq_init(&priv->txpower_tracking_wq, (void*)dm_txpower_trackingcallback, dev);
-       tq_init(&priv->rfpath_check_wq, (void*)dm_rf_pathcheck_workitemcallback, dev);
-       tq_init(&priv->update_beacon_wq, (void*)rtl8192_update_beacon, dev);
-       //tq_init(&priv->SwChnlWorkItem, (void*) rtl8192_SwChnl_WorkItem, dev);
-       //tq_init(&priv->SetBWModeWorkItem, (void*)rtl8192_SetBWModeWorkItem, dev);
-       tq_init(&priv->qos_activate, (void *)rtl8192_qos_activate, dev);
-       tq_init(&priv->ieee80211->hw_wakeup_wq,(void*) rtl8192_hw_wakeup_wq, dev);
-       tq_init(&priv->ieee80211->hw_sleep_wq,(void*) rtl8192_hw_sleep_wq, dev);
-
-#else
-       INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8192_restart,dev);
-//     INIT_WORK(&priv->watch_dog_wq, (void(*)(void*)) hal_dm_watchdog,dev);
-       INIT_WORK(&priv->watch_dog_wq, (void(*)(void*)) rtl819x_watchdog_wqcallback,dev);
-       INIT_WORK(&priv->txpower_tracking_wq, (void(*)(void*)) dm_txpower_trackingcallback,dev);
-       INIT_WORK(&priv->rfpath_check_wq, (void(*)(void*)) dm_rf_pathcheck_workitemcallback,dev);
-       INIT_WORK(&priv->update_beacon_wq, (void(*)(void*))rtl8192_update_beacon,dev);
-       //INIT_WORK(&priv->SwChnlWorkItem, (void(*)(void*)) rtl8192_SwChnl_WorkItem, dev);
-       //INIT_WORK(&priv->SetBWModeWorkItem, (void(*)(void*)) rtl8192_SetBWModeWorkItem, dev);
-       INIT_WORK(&priv->qos_activate, (void(*)(void *))rtl8192_qos_activate, dev);
-       INIT_WORK(&priv->ieee80211->hw_wakeup_wq,(void*) rtl8192_hw_wakeup_wq, dev);
-       INIT_WORK(&priv->ieee80211->hw_sleep_wq,(void*) rtl8192_hw_sleep_wq, dev);
-#endif
-#endif
-
        tasklet_init(&priv->irq_rx_tasklet,
             (void(*)(unsigned long))rtl8192_irq_rx_tasklet,
             (unsigned long)priv);
@@ -3067,13 +2548,6 @@ static void rtl8192_read_eeprom_info(struct net_device* dev)
                // when auto load failed,  the last address byte set to be a random one.
                // added by david woo.2007/11/7
                memcpy(dev->dev_addr, bMac_Tmp_Addr, 6);
-               #if 0
-               for(i = 0; i < 6; i++)
-               {
-                       Adapter->PermanentAddress[i] = sMacAddr[i];
-                       PlatformEFIOWrite1Byte(Adapter, IDR0+i, sMacAddr[i]);
-               }
-               #endif
        }
 
        RT_TRACE(COMP_INIT, "Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n",
@@ -3088,7 +2562,7 @@ static void rtl8192_read_eeprom_info(struct net_device* dev)
                priv->bTXPowerDataReadFromEEPORM = false;
        }
 
-       // 2007/11/15 MH 8190PCI Default=2T4R, 8192PCIE dafault=1T2R
+       // 2007/11/15 MH 8190PCI Default=2T4R, 8192PCIE default=1T2R
        priv->rf_type = RTL819X_DEFAULT_RF_TYPE;
 
        if(priv->card_8192_version > VERSION_8190_BD)
@@ -3468,7 +2942,7 @@ static void rtl8192_read_eeprom_info(struct net_device* dev)
 }
 
 
-short rtl8192_get_channel_map(struct net_device * dev)
+static short rtl8192_get_channel_map(struct net_device * dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
 #ifdef ENABLE_DOT11D
@@ -3496,7 +2970,8 @@ short rtl8192_get_channel_map(struct net_device * dev)
 #endif
        return 0;
 }
-short rtl8192_init(struct net_device *dev)
+
+static short rtl8192_init(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        memset(&(priv->stats),0,sizeof(struct Stats));
@@ -3528,10 +3003,6 @@ short rtl8192_init(struct net_device *dev)
 
        //rtl8192_rx_enable(dev);
        //rtl8192_adapter_start(dev);
-//#ifdef DEBUG_EPROM
-//     dump_eprom(dev);
-//#endif
-       //rtl8192_dump_reg(dev);
        return 0;
 }
 
@@ -3543,7 +3014,7 @@ short rtl8192_init(struct net_device *dev)
  *  return:  none
  *  notice:  This part need to modified according to the rate set we filtered
  * ****************************************************************************/
-void rtl8192_hwconfig(struct net_device* dev)
+static void rtl8192_hwconfig(struct net_device* dev)
 {
        u32 regRATR = 0, regRRSR = 0;
        u8 regBwOpMode = 0, regTmp = 0;
@@ -3616,7 +3087,7 @@ void rtl8192_hwconfig(struct net_device* dev)
 }
 
 
-RT_STATUS rtl8192_adapter_start(struct net_device *dev)
+static RT_STATUS rtl8192_adapter_start(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
 //     struct ieee80211_device *ieee = priv->ieee80211;
@@ -3707,7 +3178,6 @@ RT_STATUS rtl8192_adapter_start(struct net_device *dev)
        //3//
        //3// Initialize BB before MAC
        //3//
-       //rtl8192_dump_reg(dev);
        RT_TRACE(COMP_INIT, "BB Config Start!\n");
        rtStatus = rtl8192_BBConfig(dev);
        if(rtStatus != RT_STATUS_SUCCESS)
@@ -3717,8 +3187,6 @@ RT_STATUS rtl8192_adapter_start(struct net_device *dev)
        }
        RT_TRACE(COMP_INIT,"BB Config Finished!\n");
 
-       //rtl8192_dump_reg(dev);
-       //
        //3//Set Loopback mode or Normal mode
        //3//
        //2006.12.13 by emily. Note!We should not merge these two CPU_GEN register writings
@@ -3833,11 +3301,8 @@ RT_STATUS rtl8192_adapter_start(struct net_device *dev)
        //3Beacon related
        write_nic_word(dev, ATIMWND, 2);
        write_nic_word(dev, BCN_INTERVAL, 100);
-       {
-               int i;
-               for (i=0; i<QOS_QUEUE_NUM; i++)
+       for (i=0; i<QOS_QUEUE_NUM; i++)
                write_nic_dword(dev, WDCAPARA_ADD[i], 0x005e4332);
-       }
        //
        // Switching regulator controller: This is set temporarily.
        // It's not sure if this can be removed in the future.
@@ -4089,7 +3554,7 @@ void rtl8192_prepare_beacon(struct r8192_priv *priv)
        //spin_lock_irqsave(&priv->tx_lock,flags);
        /* prepare misc info for the beacon xmit */
        tcb_desc->queue_index = BEACON_QUEUE;
-       /* IBSS does not support HT yet, use 1M defautly */
+       /* IBSS does not support HT yet, use 1M defaultly */
        tcb_desc->data_rate = 2;
        tcb_desc->RATRIndex = 7;
        tcb_desc->bTxDisableRateFallBack = 1;
@@ -4102,23 +3567,6 @@ void rtl8192_prepare_beacon(struct r8192_priv *priv)
        //spin_unlock_irqrestore (&priv->tx_lock, flags);
 }
 
-#if 0
-void rtl8192_beacon_tx_enable(struct net_device *dev)
-{
-       struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
-
-       rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
-#ifdef CONFIG_RTL8185B
-       priv->dma_poll_stop_mask &= ~(TPPOLLSTOP_BQ);MgntQuery_MgntFrameTxRateMgntQuery_MgntFrameTxRate
-       write_nic_byte(dev,TPPollStop, priv->dma_poll_mask);
-#else
-       priv->dma_poll_mask &=~(1<<TX_DMA_STOP_BEACON_SHIFT);
-       write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
-#endif
-       rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
-}
-#endif
-
 
 /* this configures registers for beacon tx and enables it via
  * rtl8192_beacon_tx_enable(). rtl8192_beacon_tx_disable() might
@@ -4174,18 +3622,10 @@ void rtl8192_start_beacon(struct net_device *dev)
 /***************************************************************************
     -------------------------------NET STUFF---------------------------
 ***************************************************************************/
-#if 0
-static struct net_device_stats *rtl8192_stats(struct net_device *dev)
-{
-       struct r8192_priv *priv = ieee80211_priv(dev);
 
-       return &priv->ieee80211->stats;
-}
-#endif
 
 
-
-bool HalTxCheckStuck8190Pci(struct net_device *dev)
+static bool HalTxCheckStuck8190Pci(struct net_device *dev)
 {
        u16                             RegTxCounter = read_nic_word(dev, 0x128);
        struct r8192_priv *priv = ieee80211_priv(dev);
@@ -4203,7 +3643,7 @@ bool HalTxCheckStuck8190Pci(struct net_device *dev)
 *      <Assumption: RT_TX_SPINLOCK is acquired.>
 *      First added: 2006.11.19 by emily
 */
-RESET_TYPE
+static RESET_TYPE
 TxCheckStuck(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
@@ -4283,13 +3723,6 @@ TxCheckStuck(struct net_device *dev)
                                continue;
                        }
                        txring->nStuckCount++;
-                       #if 0
-                       if(txring->nStuckCount > ResetThreshold)
-                       {
-                               RT_TRACE( COMP_RESET, "<== TxCheckStuck()\n" );
-                               return RESET_TYPE_NORMAL;
-                       }
-                       #endif
                        bCheckFwTxCnt = TRUE;
                }
        }
@@ -4307,7 +3740,7 @@ TxCheckStuck(struct net_device *dev)
 }
 
 
-bool HalRxCheckStuck8190Pci(struct net_device *dev)
+static bool HalRxCheckStuck8190Pci(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        u16                             RegRxCounter = read_nic_word(dev, 0x130);
@@ -4363,12 +3796,6 @@ bool HalRxCheckStuck8190Pci(struct net_device *dev)
                        //DbgPrint("RSSI <= %d, check this time \n", VeryLowRSSI);
                }
        }
-#if 0
-       if (rx_chk_cnt < 2)
-               return bStuck;
-       else
-               rx_chk_cnt = 0;
-#endif
        if(priv->RxCounter==RegRxCounter)
                bStuck = TRUE;
 
@@ -4377,7 +3804,7 @@ bool HalRxCheckStuck8190Pci(struct net_device *dev)
        return bStuck;
 }
 
-RESET_TYPE RxCheckStuck(struct net_device *dev)
+static RESET_TYPE RxCheckStuck(struct net_device *dev)
 {
 
        if(HalRxCheckStuck8190Pci(dev))
@@ -4389,7 +3816,7 @@ RESET_TYPE RxCheckStuck(struct net_device *dev)
        return RESET_TYPE_NORESET;
 }
 
-RESET_TYPE
+static RESET_TYPE
 rtl819x_ifcheck_resetornot(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
@@ -4428,7 +3855,7 @@ rtl819x_ifcheck_resetornot(struct net_device *dev)
 }
 
 
-void CamRestoreAllEntry(       struct net_device *dev)
+static void CamRestoreAllEntry(struct net_device *dev)
 {
        u8 EntryId = 0;
        struct r8192_priv *priv = ieee80211_priv(dev);
@@ -4571,7 +3998,7 @@ int _rtl8192_up(struct net_device *dev);
  * The method checking Tx/Rx stuck of this function is supported by FW,
  * which reports Tx and Rx counter to register 0x128 and 0x130.
  * */
-void rtl819x_ifsilentreset(struct net_device *dev)
+static void rtl819x_ifsilentreset(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        u8      reset_times = 0;
@@ -4617,9 +4044,7 @@ RESET_START:
                        printk("ieee->state is IEEE80211_LINKED\n");
                        ieee80211_stop_send_beacons(priv->ieee80211);
                        del_timer_sync(&ieee->associate_timer);
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
                         cancel_delayed_work(&ieee->associate_retry_wq);
-#endif
                        ieee80211_stop_scan(ieee);
                        netif_carrier_off(dev);
                        up(&ieee->wx_sem);
@@ -4657,11 +4082,7 @@ RESET_START:
                        ieee->set_chan(ieee->dev, ieee->current_network.channel);
 
 #if 1
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
                        queue_work(ieee->wq, &ieee->associate_complete_wq);
-#else
-                       schedule_task(&ieee->associate_complete_wq);
-#endif
 #endif
 
                }
@@ -4725,10 +4146,6 @@ void InactivePsWorkItemCallback(struct net_device *dev)
        //
        // To solve CAM values miss in RF OFF, rewrite CAM values after RF ON. By Bruce, 2007-09-20.
        //
-#if 0
-       if(pPSC->eInactivePowerState == eRfOn)
-               CamRestoreAllEntry(dev);
-#endif
        pPSC->bSwRfProcessing = FALSE;
        RT_TRACE(COMP_POWER, "InactivePsWorkItemCallback() <--------- \n");
 }
@@ -4793,48 +4210,8 @@ IPSLeave(struct net_device *dev)
        }
 }
 #endif
-void CAM_read_entry(
-       struct net_device *dev,
-       u32                     iIndex
-)
-{
-       u32 target_command=0;
-        u32 target_content=0;
-        u8 entry_i=0;
-        u32 ulStatus;
-       s32 i=100;
-//     printk("=======>start read CAM\n");
-       for(entry_i=0;entry_i<CAM_CONTENT_COUNT;entry_i++)
-       {
-       // polling bit, and No Write enable, and address
-               target_command= entry_i+CAM_CONTENT_COUNT*iIndex;
-               target_command= target_command | BIT31;
-
-       //Check polling bit is clear
-//     mdelay(1);
-#if 1
-               while((i--)>=0)
-               {
-                       ulStatus = read_nic_dword(dev, RWCAM);
-                       if(ulStatus & BIT31){
-                               continue;
-                       }
-                       else{
-                               break;
-                       }
-               }
-#endif
-               write_nic_dword(dev, RWCAM, target_command);
-               RT_TRACE(COMP_SEC,"CAM_read_entry(): WRITE A0: %x \n",target_command);
-        //     printk("CAM_read_entry(): WRITE A0: %lx \n",target_command);
-               target_content = read_nic_dword(dev, RCAMO);
-               RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A8: %x \n",target_content);
-        //     printk("CAM_read_entry(): WRITE A8: %lx \n",target_content);
-       }
-       printk("\n");
-}
 
-void rtl819x_update_rxcounts(
+static void rtl819x_update_rxcounts(
        struct r8192_priv *priv,
        u32* TotalRxBcnNum,
        u32* TotalRxDataNum
@@ -4856,17 +4233,11 @@ void rtl819x_update_rxcounts(
 }
 
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
-extern void    rtl819x_watchdog_wqcallback(struct work_struct *work)
+void rtl819x_watchdog_wqcallback(struct work_struct *work)
 {
        struct delayed_work *dwork = container_of(work,struct delayed_work,work);
        struct r8192_priv *priv = container_of(dwork,struct r8192_priv,watch_dog_wq);
        struct net_device *dev = priv->ieee80211->dev;
-#else
-extern void    rtl819x_watchdog_wqcallback(struct net_device *dev)
-{
-       struct r8192_priv *priv = ieee80211_priv(dev);
-#endif
        struct ieee80211_device* ieee = priv->ieee80211;
        RESET_TYPE      ResetType = RESET_TYPE_NORESET;
        static u8       check_reset_cnt=0;
@@ -4924,18 +4295,13 @@ extern  void    rtl819x_watchdog_wqcallback(struct net_device *dev)
                                ieee->is_roaming = true;
                                ieee->is_set_key = false;
                              ieee->link_change(dev);
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
                                 queue_work(ieee->wq, &ieee->associate_procedure_wq);
-#else
-                                schedule_task(&ieee->associate_procedure_wq);
-#endif
                        }
                }
              ieee->LinkDetectInfo.NumRecvBcnInPeriod=0;
               ieee->LinkDetectInfo.NumRecvDataInPeriod=0;
 
        }
-//     CAM_read_entry(dev,0);
        //check if reset the driver
        spin_lock_irqsave(&priv->tx_lock,flags);
        if(check_reset_cnt++ >= 3 && !ieee->is_roaming && (last_time != 1))
@@ -4971,15 +4337,7 @@ extern   void    rtl819x_watchdog_wqcallback(struct net_device *dev)
 void watch_dog_timer_callback(unsigned long data)
 {
        struct r8192_priv *priv = ieee80211_priv((struct net_device *) data);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
        queue_delayed_work(priv->priv_wq,&priv->watch_dog_wq,0);
-#else
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-       schedule_task(&priv->watch_dog_wq);
-#else
-       queue_work(priv->priv_wq,&priv->watch_dog_wq);
-#endif
-#endif
        mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME));
 
 }
@@ -5016,7 +4374,7 @@ int _rtl8192_up(struct net_device *dev)
 }
 
 
-int rtl8192_open(struct net_device *dev)
+static int rtl8192_open(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        int ret;
@@ -5039,7 +4397,7 @@ int rtl8192_up(struct net_device *dev)
 }
 
 
-int rtl8192_close(struct net_device *dev)
+static int rtl8192_close(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        int ret;
@@ -5128,22 +4486,10 @@ void rtl8192_commit(struct net_device *dev)
        _rtl8192_up(dev);
 }
 
-/*
-void rtl8192_restart(struct net_device *dev)
-{
-       struct r8192_priv *priv = ieee80211_priv(dev);
-*/
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
 void rtl8192_restart(struct work_struct *work)
 {
         struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq);
         struct net_device *dev = priv->ieee80211->dev;
-#else
-void rtl8192_restart(struct net_device *dev)
-{
-
-        struct r8192_priv *priv = ieee80211_priv(dev);
-#endif
 
        down(&priv->wx_sem);
 
@@ -5175,7 +4521,7 @@ static void r8192_set_multicast(struct net_device *dev)
 }
 
 
-int r8192_set_mac_adr(struct net_device *dev, void *mac)
+static int r8192_set_mac_adr(struct net_device *dev, void *mac)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        struct sockaddr *addr = mac;
@@ -5184,18 +4530,14 @@ int r8192_set_mac_adr(struct net_device *dev, void *mac)
 
        memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
        schedule_work(&priv->reset_wq);
-#else
-       schedule_task(&priv->reset_wq);
-#endif
        up(&priv->wx_sem);
 
        return 0;
 }
 
 /* based on ipw2200 driver */
-int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
        struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
        struct iwreq *wrq = (struct iwreq *)rq;
@@ -5317,7 +4659,7 @@ out:
        return ret;
 }
 
-u8 HwRateToMRate90(bool bIsHT, u8 rate)
+static u8 HwRateToMRate90(bool bIsHT, u8 rate)
 {
        u8  ret_rate = 0x02;
 
@@ -5385,7 +4727,7 @@ u8 HwRateToMRate90(bool bIsHT, u8 rate)
  * Return:
  *               None
  */
-void UpdateRxPktTimeStamp8190 (struct net_device *dev, struct ieee80211_rx_stats *stats)
+static void UpdateRxPktTimeStamp8190 (struct net_device *dev, struct ieee80211_rx_stats *stats)
 {
        struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
 
@@ -5398,7 +4740,7 @@ void UpdateRxPktTimeStamp8190 (struct net_device *dev, struct ieee80211_rx_stats
        }
 }
 
-long rtl819x_translate_todbm(u8 signal_strength_index  )// 0-100 index.
+static long rtl819x_translate_todbm(u8 signal_strength_index)// 0-100 index.
 {
        long    signal_power; // in dBm.
 
@@ -5419,7 +4761,7 @@ long rtl819x_translate_todbm(u8 signal_strength_index     )// 0-100 index.
 //             In normal operation, user only care about the information of the BSS
 //             and we shall invoke this function if the packet received is from the BSS.
 //
-void
+static void
 rtl819x_update_rxsignalstatistics8190pci(
        struct r8192_priv * priv,
        struct ieee80211_rx_stats * pprevious_stats
@@ -5446,7 +4788,7 @@ rtl819x_update_rxsignalstatistics8190pci(
        priv->stats.recv_signal_power = (priv->stats.recv_signal_power * 5 + pprevious_stats->RecvSignalPower + weighting) / 6;
 }
 
-void
+static void
 rtl8190_process_cck_rxpathsel(
        struct r8192_priv * priv,
        struct ieee80211_rx_stats * pprevious_stats
@@ -5511,7 +4853,7 @@ rtl8190_process_cck_rxpathsel(
        be a local static. Otherwise, it may increase when we return from S3/S4. The
        value will be kept in memory or disk. We must delcare the value in adapter
        and it will be reinitialized when return from S3/S4. */
-void rtl8192_process_phyinfo(struct r8192_priv * priv, u8* buffer,struct ieee80211_rx_stats * pprevious_stats, struct ieee80211_rx_stats * pcurrent_stats)
+static void rtl8192_process_phyinfo(struct r8192_priv * priv, u8* buffer,struct ieee80211_rx_stats * pprevious_stats, struct ieee80211_rx_stats * pcurrent_stats)
 {
        bool bcheck = false;
        u8      rfpath;
@@ -5820,10 +5162,7 @@ rtl819x_evm_dbtopercentage(
 //     We want good-looking for signal strength/quality
 //     2007/7/19 01:09, by cosa.
 //
-long
-rtl819x_signal_scale_mapping(
-       long currsig
-       )
+static long rtl819x_signal_scale_mapping(long currsig)
 {
        long retsig;
 
@@ -6150,7 +5489,7 @@ static void rtl8192_query_rxphystatus(
        }
 }      /* QueryRxPhyStatus8190Pci */
 
-void
+static void
 rtl8192_record_rxdesc_forlateruse(
        struct ieee80211_rx_stats * psrc_stats,
        struct ieee80211_rx_stats * ptarget_stats
@@ -6163,7 +5502,7 @@ rtl8192_record_rxdesc_forlateruse(
 
 
 
-void TranslateRxSignalStuff819xpci(struct net_device *dev,
+static void TranslateRxSignalStuff819xpci(struct net_device *dev,
         struct sk_buff *skb,
         struct ieee80211_rx_stats * pstats,
         prx_desc_819x_pci pdesc,
@@ -6229,7 +5568,7 @@ void TranslateRxSignalStuff819xpci(struct net_device *dev,
 }
 
 
-void rtl8192_tx_resume(struct net_device *dev)
+static void rtl8192_tx_resume(struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
        struct ieee80211_device *ieee = priv->ieee80211;
@@ -6272,7 +5611,7 @@ void rtl8192_irq_tx_tasklet(struct r8192_priv *priv)
 * Return:
 *              None
 */
-void UpdateReceivedRateHistogramStatistics8190(
+static void UpdateReceivedRateHistogramStatistics8190(
        struct net_device *dev,
        struct ieee80211_rx_stats* pstats
        )
@@ -6343,7 +5682,7 @@ void UpdateReceivedRateHistogramStatistics8190(
        priv->stats.received_rate_histogram[rcvType][rateIndex]++;
 }
 
-void rtl8192_rx(struct net_device *dev)
+static void rtl8192_rx(struct net_device *dev)
 {
     struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
     struct ieee80211_hdr_1addr *ieee80211_hdr = NULL;
@@ -6398,11 +5737,7 @@ void rtl8192_rx(struct net_device *dev)
                 stats.RxBufShift = ((pdesc->Shift)&0x03);
                 stats.Decrypted = !pdesc->SWDec;
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
                 pci_dma_sync_single_for_cpu(priv->pdev,
-#else
-                    pci_unmap_single(priv->pdev,
-#endif
                      *((dma_addr_t *)skb->cb),
                      priv->rxbuffersize,
                      PCI_DMA_FROMDEVICE);
@@ -6460,7 +5795,7 @@ void rtl8192_rx(struct net_device *dev)
                 stats.fragoffset = 0;
                 stats.ntotalfrag = 1;
 
-                if(!ieee80211_rx(priv->ieee80211, skb, &stats)){
+                if(!ieee80211_rtl_rx(priv->ieee80211, skb, &stats)){
                     dev_kfree_skb_any(skb);
                 } else {
                     priv->stats.rxok++;
@@ -6502,7 +5837,7 @@ static const struct net_device_ops rtl8192_netdev_ops = {
        .ndo_do_ioctl =                 rtl8192_ioctl,
        .ndo_set_multicast_list =       r8192_set_multicast,
        .ndo_set_mac_address =          r8192_set_mac_adr,
-       .ndo_start_xmit =               ieee80211_xmit,
+       .ndo_start_xmit =               ieee80211_rtl_xmit,
 };
 
 /****************************************************************************
@@ -6533,33 +5868,19 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev,
        pci_set_master(pdev);
        //pci_set_wmi(pdev);
        pci_set_dma_mask(pdev, 0xffffff00ULL);
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
        pci_set_consistent_dma_mask(pdev,0xffffff00ULL);
-#endif
        dev = alloc_ieee80211(sizeof(struct r8192_priv));
        if (!dev)
                return -ENOMEM;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
-       SET_MODULE_OWNER(dev);
-#endif
-
        pci_set_drvdata(pdev, dev);
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
        SET_NETDEV_DEV(dev, &pdev->dev);
-#endif
        priv = ieee80211_priv(dev);
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
        priv->ieee80211 = netdev_priv(dev);
-#else
-       priv->ieee80211 = (struct ieee80211_device *)dev->priv;
-#endif
        priv->pdev=pdev;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
        if((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK)&&(pdev->subsystem_device == 0x3304)){
                priv->ieee80211->bSupportRemoteWakeUp = 1;
        } else
-#endif
        {
                priv->ieee80211->bSupportRemoteWakeUp = 0;
        }
@@ -6670,11 +5991,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev,
 
 
        RT_TRACE(COMP_INIT, "Driver probe completed\n");
-//#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-//     return dev;
-//#else
        return 0;
-//#endif
 
 fail1:
 
@@ -6721,7 +6038,6 @@ void rtl8192_cancel_deferred_work(struct r8192_priv* priv)
          * Otherwise call cancel_delayed_work is enough.
          * FIXME (2.6.20 shoud 2.6.22, work_struct shoud not cancel)
          * */
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
        cancel_delayed_work(&priv->watch_dog_wq);
        cancel_delayed_work(&priv->update_beacon_wq);
        cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq);
@@ -6729,20 +6045,10 @@ void rtl8192_cancel_deferred_work(struct r8192_priv* priv)
 #ifdef RTL8192E
        cancel_delayed_work(&priv->gpio_change_rf_wq);
 #endif
-#endif
-#if LINUX_VERSION_CODE >=KERNEL_VERSION(2,6,22)
        cancel_work_sync(&priv->reset_wq);
        cancel_work_sync(&priv->qos_activate);
        //cancel_work_sync(&priv->SetBWModeWorkItem);
        //cancel_work_sync(&priv->SwChnlWorkItem);
-#else
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
-       cancel_delayed_work(&priv->reset_wq);
-       cancel_delayed_work(&priv->qos_activate);
-       //cancel_delayed_work(&priv->SetBWModeWorkItem);
-       //cancel_delayed_work(&priv->SwChnlWorkItem);
-#endif
-#endif
 
 }
 
@@ -6768,9 +6074,7 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev)
                }
        //      priv->rf_close(dev);
        //      rtl8192_usb_deleteendpoints(dev);
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
                destroy_workqueue(priv->priv_wq);
-#endif
                 /* redundant with rtl8192_down */
                // rtl8192_irq_disable(dev);
                // rtl8192_reset(dev);
@@ -6817,14 +6121,14 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev)
        RT_TRACE(COMP_DOWN, "wlan driver removed\n");
 }
 
-extern int ieee80211_init(void);
-extern void ieee80211_exit(void);
+extern int ieee80211_rtl_init(void);
+extern void ieee80211_rtl_exit(void);
 
 static int __init rtl8192_pci_module_init(void)
 {
        int retval;
 
-       retval = ieee80211_init();
+       retval = ieee80211_rtl_init();
        if (retval)
                return retval;
 
@@ -6833,11 +6137,7 @@ static int __init rtl8192_pci_module_init(void)
        RT_TRACE(COMP_INIT, "Initializing module");
        RT_TRACE(COMP_INIT, "Wireless extensions version %d", WIRELESS_EXT);
        rtl8192_proc_module_init();
-#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
-      if(0!=pci_module_init(&rtl8192_pci_driver))
-#else
       if(0!=pci_register_driver(&rtl8192_pci_driver))
-#endif
        {
                DMESG("No device found");
                /*pci_unregister_driver (&rtl8192_pci_driver);*/
@@ -6853,19 +6153,11 @@ static void __exit rtl8192_pci_module_exit(void)
 
        RT_TRACE(COMP_DOWN, "Exiting");
        rtl8192_proc_module_remove();
-       ieee80211_exit();
+       ieee80211_rtl_exit();
 }
 
 //warning message WB
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-void rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs)
-#else
-irqreturn_t rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs)
-#endif
-#else
 irqreturn_t rtl8192_interrupt(int irq, void *netdev)
-#endif
 {
     struct net_device *dev = (struct net_device *) netdev;
     struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
@@ -6873,11 +6165,7 @@ irqreturn_t rtl8192_interrupt(int irq, void *netdev)
     u32 inta;
     /* We should return IRQ_NONE, but for now let me keep this */
     if(priv->irq_enabled == 0){
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-        return;
-#else
         return IRQ_HANDLED;
-#endif
     }
 
     spin_lock_irqsave(&priv->irq_th_lock,flags);
@@ -6891,11 +6179,7 @@ irqreturn_t rtl8192_interrupt(int irq, void *netdev)
     //DMESG("Enter interrupt, ISR value = 0x%08x", inta);
     if(!inta){
         spin_unlock_irqrestore(&priv->irq_th_lock,flags);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-        return;
-#else
         return IRQ_HANDLED;
-#endif
         /*
            most probably we can safely return IRQ_NONE,
            but for now is better to avoid problems
@@ -6905,11 +6189,7 @@ irqreturn_t rtl8192_interrupt(int irq, void *netdev)
     if(inta == 0xffff){
         /* HW disappared */
         spin_unlock_irqrestore(&priv->irq_th_lock,flags);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-        return;
-#else
         return IRQ_HANDLED;
-#endif
     }
 
     priv->stats.ints++;
@@ -6921,11 +6201,7 @@ irqreturn_t rtl8192_interrupt(int irq, void *netdev)
 
     if(!netif_running(dev)) {
         spin_unlock_irqrestore(&priv->irq_th_lock,flags);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-        return;
-#else
         return IRQ_HANDLED;
-#endif
     }
 
     if(inta & IMR_TIMEOUT0){
@@ -7022,11 +6298,7 @@ irqreturn_t rtl8192_interrupt(int irq, void *netdev)
     force_pci_posting(dev);
     spin_unlock_irqrestore(&priv->irq_th_lock,flags);
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-    return;
-#else
     return IRQ_HANDLED;
-#endif
 }
 
 void rtl8192_try_wake_queue(struct net_device *dev, int pri)
@@ -7041,7 +6313,7 @@ void rtl8192_try_wake_queue(struct net_device *dev, int pri)
         spin_unlock_irqrestore(&priv->tx_lock,flags);
 
        if(enough_desc)
-               ieee80211_wake_queue(priv->ieee80211);
+               ieee80211_rtl_wake_queue(priv->ieee80211);
 #endif
 }
 
@@ -7161,7 +6433,6 @@ void setKey(      struct net_device *dev,
        }
        }
        RT_TRACE(COMP_SEC,"=========>after set key, usconfig:%x\n", usConfig);
-//     CAM_read_entry(dev, 0);
 }
 // This function seems not ready! WB
 void CamPrintDbgReg(struct net_device* dev)