[OPW,kernel,v3,06/28] staging: rtl8723au: core: rtw_mlme_ext.c: Replace non-standard return values
diff mbox

Message ID 1414668396-4093-7-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/core/rtw_mlme_ext.c | 275 +++++++++++++-------------
 1 file changed, 142 insertions(+), 133 deletions(-)

Patch
diff mbox

diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
index 0e0f73c..258bb84 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
@@ -354,7 +354,7 @@  int init_hw_mlme_ext23a(struct rtw_adapter *padapter)
 
 	set_channel_bwmode23a(padapter, pmlmeext->cur_channel,
 			      pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
-	return _SUCCESS;
+	return 0;
 }
 
 static void init_mlme_ext_priv23a_value(struct rtw_adapter *padapter)
@@ -593,7 +593,7 @@  int init_mlme_ext_priv23a(struct rtw_adapter *padapter)
 	pmlmeext->mlmeext_init = true;
 
 	pmlmeext->active_keep_alive_check = true;
-	return _SUCCESS;
+	return 0;
 }
 
 void free_mlme_ext_priv23a (struct mlme_ext_priv *pmlmeext)
@@ -732,17 +732,17 @@  OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 	int len = skb->len;
 
 	if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
-		return _SUCCESS;
+		return 0;
 
 	if (!check_fwstate(pmlmepriv, _FW_LINKED) &&
 	    !check_fwstate(pmlmepriv,
 			   WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE))
-		return _SUCCESS;
+		return 0;
 
 	if (unlikely(!ieee80211_is_probe_req(mgmt->frame_control))) {
 		printk(KERN_WARNING "%s: Received non probe request frame\n",
 		       __func__);
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	len -= offsetof(struct ieee80211_mgmt, u.probe_req.variable);
@@ -755,7 +755,7 @@  OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 
 	if ((ie[1] && memcmp(ie + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) ||
 	    (ie[1] == 0 && pmlmeinfo->hidden_ssid_mode)) {
-		return _SUCCESS;
+		return 0;
 	}
 
 	if (check_fwstate(pmlmepriv, _FW_LINKED) &&
@@ -763,7 +763,7 @@  OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 		issue_probersp(padapter, mgmt->sa, false);
 
 out:
-	return _SUCCESS;
+	return 0;
 }
 
 static int
@@ -773,10 +773,10 @@  OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 
 	if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
 		report_survey_event23a(padapter, precv_frame);
-		return _SUCCESS;
+		return 0;
 	}
 
-	return _SUCCESS;
+	return 0;
 }
 
 static int
@@ -792,7 +792,7 @@  OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
 	int pkt_len = skb->len;
 	struct wlan_bssid_ex *pbss;
-	int ret = _SUCCESS;
+	int ret = 0;
 	u8 *p, *pie;
 	int pie_len;
 	u32 ielen = 0;
@@ -816,7 +816,7 @@  OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 
 	if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
 		report_survey_event23a(padapter, precv_frame);
-		return _SUCCESS;
+		return 0;
 	}
 
 	if (!ether_addr_equal(mgmt->bssid,
@@ -845,7 +845,7 @@  OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 		/* start auth */
 		start_clnt_auth(padapter);
 
-		return _SUCCESS;
+		return 0;
 	}
 
 	if (((pmlmeinfo->state & 0x03) == MSR_AP) &&
@@ -853,11 +853,11 @@  OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 		psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
 		if (psta) {
 			ret = rtw_check_bcn_info23a(padapter, mgmt, pkt_len);
-			if (ret != _SUCCESS) {
+			if (ret != 0) {
 				DBG_8723A_LEVEL(_drv_always_, "ap has changed, "
 						"disconnect now\n");
 				receive_disconnect23a(padapter, pmlmeinfo->network.MacAddress, 65535);
-				return _SUCCESS;
+				return 0;
 			}
 			/* update WMM, ERP in the beacon */
 			/* todo: the timer is used instead of
@@ -887,7 +887,7 @@  OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 
 			/* get supported rate */
 			if (update_sta_support_rate23a(padapter, pie, pie_len,
-						       cam_idx) == _FAIL) {
+						       cam_idx) < 0) {
 				pmlmeinfo->FW_sta_info[cam_idx].status = 0;
 				goto out;
 			}
@@ -903,7 +903,7 @@  OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 
 out:
 
-	return _SUCCESS;
+	return 0;
 }
 
 #ifdef CONFIG_8723AU_AP_MODE
@@ -925,7 +925,7 @@  OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 	int status, len = skb->len;
 
 	if ((pmlmeinfo->state & 0x03) != MSR_AP)
-		return _FAIL;
+		return -EINVAL;
 
 	DBG_8723A("+OnAuth23a\n");
 
@@ -1076,7 +1076,7 @@  OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 	if (pstat->state & WIFI_FW_AUTH_SUCCESS)
 		pstat->auth_seq = 0;
 
-	return _SUCCESS;
+	return 0;
 
 auth_fail:
 
@@ -1090,7 +1090,7 @@  auth_fail:
 
 	issue_auth(padapter, pstat, (unsigned short)status);
 
-	return _FAIL;
+	return -EOPNOTSUPP;
 }
 #endif
 
@@ -1111,10 +1111,10 @@  OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 
 	/* check A1 matches or not */
 	if (!ether_addr_equal(myid(&padapter->eeprompriv), mgmt->da))
-		return _SUCCESS;
+		return 0;
 
 	if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE))
