]> Pileus Git - ~andy/linux/blobdiff - drivers/staging/rtl8192e/r8192E_core.c
Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd
[~andy/linux] / drivers / staging / rtl8192e / r8192E_core.c
index 3877ce57d40a15547a0434f5f0ce7f20885771cb..58d800f1b5ee1878f66da3717677eb816cdc7e74 100644 (file)
@@ -96,13 +96,13 @@ static struct pci_driver rtl8192_pci_driver = {
 #endif
 };
 
-static void rtl8192_start_beacon(struct net_device *dev);
-static void rtl8192_stop_beacon(struct net_device *dev);
+static void rtl8192_start_beacon(struct ieee80211_device *ieee80211);
+static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211);
 static void rtl819x_watchdog_wqcallback(struct work_struct *work);
 static void rtl8192_irq_rx_tasklet(unsigned long arg);
 static void rtl8192_irq_tx_tasklet(unsigned long arg);
 static void rtl8192_prepare_beacon(unsigned long arg);
-static irqreturn_t rtl8192_interrupt(int irq, void *netdev);
+static irqreturn_t rtl8192_interrupt(int irq, void *param);
 static void rtl819xE_tx_cmd(struct r8192_priv *priv, struct sk_buff *skb);
 static void rtl8192_update_ratr_table(struct r8192_priv *priv);
 static void rtl8192_restart(struct work_struct *work);
@@ -271,10 +271,9 @@ u8 rtl8192e_ap_sec_type(struct ieee80211_device *ieee)
        }
 }
 
-void
-rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val)
+void rtl8192e_SetHwReg(struct ieee80211_device *ieee80211, u8 variable, u8 *val)
 {
-       struct r8192_priv* priv = ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
 
        switch(variable)
        {
@@ -368,8 +367,7 @@ static int proc_get_stats_ap(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);
+       struct r8192_priv *priv = data;
        struct ieee80211_device *ieee = priv->ieee80211;
        struct ieee80211_network *target;
        int len = 0;
@@ -398,8 +396,7 @@ static int proc_get_registers(char *page, char **start,
                          off_t offset, int count,
                          int *eof, void *data)
 {
-       struct net_device *dev = data;
-       struct r8192_priv *priv = ieee80211_priv(dev);
+       struct r8192_priv *priv = data;
        int len = 0;
        int i,n;
        int max=0xff;
@@ -451,8 +448,7 @@ static int proc_get_stats_tx(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);
+       struct r8192_priv *priv = data;
 
        int len = 0;
 
@@ -477,7 +473,7 @@ static int proc_get_stats_tx(char *page, char **start,
                priv->stats.txbeaconokint,
                priv->stats.txbeaconerr,
                priv->stats.txcmdpktokint,
-               netif_queue_stopped(dev),
+               netif_queue_stopped(priv->ieee80211->dev),
                priv->stats.txoverflow,
                priv->ieee80211->stats.tx_packets,
                priv->ieee80211->stats.tx_bytes);
@@ -492,9 +488,7 @@ static int proc_get_stats_rx(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);
-
+       struct r8192_priv *priv = data;
        int len = 0;
 
        len += snprintf(page + len, count - len,
@@ -553,7 +547,7 @@ static void rtl8192_proc_init_one(struct r8192_priv *priv)
                return;
        }
        e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
-                                  priv->dir_dev, proc_get_stats_rx, dev);
+                                  priv->dir_dev, proc_get_stats_rx, priv);
 
        if (!e) {
                RT_TRACE(COMP_ERR,"Unable to initialize "
@@ -563,7 +557,7 @@ static void rtl8192_proc_init_one(struct r8192_priv *priv)
 
 
        e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
-                                  priv->dir_dev, proc_get_stats_tx, dev);
+                                  priv->dir_dev, proc_get_stats_tx, priv);
 
        if (!e) {
                RT_TRACE(COMP_ERR, "Unable to initialize "
@@ -572,7 +566,7 @@ static void rtl8192_proc_init_one(struct r8192_priv *priv)
        }
 
        e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
-                                  priv->dir_dev, proc_get_stats_ap, dev);
+                                  priv->dir_dev, proc_get_stats_ap, priv);
 
        if (!e) {
                RT_TRACE(COMP_ERR, "Unable to initialize "
@@ -581,7 +575,7 @@ static void rtl8192_proc_init_one(struct r8192_priv *priv)
        }
 
        e = create_proc_read_entry("registers", S_IFREG | S_IRUGO,
-                                  priv->dir_dev, proc_get_registers, dev);
+                                  priv->dir_dev, proc_get_registers, priv);
        if (!e) {
                RT_TRACE(COMP_ERR, "Unable to initialize "
                      "/proc/net/rtl8192/%s/registers\n",
@@ -589,9 +583,9 @@ static void rtl8192_proc_init_one(struct r8192_priv *priv)
        }
 }
 
