staging: rtl8723au: rtw_ioctl_set.c: Fix up messy error code handling
authorJes Sorensen <Jes.Sorensen@redhat.com>
Fri, 16 May 2014 08:04:33 +0000 (10:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 May 2014 18:34:29 +0000 (11:34 -0700)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/core/rtw_ioctl_set.c
drivers/staging/rtl8723au/include/rtw_ioctl_set.h
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c

index eb4aa925287a9924acfc5f911e69b4922d82446c..a2dfb93b04eb6333f8d6152787c51dfcf01afa26 100644 (file)
 #include <usb_ops.h>
 #include <linux/ieee80211.h>
 
-u8 rtw_do_join23a(struct rtw_adapter *padapter)
+int rtw_do_join23a(struct rtw_adapter *padapter)
 {
        struct list_head *plist, *phead;
        u8* pibss = NULL;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct rtw_queue *queue = &pmlmepriv->scanned_queue;
-       u8 ret = _SUCCESS;
+       int ret = _SUCCESS;
 
        spin_lock_bh(&pmlmepriv->scanned_queue.lock);
        phead = get_list_head(queue);
@@ -151,9 +151,10 @@ exit:
        return ret;
 }
 
-u8 rtw_set_802_11_ssid23a(struct rtw_adapter* padapter, struct cfg80211_ssid *ssid)
+int rtw_set_802_11_ssid23a(struct rtw_adapter* padapter,
+                          struct cfg80211_ssid *ssid)
 {
-       u8 status = _SUCCESS;
+       int status = _SUCCESS;
        u32 cur_time = 0;
 
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -278,7 +279,7 @@ exit:
        return status;
 }
 
-u8 rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter,
+int rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter,
                                         enum ndis_802_11_net_infra networktype)
 {
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -361,25 +362,26 @@ u8 rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter,
                spin_unlock_bh(&pmlmepriv->lock);
        }
 
-       return true;
+       return _SUCCESS;
 }
 
-u8 rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter,
-                                 struct cfg80211_ssid *pssid, int ssid_max_num)
+int rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter,
+                                     struct cfg80211_ssid *pssid,
+                                     int ssid_max_num)
 {
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       u8 res = true;
+       int res = _SUCCESS;
 
        RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
                 ("+rtw_set_802_11_bssid23a_list_scan(), fw_state =%x\n",
                  get_fwstate(pmlmepriv)));
 
        if (!padapter) {
-               res = false;
+               res = _FAIL;
                goto exit;
        }
        if (padapter->hw_init_completed == false) {
-               res = false;
+               res = _FAIL;
                RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
                         ("\n === rtw_set_802_11_bssid23a_list_scan:"
                          "hw_init_completed == false ===\n"));
@@ -392,7 +394,6 @@ u8 rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter,
                RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
                         ("rtw_set_802_11_bssid23a_list_scan fail since fw_state "
                          "= %x\n", get_fwstate(pmlmepriv)));
-               res = true;
 
                if (check_fwstate(pmlmepriv,
                                  (_FW_UNDER_SURVEY|_FW_UNDER_LINKING))) {
@@ -421,12 +422,11 @@ exit:
        return res;
 }
 
-u8 rtw_set_802_11_authentication_mode23a(struct rtw_adapter* padapter,
-                                     enum ndis_802_11_auth_mode authmode)
+int rtw_set_802_11_authentication_mode23a(struct rtw_adapter* padapter,
+                                         enum ndis_802_11_auth_mode authmode)
 {
        struct security_priv *psecuritypriv = &padapter->securitypriv;
        int res;
-       u8 ret;
 
        RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
                 ("set_802_11_auth.mode(): mode =%x\n", authmode));
@@ -443,22 +443,16 @@ u8 rtw_set_802_11_authentication_mode23a(struct rtw_adapter* padapter,
 
        res = rtw_set_auth23a(padapter, psecuritypriv);
 
-       if (res == _SUCCESS)
-               ret = true;
-       else
-               ret = false;
-
-       return ret;
+       return res;
 }
 