-		return _SUCCESS;
+		return 0;
 
 	pie = mgmt->u.auth.variable;
 	plen -= offsetof(struct ieee80211_mgmt, u.auth.variable);
@@ -1153,7 +1153,7 @@  OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 			issue_auth(padapter, NULL, 0);
 			set_link_timer(pmlmeext, REAUTH_TO);
 
-			return _SUCCESS;
+			return 0;
 		} else {
 			/*  open system */
 			go2asoc = 1;
@@ -1173,14 +1173,14 @@  OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 	if (go2asoc) {
 		DBG_8723A_LEVEL(_drv_always_, "auth success, start assoc\n");
 		start_clnt_assoc(padapter);
-		return _SUCCESS;
+		return 0;
 	}
 
 authclnt_fail:
 
 	/* pmlmeinfo->state &= ~(WIFI_FW_AUTH_STATE); */
 
-	return _FAIL;
+	return -EOPNOTSUPP;
 }
 
 #ifdef CONFIG_8723AU_AP_MODE
@@ -1344,7 +1344,7 @@  OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 	int r;
 
 	if ((pmlmeinfo->state & 0x03) != MSR_AP)
-		return _FAIL;
+		return -EINVAL;
 
 	left = pkt_len - sizeof(struct ieee80211_hdr_3addr);
 	if (ieee80211_is_assoc_req(mgmt->frame_control)) {
@@ -1360,7 +1360,7 @@  OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 	if (left < 0) {
 		DBG_8723A("handle_assoc(reassoc =%d) - too short payload "
 			  "(len =%lu)\n", reassoc, (unsigned long)pkt_len);
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	pstat = rtw_get_stainfo23a(pstapriv, mgmt->sa);
@@ -1477,7 +1477,7 @@  OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 			r = rtw_parse_wpa2_ie23a(wpa_ie, wpa_ie_len + 2,
 						 &group_cipher,
 						 &pairwise_cipher, NULL);
-			if (r == _SUCCESS) {
+			if (r == 0) {
 				pstat->dot8021xalg = 1;/* psk,  todo:802.1x */
 				pstat->wpa_psk |= BIT(1);
 
@@ -1491,7 +1491,7 @@  OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 			r = rtw_parse_wpa_ie23a(wpa_ie, wpa_ie_len + 2,
 						&group_cipher, &pairwise_cipher,
 						NULL);
-			if (r == _SUCCESS) {
+			if (r == 0) {
 				pstat->dot8021xalg = 1;/* psk,  todo:802.1x */
 				pstat->wpa_psk |= BIT(0);
 
@@ -1742,14 +1742,14 @@  OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 #endif
 	}
 
-	return _SUCCESS;
+	return 0;
 
 asoc_class2_error:
 
 #ifdef CONFIG_8723AU_AP_MODE
 	issue_deauth23a(padapter, mgmt->sa, status);
 #endif
-	return _FAIL;
+	return -EOPNOTSUPP;
 
 OnAssocReq23aFail:
 
@@ -1765,7 +1765,7 @@  OnAssocReq23aFail:
 
 #endif /* CONFIG_8723AU_AP_MODE */
 
-	return _FAIL;
+	return -EOPNOTSUPP;
 }
 
 static int
@@ -1787,13 +1787,13 @@  OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 
 	/* check A1 matches or not */
 	if (!ether_addr_equal(myid(&padapter->eeprompriv), pmgmt->da))
-		return _SUCCESS;
+		return 0;
 
 	if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE)))
-		return _SUCCESS;
+		return 0;
 
 	if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)