-static short check_nic_enough_desc(struct net_device *dev, int prio)
+static short check_nic_enough_desc(struct ieee80211_device *ieee, int prio)
 {
-    struct r8192_priv *priv = ieee80211_priv(dev);
+    struct r8192_priv *priv = ieee80211_priv(ieee->dev);
     struct rtl8192_tx_ring *ring = &priv->tx_ring[prio];
 
     /* for now we reserve two free descriptor as a safety boundary
@@ -653,16 +647,16 @@ static void rtl8192_update_msr(struct r8192_priv *priv)
        write_nic_byte(priv, MSR, msr);
 }
 
-static void rtl8192_set_chan(struct net_device *dev,short ch)
+static void rtl8192_set_chan(struct ieee80211_device *ieee80211, short ch)
 {
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
 
        priv->chan = ch;
 
        /* need to implement rf set channel here WB */
 
        if (priv->rf_set_chan)
-               priv->rf_set_chan(dev, priv->chan);
+               priv->rf_set_chan(ieee80211, priv->chan);
 }
 
 static void rtl8192_rx_enable(struct r8192_priv *priv)
@@ -753,13 +747,12 @@ void PHY_SetRtl8192eRfOff(struct r8192_priv *priv)
 
 static void rtl8192_halt_adapter(struct r8192_priv *priv, bool reset)
 {
-       struct net_device *dev = priv->ieee80211->dev;
        int i;
        u8 OpMode;
        u32 ulRegRead;
 
        OpMode = RT_OP_MODE_NO_LINK;
-       priv->ieee80211->SetHwRegHandler(dev, HW_VAR_MEDIA_STATUS, &OpMode);
+       priv->ieee80211->SetHwRegHandler(priv->ieee80211, HW_VAR_MEDIA_STATUS, &OpMode);
 
        if (!priv->ieee80211->bSupportRemoteWakeUp) {
                /*
@@ -808,11 +801,11 @@ static void rtl8192_halt_adapter(struct r8192_priv *priv, bool reset)
        skb_queue_purge(&priv->skb_queue);
 }
 
-static void rtl8192_data_hard_stop(struct net_device *dev)
+static void rtl8192_data_hard_stop(struct ieee80211_device *ieee80211)
 {
 }
 
-static void rtl8192_data_hard_resume(struct net_device *dev)
+static void rtl8192_data_hard_resume(struct ieee80211_device *ieee80211)
 {
 }
 
@@ -820,9 +813,10 @@ static 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
  */
-static 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 ieee80211_device *ieee80211, int rate)
 {
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
        int ret;
        cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
        u8 queue_index = tcb_desc->queue_index;
@@ -836,8 +830,6 @@ static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
                return;
        }
 
-       memcpy(skb->cb, &dev, sizeof(dev));
-
        skb_push(skb, priv->ieee80211->tx_headroom);
        ret = rtl8192_tx(priv, skb);
        if (ret != 0) {
@@ -856,9 +848,9 @@ static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
  * If the ring is full packet are dropped (for data frame the queue
  * is stopped before this can happen).
  */
-static int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
+static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct ieee80211_device *ieee80211)
 {
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
        int ret;
         cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
         u8 queue_index = tcb_desc->queue_index;
@@ -871,7 +863,6 @@ static int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
                }
         }
 
