From 7e761c5a2ad625f3f73fa458ed2fac26611ffdfa Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:33 +0200 Subject: [PATCH] staging: rtl8723au: rtw_ioctl_set.c: Fix up messy error code handling Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723au/core/rtw_ioctl_set.c | 46 ++++++++----------- .../staging/rtl8723au/include/rtw_ioctl_set.h | 22 +++++---- .../staging/rtl8723au/os_dep/ioctl_cfg80211.c | 8 ++-- 3 files changed, 35 insertions(+), 41 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index eb4aa925287a..a2dfb93b04eb 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -22,13 +22,13 @@ #include #include -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; } /* diff --git a/drivers/staging/rtl8723au/include/rtw_ioctl_set.h b/drivers/staging/rtl8723au/include/rtw_ioctl_set.h index e18820012edc..13f7fcb2a73a 100644 --- a/drivers/staging/rtl8723au/include/rtw_ioctl_set.h +++ b/drivers/staging/rtl8723au/include/rtw_ioctl_set.h @@ -17,18 +17,20 @@ #include -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 diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 53cec46763f0..627d75c1b329 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -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); -- 2.20.1