-		return _SUCCESS;
+		return 0;
 
 	del_timer_sync(&pmlmeext->link_timer);
 
@@ -1874,7 +1874,7 @@  report_assoc_result:
 
 	report_join_res23a(padapter, res);
 
-	return _SUCCESS;
+	return 0;
 }
 
 static int
@@ -1889,7 +1889,7 @@  OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 
 	if (!ether_addr_equal(mgmt->bssid,
 			      get_my_bssid23a(&pmlmeinfo->network)))
-		return _SUCCESS;
+		return 0;
 
 	reason = le16_to_cpu(mgmt->u.deauth.reason_code);
 
@@ -1919,7 +1919,7 @@  OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 			associated_clients_update23a(padapter, updated);
 		}
 
-		return _SUCCESS;
+		return 0;
 	} else
 #endif
 	{
@@ -1930,7 +1930,7 @@  OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 	}
 	pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
 
-	return _SUCCESS;
+	return 0;
 }
 
 static int
@@ -1945,7 +1945,7 @@  OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 
 	if (!ether_addr_equal(mgmt->bssid,
 			      get_my_bssid23a(&pmlmeinfo->network)))
-		return _SUCCESS;
+		return 0;
 
 	reason = le16_to_cpu(mgmt->u.disassoc.reason_code);
 
@@ -1975,7 +1975,7 @@  OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 			associated_clients_update23a(padapter, updated);
 		}
 
-		return _SUCCESS;
+		return 0;
 	} else
 #endif
 	{
@@ -1985,32 +1985,32 @@  OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 		receive_disconnect23a(padapter, mgmt->bssid, reason);
 	}
 	pmlmepriv->LinkDetectInfo.bBusyTraffic = false;
-	return _SUCCESS;
+	return 0;
 }
 
 static int
 OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
 	DBG_8723A("%s\n", __func__);
-	return _SUCCESS;
+	return 0;
 }
 
 static int
 on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
-	return _FAIL;
+	return 0;
 }
 
 static int
 OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
-	return _SUCCESS;
+	return 0;
 }
 
 static int
 OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
-	return _SUCCESS;
+	return 0;
 }
 
 static int OnAction23a_back23a(struct rtw_adapter *padapter,
@@ -2029,24 +2029,24 @@  static int OnAction23a_back23a(struct rtw_adapter *padapter,
 
 	/* check RA matches or not */
 	if (!ether_addr_equal(myid(&padapter->eeprompriv), mgmt->da))
-		return _SUCCESS;
+		return 0;
 
 	DBG_8723A("%s\n", __func__);
 
 	if ((pmlmeinfo->state&0x03) != MSR_AP)
 		if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS))
-			return _SUCCESS;
+			return 0;
 
 	addr = mgmt->sa;
 	psta = rtw_get_stainfo23a(pstapriv, addr);
 
 	if (!psta)
-		return _SUCCESS;
+		return 0;
 
 	category = mgmt->u.action.category;
 	if (category == WLAN_CATEGORY_BACK) { /*  representing Block Ack */
 		if (!pmlmeinfo->HT_enable)
-			return _SUCCESS;
+			return 0;
 		/* action_code is located in the same place for all
 		   action events, so pick any */
 		action = mgmt->u.action.u.wme_action.action_code;
@@ -2103,7 +2103,7 @@  static int OnAction23a_back23a(struct rtw_adapter *padapter,
 			break;
 		}
 	}
-	return _SUCCESS;
+	return 0;
 }
 
 static int on_action_public23a(struct rtw_adapter *padapter,
@@ -2116,7 +2116,7 @@  static int on_action_public23a(struct rtw_adapter *padapter,
 
 	/* check RA matches or not */
 	if (!ether_addr_equal(myid(&padapter->eeprompriv), hdr->addr1))
-		return _FAIL;
+		return -EINVAL;
 
 	channel = rtw_get_oper_ch23a(padapter);
 
@@ -2129,27 +2129,27 @@  static int on_action_public23a(struct rtw_adapter *padapter,
 
 	if (cfg80211_rx_mgmt(padapter->rtw_wdev, freq, 0, pframe,
 			     skb->len, 0))
-		return _SUCCESS;
+		return 0;
 
-	return _FAIL;
+	return -EINVAL;
 }
 
 static int
 OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
-	return _SUCCESS;
+	return 0;
 }
 
 static int
 OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
-	return _SUCCESS;
+	return 0;
 }
 
 static int
 OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 {
-	return _SUCCESS;
+	return 0;
 }
 
 static int
