These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / rtl8192e / rtl8192e / rtl_wx.c
index 8d6a109..70df6a1 100644 (file)
@@ -6,10 +6,6 @@
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  * more details.
  *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
  * The full GNU General Public License is included in this distribution in the
  * file called LICENSE.
  *
@@ -31,9 +27,9 @@ static u32 rtl8192_rates[] = {
 #define ENETDOWN 1
 #endif
 
-static int r8192_wx_get_freq(struct net_device *dev,
-                            struct iw_request_info *a,
-                            union iwreq_data *wrqu, char *b)
+static int _rtl92e_wx_get_freq(struct net_device *dev,
+                              struct iw_request_info *a,
+                              union iwreq_data *wrqu, char *b)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
@@ -41,28 +37,27 @@ static int r8192_wx_get_freq(struct net_device *dev,
 }
 
 
-static int r8192_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
-                            union iwreq_data *wrqu, char *b)
+static int _rtl92e_wx_get_mode(struct net_device *dev,
+                              struct iw_request_info *a,
+                              union iwreq_data *wrqu, char *b)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
        return rtllib_wx_get_mode(priv->rtllib, a, wrqu, b);
 }
 
-static int r8192_wx_get_rate(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_get_rate(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
        return rtllib_wx_get_rate(priv->rtllib, info, wrqu, extra);
 }
 
-
-
-static int r8192_wx_set_rate(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_rate(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
 {
        int ret;
        struct r8192_priv *priv = rtllib_priv(dev);
@@ -79,10 +74,9 @@ static int r8192_wx_set_rate(struct net_device *dev,
        return ret;
 }
 
-
-static int r8192_wx_set_rts(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_rts(struct net_device *dev,
+                             struct iw_request_info *info,
+                             union iwreq_data *wrqu, char *extra)
 {
        int ret;
        struct r8192_priv *priv = rtllib_priv(dev);
@@ -99,26 +93,25 @@ static int r8192_wx_set_rts(struct net_device *dev,
        return ret;
 }
 
-static int r8192_wx_get_rts(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_get_rts(struct net_device *dev,
+                             struct iw_request_info *info,
+                             union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
        return rtllib_wx_get_rts(priv->rtllib, info, wrqu, extra);
 }
 
-static int r8192_wx_set_power(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_power(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
 {
        int ret;
        struct r8192_priv *priv = rtllib_priv(dev);
 
        if (priv->bHwRadioOff) {
-               RT_TRACE(COMP_ERR,
-                        "%s():Hw is Radio Off, we can't set Power,return\n",
-                        __func__);
+               netdev_warn(dev, "%s(): Can't set Power: Radio is Off.\n",
+                           __func__);
                return 0;
        }
        down(&priv->wx_sem);
@@ -130,18 +123,18 @@ static int r8192_wx_set_power(struct net_device *dev,
        return ret;
 }
 
-static int r8192_wx_get_power(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_get_power(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
        return rtllib_wx_get_power(priv->rtllib, info, wrqu, extra);
 }
 
-static int r8192_wx_set_rawtx(struct net_device *dev,
-                             struct iw_request_info *info,
-                             union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_rawtx(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        int ret;
@@ -159,9 +152,9 @@ static int r8192_wx_set_rawtx(struct net_device *dev,
 
 }
 
-static int r8192_wx_force_reset(struct net_device *dev,
-               struct iw_request_info *info,
-               union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_force_reset(struct net_device *dev,
+                                 struct iw_request_info *info,
+                                 union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
@@ -175,51 +168,9 @@ static int r8192_wx_force_reset(struct net_device *dev,
 
 }
 
-static int r8192_wx_force_mic_error(struct net_device *dev,
-               struct iw_request_info *info,
-               union iwreq_data *wrqu, char *extra)
-{
-       struct r8192_priv *priv = rtllib_priv(dev);
-       struct rtllib_device *ieee = priv->rtllib;
-
-       down(&priv->wx_sem);
-
-       RT_TRACE(COMP_DBG, "%s(): force mic error !\n", __func__);
-       ieee->force_mic_error = true;
-       up(&priv->wx_sem);
-       return 0;
-
-}
-
-#define MAX_ADHOC_PEER_NUM 64
-struct adhoc_peer_entry {
-       unsigned char MacAddr[ETH_ALEN];
-       unsigned char WirelessMode;
-       unsigned char bCurTxBW40MHz;
-};
-struct adhoc_peers_info {
-       struct adhoc_peer_entry Entry[MAX_ADHOC_PEER_NUM];
-       unsigned char num;
-};
-
-static int r8192_wx_get_adhoc_peers(struct net_device *dev,
-                                   struct iw_request_info *info,
-                                   union iwreq_data *wrqu, char *extra)
-{
-       return 0;
-}
-
-
-static int r8191se_wx_get_firm_version(struct net_device *dev,
-               struct iw_request_info *info,
-               struct iw_param *wrqu, char *extra)
-{
-       return 0;
-}
-
-static int r8192_wx_adapter_power_status(struct net_device *dev,
-               struct iw_request_info *info,
-               union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_adapter_power_status(struct net_device *dev,
+                                          struct iw_request_info *info,
+                                          union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
@@ -235,7 +186,7 @@ static int r8192_wx_adapter_power_status(struct net_device *dev,
                pPSC->bLeisurePs = true;
        } else {
                if (priv->rtllib->state == RTLLIB_LINKED)
-                       LeisurePSLeave(dev);
+                       rtl92e_leisure_ps_leave(dev);
 
                priv->ps_force = true;
                pPSC->bLeisurePs = false;
@@ -247,31 +198,10 @@ static int r8192_wx_adapter_power_status(struct net_device *dev,
        return 0;
 }
 
-static int r8192se_wx_set_radio(struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu, char *extra)
-{
-       struct r8192_priv *priv = rtllib_priv(dev);
-
-       down(&priv->wx_sem);
-
-       netdev_info(dev, "%s(): set radio ! extra is %d\n", __func__, *extra);
-       if ((*extra != 0) && (*extra != 1)) {
-               RT_TRACE(COMP_ERR,
-                        "%s(): set radio an err value,must 0(radio off) or 1(radio on)\n",
-                        __func__);
-               up(&priv->wx_sem);
-               return -1;
-       }
-       priv->sw_radio_on = *extra;
-       up(&priv->wx_sem);
-       return 0;
-
-}
-
-static int r8192se_wx_set_lps_awake_interval(struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_lps_awake_interval(struct net_device *dev,
+                                            struct iw_request_info *info,
+                                            union iwreq_data *wrqu,
+                                            char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
@@ -287,9 +217,9 @@ static int r8192se_wx_set_lps_awake_interval(struct net_device *dev,
        return 0;
 }
 
-static int r8192se_wx_set_force_lps(struct net_device *dev,
-               struct iw_request_info *info,
-               union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_force_lps(struct net_device *dev,
+                                   struct iw_request_info *info,
+                                   union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
@@ -304,9 +234,9 @@ static int r8192se_wx_set_force_lps(struct net_device *dev,
 
 }
 
-static int r8192_wx_set_debugflag(struct net_device *dev,
-                                 struct iw_request_info *info,
-                                 union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_debug(struct net_device *dev,
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        u8 c = *extra;
@@ -323,8 +253,9 @@ static int r8192_wx_set_debugflag(struct net_device *dev,
        return 0;
 }
 
-static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
-                            union iwreq_data *wrqu, char *b)
+static int _rtl92e_wx_set_mode(struct net_device *dev,
+                              struct iw_request_info *a,
+                              union iwreq_data *wrqu, char *b)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtllib_device *ieee = netdev_priv_rsl(dev);
@@ -342,15 +273,16 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
                        if (rtState == eRfOff) {
                                if (priv->rtllib->RfOffReason >
                                    RF_CHANGE_BY_IPS) {
-                                       RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",
-                                                __func__);
+                                       netdev_warn(dev, "%s(): RF is OFF.\n",
+                                                   __func__);
                                        up(&priv->wx_sem);
                                        return -1;
                                }
-                               netdev_info(dev,  "=========>%s(): IPSLeave\n",
+                               netdev_info(dev,
+                                           "=========>%s(): rtl92e_ips_leave\n",
                                            __func__);
                                down(&priv->rtllib->ips_sem);
-                               IPSLeave(dev);
+                               rtl92e_ips_leave(dev);
                                up(&priv->rtllib->ips_sem);
                        }
                }
@@ -383,7 +315,7 @@ struct  iw_range_with_scan_capa {
        __u8        scan_capa;
 };
 
-static int rtl8192_wx_get_range(struct net_device *dev,
+static int _rtl92e_wx_get_range(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *extra)
 {
@@ -398,10 +330,9 @@ static int rtl8192_wx_get_range(struct net_device *dev,
        /* ~130 Mb/s real (802.11n) */
        range->throughput = 130 * 1000 * 1000;
 
-       if (priv->rf_set_sens != NULL) {
+       if (priv->rf_set_sens != NULL)
                /* signal level threshold range */
                range->sensitivity = priv->max_sens;
-       }
 
        range->max_qual.qual = 100;
        range->max_qual.level = 0;
@@ -455,8 +386,9 @@ static int rtl8192_wx_get_range(struct net_device *dev,
        return 0;
 }
 
-static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
-                            union iwreq_data *wrqu, char *b)
+static int _rtl92e_wx_set_scan(struct net_device *dev,
+                              struct iw_request_info *a,
+                              union iwreq_data *wrqu, char *b)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtllib_device *ieee = priv->rtllib;
@@ -502,16 +434,16 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
                        if (rtState == eRfOff) {
                                if (priv->rtllib->RfOffReason >
                                    RF_CHANGE_BY_IPS) {
-                                       RT_TRACE(COMP_ERR,
-                                                "%s(): RF is OFF.\n",
-                                                __func__);
+                                       netdev_warn(dev, "%s(): RF is OFF.\n",
+                                                   __func__);
                                        up(&priv->wx_sem);
                                        return -1;
                                }
-                               RT_TRACE(COMP_PS, "=========>%s(): IPSLeave\n",
+                               RT_TRACE(COMP_PS,
+                                        "=========>%s(): rtl92e_ips_leave\n",
                                         __func__);
                                down(&priv->rtllib->ips_sem);
-                               IPSLeave(dev);
+                               rtl92e_ips_leave(dev);
                                up(&priv->rtllib->ips_sem);
                        }
                }
@@ -544,8 +476,9 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
 }
 
 
-static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
-                            union iwreq_data *wrqu, char *b)
+static int _rtl92e_wx_get_scan(struct net_device *dev,
+                              struct iw_request_info *a,
+                              union iwreq_data *wrqu, char *b)
 {
 
        int ret;
@@ -567,9 +500,9 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
        return ret;
 }
 
-static int r8192_wx_set_essid(struct net_device *dev,
-                             struct iw_request_info *a,
-                             union iwreq_data *wrqu, char *b)
+static int _rtl92e_wx_set_essid(struct net_device *dev,
+                               struct iw_request_info *a,
+                               union iwreq_data *wrqu, char *b)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        int ret;
@@ -588,9 +521,9 @@ static int r8192_wx_set_essid(struct net_device *dev,
        return ret;
 }
 
-static int r8192_wx_get_essid(struct net_device *dev,
-                             struct iw_request_info *a,
-                             union iwreq_data *wrqu, char *b)
+static int _rtl92e_wx_get_essid(struct net_device *dev,
+                               struct iw_request_info *a,
+                               union iwreq_data *wrqu, char *b)
 {
        int ret;
        struct r8192_priv *priv = rtllib_priv(dev);
@@ -604,16 +537,17 @@ static int r8192_wx_get_essid(struct net_device *dev,
        return ret;
 }
 
-static int r8192_wx_set_nick(struct net_device *dev,
-                          struct iw_request_info *info,
-                          union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_nick(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
        if (wrqu->data.length > IW_ESSID_MAX_SIZE)
                return -E2BIG;
        down(&priv->wx_sem);
-       wrqu->data.length = min_t(size_t, wrqu->data.length, sizeof(priv->nick));
+       wrqu->data.length = min_t(size_t, wrqu->data.length,
+                                 sizeof(priv->nick));
        memset(priv->nick, 0, sizeof(priv->nick));
        memcpy(priv->nick, extra, wrqu->data.length);
        up(&priv->wx_sem);
@@ -621,9 +555,9 @@ static int r8192_wx_set_nick(struct net_device *dev,
 
 }
 
-static int r8192_wx_get_nick(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_get_nick(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
@@ -635,8 +569,9 @@ static int r8192_wx_get_nick(struct net_device *dev,
        return 0;
 }
 
-static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a,
-                            union iwreq_data *wrqu, char *b)
+static int _rtl92e_wx_set_freq(struct net_device *dev,
+                              struct iw_request_info *a,
+                              union iwreq_data *wrqu, char *b)
 {
        int ret;
        struct r8192_priv *priv = rtllib_priv(dev);
@@ -652,9 +587,9 @@ static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a,
        return ret;
 }
 
-static int r8192_wx_get_name(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_get_name(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
@@ -662,9 +597,9 @@ static int r8192_wx_get_name(struct net_device *dev,
 }
 
 
-static int r8192_wx_set_frag(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_frag(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
@@ -685,9 +620,9 @@ static int r8192_wx_set_frag(struct net_device *dev,
 }
 
 
-static int r8192_wx_get_frag(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_get_frag(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
@@ -699,10 +634,9 @@ static int r8192_wx_get_frag(struct net_device *dev,
 }
 
 
-static int r8192_wx_set_wap(struct net_device *dev,
-                        struct iw_request_info *info,
-                        union iwreq_data *awrq,
-                        char *extra)
+static int _rtl92e_wx_set_wap(struct net_device *dev,
+                             struct iw_request_info *info,
+                             union iwreq_data *awrq, char *extra)
 {
        int ret;
        struct r8192_priv *priv = rtllib_priv(dev);
@@ -721,9 +655,9 @@ static int r8192_wx_set_wap(struct net_device *dev,
 }
 
 
-static int r8192_wx_get_wap(struct net_device *dev,
-                           struct iw_request_info *info,
-                           union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_get_wap(struct net_device *dev,
+                             struct iw_request_info *info,
+                             union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
@@ -731,18 +665,18 @@ static int r8192_wx_get_wap(struct net_device *dev,
 }
 
 
-static int r8192_wx_get_enc(struct net_device *dev,
-                           struct iw_request_info *info,
-                           union iwreq_data *wrqu, char *key)
+static int _rtl92e_wx_get_enc(struct net_device *dev,
+                             struct iw_request_info *info,
+                             union iwreq_data *wrqu, char *key)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
        return rtllib_wx_get_encode(priv->rtllib, info, wrqu, key);
 }
 
-static int r8192_wx_set_enc(struct net_device *dev,
-                           struct iw_request_info *info,
-                           union iwreq_data *wrqu, char *key)
+static int _rtl92e_wx_set_enc(struct net_device *dev,
+                             struct iw_request_info *info,
+                             union iwreq_data *wrqu, char *key)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        int ret;
@@ -765,7 +699,7 @@ static int r8192_wx_set_enc(struct net_device *dev,
 
        priv->rtllib->wx_set_enc = 1;
        down(&priv->rtllib->ips_sem);
-       IPSLeave(dev);
+       rtl92e_ips_leave(dev);
        up(&priv->rtllib->ips_sem);
        down(&priv->wx_sem);
 
@@ -776,7 +710,7 @@ static int r8192_wx_set_enc(struct net_device *dev,
 
        if (wrqu->encoding.flags & IW_ENCODE_DISABLED) {
                ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA;
-               CamResetAllEntry(dev);
+               rtl92e_cam_reset(dev);
                memset(priv->rtllib->swcamtable, 0,
                       sizeof(struct sw_cam_table) * 32);
                goto end_hw_sec;
@@ -794,9 +728,6 @@ static int r8192_wx_set_enc(struct net_device *dev,
                        hwkey[i] |= (key[4 * i + 3] & mask) << 24;
                }
 
-               #define CONF_WEP40  0x4
-               #define CONF_WEP104 0x14
-
                switch (wrqu->encoding.flags & IW_ENCODE_INDEX) {
                case 0:
                        key_idx = ieee->crypt_info.tx_keyidx;
@@ -818,16 +749,16 @@ static int r8192_wx_set_enc(struct net_device *dev,
                }
                if (wrqu->encoding.length == 0x5) {
                        ieee->pairwise_key_type = KEY_TYPE_WEP40;
-                       EnableHWSecurityConfig8192(dev);
+                       rtl92e_enable_hw_security_config(dev);
                }
 
                else if (wrqu->encoding.length == 0xd) {
                        ieee->pairwise_key_type = KEY_TYPE_WEP104;
-                               EnableHWSecurityConfig8192(dev);
-                       setKey(dev, key_idx, key_idx, KEY_TYPE_WEP104,
-                              zero_addr[key_idx], 0, hwkey);
-                       set_swcam(dev, key_idx, key_idx, KEY_TYPE_WEP104,
-                                 zero_addr[key_idx], 0, hwkey, 0);
+                               rtl92e_enable_hw_security_config(dev);
+                       rtl92e_set_key(dev, key_idx, key_idx, KEY_TYPE_WEP104,
+                                      zero_addr[key_idx], 0, hwkey);
+                       rtl92e_set_swcam(dev, key_idx, key_idx, KEY_TYPE_WEP104,
+                                        zero_addr[key_idx], 0, hwkey, 0);
                } else {
                        netdev_info(dev,
                                    "wrong type in WEP, not WEP40 and WEP104\n");
@@ -839,9 +770,9 @@ end_hw_sec:
        return ret;
 }
 
-static int r8192_wx_set_scan_type(struct net_device *dev,
-                                 struct iw_request_info *aa,
-                                 union iwreq_data *wrqu, char *p)
+static int _rtl92e_wx_set_scan_type(struct net_device *dev,
+                                   struct iw_request_info *aa,
+                                   union iwreq_data *wrqu, char *p)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        int *parms = (int *)p;
@@ -858,7 +789,7 @@ static int r8192_wx_set_scan_type(struct net_device *dev,
 
 
 #define R8192_MAX_RETRY 255
-static int r8192_wx_set_retry(struct net_device *dev,
+static int _rtl92e_wx_set_retry(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *extra)
 {
@@ -884,26 +815,19 @@ static int r8192_wx_set_retry(struct net_device *dev,
                err = -EINVAL;
                goto exit;
        }
-       if (wrqu->retry.flags & IW_RETRY_MAX) {
+       if (wrqu->retry.flags & IW_RETRY_MAX)
                priv->retry_rts = wrqu->retry.value;
-               DMESG("Setting retry for RTS/CTS data to %d",
-                     wrqu->retry.value);
-
-       } else {
+       else
                priv->retry_data = wrqu->retry.value;
-               DMESG("Setting retry for non RTS/CTS data to %d",
-                     wrqu->retry.value);
-       }
 
-
-       rtl8192_commit(dev);
+       rtl92e_commit(dev);
 exit:
        up(&priv->wx_sem);
 
        return err;
 }
 
-static int r8192_wx_get_retry(struct net_device *dev,
+static int _rtl92e_wx_get_retry(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *extra)
 {
@@ -926,9 +850,9 @@ static int r8192_wx_get_retry(struct net_device *dev,
        return 0;
 }
 
-static int r8192_wx_get_sens(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_get_sens(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
@@ -939,9 +863,9 @@ static int r8192_wx_get_sens(struct net_device *dev,
 }
 
 
-static int r8192_wx_set_sens(struct net_device *dev,
-                               struct iw_request_info *info,
-                               union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_sens(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
 {
 
        struct r8192_priv *priv = rtllib_priv(dev);
@@ -967,9 +891,9 @@ exit:
        return err;
 }
 
-static int r8192_wx_set_enc_ext(struct net_device *dev,
-                               struct iw_request_info *info,
-                               union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_encode_ext(struct net_device *dev,
+                                    struct iw_request_info *info,
+                                    union iwreq_data *wrqu, char *extra)
 {
        int ret = 0;
        struct r8192_priv *priv = rtllib_priv(dev);
@@ -982,13 +906,13 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
 
        priv->rtllib->wx_set_enc = 1;
        down(&priv->rtllib->ips_sem);
-       IPSLeave(dev);
+       rtl92e_ips_leave(dev);
        up(&priv->rtllib->ips_sem);
 
        ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra);
        {
-               u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-               u8 zero[6] = {0};
+               const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+               const u8 zero[ETH_ALEN] = {0};
                u32 key[4] = {0};
                struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
                struct iw_point *encoding = &wrqu->encoding;
@@ -998,7 +922,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
                     ext->alg == IW_ENCODE_ALG_NONE) {
                        ieee->pairwise_key_type = ieee->group_key_type
                                                = KEY_TYPE_NA;
-                       CamResetAllEntry(dev);
+                       rtl92e_cam_reset(dev);
                        memset(priv->rtllib->swcamtable, 0,
                               sizeof(struct sw_cam_table) * 32);
                        goto end_hw_sec;
@@ -1010,33 +934,34 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
                        idx--;
                group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY;
 
-               if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) ||
+               if ((!group) || (ieee->iw_mode == IW_MODE_ADHOC) ||
                    (alg ==  KEY_TYPE_WEP40)) {
                        if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40))
                                alg = KEY_TYPE_WEP104;
                        ieee->pairwise_key_type = alg;
-                       EnableHWSecurityConfig8192(dev);
+                       rtl92e_enable_hw_security_config(dev);
                }
                memcpy((u8 *)key, ext->key, 16);
 
                if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode != 2)) {
                        if (ext->key_len == 13)
                                ieee->pairwise_key_type = alg = KEY_TYPE_WEP104;
-                       setKey(dev, idx, idx, alg, zero, 0, key);
-                       set_swcam(dev, idx, idx, alg, zero, 0, key, 0);
+                       rtl92e_set_key(dev, idx, idx, alg, zero, 0, key);
+                       rtl92e_set_swcam(dev, idx, idx, alg, zero, 0, key, 0);
                } else if (group) {
                        ieee->group_key_type = alg;
-                       setKey(dev, idx, idx, alg, broadcast_addr, 0, key);
-                       set_swcam(dev, idx, idx, alg, broadcast_addr, 0,
-                                 key, 0);
+                       rtl92e_set_key(dev, idx, idx, alg, broadcast_addr, 0,
+                                      key);
+                       rtl92e_set_swcam(dev, idx, idx, alg, broadcast_addr, 0,
+                                        key, 0);
                } else {
                        if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) &&
                             ieee->pHTInfo->bCurrentHTSupport)
-                               write_nic_byte(dev, 0x173, 1);
-                       setKey(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr,
-                              0, key);
-                       set_swcam(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr,
-                                 0, key, 0);
+                               rtl92e_writeb(dev, 0x173, 1);
+                       rtl92e_set_key(dev, 4, idx, alg,
+                                      (u8 *)ieee->ap_mac_addr, 0, key);
+                       rtl92e_set_swcam(dev, 4, idx, alg,
+                                        (u8 *)ieee->ap_mac_addr, 0, key, 0);
                }
 
 
@@ -1048,9 +973,10 @@ end_hw_sec:
        return ret;
 
 }
-static int r8192_wx_set_auth(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *data, char *extra)
+
+static int _rtl92e_wx_set_auth(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *data, char *extra)
 {
        int ret = 0;
 
@@ -1065,9 +991,9 @@ static int r8192_wx_set_auth(struct net_device *dev,
        return ret;
 }
 
-static int r8192_wx_set_mlme(struct net_device *dev,
-                            struct iw_request_info *info,
-                            union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_mlme(struct net_device *dev,
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
 {
 
        int ret = 0;
@@ -1083,9 +1009,9 @@ static int r8192_wx_set_mlme(struct net_device *dev,
        return ret;
 }
 
-static int r8192_wx_set_gen_ie(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *data, char *extra)
+static int _rtl92e_wx_set_gen_ie(struct net_device *dev,
+                                struct iw_request_info *info,
+                                union iwreq_data *data, char *extra)
 {
        int ret = 0;
 
@@ -1100,9 +1026,9 @@ static int r8192_wx_set_gen_ie(struct net_device *dev,
        return ret;
 }
 
-static int r8192_wx_get_gen_ie(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *data, char *extra)
+static int _rtl92e_wx_get_gen_ie(struct net_device *dev,
+                                struct iw_request_info *info,
+                                union iwreq_data *data, char *extra)
 {
        int ret = 0;
        struct r8192_priv *priv = rtllib_priv(dev);
@@ -1123,9 +1049,9 @@ static int r8192_wx_get_gen_ie(struct net_device *dev,
 
 #define OID_RT_INTEL_PROMISCUOUS_MODE  0xFF0101F6
 
-static int r8192_wx_set_PromiscuousMode(struct net_device *dev,
-               struct iw_request_info *info,
-               union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_set_promisc_mode(struct net_device *dev,
+                                      struct iw_request_info *info,
+                                      union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtllib_device *ieee = priv->rtllib;
@@ -1143,7 +1069,7 @@ static int r8192_wx_set_PromiscuousMode(struct net_device *dev,
        bPromiscuousOn = info_buf[1];
        bFilterSourceStationFrame = info_buf[2];
 
-       if (OID_RT_INTEL_PROMISCUOUS_MODE == oid) {
+       if (oid == OID_RT_INTEL_PROMISCUOUS_MODE) {
                ieee->IntelPromiscuousModeInfo.bPromiscuousOn =
                                        (bPromiscuousOn) ? (true) : (false);
                ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame =
@@ -1164,9 +1090,9 @@ static int r8192_wx_set_PromiscuousMode(struct net_device *dev,
 }
 
 
-static int r8192_wx_get_PromiscuousMode(struct net_device *dev,
-                              struct iw_request_info *info,
-                              union iwreq_data *wrqu, char *extra)
+static int _rtl92e_wx_get_promisc_mode(struct net_device *dev,
+                                      struct iw_request_info *info,
+                                      union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtllib_device *ieee = priv->rtllib;
@@ -1184,41 +1110,41 @@ static int r8192_wx_get_PromiscuousMode(struct net_device *dev,
 }
 
 
-#define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT]
+#define IW_IOCTL(x) ((x) - SIOCSIWCOMMIT)
 static iw_handler r8192_wx_handlers[] = {
-       IW_IOCTL(SIOCGIWNAME) = r8192_wx_get_name,
-       IW_IOCTL(SIOCSIWFREQ) = r8192_wx_set_freq,
-       IW_IOCTL(SIOCGIWFREQ) = r8192_wx_get_freq,
-       IW_IOCTL(SIOCSIWMODE) = r8192_wx_set_mode,
-       IW_IOCTL(SIOCGIWMODE) = r8192_wx_get_mode,
-       IW_IOCTL(SIOCSIWSENS) = r8192_wx_set_sens,
-       IW_IOCTL(SIOCGIWSENS) = r8192_wx_get_sens,
-       IW_IOCTL(SIOCGIWRANGE) = rtl8192_wx_get_range,
-       IW_IOCTL(SIOCSIWAP) = r8192_wx_set_wap,
-       IW_IOCTL(SIOCGIWAP) = r8192_wx_get_wap,
-       IW_IOCTL(SIOCSIWSCAN) = r8192_wx_set_scan,
-       IW_IOCTL(SIOCGIWSCAN) = r8192_wx_get_scan,
-       IW_IOCTL(SIOCSIWESSID) = r8192_wx_set_essid,
-       IW_IOCTL(SIOCGIWESSID) = r8192_wx_get_essid,
-       IW_IOCTL(SIOCSIWNICKN) = r8192_wx_set_nick,
-               IW_IOCTL(SIOCGIWNICKN) = r8192_wx_get_nick,
-       IW_IOCTL(SIOCSIWRATE) = r8192_wx_set_rate,
-       IW_IOCTL(SIOCGIWRATE) = r8192_wx_get_rate,
-       IW_IOCTL(SIOCSIWRTS) = r8192_wx_set_rts,
-       IW_IOCTL(SIOCGIWRTS) = r8192_wx_get_rts,
-       IW_IOCTL(SIOCSIWFRAG) = r8192_wx_set_frag,
-       IW_IOCTL(SIOCGIWFRAG) = r8192_wx_get_frag,
-       IW_IOCTL(SIOCSIWRETRY) = r8192_wx_set_retry,
-       IW_IOCTL(SIOCGIWRETRY) = r8192_wx_get_retry,
-       IW_IOCTL(SIOCSIWENCODE) = r8192_wx_set_enc,
-       IW_IOCTL(SIOCGIWENCODE) = r8192_wx_get_enc,
-       IW_IOCTL(SIOCSIWPOWER) = r8192_wx_set_power,
-       IW_IOCTL(SIOCGIWPOWER) = r8192_wx_get_power,
-       IW_IOCTL(SIOCSIWGENIE) = r8192_wx_set_gen_ie,
-       IW_IOCTL(SIOCGIWGENIE) = r8192_wx_get_gen_ie,
-       IW_IOCTL(SIOCSIWMLME) = r8192_wx_set_mlme,
-       IW_IOCTL(SIOCSIWAUTH) = r8192_wx_set_auth,
-       IW_IOCTL(SIOCSIWENCODEEXT) = r8192_wx_set_enc_ext,
+       [IW_IOCTL(SIOCGIWNAME)] = _rtl92e_wx_get_name,
+       [IW_IOCTL(SIOCSIWFREQ)] = _rtl92e_wx_set_freq,
+       [IW_IOCTL(SIOCGIWFREQ)] = _rtl92e_wx_get_freq,
+       [IW_IOCTL(SIOCSIWMODE)] = _rtl92e_wx_set_mode,
+       [IW_IOCTL(SIOCGIWMODE)] = _rtl92e_wx_get_mode,
+       [IW_IOCTL(SIOCSIWSENS)] = _rtl92e_wx_set_sens,
+       [IW_IOCTL(SIOCGIWSENS)] = _rtl92e_wx_get_sens,
+       [IW_IOCTL(SIOCGIWRANGE)] = _rtl92e_wx_get_range,
+       [IW_IOCTL(SIOCSIWAP)] = _rtl92e_wx_set_wap,
+       [IW_IOCTL(SIOCGIWAP)] = _rtl92e_wx_get_wap,
+       [IW_IOCTL(SIOCSIWSCAN)] = _rtl92e_wx_set_scan,
+       [IW_IOCTL(SIOCGIWSCAN)] = _rtl92e_wx_get_scan,
+       [IW_IOCTL(SIOCSIWESSID)] = _rtl92e_wx_set_essid,
+       [IW_IOCTL(SIOCGIWESSID)] = _rtl92e_wx_get_essid,
+       [IW_IOCTL(SIOCSIWNICKN)] = _rtl92e_wx_set_nick,
+       [IW_IOCTL(SIOCGIWNICKN)] = _rtl92e_wx_get_nick,
+       [IW_IOCTL(SIOCSIWRATE)] = _rtl92e_wx_set_rate,
+       [IW_IOCTL(SIOCGIWRATE)] = _rtl92e_wx_get_rate,
+       [IW_IOCTL(SIOCSIWRTS)] = _rtl92e_wx_set_rts,
+       [IW_IOCTL(SIOCGIWRTS)] = _rtl92e_wx_get_rts,
+       [IW_IOCTL(SIOCSIWFRAG)] = _rtl92e_wx_set_frag,
+       [IW_IOCTL(SIOCGIWFRAG)] = _rtl92e_wx_get_frag,
+       [IW_IOCTL(SIOCSIWRETRY)] = _rtl92e_wx_set_retry,
+       [IW_IOCTL(SIOCGIWRETRY)] = _rtl92e_wx_get_retry,
+       [IW_IOCTL(SIOCSIWENCODE)] = _rtl92e_wx_set_enc,
+       [IW_IOCTL(SIOCGIWENCODE)] = _rtl92e_wx_get_enc,
+       [IW_IOCTL(SIOCSIWPOWER)] = _rtl92e_wx_set_power,
+       [IW_IOCTL(SIOCGIWPOWER)] = _rtl92e_wx_get_power,
+       [IW_IOCTL(SIOCSIWGENIE)] = _rtl92e_wx_set_gen_ie,
+       [IW_IOCTL(SIOCGIWGENIE)] = _rtl92e_wx_get_gen_ie,
+       [IW_IOCTL(SIOCSIWMLME)] = _rtl92e_wx_set_mlme,
+       [IW_IOCTL(SIOCSIWAUTH)] = _rtl92e_wx_set_auth,
+       [IW_IOCTL(SIOCSIWENCODEEXT)] = _rtl92e_wx_set_encode_ext,
 };
 
 /* the following rule need to be following,
@@ -1238,21 +1164,10 @@ static const struct iw_priv_args r8192_private_args[] = {
        }, {
                SIOCIWFIRSTPRIV + 0x3,
                IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset"
-       }, {
-               SIOCIWFIRSTPRIV + 0x4,
-               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "force_mic_error"
-       }, {
-               SIOCIWFIRSTPRIV + 0x5,
-               IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1,
-               "firm_ver"
        }, {
                SIOCIWFIRSTPRIV + 0x6,
                IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
                "set_power"
-       }, {
-               SIOCIWFIRSTPRIV + 0x9,
-               IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
-               "radio"
        }, {
                SIOCIWFIRSTPRIV + 0xa,
                IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
@@ -1261,9 +1176,6 @@ static const struct iw_priv_args r8192_private_args[] = {
                SIOCIWFIRSTPRIV + 0xb,
                IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
                "lps_force"
-       }, {
-               SIOCIWFIRSTPRIV + 0xc,
-               0, IW_PRIV_TYPE_CHAR|2047, "adhoc_peer_list"
        }, {
                SIOCIWFIRSTPRIV + 0x16,
                IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "setpromisc"
@@ -1275,19 +1187,19 @@ static const struct iw_priv_args r8192_private_args[] = {
 };
 
 static iw_handler r8192_private_handler[] = {
-       (iw_handler)r8192_wx_set_debugflag,   /*SIOCIWSECONDPRIV*/
-       (iw_handler)r8192_wx_set_scan_type,
-       (iw_handler)r8192_wx_set_rawtx,
-       (iw_handler)r8192_wx_force_reset,
-       (iw_handler)r8192_wx_force_mic_error,
-       (iw_handler)r8191se_wx_get_firm_version,
-       (iw_handler)r8192_wx_adapter_power_status,
+       (iw_handler)_rtl92e_wx_set_debug,   /*SIOCIWSECONDPRIV*/
+       (iw_handler)_rtl92e_wx_set_scan_type,
+       (iw_handler)_rtl92e_wx_set_rawtx,
+       (iw_handler)_rtl92e_wx_force_reset,
+       (iw_handler)NULL,
+       (iw_handler)NULL,
+       (iw_handler)_rtl92e_wx_adapter_power_status,
+       (iw_handler)NULL,
+       (iw_handler)NULL,
        (iw_handler)NULL,
+       (iw_handler)_rtl92e_wx_set_lps_awake_interval,
+       (iw_handler)_rtl92e_wx_set_force_lps,
        (iw_handler)NULL,
-       (iw_handler)r8192se_wx_set_radio,
-       (iw_handler)r8192se_wx_set_lps_awake_interval,
-       (iw_handler)r8192se_wx_set_force_lps,
-       (iw_handler)r8192_wx_get_adhoc_peers,
        (iw_handler)NULL,
        (iw_handler)NULL,
        (iw_handler)NULL,
@@ -1297,11 +1209,11 @@ static iw_handler r8192_private_handler[] = {
        (iw_handler)NULL,
        (iw_handler)NULL,
        (iw_handler)NULL,
-       (iw_handler)r8192_wx_set_PromiscuousMode,
-       (iw_handler)r8192_wx_get_PromiscuousMode,
+       (iw_handler)_rtl92e_wx_set_promisc_mode,
+       (iw_handler)_rtl92e_wx_get_promisc_mode,
 };
 
-static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
+static struct iw_statistics *_rtl92e_get_wireless_stats(struct net_device *dev)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtllib_device *ieee = priv->rtllib;
@@ -1313,7 +1225,7 @@ static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
        if (ieee->state < RTLLIB_LINKED) {
                wstats->qual.qual = 10;
                wstats->qual.level = 0;
-               wstats->qual.noise = -100;
+               wstats->qual.noise = 0x100 - 100;       /* -100 dBm */
                wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
                return wstats;
        }
@@ -1336,6 +1248,6 @@ const struct iw_handler_def r8192_wx_handlers_def = {
        .num_private = ARRAY_SIZE(r8192_private_handler),
        .num_private_args = sizeof(r8192_private_args) /
                            sizeof(struct iw_priv_args),
-       .get_wireless_stats = r8192_get_wireless_stats,
+       .get_wireless_stats = _rtl92e_get_wireless_stats,
        .private_args = (struct iw_priv_args *)r8192_private_args,
 };