-u8 rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter,
+int rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter,
                          struct ndis_802_11_wep *wep)
 {
        u8 bdefaultkey;
        u8 btransmitkey;
        int keyid, res;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
-       u8 ret = _SUCCESS;
 
        bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? false : true;
        btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? true  : false;
@@ -467,7 +461,7 @@ u8 rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter,
        if (keyid >= 4) {
                RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
                         ("MgntActrtw_set_802_11_add_wep23a:keyid>4 =>fail\n"));
-               ret = false;
+               res = _FAIL;
                goto exit;
        }
 
@@ -522,11 +516,9 @@ u8 rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter,
 
        res = rtw_set_key23a(padapter, psecuritypriv, keyid, 1);
 
-       if (res == _FAIL)
-               ret = false;
 exit:
 
-       return ret;
+       return res;
 }
 
 /*
index e18820012edc39d43e93146730e98eabd8b778e1..13f7fcb2a73a2569b02626e44e76de12b74c5fc4 100644 (file)
 
 #include <drv_types.h>
 
-u8 rtw_set_802_11_authentication_mode23a(struct rtw_adapter *pdapter,
-                                     enum ndis_802_11_auth_mode authmode);
-u8 rtw_set_802_11_add_wep23a(struct rtw_adapter * padapter,
-                         struct ndis_802_11_wep *wep);
-u8 rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter,
-                                 struct cfg80211_ssid *pssid, int ssid_max_num);
-u8 rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter *padapter,
-                                     enum ndis_802_11_net_infra networktype);
-u8 rtw_set_802_11_ssid23a(struct rtw_adapter * padapter, struct cfg80211_ssid * ssid);
+int rtw_set_802_11_authentication_mode23a(struct rtw_adapter *pdapter,
+                                         enum ndis_802_11_auth_mode authmode);
+int rtw_set_802_11_add_wep23a(struct rtw_adapter * padapter,
+                             struct ndis_802_11_wep *wep);
+int rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter,
+                                     struct cfg80211_ssid *pssid,
+                                     int ssid_max_num);
+int rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter *padapter,
+                                         enum ndis_802_11_net_infra networktype);
+int rtw_set_802_11_ssid23a(struct rtw_adapter * padapter,
+                          struct cfg80211_ssid * ssid);
 
 u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter);
 s32 FillH2CCmd(struct rtw_adapter *padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer);
-u8 rtw_do_join23a(struct rtw_adapter *padapter);
+int rtw_do_join23a(struct rtw_adapter *padapter);
 
 #endif
index 53cec46763f00c12036f9a912110f51e8b8e3642..627d75c1b329561dfbccc27e0f4483365d64c461 100644 (file)
@@ -1343,7 +1343,8 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
 
        rtw_wdev->iftype = type;
 
-       if (rtw_set_802_11_infrastructure_mode23a(padapter, networkType) == false) {
+       if (rtw_set_802_11_infrastructure_mode23a
+           (padapter, networkType) != _SUCCESS) {
                rtw_wdev->iftype = old_type;
                ret = -EPERM;
                goto exit;
@@ -1982,7 +1983,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
        }
 
        if (rtw_set_802_11_infrastructure_mode23a
-           (padapter, pnetwork->network.InfrastructureMode) == false) {
+           (padapter, pnetwork->network.InfrastructureMode) != _SUCCESS) {
                ret = -EPERM;
                goto exit;
        }
@@ -2069,9 +2070,8 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 
                memcpy(pwep->KeyMaterial, (void *)sme->key, pwep->KeyLength);
 
-               if (rtw_set_802_11_add_wep23a(padapter, pwep) == (u8) _FAIL) {
+               if (rtw_set_802_11_add_wep23a(padapter, pwep) != _SUCCESS)
                        ret = -EOPNOTSUPP;
-               }
 
                kfree(pwep);