@@ -2171,13 +2171,13 @@  OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
 			ptable->func(padapter, precv_frame);
 	}
 
-	return _SUCCESS;
+	return 0;
 }
 
 static int DoReserved23a(struct rtw_adapter *padapter,
 			 struct recv_frame *precv_frame)
 {
-	return _SUCCESS;
+	return 0;
 }
 
 struct xmit_frame *alloc_mgtxmitframe23a(struct xmit_priv *pxmitpriv)
@@ -2272,7 +2272,7 @@  void dump_mgntframe23a(struct rtw_adapter *padapter,
 int dump_mgntframe23a_and_wait(struct rtw_adapter *padapter,
 			       struct xmit_frame *pmgntframe, int timeout_ms)
 {
-	int ret = _FAIL;
+	int ret;
 	unsigned long irqL;
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 	struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf;
@@ -2280,14 +2280,14 @@  int dump_mgntframe23a_and_wait(struct rtw_adapter *padapter,
 
 	if (padapter->bSurpriseRemoved == true ||
 	    padapter->bDriverStopped == true)
-		return ret;
+		return -ENODEV;
 
 	rtw_sctx_init23a(&sctx, timeout_ms);
 	pxmitbuf->sctx = &sctx;
 
 	ret = rtl8723au_mgnt_xmit(padapter, pmgntframe);
 
-	if (ret == _SUCCESS)
+	if (ret == 0)
 		ret = rtw_sctx_wait23a(&sctx);
 
 	spin_lock_irqsave(&pxmitpriv->lock_sctx, irqL);
@@ -2300,19 +2300,19 @@  int dump_mgntframe23a_and_wait(struct rtw_adapter *padapter,
 int dump_mgntframe23a_and_wait_ack23a(struct rtw_adapter *padapter,
 				      struct xmit_frame *pmgntframe)
 {
-	int ret = _FAIL;
+	int ret;
 	u32 timeout_ms = 500;/*   500ms */
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 
 	if (padapter->bSurpriseRemoved == true ||
 	    padapter->bDriverStopped == true)
-		return _FAIL;
+		return -ENODEV;
 
 	mutex_lock(&pxmitpriv->ack_tx_mutex);
 	pxmitpriv->ack_tx = true;
 
 	pmgntframe->ack_report = 1;
-	if (rtl8723au_mgnt_xmit(padapter, pmgntframe) == _SUCCESS)
+	if (rtl8723au_mgnt_xmit(padapter, pmgntframe) == 0)
 		ret = rtw_ack_tx_wait23a(pxmitpriv, timeout_ms);
 
 	pxmitpriv->ack_tx = false;
@@ -2673,7 +2673,7 @@  static void issue_probersp(struct rtw_adapter *padapter, unsigned char *da,
 static int _issue_probereq(struct rtw_adapter *padapter,
 			   struct cfg80211_ssid *pssid, u8 *da, int wait_ack)
 {
-	int ret = _FAIL;
+	int ret;
 	struct xmit_frame *pmgntframe;
 	struct pkt_attrib *pattrib;
 	unsigned char *pframe;
@@ -2690,8 +2690,10 @@  static int _issue_probereq(struct rtw_adapter *padapter,
 		 ("+%s\n", __func__));
 
 	pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
-	if (!pmgntframe)
+	if (!pmgntframe) {
+		ret = -ENOMEM;
 		goto exit;
+	}
 
 	/* update attribute */
 	pattrib = &pmgntframe->attrib;
@@ -2764,7 +2766,7 @@  static int _issue_probereq(struct rtw_adapter *padapter,
 		ret = dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe);
 	} else {
 		dump_mgntframe23a(padapter, pmgntframe);
-		ret = _SUCCESS;
+		ret = 0;
 	}
 
 exit:
@@ -2794,13 +2796,13 @@  static int issue_probereq_ex(struct rtw_adapter *padapter,
 		if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
 			break;
 
-		if (i < try_cnt && wait_ms > 0 && ret == _FAIL)
+		if (i < try_cnt && wait_ms > 0 && ret < 0)
 			msleep(wait_ms);
 
-	} while((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0)));
+	} while ((i < try_cnt) && ((ret < 0) || (wait_ms == 0)));
 
-	if (ret != _FAIL) {
-		ret = _SUCCESS;
+	if (ret >= 0) {
+		ret = 0;
 		goto exit;
 	}
 
@@ -2810,13 +2812,13 @@  static int issue_probereq_ex(struct rtw_adapter *padapter,
 				  "in %u ms\n",	__func__,
 				  padapter->pnetdev->name,
 				  MAC_ARG(da), rtw_get_oper_ch23a(padapter),
-				  ret == _SUCCESS?", acked":"", i, try_cnt,
+				  ret == 0?", acked":"", i, try_cnt,
 				  jiffies_to_msecs(jiffies - start));
 		else
 			DBG_8723A("%s(%s):, ch:%u%s, %d/%d in %u ms\n",
 				  __func__, padapter->pnetdev->name,
 				  rtw_get_oper_ch23a(padapter),
-				  ret == _SUCCESS?", acked":"", i, try_cnt,
+				  ret == 0?", acked":"", i, try_cnt,
 				  jiffies_to_msecs(jiffies - start));
 	}
 exit:
@@ -3096,7 +3098,7 @@  static void issue_assocrsp(struct rtw_adapter *padapter, unsigned short status,
 
 static void issue_assocreq(struct rtw_adapter *padapter)
 {
-	int ret = _FAIL;
+	int ret;
 	struct xmit_frame *pmgntframe;
 	struct pkt_attrib *pattrib;
 	unsigned char *pframe;
@@ -3336,11 +3338,11 @@  static void issue_assocreq(struct rtw_adapter *padapter)
 	pattrib->last_txcmdsz = pattrib->pktlen;
 	dump_mgntframe23a(padapter, pmgntframe);
 
-	ret = _SUCCESS;
+	ret = 0;
 
 exit:
 	pmlmepriv->assoc_req_len = 0;
-	if (ret == _SUCCESS) {
+	if (ret == 0) {
 		kfree(pmlmepriv->assoc_req);
 		pmlmepriv->assoc_req = kmalloc(pattrib->pktlen, GFP_ATOMIC);
 		if (pmlmepriv->assoc_req) {
@@ -3357,7 +3359,7 @@  exit:
 static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
 			      unsigned int power_mode, int wait_ack)
 {
-	int ret = _FAIL;
+	int ret;
 	struct xmit_frame *pmgntframe;
 	struct pkt_attrib *pattrib;
 	unsigned char *pframe;
@@ -3368,16 +3370,20 @@  static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
 
 	/* DBG_8723A("%s:%d\n", __func__, power_mode); */
 
-	if (!padapter)
+	if (!padapter) {
+		ret = -EINVAL;
 		goto exit;
+	}
 
 	pxmitpriv = &padapter->xmitpriv;
 	pmlmeext = &padapter->mlmeextpriv;
 	pmlmeinfo = &pmlmeext->mlmext_info;
 
 	pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
-	if (!pmgntframe)
+	if (!pmgntframe) {
+		ret = -ENOMEM;
 		goto exit;
+	}
 
 	/* update attribute */
 	pattrib = &pmgntframe->attrib;
@@ -3417,7 +3423,7 @@  static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
 		ret = dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe);
 	else {
 		dump_mgntframe23a(padapter, pmgntframe);
-		ret = _SUCCESS;
+		ret = 0;
 	}
 
 exit:
@@ -3448,13 +3454,13 @@  int issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
 		if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
 			break;
 
-		if (i < try_cnt && wait_ms > 0 && ret == _FAIL)
+		if (i < try_cnt && wait_ms > 0 && ret < 0)
 			msleep(wait_ms);
 
-	} while((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0)));
+	} while ((i < try_cnt) && ((ret < 0) || (wait_ms == 0)));
 
-	if (ret != _FAIL) {
-		ret = _SUCCESS;
+	if (ret >= 0) {
+		ret = 0;
 		goto exit;
 	}
 
@@ -3464,13 +3470,13 @@  int issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
 				  "in %u ms\n", __func__,
 				  padapter->pnetdev->name,
 				  MAC_ARG(da), rtw_get_oper_ch23a(padapter),
-				  ret == _SUCCESS?", acked":"", i, try_cnt,
+				  ret == 0?", acked":"", i, try_cnt,
 				  jiffies_to_msecs(jiffies - start));
 		else
 			DBG_8723A("%s(%s):, ch:%u%s, %d/%d in %u ms\n",
 				  __func__, padapter->pnetdev->name,
 				  rtw_get_oper_ch23a(padapter),
-				  ret == _SUCCESS?", acked":"", i, try_cnt,
+				  ret == 0?", acked":"", i, try_cnt,
 				  jiffies_to_msecs(jiffies - start));
 	}
 exit:
@@ -3481,7 +3487,7 @@  exit:
 static int _issue_qos_nulldata23a(struct rtw_adapter *padapter,
 				  unsigned char *da, u16 tid, int wait_ack)
 {
-	int ret = _FAIL;
+	int ret;
 	struct xmit_frame *pmgntframe;
 	struct pkt_attrib *pattrib;
 	unsigned char *pframe;
@@ -3493,8 +3499,10 @@  static int _issue_qos_nulldata23a(struct rtw_adapter *padapter,
 	DBG_8723A("%s\n", __func__);
 
 	pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
-	if (!pmgntframe)
+	if (!pmgntframe) {
+		ret = -ENOMEM;
 		goto exit;
+	}
 
 	/* update attribute */
 	pattrib = &pmgntframe->attrib;
@@ -3545,7 +3553,7 @@  static int _issue_qos_nulldata23a(struct rtw_adapter *padapter,
 		ret = dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe);
 	else {
 		dump_mgntframe23a(padapter, pmgntframe);
-		ret = _SUCCESS;
+		ret = 0;
 	}
 
 exit:
@@ -3576,12 +3584,12 @@  int issue_qos_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
 		if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
 			break;
 
-		if (i < try_cnt && wait_ms > 0 && ret == _FAIL)
+		if (i < try_cnt && wait_ms > 0 && ret < 0)
 			msleep(wait_ms);
-	} while((i < try_cnt) && ((ret == _FAIL)||(wait_ms == 0)));
+	} while ((i < try_cnt) && ((ret < 0) || (wait_ms == 0)));
 
-	if (ret != _FAIL) {
-		ret = _SUCCESS;
+	if (ret >= 0) {
+		ret = 0;
 		goto exit;
 	}
 
@@ -3591,13 +3599,13 @@  int issue_qos_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
 				  "in %u ms\n", __func__,
 				  padapter->pnetdev->name,
 				  MAC_ARG(da), rtw_get_oper_ch23a(padapter),
-				  ret == _SUCCESS?", acked":"", i, try_cnt,
+				  ret == 0?", acked":"", i, try_cnt,
 				  jiffies_to_msecs(jiffies - start));
 		else
 			DBG_8723A("%s(%s):, ch:%u%s, %d/%d in %u ms\n",
 				  __func__, padapter->pnetdev->name,
 				  rtw_get_oper_ch23a(padapter),
-				  ret == _SUCCESS?", acked":"", i, try_cnt,
+				  ret == 0?", acked":"", i, try_cnt,
 				  jiffies_to_msecs(jiffies - start));
 	}
 exit:
@@ -3613,13 +3621,15 @@  static int _issue_deauth(struct rtw_adapter *padapter, unsigned char *da,
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-	int ret = _FAIL;
+	int ret;
 
 	/* DBG_8723A("%s to "MAC_FMT"\n", __func__, MAC_ARG(da)); */
 
 	pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
-	if (!pmgntframe)
+	if (!pmgntframe) {
+		ret = -ENOMEM;
 		goto exit;
+	}
 
 	/* update attribute */
 	pattrib = &pmgntframe->attrib;
@@ -3650,7 +3660,7 @@  static int _issue_deauth(struct rtw_adapter *padapter, unsigned char *da,
 		ret = dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe);
 	else {
 		dump_mgntframe23a(padapter, pmgntframe);
-		ret = _SUCCESS;
+		ret = 0;
 	}
 
 exit:
@@ -3680,13 +3690,13 @@  static int issue_deauth_ex(struct rtw_adapter *padapter, u8 *da,
 		if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
 			break;
 
-		if (i < try_cnt && wait_ms > 0 && ret == _FAIL)
+		if (i < try_cnt && wait_ms > 0 && ret < 0)
 			msleep(wait_ms);
 
-	} while((i < try_cnt) && ((ret == _FAIL)||(wait_ms == 0)));
+	} while ((i < try_cnt) && ((ret < 0) || (wait_ms == 0)));
 
-	if (ret != _FAIL) {
-		ret = _SUCCESS;
+	if (ret >= 0) {
+		ret = 0;
 		goto exit;
 	}
 
@@ -3696,13 +3706,13 @@  static int issue_deauth_ex(struct rtw_adapter *padapter, u8 *da,
 				  "in %u ms\n", __func__,
 				  padapter->pnetdev->name,
 				  MAC_ARG(da), rtw_get_oper_ch23a(padapter),
-				  ret == _SUCCESS?", acked":"", i, try_cnt,
+				  ret == 0?", acked":"", i, try_cnt,
 				  jiffies_to_msecs(jiffies - start));
 		else
 			DBG_8723A("%s(%s):, ch:%u%s, %d/%d in %u ms\n",
 				  __func__, padapter->pnetdev->name,
 				  rtw_get_oper_ch23a(padapter),
-				  ret == _SUCCESS?", acked":"", i, try_cnt,
+				  ret == 0?", acked":"", i, try_cnt,
 				  jiffies_to_msecs(jiffies - start));
 	}
 exit:
@@ -3953,11 +3963,11 @@  int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr)
 
 	if ((pmlmeinfo->state&0x03) != MSR_AP)
 		if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS))