-        memcpy(skb->cb, &dev, sizeof(dev));
        if (queue_index == TXCMD_QUEUE) {
                rtl819xE_tx_cmd(priv, skb);
                ret = 0;
@@ -881,7 +872,7 @@ static int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
                tcb_desc->bTxDisableRateFallBack = 1;
                tcb_desc->bTxUseDriverAssingedRate = 1;
                tcb_desc->bTxEnableFwCalcDur = 1;
-               skb_push(skb, priv->ieee80211->tx_headroom);
+               skb_push(skb, ieee80211->tx_headroom);
                ret = rtl8192_tx(priv, skb);
                if (ret != 0) {
                        kfree_skb(skb);
@@ -923,7 +914,7 @@ static void rtl8192_tx_isr(struct r8192_priv *priv, int prio)
        }
 }
 
-static void rtl8192_stop_beacon(struct net_device *dev)
+static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211)
 {
 }
 
@@ -1470,10 +1461,9 @@ static void rtl8192_pci_resetdescring(struct r8192_priv *priv)
     }
 }
 
-static void rtl8192_link_change(struct net_device *dev)
+static void rtl8192_link_change(struct ieee80211_device *ieee)
 {
-       struct r8192_priv *priv = ieee80211_priv(dev);
-       struct ieee80211_device* ieee = priv->ieee80211;
+       struct r8192_priv *priv = ieee80211_priv(ieee->dev);
 
        if (ieee->state == IEEE80211_LINKED)
        {
@@ -1604,11 +1594,11 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
 }
 
 /* handle manage frame frame beacon and probe response */
-static int rtl8192_handle_beacon(struct net_device * dev,
+static int rtl8192_handle_beacon(struct ieee80211_device *ieee,
                               struct ieee80211_beacon * beacon,
                               struct ieee80211_network * network)
 {
-       struct r8192_priv *priv = ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee->dev);
 
        rtl8192_qos_handle_probe_response(priv,1,network);
 
@@ -1670,11 +1660,11 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv,
 }
 
 
-static int rtl8192_handle_assoc_response(struct net_device *dev,
+static int rtl8192_handle_assoc_response(struct ieee80211_device *ieee,
                                      struct ieee80211_assoc_response_frame *resp,
                                      struct ieee80211_network *network)
 {
-        struct r8192_priv *priv = ieee80211_priv(dev);
+        struct r8192_priv *priv = ieee80211_priv(ieee->dev);
         rtl8192_qos_association_resp(priv, network);
         return 0;
 }
@@ -1726,11 +1716,8 @@ static void rtl8192_update_ratr_table(struct r8192_priv* priv)
        write_nic_byte(priv, UFWP, 1);
 }
 
-static bool GetNmodeSupportBySecCfg8190Pci(struct net_device*dev)
+static bool GetNmodeSupportBySecCfg8190Pci(struct ieee80211_device *ieee)
 {
-       struct r8192_priv *priv = ieee80211_priv(dev);
-       struct ieee80211_device *ieee = priv->ieee80211;
-
        return !(ieee->rtllib_ap_sec_type &&
                 (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP)));
 }
@@ -1752,9 +1739,9 @@ static u8 rtl8192_getSupportedWireleeMode(void)
        return (WIRELESS_MODE_N_24G|WIRELESS_MODE_G|WIRELESS_MODE_B);
 }
 
-static void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode)
+static void rtl8192_SetWirelessMode(struct ieee80211_device *ieee, u8 wireless_mode)
 {
-       struct r8192_priv *priv = ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee->dev);
        u8 bSupportMode = rtl8192_getSupportedWireleeMode();
 
        if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode&bSupportMode)==0))
@@ -1794,18 +1781,16 @@ static void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode)
        rtl8192_refresh_supportrate(priv);
 }
 
-static bool GetHalfNmodeSupportByAPs819xPci(struct net_device* dev)
+static bool GetHalfNmodeSupportByAPs819xPci(struct ieee80211_device* ieee)
 {
-       struct r8192_priv* priv = ieee80211_priv(dev);
-       struct ieee80211_device* ieee = priv->ieee80211;
-
        return ieee->bHalfWirelessN24GMode;
 }
 
