[OPW,kernel,v3,22/28] staging: rtl8723au: os_dep: ioctl_cfg80211.c: Replace non-standard return values
diff mbox

Message ID 1414668396-4093-23-git-send-email-roberta.dobrescu@gmail.com
State New, archived
Headers show

Commit Message

Roberta Dobrescu Oct. 30, 2014, 11:26 a.m. UTC
This patch replaces non-standard return values _SUCCESS/_FAIL with 0
or an appropriate err code and modifies the code according to that.

Signed-off-by: Roberta Dobrescu <roberta.dobrescu@gmail.com>
---
 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 79 +++++++++++------------
 1 file changed, 37 insertions(+), 42 deletions(-)

Patch
diff mbox

diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
index e154de9..ce4dc0f 100644
--- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
@@ -390,18 +390,18 @@  static int set_pairwise_key(struct rtw_adapter *padapter, struct sta_info *psta)
 	struct cmd_obj *ph2c;
 	struct set_stakey_parm *psetstakey_para;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
 	if (ph2c == NULL) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
 	psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL);
 	if (psetstakey_para == NULL) {
 		kfree(ph2c);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -425,24 +425,25 @@  static int set_group_key(struct rtw_adapter *padapter, struct key_params *parms,
 	struct cmd_obj *pcmd;
 	struct setkey_parm *psetkeyparm;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	DBG_8723A("%s\n", __func__);
 
 	if (keyid >= 4) {
-		res = _FAIL;
+		res = -EINVAL;
 		goto exit;
 	}
 
 	pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
 	if (!pcmd) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
+
 	psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL);
 	if (!psetkeyparm) {
 		kfree(pcmd);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -1202,7 +1203,7 @@  static int cfg80211_infrastructure_mode(struct rtw_adapter *padapter,
 		spin_unlock_bh(&pmlmepriv->lock);
 	}
 
-	return _SUCCESS;
+	return 0;
 }
 
 static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
@@ -1241,7 +1242,7 @@  static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
 
 	rtw_wdev->iftype = type;
 
-	if (cfg80211_infrastructure_mode(padapter, type) != _SUCCESS) {
+	if (cfg80211_infrastructure_mode(padapter, type) != 0) {
 		rtw_wdev->iftype = old_type;
 		ret = -EPERM;
 		goto exit;
@@ -1342,7 +1343,6 @@  static int cfg80211_rtw_scan(struct wiphy *wiphy,
 			     struct cfg80211_scan_request *request)
 {
 	int i;
-	u8 _status = false;
 	int ret = 0;
 	struct rtw_adapter *padapter = wiphy_to_adapter(wiphy);
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -1364,7 +1364,7 @@  static int cfg80211_rtw_scan(struct wiphy *wiphy,
 		/* goto check_need_indicate_scan_done; */
 	}
 
-	if (rtw_pwr_wakeup(padapter) == _FAIL) {
+	if (rtw_pwr_wakeup(padapter) < 0) {
 		need_indicate_scan_done = true;
 		goto check_need_indicate_scan_done;
 	}
@@ -1422,17 +1422,14 @@  static int cfg80211_rtw_scan(struct wiphy *wiphy,
 	if (request->n_channels == 1) {
 		memcpy(&ch[1], &ch[0], sizeof(struct rtw_ieee80211_channel));
 		memcpy(&ch[2], &ch[0], sizeof(struct rtw_ieee80211_channel));
-		_status = rtw_sitesurvey_cmd23a(padapter, ssid,
+		ret = rtw_sitesurvey_cmd23a(padapter, ssid,
 					     RTW_SSID_SCAN_AMOUNT, ch, 3);
 	} else {
-		_status = rtw_sitesurvey_cmd23a(padapter, ssid,
+		ret = rtw_sitesurvey_cmd23a(padapter, ssid,
 					     RTW_SSID_SCAN_AMOUNT, NULL, 0);
 	}
 	spin_unlock_bh(&pmlmepriv->lock);
 
-	if (_status == false)
-		ret = -1;
-
 check_need_indicate_scan_done:
 	if (need_indicate_scan_done)
 		rtw_cfg80211_surveydone_event_callback(padapter);
@@ -1605,7 +1602,7 @@  static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
 	if (ielen < RSN_HEADER_LEN) {
 		RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_,
 			 ("Ie len too short %d\n", (int)ielen));
-		ret = -1;
+		ret = -EINVAL;
 		goto exit;
 	}
 
@@ -1614,7 +1611,7 @@  static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
 				       pie, ielen);
 	if (pwpa && pwpa[1] > 0) {
 		if (rtw_parse_wpa_ie23a(pwpa, pwpa[1] + 2, &group_cipher,
-					&pairwise_cipher, NULL) == _SUCCESS) {
+					&pairwise_cipher, NULL) == 0) {
 			padapter->securitypriv.dot11AuthAlgrthm =
 				dot11AuthAlgrthm_8021X;
 			padapter->securitypriv.ndisauthtype =
@@ -1629,7 +1626,7 @@  static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
 	pwpa2 = cfg80211_find_ie(WLAN_EID_RSN, pie, ielen);
 	if (pwpa2 && pwpa2[1] > 0) {
 		if (rtw_parse_wpa2_ie23a (pwpa2, pwpa2[1] + 2, &group_cipher,
-					  &pairwise_cipher, NULL) == _SUCCESS) {
+					  &pairwise_cipher, NULL) == 0) {
 			padapter->securitypriv.dot11AuthAlgrthm =
 				dot11AuthAlgrthm_8021X;
 			padapter->securitypriv.ndisauthtype =
@@ -1748,7 +1745,7 @@  static int rtw_cfg80211_add_wep(struct rtw_adapter *padapter,
 	if (keyid >= NUM_WEP_KEYS) {
 		RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
 			 ("%s:keyid>4 =>fail\n", __func__));
-		res = _FAIL;
+		res = -EINVAL;
 		goto exit;
 	}
 
@@ -1767,7 +1764,7 @@  static int rtw_cfg80211_add_wep(struct rtw_adapter *padapter,
 		psecuritypriv->dot11PrivacyAlgrthm = 0;
 		RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
 			 ("%s:wep->KeyLength!= 5 or 13\n", __func__));
-		res = _FAIL;
+		res = -EINVAL;
 		goto exit;
 	}
 
@@ -1808,7 +1805,7 @@  static int rtw_set_ssid(struct rtw_adapter *padapter,
 {
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 	struct wlan_network *pnetwork = &pmlmepriv->cur_network;
-	int status = _SUCCESS;
+	int status = 0;
 	u32 cur_time = 0;
 
 	DBG_8723A_LEVEL(_drv_always_, "set ssid [%s] fw_state = 0x%08x\n",
@@ -1817,7 +1814,7 @@  static int rtw_set_ssid(struct rtw_adapter *padapter,
 	if (padapter->hw_init_completed == false) {
 		RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
 			 ("set_ssid: hw_init_completed == false =>exit!!!\n"));
-		status = _FAIL;
+		status = -EINVAL;
 		goto exit;
 	}
 
@@ -1911,7 +1908,7 @@  handle_tkip_countermeasure:
 			padapter->securitypriv.btkip_countermeasure = false;
 			padapter->securitypriv.btkip_countermeasure_time = 0;
 		} else {
-			status = _FAIL;
+			status = -EINVAL;
 			goto release_mlme_lock;
 		}
 	}
@@ -1927,18 +1924,18 @@  handle_tkip_countermeasure:
 		pmlmepriv->cur_network.join_res = -2;
 
 		status = rtw_do_join_network(padapter, newnetwork);
-		if (status == _SUCCESS) {
+		if (status == 0) {
 			pmlmepriv->to_join = false;
 		} else {
 			if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
 				/* switch to ADHOC_MASTER */
 				status = rtw_do_join_adhoc(padapter);
-				if (status != _SUCCESS)
+				if (status != 0)
 					goto release_mlme_lock;
 			} else {
 				/* can't associate ; reset under-linking */
 				_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
-				status = _FAIL;
+				status = -EOPNOTSUPP;
 				pmlmepriv->to_join = false;
 			}
 		}
@@ -1971,7 +1968,7 @@  static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 	DBG_8723A("privacy =%d, key =%p, key_len =%d, key_idx =%d\n",
 		  sme->privacy, sme->key, sme->key_len, sme->key_idx);
 
-	if (_FAIL == rtw_pwr_wakeup(padapter)) {
+	if (rtw_pwr_wakeup(padapter) < 0) {
 		ret = -EPERM;
 		goto exit;
 	}
@@ -2051,7 +2048,7 @@  static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 	}
 
 	if (cfg80211_infrastructure_mode(
-		    padapter, pnetwork->network.ifmode) != _SUCCESS) {
+		    padapter, pnetwork->network.ifmode) != 0) {
 		ret = -EPERM;
 		goto exit;
 	}
@@ -2123,8 +2120,7 @@  static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 
 		memcpy(wep_key.key, (void *)sme->key, wep_key.keylen);
 
-		if (rtw_cfg80211_add_wep(padapter, &wep_key, wep_key_idx) !=
-		    _SUCCESS)
+		if (rtw_cfg80211_add_wep(padapter, &wep_key, wep_key_idx) != 0)
 			ret = -EOPNOTSUPP;
 
 		if (ret < 0)
@@ -2146,7 +2142,7 @@  static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 	if (psecuritypriv->ndisauthtype > 3)
 		psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
 
-	if (rtw_set_auth23a(padapter, psecuritypriv) != _SUCCESS) {
+	if (rtw_set_auth23a(padapter, psecuritypriv) != 0) {
 		ret = -EBUSY;
 		goto exit;
 	}
@@ -2154,7 +2150,7 @@  static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 	/* rtw_set_802_11_encryption_mode(padapter,
 	   padapter->securitypriv.ndisencryptstatus); */
 
-	if (rtw_set_ssid(padapter, pnetwork) != _SUCCESS) {
+	if (rtw_set_ssid(padapter, pnetwork) != 0) {
 		ret = -EBUSY;
 		goto exit;
 	}
@@ -2772,7 +2768,7 @@  static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head,
 			     WLAN_EID_VENDOR_SPECIFIC, WFD_OUI23A, 4);
 
 	len = ielen + offsetof(struct ieee80211_mgmt, u.beacon.variable);
-	if (rtw_check_beacon_data23a(adapter, tmpmgmt, len) == _SUCCESS) {
+	if (rtw_check_beacon_data23a(adapter, tmpmgmt, len) == 0) {
 		ret = 0;
 	} else {
 		ret = -EINVAL;
@@ -2956,12 +2952,12 @@  static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch,
 	struct xmit_frame *pmgntframe;
 	struct pkt_attrib *pattrib;
 	unsigned char *pframe;
-	int ret = _FAIL;
+	int ret;
 	struct ieee80211_hdr *pwlanhdr;
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 
-	if (_FAIL == rtw_pwr_wakeup(padapter)) {
+	if (rtw_pwr_wakeup(padapter) < 0) {
 		ret = -EFAULT;
 		goto exit;
 	}
@@ -2981,8 +2977,7 @@  static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch,
 	/* starting alloc mgmt frame to dump it */
 	pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
 	if (!pmgntframe) {
-		/* ret = -ENOMEM; */
-		ret = _FAIL;
+		ret = -ENOMEM;
 		goto exit;
 	}
 
@@ -3008,7 +3003,7 @@  static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch,
 
 	ret = dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe);
 
-	if (ret  != _SUCCESS)
+	if (ret != 0)
 		DBG_8723A("%s, ack == false\n", __func__);
 	else
 		DBG_8723A("%s, ack == true\n", __func__);
@@ -3061,12 +3056,12 @@  static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
 	do {
 		dump_cnt++;
 		tx_ret = _cfg80211_rtw_mgmt_tx(padapter, tx_ch, buf, len);
-	} while (dump_cnt < dump_limit && tx_ret != _SUCCESS);
+	} while (dump_cnt < dump_limit && tx_ret != 0);
 
-	if (tx_ret != _SUCCESS || dump_cnt > 1) {
+	if (tx_ret != 0 || dump_cnt > 1) {
 		DBG_8723A("%s(%s): %s (%d/%d) in %d ms\n",
 			  __func__, padapter->pnetdev->name,
-			  tx_ret == _SUCCESS ? "OK" : "FAIL", dump_cnt,
+			  tx_ret == 0 ? "OK" : "FAIL", dump_cnt,
 			  dump_limit, jiffies_to_msecs(jiffies - start));
 	}