-			return _SUCCESS;
+			return 0;
 
 	psta = rtw_get_stainfo23a(pstapriv, addr);
 	if (psta == NULL)
-		return _SUCCESS;
+		return 0;
 
 	if (initiator == 0) {  /*  recipient */
 		for (tid = 0; tid < MAXTID; tid++) {
@@ -3979,7 +3989,7 @@  int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr)
 			}
 		}
 	}
-	return _SUCCESS;
+	return 0;
 }
 
 int send_beacon23a(struct rtw_adapter *padapter)
@@ -4006,19 +4016,19 @@  int send_beacon23a(struct rtw_adapter *padapter)
 		 !padapter->bDriverStopped);
 
 	if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
-		return _FAIL;
+		return -ENODEV;
 
 	passing_time = jiffies_to_msecs(jiffies - start);
 
 	if (!bxmitok) {
 		DBG_8723A("%s fail! %u ms\n", __func__, passing_time);
-		return _FAIL;
+		return -EINVAL;
 	} else {
 
 		if (passing_time > 100 || issue > 3)
 			DBG_8723A("%s success, issue:%d, poll:%d, %u ms\n",
 				  __func__, issue, poll, passing_time);
-		return _SUCCESS;
+		return 0;
 	}
 }
 
@@ -4346,7 +4356,7 @@  static void start_create_ibss(struct rtw_adapter *padapter)
 		rtl8723a_set_media_status(padapter, pmlmeinfo->state & 0x3);
 
 		/* issue beacon */