-static short rtl8192_is_tx_queue_empty(struct net_device *dev)
+static short rtl8192_is_tx_queue_empty(struct ieee80211_device *ieee)
 {
        int i=0;
-       struct r8192_priv *priv = ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee->dev);
+
        for (i=0; i<=MGNT_QUEUE; i++)
        {
                if ((i== TXCMD_QUEUE) || (i == HCCA_QUEUE) )
@@ -1823,9 +1808,9 @@ static void rtl8192_hw_sleep_down(struct r8192_priv *priv)
        MgntActSet_RF_State(priv, eRfSleep, RF_CHANGE_BY_PS);
 }
 
-static void rtl8192_hw_wakeup(struct net_device* dev)
+static void rtl8192_hw_wakeup(struct ieee80211_device *ieee)
 {
-       struct r8192_priv *priv = ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee->dev);
        MgntActSet_RF_State(priv, eRfOn, RF_CHANGE_BY_PS);
 }
 
@@ -1833,16 +1818,15 @@ static 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;
-       rtl8192_hw_wakeup(dev);
 
+       rtl8192_hw_wakeup(ieee);
 }
 
 #define MIN_SLEEP_TIME 50
 #define MAX_SLEEP_TIME 10000
-static void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl)
+static void rtl8192_hw_to_sleep(struct ieee80211_device *ieee, u32 th, u32 tl)
 {
-       struct r8192_priv *priv = ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee->dev);
        u32 tmp;
        u32 rb = jiffies;
 
@@ -1932,8 +1916,8 @@ static void rtl8192_init_priv_variable(struct r8192_priv *priv)
        priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
        priv->ieee80211->host_encrypt = 1;
        priv->ieee80211->host_decrypt = 1;
-       priv->ieee80211->start_send_beacons = rtl8192_start_beacon;//+by david 081107
-       priv->ieee80211->stop_send_beacons = rtl8192_stop_beacon;//+by david 081107
+       priv->ieee80211->start_send_beacons = rtl8192_start_beacon;
+       priv->ieee80211->stop_send_beacons = rtl8192_stop_beacon;
        priv->ieee80211->softmac_hard_start_xmit = rtl8192_hard_start_xmit;
        priv->ieee80211->set_chan = rtl8192_set_chan;
        priv->ieee80211->link_change = rtl8192_link_change;
@@ -2305,7 +2289,7 @@ static void rtl8192_read_eeprom_info(struct r8192_priv *priv)
 
        // 2008/01/16 MH We can only know RF type in the function. So we have to init
        // DIG RATR table again.
-       init_rate_adaptive(dev);
+       init_rate_adaptive(priv);
 
        //1 Make a copy for following variables and we can change them if we want
 
@@ -2421,11 +2405,11 @@ static short rtl8192_init(struct r8192_priv *priv)
        rtl8192_get_eeprom_size(priv);
        rtl8192_read_eeprom_info(priv);
        rtl8192_get_channel_map(priv);
-       init_hal_dm(dev);
+       init_hal_dm(priv);
        init_timer(&priv->watch_dog_timer);
        priv->watch_dog_timer.data = (unsigned long)priv;
        priv->watch_dog_timer.function = watch_dog_timer_callback;