-		if (send_beacon23a(padapter) == _FAIL) {
+		if (send_beacon23a(padapter) < 0) {
 			RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("issuing beacon frame fail....\n"));
 
 			report_join_res23a(padapter, -1);
@@ -4476,7 +4486,7 @@  int receive_disconnect23a(struct rtw_adapter *padapter,
 
 	/* check A3 */
 	if (!ether_addr_equal(MacAddr, get_my_bssid23a(&pmlmeinfo->network)))
-		return _SUCCESS;
+		return 0;
 
 	DBG_8723A("%s\n", __func__);
 
@@ -4491,7 +4501,7 @@  int receive_disconnect23a(struct rtw_adapter *padapter,
 		}
 	}
 
-	return _SUCCESS;
+	return 0;
 }
 
 static void process_80211d(struct rtw_adapter *padapter,
@@ -5120,7 +5130,7 @@  void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter,
 			rtw_correct_TSF(padapter);
 
 			/* start beacon */
-			if (send_beacon23a(padapter) != _SUCCESS) {
+			if (send_beacon23a(padapter) != 0) {
 				pmlmeinfo->FW_sta_info[psta->mac_id].status = 0;
 
 				pmlmeinfo->state ^= MSR_ADHOC;
@@ -5204,7 +5214,7 @@  void linked_status_chk23a(struct rtw_adapter *padapter)
 	if (is_client_associated_to_ap23a(padapter)) {
 		/* linked infrastructure client mode */
 
-		int tx_chk = _SUCCESS, rx_chk = _SUCCESS;
+		int tx_chk = 0, rx_chk = 0;
 		int rx_chk_limit;
 
 		rx_chk_limit = 4;
@@ -5215,13 +5225,13 @@  void linked_status_chk23a(struct rtw_adapter *padapter)
 			bool is_p2p_enable = false;
 
 			if (chk_ap_is_alive(padapter, psta) == false)
-				rx_chk = _FAIL;
+				rx_chk = -EINVAL;
 
 			if (pxmitpriv->last_tx_pkts == pxmitpriv->tx_pkts)
-				tx_chk = _FAIL;
+				tx_chk = -EINVAL;
 
 			if (pmlmeext->active_keep_alive_check &&
-			    (rx_chk == _FAIL || tx_chk == _FAIL)) {
+			    (rx_chk < 0 || tx_chk < 0)) {
 				u8 backup_oper_channel = 0;
 
 				/* switch to correct channel of current
@@ -5234,21 +5244,20 @@  void linked_status_chk23a(struct rtw_adapter *padapter)
 							 pmlmeext->cur_channel);
 				}
 
-				if (rx_chk != _SUCCESS)
+				if (rx_chk != 0)
 					issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, psta->hwaddr, 3, 1);
 
-				if ((tx_chk != _SUCCESS &&
+				if ((tx_chk != 0 &&
 				     pmlmeinfo->link_count++ == 0xf) ||
-				    rx_chk != _SUCCESS) {
+				    rx_chk != 0) {
 					tx_chk = issue_nulldata23a(padapter,
 								   psta->hwaddr,
 								   0, 3, 1);
 					/* if tx acked and p2p disabled,
-					   set rx_chk _SUCCESS to reset retry
+					   set rx_chk 0 to reset retry
 					   count */
-					if (tx_chk == _SUCCESS &&
-					    !is_p2p_enable)
-						rx_chk = _SUCCESS;
+					if (tx_chk == 0 && !is_p2p_enable)
+						rx_chk = 0;
 				}
 
 				/* back to the original operation channel */
@@ -5256,7 +5265,7 @@  void linked_status_chk23a(struct rtw_adapter *padapter)
 					SelectChannel23a(padapter,
 							 backup_oper_channel);
 			} else {
-				if (rx_chk != _SUCCESS) {
+				if (rx_chk != 0) {
 					if (pmlmeext->retry == 0) {
 						issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress);
 						issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress);
@@ -5264,14 +5273,14 @@  void linked_status_chk23a(struct rtw_adapter *padapter)
 					}
 				}
 
-				if (tx_chk != _SUCCESS &&
+				if (tx_chk != 0 &&
 				    pmlmeinfo->link_count++ == 0xf)
 					tx_chk = issue_nulldata23a(padapter,
 								   NULL, 0, 1,
 								   0);
 			}
 
-			if (rx_chk == _FAIL) {
+			if (rx_chk < 0) {
 				pmlmeext->retry++;
 				if (pmlmeext->retry > rx_chk_limit) {
 					DBG_8723A_LEVEL(_drv_always_,
@@ -5285,7 +5294,7 @@  void linked_status_chk23a(struct rtw_adapter *padapter)
 			} else
 				pmlmeext->retry = 0;
 
-			if (tx_chk == _FAIL)
+			if (tx_chk < 0)
 				pmlmeinfo->link_count &= 0xf;
 			else {
 				pxmitpriv->last_tx_pkts = pxmitpriv->tx_pkts;
@@ -6018,19 +6027,19 @@  int set_tx_beacon_cmd23a(struct rtw_adapter *padapter)
 	struct cmd_priv	*pcmdpriv = &padapter->cmdpriv;
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
-	u8 res = _SUCCESS;
+	int res = 0;
 	int len_diff = 0;
 
 	ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 	if (!ph2c) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
 	ptxBeacon_parm = kzalloc(sizeof(struct Tx_Beacon_param), GFP_ATOMIC);
 	if (!ptxBeacon_parm) {
 		kfree(ph2c);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -6097,7 +6106,7 @@  int h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 
 int tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
-	if (send_beacon23a(padapter) == _FAIL) {
+	if (send_beacon23a(padapter) < 0) {
 		DBG_8723A("issue_beacon23a, fail!\n");
 		return H2C_PARAMETERS_ERROR;
 	}