-        if (request_irq(dev->irq, rtl8192_interrupt, IRQF_SHARED, dev->name, dev)) {
+        if (request_irq(dev->irq, rtl8192_interrupt, IRQF_SHARED, dev->name, priv)) {
                printk("Error allocating IRQ %d",dev->irq);
                return -1;
        }else{
@@ -2665,7 +2649,7 @@ static RT_STATUS rtl8192_adapter_start(struct r8192_priv *priv)
        write_nic_byte(priv, ACK_TIMEOUT, 0x30);
 
        if(priv->ResetProgress == RESET_TYPE_NORESET)
-       rtl8192_SetWirelessMode(dev, priv->ieee80211->mode);
+       rtl8192_SetWirelessMode(priv->ieee80211, priv->ieee80211->mode);
        //-----------------------------------------------------------------------------
        // Set up security related. 070106, by rcnjko:
        // 1. Clear all H/W keys.
@@ -2726,7 +2710,7 @@ static RT_STATUS rtl8192_adapter_start(struct r8192_priv *priv)
 
        //Firmware download
        RT_TRACE(COMP_INIT, "Load Firmware!\n");
-       bfirmwareok = init_firmware(dev);
+       bfirmwareok = init_firmware(priv);
        if(bfirmwareok != true) {
                rtStatus = RT_STATUS_FAILURE;
                return rtStatus;
@@ -2858,9 +2842,9 @@ static void rtl8192_prepare_beacon(unsigned long arg)
  * rtl8192_beacon_tx_enable(). rtl8192_beacon_tx_disable() might
  * be used to stop beacon transmission
  */
-static void rtl8192_start_beacon(struct net_device *dev)
+static void rtl8192_start_beacon(struct ieee80211_device *ieee80211)
 {
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
        struct ieee80211_network *net = &priv->ieee80211->current_network;
        u16 BcnTimeCfg = 0;
         u16 BcnCW = 6;
@@ -2976,38 +2960,31 @@ static RESET_TYPE RxCheckStuck(struct r8192_priv *priv)
        return RESET_TYPE_NORESET;
 }
 
-static RESET_TYPE
-rtl819x_ifcheck_resetornot(struct r8192_priv *priv)
+static RESET_TYPE rtl819x_check_reset(struct r8192_priv *priv)
 {
-       RESET_TYPE      TxResetType = RESET_TYPE_NORESET;
-       RESET_TYPE      RxResetType = RESET_TYPE_NORESET;
-       RT_RF_POWER_STATE       rfState;
+       RESET_TYPE RxResetType = RESET_TYPE_NORESET;
+       RT_RF_POWER_STATE rfState;
 
        rfState = priv->eRFPowerState;
 
-       if( rfState != eRfOff &&
-               /*ADAPTER_TEST_STATUS_FLAG(Adapter, ADAPTER_STATUS_FW_DOWNLOAD_FAILURE)) &&*/
-               (priv->ieee80211->iw_mode != IW_MODE_ADHOC))
-       {
-               // If driver is in the status of firmware download failure , driver skips RF initialization and RF is
-               // in turned off state. Driver should check whether Rx stuck and do silent reset. And
-               // if driver is in firmware download failure status, driver should initialize RF in the following
-               // silent reset procedure Emily, 2008.01.21
-
-               // Driver should not check RX stuck in IBSS mode because it is required to
-               // set Check BSSID in order to send beacon, however, if check BSSID is
-               // set, STA cannot hear any packet a all. Emily, 2008.04.12
+       if (rfState != eRfOff && (priv->ieee80211->iw_mode != IW_MODE_ADHOC)) {
+               /*
+                * If driver is in the status of firmware download failure,
+                * driver skips RF initialization and RF is in turned off state.
+                * Driver should check whether Rx stuck and do silent reset. And
+                * if driver is in firmware download failure status, driver
+                * should initialize RF in the following silent reset procedure
+                *
+                * Driver should not check RX stuck in IBSS mode because it is
+                * required to set Check BSSID in order to send beacon, however,
+                * if check BSSID is set, STA cannot hear any packet a all.
+                */
                RxResetType = RxCheckStuck(priv);
        }
 
-       RT_TRACE(COMP_RESET,"%s(): TxResetType is %d, RxResetType is %d\n",__FUNCTION__,TxResetType,RxResetType);
-       if(TxResetType==RESET_TYPE_NORMAL || RxResetType==RESET_TYPE_NORMAL)
-               return RESET_TYPE_NORMAL;
-       else if(TxResetType==RESET_TYPE_SILENT || RxResetType==RESET_TYPE_SILENT)
-               return RESET_TYPE_SILENT;
-       else
-               return RESET_TYPE_NORESET;
+       RT_TRACE(COMP_RESET, "%s():  RxResetType is %d\n", __FUNCTION__, RxResetType);
 
+       return RxResetType;
 }
 
 #ifdef ENABLE_IPS
@@ -3069,7 +3046,7 @@ bool MgntActSet_802_11_PowerSaveMode(struct r8192_priv *priv, u8 rtPsMode)
        if(priv->ieee80211->sta_sleep != 0 && rtPsMode == IEEE80211_PS_DISABLED)
        {
                // Notify the AP we awke.
-               rtl8192_hw_wakeup(priv->ieee80211->dev);
+               rtl8192_hw_wakeup(priv->ieee80211);
                priv->ieee80211->sta_sleep = 0;
 
                 spin_lock(&priv->ieee80211->mgmt_tx_lock);
@@ -3082,9 +3059,9 @@ bool MgntActSet_802_11_PowerSaveMode(struct r8192_priv *priv, u8 rtPsMode)
 }
 
 /* Enter the leisure power save mode. */
-void LeisurePSEnter(struct net_device *dev)
+void LeisurePSEnter(struct ieee80211_device *ieee80211)
 {
-       struct r8192_priv *priv = ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
        PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl;
 
        if(!((priv->ieee80211->iw_mode == IW_MODE_INFRA) &&
@@ -3112,9 +3089,9 @@ void LeisurePSEnter(struct net_device *dev)
 
 
 /* Leave leisure power save mode. */
-void LeisurePSLeave(struct net_device *dev)
+void LeisurePSLeave(struct ieee80211_device *ieee80211)
 {
-       struct r8192_priv *priv = ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
        PRT_POWER_SAVE_CONTROL pPSC = &priv->PowerSaveControl;
 
        if (pPSC->bLeisurePs)
@@ -3192,9 +3169,9 @@ void IPSLeave_wq(struct work_struct *work)
        up(&priv->ieee80211->ips_sem);
 }
 
-void ieee80211_ips_leave_wq(struct net_device *dev)
+void ieee80211_ips_leave_wq(struct ieee80211_device *ieee80211)
 {
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
        RT_RF_POWER_STATE       rtState;
        rtState = priv->eRFPowerState;
 
@@ -3213,12 +3190,12 @@ void ieee80211_ips_leave_wq(struct net_device *dev)
        }
 }
 //added by amy 090331 end
-void ieee80211_ips_leave(struct net_device *dev)
+void ieee80211_ips_leave(struct ieee80211_device *ieee80211)
 {
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-       down(&priv->ieee80211->ips_sem);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
+       down(&ieee80211->ips_sem);
        IPSLeave(priv);
-       up(&priv->ieee80211->ips_sem);
+       up(&ieee80211->ips_sem);
 }
 #endif
 
@@ -3248,7 +3225,6 @@ static 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;
        struct ieee80211_device* ieee = priv->ieee80211;
        RESET_TYPE      ResetType = RESET_TYPE_NORESET;
        bool bBusyTraffic = false;
@@ -3259,7 +3235,7 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
 
        if(!priv->up)
                return;
-       hal_dm_watchdog(dev);
+       hal_dm_watchdog(priv);
 #ifdef ENABLE_IPS
        if(ieee->actscanning == false){
                if((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == IEEE80211_NOLINK) &&
@@ -3294,11 +3270,11 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
                        // LeisurePS only work in infra mode.
                        if(bEnterPS)
                        {
-                               LeisurePSEnter(dev);
+                               LeisurePSEnter(priv->ieee80211);
                        }
                        else
                        {
-                               LeisurePSLeave(dev);
+                               LeisurePSLeave(priv->ieee80211);
                        }
 #endif
 
@@ -3306,7 +3282,7 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
                else
                {
 #ifdef ENABLE_LPS
-                       LeisurePSLeave(dev);
+                       LeisurePSLeave(priv->ieee80211);
 #endif
                }
 
@@ -3335,7 +3311,7 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
                                RemovePeerTS(priv->ieee80211,priv->ieee80211->current_network.bssid);
                                ieee->is_roaming = true;
                                ieee->is_set_key = false;
-                               ieee->link_change(dev);
+                               ieee->link_change(ieee);
                                queue_work(ieee->wq, &ieee->associate_procedure_wq);
                        }
                }
@@ -3346,7 +3322,7 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
        if (priv->watchdog_check_reset_cnt++ >= 3 && !ieee->is_roaming && 
            priv->watchdog_last_time != 1)
        {
-               ResetType = rtl819x_ifcheck_resetornot(priv);
+               ResetType = rtl819x_check_reset(priv);
                priv->watchdog_check_reset_cnt = 3;
        }
        if(!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL)
@@ -3460,7 +3436,7 @@ int rtl8192_down(struct net_device *dev)
 #ifdef ENABLE_LPS
        //LZM for PS-Poll AID issue. 090429
        if(priv->ieee80211->state == IEEE80211_LINKED)
-               LeisurePSLeave(dev);
+               LeisurePSLeave(priv->ieee80211);
 #endif
 
        priv->up=0;
@@ -3472,7 +3448,7 @@ int rtl8192_down(struct net_device *dev)
 
        rtl8192_irq_disable(priv);
        rtl8192_cancel_deferred_work(priv);
-       deinit_hal_dm(dev);
+       deinit_hal_dm(priv);
        del_timer_sync(&priv->watch_dog_timer);
 
        ieee80211_softmac_stop_protocol(priv->ieee80211,true);
@@ -4308,17 +4284,16 @@ static void TranslateRxSignalStuff819xpci(struct r8192_priv *priv,
 static void rtl8192_tx_resume(struct r8192_priv *priv)
 {
        struct ieee80211_device *ieee = priv->ieee80211;
-       struct net_device *dev = priv->ieee80211->dev;
        struct sk_buff *skb;
-       int queue_index;
+       int i;
 
-       for(queue_index = BK_QUEUE; queue_index < TXCMD_QUEUE;queue_index++) {
-               while((!skb_queue_empty(&ieee->skb_waitQ[queue_index]))&&
-                               (priv->ieee80211->check_nic_enough_desc(dev,queue_index) > 0)) {
+       for (i = BK_QUEUE; i < TXCMD_QUEUE; i++) {
+               while ((!skb_queue_empty(&ieee->skb_waitQ[i])) &&
+                      (priv->ieee80211->check_nic_enough_desc(ieee, i) > 0)) {
                        /* 1. dequeue the packet from the wait queue */
-                       skb = skb_dequeue(&ieee->skb_waitQ[queue_index]);
+                       skb = skb_dequeue(&ieee->skb_waitQ[i]);
                        /* 2. tx the packet directly */
-                       ieee->softmac_data_hard_start_xmit(skb,dev,0/* rate useless now*/);
+                       ieee->softmac_data_hard_start_xmit(skb, ieee, 0);
                }
        }
 }
@@ -4327,7 +4302,6 @@ static void rtl8192_irq_tx_tasklet(unsigned long arg)
 {
        struct r8192_priv *priv = (struct r8192_priv*) arg;
        struct rtl8192_tx_ring *mgnt_ring = &priv->tx_ring[MGNT_QUEUE];
-       struct net_device *dev = priv->ieee80211->dev;
        unsigned long flags;
 
        /* check if we need to report that the management queue is drained */
@@ -4335,7 +4309,7 @@ static void rtl8192_irq_tx_tasklet(unsigned long arg)
 
        if (!skb_queue_len(&mgnt_ring->queue) &&
            priv->ieee80211->ack_tx_to_ieee &&
-           rtl8192_is_tx_queue_empty(dev)) {
+           rtl8192_is_tx_queue_empty(priv->ieee80211)) {
                priv->ieee80211->ack_tx_to_ieee = 0;
                ieee80211_ps_tx_ack(priv->ieee80211, 1);
        }
@@ -4663,8 +4637,8 @@ fail:
        if(dev){
 
                if (priv->irq) {
-                       free_irq(dev->irq, dev);
-                       dev->irq=0;
+                       free_irq(priv->irq, priv);
+                       priv->irq = 0;
                }
                free_ieee80211(dev);
        }
@@ -4725,9 +4699,9 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev)
                        rtl8192_free_tx_ring(priv, i);
 
                if (priv->irq) {
-                       printk("Freeing irq %d\n",dev->irq);
-                       free_irq(dev->irq, dev);
-                       priv->irq=0;
+                       printk("Freeing irq %d\n", priv->irq);
+                       free_irq(priv->irq, priv);
+                       priv->irq = 0;
                }
 
                if (priv->mem_start) {
@@ -4777,10 +4751,10 @@ static void __exit rtl8192_pci_module_exit(void)
        ieee80211_rtl_exit();
 }
 
-static irqreturn_t rtl8192_interrupt(int irq, void *netdev)
+static irqreturn_t rtl8192_interrupt(int irq, void *param)
 {
-       struct net_device *dev = (struct net_device *) netdev;
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+       struct r8192_priv *priv = param;
+       struct net_device *dev = priv->ieee80211->dev;
        unsigned long flags;
        u32 inta;
        irqreturn_t ret = IRQ_HANDLED;