[OPW,kernel,v2,1/5] staging: rtl8723au: core: Replace non-standard return values
diff mbox

Message ID 1414607161-591-2-git-send-email-roberta.dobrescu@gmail.com
State New, archived
Headers show

Commit Message

Roberta Dobrescu Oct. 29, 2014, 6:25 p.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_ap.c        |  21 +-
 drivers/staging/rtl8723au/core/rtw_cmd.c       | 128 ++++++------
 drivers/staging/rtl8723au/core/rtw_efuse.c     |  26 +--
 drivers/staging/rtl8723au/core/rtw_ieee80211.c |  61 +++---
 drivers/staging/rtl8723au/core/rtw_mlme.c      |  40 ++--
 drivers/staging/rtl8723au/core/rtw_mlme_ext.c  | 275 +++++++++++++------------
 drivers/staging/rtl8723au/core/rtw_pwrctrl.c   |  20 +-
 drivers/staging/rtl8723au/core/rtw_recv.c      | 163 +++++++--------
 drivers/staging/rtl8723au/core/rtw_security.c  |  42 ++--
 drivers/staging/rtl8723au/core/rtw_sta_mgt.c   |  12 +-
 drivers/staging/rtl8723au/core/rtw_wlan_util.c |  31 ++-
 drivers/staging/rtl8723au/core/rtw_xmit.c      |  90 ++++----
 12 files changed, 446 insertions(+), 463 deletions(-)

Comments

Greg KH Oct. 29, 2014, 8:36 p.m. UTC | #1
On Wed, Oct 29, 2014 at 08:25:57PM +0200, Roberta Dobrescu wrote:
> 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_ap.c        |  21 +-
>  drivers/staging/rtl8723au/core/rtw_cmd.c       | 128 ++++++------
>  drivers/staging/rtl8723au/core/rtw_efuse.c     |  26 +--
>  drivers/staging/rtl8723au/core/rtw_ieee80211.c |  61 +++---
>  drivers/staging/rtl8723au/core/rtw_mlme.c      |  40 ++--
>  drivers/staging/rtl8723au/core/rtw_mlme_ext.c  | 275 +++++++++++++------------
>  drivers/staging/rtl8723au/core/rtw_pwrctrl.c   |  20 +-
>  drivers/staging/rtl8723au/core/rtw_recv.c      | 163 +++++++--------
>  drivers/staging/rtl8723au/core/rtw_security.c  |  42 ++--
>  drivers/staging/rtl8723au/core/rtw_sta_mgt.c   |  12 +-
>  drivers/staging/rtl8723au/core/rtw_wlan_util.c |  31 ++-
>  drivers/staging/rtl8723au/core/rtw_xmit.c      |  90 ++++----
>  12 files changed, 446 insertions(+), 463 deletions(-)

This really is too big of a single patch to review easily.  Can you
please break this up into smaller parts?

Take pity on a maintainer who has to deal with hundreds of patches a
day...

thanks,

greg k-h
Roberta Dobrescu Oct. 29, 2014, 9:01 p.m. UTC | #2
.
On 29.10.2014 22:36, Greg KH wrote:
> On Wed, Oct 29, 2014 at 08:25:57PM +0200, Roberta Dobrescu wrote:
>> 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_ap.c        |  21 +-
>>   drivers/staging/rtl8723au/core/rtw_cmd.c       | 128 ++++++------
>>   drivers/staging/rtl8723au/core/rtw_efuse.c     |  26 +--
>>   drivers/staging/rtl8723au/core/rtw_ieee80211.c |  61 +++---
>>   drivers/staging/rtl8723au/core/rtw_mlme.c      |  40 ++--
>>   drivers/staging/rtl8723au/core/rtw_mlme_ext.c  | 275 +++++++++++++------------
>>   drivers/staging/rtl8723au/core/rtw_pwrctrl.c   |  20 +-
>>   drivers/staging/rtl8723au/core/rtw_recv.c      | 163 +++++++--------
>>   drivers/staging/rtl8723au/core/rtw_security.c  |  42 ++--
>>   drivers/staging/rtl8723au/core/rtw_sta_mgt.c   |  12 +-
>>   drivers/staging/rtl8723au/core/rtw_wlan_util.c |  31 ++-
>>   drivers/staging/rtl8723au/core/rtw_xmit.c      |  90 ++++----
>>   12 files changed, 446 insertions(+), 463 deletions(-)
>
> This really is too big of a single patch to review easily.  Can you
> please break this up into smaller parts?

I thought that so, but I wasn't sure one what criteria should I do
that. Actually, patch 2 and 3 are also pretty big. It crossed my mind
that I can do a patch for each file, but then there would probably be
too many patches for a single patchset.

Can you give me some advice about this?

Thanks,
Roberta
Greg KH Oct. 29, 2014, 9:46 p.m. UTC | #3
On Wed, Oct 29, 2014 at 11:01:05PM +0200, Roberta Dobrescu wrote:
> .
> On 29.10.2014 22:36, Greg KH wrote:
> >On Wed, Oct 29, 2014 at 08:25:57PM +0200, Roberta Dobrescu wrote:
> >>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_ap.c        |  21 +-
> >>  drivers/staging/rtl8723au/core/rtw_cmd.c       | 128 ++++++------
> >>  drivers/staging/rtl8723au/core/rtw_efuse.c     |  26 +--
> >>  drivers/staging/rtl8723au/core/rtw_ieee80211.c |  61 +++---
> >>  drivers/staging/rtl8723au/core/rtw_mlme.c      |  40 ++--
> >>  drivers/staging/rtl8723au/core/rtw_mlme_ext.c  | 275 +++++++++++++------------
> >>  drivers/staging/rtl8723au/core/rtw_pwrctrl.c   |  20 +-
> >>  drivers/staging/rtl8723au/core/rtw_recv.c      | 163 +++++++--------
> >>  drivers/staging/rtl8723au/core/rtw_security.c  |  42 ++--
> >>  drivers/staging/rtl8723au/core/rtw_sta_mgt.c   |  12 +-
> >>  drivers/staging/rtl8723au/core/rtw_wlan_util.c |  31 ++-
> >>  drivers/staging/rtl8723au/core/rtw_xmit.c      |  90 ++++----
> >>  12 files changed, 446 insertions(+), 463 deletions(-)
> >
> >This really is too big of a single patch to review easily.  Can you
> >please break this up into smaller parts?
> 
> I thought that so, but I wasn't sure one what criteria should I do
> that. Actually, patch 2 and 3 are also pretty big. It crossed my mind
> that I can do a patch for each file, but then there would probably be
> too many patches for a single patchset.

One patch per file is good, if that is the best way to split this up.

As for "too many patches for a single patchset", I just applied two
different patch series to the staging tree, both of them over 30 patches
each.  Number of patches doesn't matter, as long as they are all easy to
review.

thanks,

greg k-h

Patch
diff mbox

diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c
index e394d12..c4c8b92 100644
--- a/drivers/staging/rtl8723au/core/rtw_ap.c
+++ b/drivers/staging/rtl8723au/core/rtw_ap.c
@@ -293,8 +293,7 @@  void	expire_timeout_chk23a(struct rtw_adapter *padapter)
 
 	/* issue null data to check sta alive*/
 	for (i = 0; i < chk_alive_num; i++) {
-
-		int ret = _FAIL;
+		int ret = -ETIMEDOUT;
 
 		psta = chk_alive_list[i];
 		if (!(psta->state & _FW_LINKED))
@@ -306,7 +305,7 @@  void	expire_timeout_chk23a(struct rtw_adapter *padapter)
 			ret = issue_nulldata23a(padapter, psta->hwaddr, 0, 3, 50);
 
 		psta->keep_alive_trycnt++;
-		if (ret == _SUCCESS) {
+		if (ret == 0) {
 			DBG_8723A("asoc check, sta(" MAC_FMT ") is alive\n", MAC_ARG(psta->hwaddr));
 			psta->expire_to = pstapriv->expire_to;
 			psta->keep_alive_trycnt = 0;
@@ -757,7 +756,7 @@  static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf)
 		update_beacon23a(padapter, WLAN_EID_TIM, NULL, false);
 
 		/* issue beacon frame */
-		if (send_beacon23a(padapter) == _FAIL)
+		if (send_beacon23a(padapter) < 0)
 			DBG_8723A("issue_beacon23a, fail!\n");
 	}
 
@@ -768,7 +767,7 @@  static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf)
 int rtw_check_beacon_data23a(struct rtw_adapter *padapter,
 			     struct ieee80211_mgmt *mgmt, unsigned int len)
 {
-	int ret = _SUCCESS;
+	int ret = 0;
 	u8 *p;
 	u8 *pHT_caps_ie = NULL;
 	u8 *pHT_info_ie = NULL;
@@ -800,10 +799,10 @@  int rtw_check_beacon_data23a(struct rtw_adapter *padapter,
 	DBG_8723A("%s, len =%d\n", __func__, len);
 
 	if (!check_fwstate(pmlmepriv, WIFI_AP_STATE))
-		return _FAIL;
+		return -EBUSY;
 
 	if (len > MAX_IE_SZ)
-		return _FAIL;
+		return -EINVAL;
 
 	pbss_network->IELength = len;
 
@@ -813,7 +812,7 @@  int rtw_check_beacon_data23a(struct rtw_adapter *padapter,
 
 	if (pbss_network->ifmode != NL80211_IFTYPE_AP &&
 	    pbss_network->ifmode != NL80211_IFTYPE_P2P_GO)
-		return _FAIL;
+		return -EOPNOTSUPP;
 
 	pbss_network->Rssi = 0;
 
@@ -880,7 +879,7 @@  int rtw_check_beacon_data23a(struct rtw_adapter *padapter,
 			  pbss_network->IELength);
 	if (p && ie_len > 0) {
 		if (rtw_parse_wpa2_ie23a(p, ie_len+2, &group_cipher,
-					 &pairwise_cipher, NULL) == _SUCCESS) {
+					 &pairwise_cipher, NULL) == 0) {
 			psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
 
 			psecuritypriv->dot8021xalg = 1;/* psk,  todo:802.1x */
@@ -902,7 +901,7 @@  int rtw_check_beacon_data23a(struct rtw_adapter *padapter,
 				  pbss_network->IELength - (ie_len + 2));
 		if ((p) && (!memcmp(p+2, RTW_WPA_OUI23A_TYPE, 4))) {
 			if (rtw_parse_wpa_ie23a(p, ie_len+2, &group_cipher,
-						&pairwise_cipher, NULL) == _SUCCESS) {
+						&pairwise_cipher, NULL) == 0) {
 				psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
 
 				/* psk,  todo:802.1x */
@@ -1013,7 +1012,7 @@  int rtw_check_beacon_data23a(struct rtw_adapter *padapter,
 					    pbss_network->MacAddress,
 					    GFP_KERNEL);
 		if (!psta)
-			return _FAIL;
+			return -ENOMEM;
 	}
 	/* fix bug of flush_cam_entry at STOP AP mode */
 	psta->state |= WIFI_AP_STATE;
diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c
index 424d96a..ca8effc 100644
--- a/drivers/staging/rtl8723au/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723au/core/rtw_cmd.c
@@ -170,17 +170,15 @@  No irqsave is necessary.
 
 int rtw_init_cmd_priv23a(struct cmd_priv *pcmdpriv)
 {
-	int res = _SUCCESS;
-
 	pcmdpriv->cmd_issued_cnt = 0;
 	pcmdpriv->cmd_done_cnt = 0;
 	pcmdpriv->rsp_cnt = 0;
 
 	pcmdpriv->wq = alloc_workqueue("rtl8723au_cmd", 0, 1);
 	if (!pcmdpriv->wq)
-		res = _FAIL;
+		return -ENOMEM;
 
-	return res;
+	return 0;
 }
 
 /* forward definition */
@@ -193,7 +191,7 @@  u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv)
 
 	INIT_WORK(&pevtpriv->irq_wk, rtw_irq_work);
 
-	return _SUCCESS;
+	return 0;
 }
 
 void rtw_free_evt_priv23a(struct evt_priv *pevtpriv)
@@ -210,23 +208,25 @@  static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
 		bAllow = true;
 
 	if (pcmdpriv->padapter->hw_init_completed == false && bAllow == false)
-		return _FAIL;
-	return _SUCCESS;
+		return -EINVAL;
+	return 0;
 }
 
 static void rtw_cmd_work(struct work_struct *work);
 
 int rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
 {
-	int res = _FAIL;
+	int res;
 
-	if (!cmd_obj)
+	if (!cmd_obj) {
+		res = -EINVAL;
 		goto exit;
+	}
 
 	cmd_obj->padapter = pcmdpriv->padapter;
 
 	res = rtw_cmd_filter(pcmdpriv, cmd_obj);
-	if (res == _FAIL) {
+	if (res < 0) {
 		rtw_free_cmd_obj23a(cmd_obj);
 		goto exit;
 	}
@@ -237,9 +237,10 @@  int rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
 
 	if (!res) {
 		printk(KERN_ERR "%s: Call to queue_work() failed\n", __func__);
-		res = _FAIL;
-	} else
-		res = _SUCCESS;
+		res = -EINVAL;
+	} else {
+		res = 0;
+	}
 exit:
 
 	return res;
@@ -278,7 +279,7 @@  static void rtw_cmd_work(struct work_struct *work)
 
 	pcmdpriv = &pcmd->padapter->cmdpriv;
 
-	if (rtw_cmd_filter(pcmdpriv, pcmd) == _FAIL) {
+	if (rtw_cmd_filter(pcmdpriv, pcmd) < 0) {
 		pcmd->res = H2C_DROPPED;
 		goto post_process;
 	}
@@ -326,7 +327,7 @@  int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter,
 			  struct cfg80211_ssid *ssid, int ssid_num,
 			  struct rtw_ieee80211_channel *ch, int ch_num)
 {
-	int res = _FAIL;
+	int res;
 	struct cmd_obj *ph2c;
 	struct sitesurvey_parm *psurveyPara;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
@@ -337,12 +338,12 @@  int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter,
 
 	ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 	if (!ph2c)
-		return _FAIL;
+		return -ENOMEM;
 
 	psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC);
 	if (!psurveyPara) {
 		kfree(ph2c);
-		return _FAIL;
+		return -ENOMEM;
 	}
 
 	rtw_free_network_queue23a(padapter);
@@ -387,7 +388,7 @@  int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter,
 
 	res = rtw_enqueue_cmd23a(pcmdpriv, ph2c);
 
-	if (res == _SUCCESS) {
+	if (res == 0) {
 		mod_timer(&pmlmepriv->scan_to_timer, jiffies +
 			  msecs_to_jiffies(SCANNING_TIMEOUT));
 
@@ -413,7 +414,7 @@  int rtw_createbss_cmd23a(struct rtw_adapter  *padapter)
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 	struct wlan_bssid_ex *pdev_network;
-	u8 res = _SUCCESS;
+	int res = 0;
 
 	pdev_network = &padapter->registrypriv.dev_network;
 
@@ -431,7 +432,7 @@  int rtw_createbss_cmd23a(struct rtw_adapter  *padapter)
 
 	pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 	if (!pcmd) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -453,7 +454,7 @@  exit:
 int rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
 		       struct wlan_network *pnetwork)
 {
-	int res = _SUCCESS;
+	int res = 0;
 	struct wlan_bssid_ex *psecnetwork;
 	struct cmd_obj *pcmd;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
@@ -480,7 +481,7 @@  int rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
 
 	pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 	if (!pcmd) {
-		res = _FAIL;
+		res = -ENOMEM;
 		RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
 			 ("rtw_joinbss_cmd23a: memory allocate for cmd_obj "
 			  "fail!!!\n"));
@@ -505,11 +506,9 @@  int rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
 	psecnetwork = &psecuritypriv->sec_bss;
 	if (!psecnetwork) {
 		kfree(pcmd);
-		res = _FAIL;
-
+		res = -EINVAL;
 		RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
 			 ("rtw_joinbss_cmd23a :psecnetwork == NULL!!!\n"));
-
 		goto exit;
 	}
 
@@ -597,7 +596,6 @@  int rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
 
 	res = rtw_enqueue_cmd23a(pcmdpriv, pcmd);
 exit:
-
 	return res;
 }
 
@@ -607,7 +605,7 @@  int rtw_disassoc_cmd23a(struct rtw_adapter*padapter, u32 deauth_timeout_ms,
 	struct cmd_obj *cmdobj = NULL;
 	struct disconnect_parm *param = NULL;
 	struct cmd_priv *cmdpriv = &padapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_,
 		 ("+rtw_disassoc_cmd23a\n"));
@@ -615,7 +613,7 @@  int rtw_disassoc_cmd23a(struct rtw_adapter*padapter, u32 deauth_timeout_ms,
 	/* prepare cmd parameter */
 	param = kzalloc(sizeof(*param), GFP_ATOMIC);
 	if (param == NULL) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 	param->deauth_timeout_ms = deauth_timeout_ms;
@@ -624,7 +622,7 @@  int rtw_disassoc_cmd23a(struct rtw_adapter*padapter, u32 deauth_timeout_ms,
 		/* need enqueue, prepare cmd_obj and enqueue */
 		cmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 		if (!cmdobj) {
-			res = _FAIL;
+			res = -ENOMEM;
 			kfree(param);
 			goto exit;
 		}
@@ -634,7 +632,7 @@  int rtw_disassoc_cmd23a(struct rtw_adapter*padapter, u32 deauth_timeout_ms,
 		/* no need to enqueue, do the cmd hdl directly and
 		   free cmd parameter */
 		if (H2C_SUCCESS != disconnect_hdl23a(padapter, (u8 *)param))
-			res = _FAIL;
+			res = -EINVAL;
 		kfree(param);
 	}
 
@@ -648,7 +646,7 @@  int rtw_setopmode_cmd23a(struct rtw_adapter *padapter,
 	struct	cmd_obj *ph2c;
 	struct	setopmode_parm *psetop;
 	struct	cmd_priv   *pcmdpriv = &padapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
 	if (!ph2c) {
@@ -680,18 +678,18 @@  int rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key)
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 	struct security_priv *psecuritypriv = &padapter->securitypriv;
 	struct sta_info *sta = (struct sta_info *)psta;
-	int res = _SUCCESS;
+	int res = 0;
 
 	ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
 	if (!ph2c) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
 	psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL);
 	if (!psetstakey_para) {
 		kfree(ph2c);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -699,7 +697,7 @@  int rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key)
 	if (!psetstakey_rsp) {
 		kfree(ph2c);
 		kfree(psetstakey_para);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -744,14 +742,14 @@  int rtw_clearstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 entry,
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
 	struct set_stakey_rsp *psetstakey_rsp = NULL;
 	struct sta_info *sta = (struct sta_info *)psta;
-	int res = _SUCCESS;
+	int res = 0;
 
 	if (!enqueue) {
 		clear_cam_entry23a(padapter, entry);
 	} else {
 		ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
 		if (!ph2c) {
-			res = _FAIL;
+			res = -ENOMEM;
 			goto exit;
 		}
 
@@ -759,7 +757,7 @@  int rtw_clearstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 entry,
 					  GFP_KERNEL);
 		if (!psetstakey_para) {
 			kfree(ph2c);
-			res = _FAIL;
+			res = -ENOMEM;
 			goto exit;
 		}
 
@@ -768,7 +766,7 @@  int rtw_clearstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 entry,
 		if (!psetstakey_rsp) {
 			kfree(ph2c);
 			kfree(psetstakey_para);
-			res = _FAIL;
+			res = -ENOMEM;
 			goto exit;
 		}
 
@@ -794,23 +792,23 @@  int rtw_addbareq_cmd23a(struct rtw_adapter*padapter, u8 tid, u8 *addr)
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
 	struct cmd_obj *ph2c;
 	struct addBaReq_parm *paddbareq_parm;
-	int res = _SUCCESS;
+	int res = 0;
 
 	if (tid >= MAXTID) {
-		res = _FAIL;
+		res = -EINVAL;
 		goto exit;
 	}
 
 	ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 	if (!ph2c) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
 	paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_ATOMIC);
 	if (!paddbareq_parm) {
 		kfree(ph2c);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -830,18 +828,18 @@  int rtw_dynamic_chk_wk_cmd23a(struct rtw_adapter*padapter)
 	struct cmd_obj *ph2c;
 	struct drvextra_cmd_parm *pdrvextra_cmd_parm;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 	if (!ph2c) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
 	pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC);
 	if (!pdrvextra_cmd_parm) {
 		kfree(ph2c);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -868,7 +866,7 @@  int rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset,
 	struct cmd_obj *pcmdobj;
 	struct set_ch_parm *set_ch_parm;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	DBG_8723A("%s(%s): ch:%u, bw:%u, ch_offset:%u\n", __func__,
 		  padapter->pnetdev->name, ch, bw, ch_offset);
@@ -878,7 +876,7 @@  int rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset,
 	/* prepare cmd parameter */
 	set_ch_parm = kzalloc(sizeof(*set_ch_parm), GFP_KERNEL);
 	if (!set_ch_parm) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 	set_ch_parm->ch = ch;
@@ -890,7 +888,7 @@  int rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset,
 		pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
 		if (!pcmdobj) {
 			kfree(set_ch_parm);
-			res = _FAIL;
+			res = -ENOMEM;
 			goto exit;
 		}
 
@@ -901,7 +899,7 @@  int rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset,
 		/* no need to enqueue, do the cmd hdl directly and
 		   free cmd parameter */
 		if (H2C_SUCCESS != set_ch_hdl23a(padapter, (u8 *)set_ch_parm))
-			res = _FAIL;
+			res = -EINVAL;
 
 		kfree(set_ch_parm);
 	}
@@ -1068,12 +1066,12 @@  int rtw_lps_ctrl_wk_cmd23a(struct rtw_adapter *padapter,
 	struct cmd_obj *ph2c;
 	struct drvextra_cmd_parm *pdrvextra_cmd_parm;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	if (enqueue) {
 		ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 		if (!ph2c) {
-			res = _FAIL;
+			res = -ENOMEM;
 			goto exit;
 		}
 
@@ -1081,7 +1079,7 @@  int rtw_lps_ctrl_wk_cmd23a(struct rtw_adapter *padapter,
 					     GFP_ATOMIC);
 		if (!pdrvextra_cmd_parm) {
 			kfree(ph2c);
-			res = _FAIL;
+			res = -ENOMEM;
 			goto exit;
 		}
 
@@ -1105,19 +1103,18 @@  int rtw_ps_cmd23a(struct rtw_adapter*padapter)
 	struct cmd_obj *ppscmd;
 	struct drvextra_cmd_parm *pdrvextra_cmd_parm;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	ppscmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 	if (!ppscmd) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
-
 	pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm),
 				     GFP_ATOMIC);
 	if (!pdrvextra_cmd_parm) {
 		kfree(ppscmd);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -1175,11 +1172,11 @@  int rtw_chk_hi_queue_cmd23a(struct rtw_adapter*padapter)
 	struct cmd_obj *ph2c;
 	struct drvextra_cmd_parm *pdrvextra_cmd_parm;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 	if (!ph2c) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -1187,7 +1184,7 @@  int rtw_chk_hi_queue_cmd23a(struct rtw_adapter*padapter)
 				     GFP_ATOMIC);
 	if (!pdrvextra_cmd_parm) {
 		kfree(ph2c);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -1210,11 +1207,11 @@  int rtw_c2h_wk_cmd23a(struct rtw_adapter *padapter, u8 *c2h_evt)
 	struct cmd_obj *ph2c;
 	struct drvextra_cmd_parm *pdrvextra_cmd_parm;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 	if (!ph2c) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -1222,7 +1219,7 @@  int rtw_c2h_wk_cmd23a(struct rtw_adapter *padapter, u8 *c2h_evt)
 				     GFP_ATOMIC);
 	if (!pdrvextra_cmd_parm) {
 		kfree(ph2c);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -1242,12 +1239,13 @@  exit:
 
 static int c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt)
 {
-	int ret = _FAIL;
+	int ret;
 	u8 buf[16];
 
 	if (!c2h_evt) {
 		/* No c2h event in cmd_obj, read c2h event before handling*/
-		if (c2h_evt_read23a(adapter, buf) == _SUCCESS) {
+		ret = -EINVAL;
+		if (c2h_evt_read23a(adapter, buf) == 0) {
 			c2h_evt = (struct c2h_evt_hdr *)buf;
 
 			ret = c2h_handler_8723a(adapter, c2h_evt);
diff --git a/drivers/staging/rtl8723au/core/rtw_efuse.c b/drivers/staging/rtl8723au/core/rtw_efuse.c
index 799b9cf..8768f67 100644
--- a/drivers/staging/rtl8723au/core/rtw_efuse.c
+++ b/drivers/staging/rtl8723au/core/rtw_efuse.c
@@ -396,10 +396,10 @@  efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data)
 		tmpidx++;
 	if (tmpidx < 100) {
 		*data = rtl8723au_read8(pAdapter, EFUSE_CTRL);
-		bResult = _SUCCESS;
+		bResult = 0;
 	} else {
 		*data = 0xff;
-		bResult = _FAIL;
+		bResult = -EFAULT;
 	}
 	return bResult;
 }
@@ -430,9 +430,9 @@  efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data)
 	}
 
 	if (tmpidx < 100)
-		bResult = _SUCCESS;
+		bResult = 0;
 	else
-		bResult = _FAIL;
+		bResult = -EFAULT;
 
 	return bResult;
 }
@@ -495,7 +495,7 @@  int rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr,
 {
 	int i = 0;
 	u16 real_content_len = 0, max_available_size = 0;
-	int res = _FAIL ;
+	int res;
 	int (*rw8)(struct rtw_adapter *, u16, u8*);
 
 	EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI,
@@ -506,11 +506,11 @@  int rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr,
 				 (void *)&max_available_size);
 
 	if (start_addr > real_content_len)
-		return _FAIL;
+		return -EINVAL;
 
 	if (true == bWrite) {
 		if ((start_addr + cnts) > max_available_size)
-			return _FAIL;
+			return -EINVAL;
 		rw8 = &efuse_write8;
 	} else
 		rw8 = &efuse_read8;
@@ -520,12 +520,12 @@  int rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr,
 	/*  e-fuse one byte read / write */
 	for (i = 0; i < cnts; i++) {
 		if (start_addr >= real_content_len) {
-			res = _FAIL;
+			res = -EINVAL;
 			break;
 		}
 
 		res = rw8(padapter, start_addr++, data++);
-		if (res == _FAIL)
+		if (res < 0)
 			break;
 	}
 
@@ -552,7 +552,7 @@  int rtw_efuse_map_read23a(struct rtw_adapter *padapter,
 				 TYPE_EFUSE_MAP_LEN, (void *)&mapLen);
 
 	if ((addr + cnts) > mapLen)
-		return _FAIL;
+		return -EINVAL;
 
 	Efuse_PowerSwitch(padapter, false, true);
 
@@ -560,7 +560,7 @@  int rtw_efuse_map_read23a(struct rtw_adapter *padapter,
 
 	Efuse_PowerSwitch(padapter, false, false);
 
-	return _SUCCESS;
+	return 0;
 }
 
 int rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter,
@@ -572,7 +572,7 @@  int rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter,
 				 TYPE_EFUSE_MAP_LEN, (void *)&mapLen);
 
 	if ((addr + cnts) > mapLen)
-		return _FAIL;
+		return -EINVAL;
 
 	Efuse_PowerSwitch(padapter, false, true);
 
@@ -580,7 +580,7 @@  int rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter,
 
 	Efuse_PowerSwitch(padapter, false, false);
 
-	return _SUCCESS;
+	return 0;
 }
 
 /*-----------------------------------------------------------------------------
diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c
index bbbcfc8..bda6b75 100644
--- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c
@@ -256,19 +256,21 @@  u8 *rtw_get_ie23a_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len,
  * @oui: OUI to match
  * @oui_len: OUI length
  *
- * Returns: _SUCCESS: ies is updated, _FAIL: not updated
+ * Returns: 0: ies is updated, negative value: not updated
  */
 int rtw_ies_remove_ie23a(u8 *ies, uint *ies_len, uint offset, u8 eid,
 		      u8 *oui, u8 oui_len)
 {
-	int ret = _FAIL;
+	int ret = -EINVAL;
 	u8 *target_ie;
 	u32 target_ielen;
 	u8 *start;
 	uint search_len;
 
-	if (!ies || !ies_len || *ies_len <= offset)
+	if (!ies || !ies_len || *ies_len <= offset) {
+		ret = -EINVAL;
 		goto exit;
+	}
 
 	start = ies + offset;
 	search_len = *ies_len - offset;
@@ -284,7 +286,7 @@  int rtw_ies_remove_ie23a(u8 *ies, uint *ies_len, uint offset, u8 eid,
 			memcpy(buf, remain_ies, remain_len);
 			memcpy(target_ie, buf, remain_len);
 			*ies_len = *ies_len - target_ielen;
-			ret = _SUCCESS;
+			ret = 0;
 
 			start = target_ie;
 			search_len = remain_len;
@@ -405,10 +407,6 @@  int rtw_generate_ie23a(struct registry_priv *pregistrypriv)
 				(pdev_network->SupportedRates + 8), &sz);
 	}
 
-
-
-	/* return _SUCCESS; */
-
 	return sz;
 }
 
@@ -446,17 +444,16 @@  static int rtw_get_wpa2_cipher_suite(const u8 *s)
 
 int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x)
 {
-	int i, ret = _SUCCESS;
+	int i;
 	int left, count;
 	const u8 *pos;
 
-	if (wpa_ie_len <= 0) {
+	if (wpa_ie_len <= 0)
 		/* No WPA IE - fail silently */
-		return _FAIL;
-	}
+		return -EINVAL;
 
 	if (wpa_ie[1] != (u8)(wpa_ie_len - 2))
-		return _FAIL;
+		return -EINVAL;
 
 	pos = wpa_ie;
 
@@ -475,7 +472,7 @@  int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int
 			 ("%s: ie length mismatch, %u too much",
 			  __func__, left));
 
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	/* pairwise_cipher */
@@ -490,7 +487,7 @@  int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int
 				 ("%s: ie count botch (pairwise), "
 				  "count %u left %u", __func__,
 				  count, left));
-			return _FAIL;
+			return -EINVAL;
 		}
 
 		for (i = 0; i < count; i++) {
@@ -502,7 +499,7 @@  int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int
 	} else if (left == 1) {
 		RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
 			 ("%s: ie too short (for key mgmt)", __func__));
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	if (is_8021x) {
@@ -517,25 +514,23 @@  int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int
 		}
 	}
 
-	return ret;
+	return 0;
 }
 
 int rtw_parse_wpa2_ie23a(const u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
 		      int *pairwise_cipher, int *is_8021x)
 {
-	int i, ret = _SUCCESS;
+	int i;
 	int left, count;
 	const u8 *pos;
 	u8 SUITE_1X[4] = {0x00, 0x0f, 0xac, 0x01};
 
-	if (rsn_ie_len <= 0) {
+	if (rsn_ie_len <= 0)
 		/* No RSN IE - fail silently */
-		return _FAIL;
-	}
+		return -EINVAL;
 
-	if (*rsn_ie != WLAN_EID_RSN || *(rsn_ie+1) != (u8)(rsn_ie_len - 2)) {
-		return _FAIL;
-	}
+	if (*rsn_ie != WLAN_EID_RSN || *(rsn_ie+1) != (u8)(rsn_ie_len - 2))
+		return -EINVAL;
 
 	pos = rsn_ie;
 	pos += 4;
@@ -551,7 +546,7 @@  int rtw_parse_wpa2_ie23a(const u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
 		RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
 			 ("%s: ie length mismatch, %u too much",
 			  __func__, left));
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	/* pairwise_cipher */
@@ -566,7 +561,7 @@  int rtw_parse_wpa2_ie23a(const u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
 				 ("%s: ie count botch (pairwise), "
 				  "count %u left %u",
 				  __func__, count, left));
-			return _FAIL;
+			return -EINVAL;
 		}
 
 		for (i = 0; i < count; i++) {
@@ -579,7 +574,7 @@  int rtw_parse_wpa2_ie23a(const u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
 		RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
 			 ("%s: ie too short (for key mgmt)",  __func__));
 
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	if (is_8021x) {
@@ -594,7 +589,7 @@  int rtw_parse_wpa2_ie23a(const u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
 		}
 	}
 
-	return ret;
+	return 0;
 }
 
 /**
@@ -688,7 +683,7 @@  static int rtw_get_cipher_info(struct wlan_network *pnetwork)
 {
 	const u8 *pbuf;
 	int group_cipher = 0, pairwise_cipher = 0, is8021x = 0;
-	int ret = _FAIL;
+	int ret = -EINVAL;
 	int r, plen;
 	char *pie;
 
@@ -703,7 +698,7 @@  static int rtw_get_cipher_info(struct wlan_network *pnetwork)
 			 ("rtw_get_cipher_info: wpa_ielen: %d", pbuf[1]));
 		r = rtw_parse_wpa_ie23a(pbuf, pbuf[1] + 2, &group_cipher,
 				     &pairwise_cipher, &is8021x);
-		if (r == _SUCCESS) {
+		if (r == 0) {
 			pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher;
 			pnetwork->BcnInfo.group_cipher = group_cipher;
 			pnetwork->BcnInfo.is_8021x = is8021x;
@@ -712,7 +707,7 @@  static int rtw_get_cipher_info(struct wlan_network *pnetwork)
 				  "8021x is %d", __func__,
 				  pnetwork->BcnInfo.pairwise_cipher,
 				  pnetwork->BcnInfo.is_8021x));
-			ret = _SUCCESS;
+			ret = 0;
 		}
 	} else {
 		pbuf = cfg80211_find_ie(WLAN_EID_RSN, pie, plen);
@@ -723,7 +718,7 @@  static int rtw_get_cipher_info(struct wlan_network *pnetwork)
 			r = rtw_parse_wpa2_ie23a(pbuf, pbuf[1] + 2,
 					      &group_cipher, &pairwise_cipher,
 					      &is8021x);
-			if (r == _SUCCESS) {
+			if (r == 0) {
 				RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
 					 ("get RSN IE  OK!!!\n"));
 				pnetwork->BcnInfo.pairwise_cipher =
@@ -737,7 +732,7 @@  static int rtw_get_cipher_info(struct wlan_network *pnetwork)
 					  pnetwork->BcnInfo.pairwise_cipher,
 					  pnetwork->BcnInfo.group_cipher,
 					  pnetwork->BcnInfo.is_8021x));
-				ret = _SUCCESS;
+				ret = 0;
 			}
 		}
 	}
diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c
index 85d1eca..8a7d577 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme.c
@@ -67,7 +67,7 @@  int rtw_init_mlme_priv23a(struct rtw_adapter *padapter)
 	rtw_clear_scan_deny(padapter);
 
 	rtw_init_mlme_timer(padapter);
-	return _SUCCESS;
+	return 0;
 }
 
 #ifdef CONFIG_8723AU_AP_MODE
@@ -249,7 +249,7 @@  static void _rtw_roaming(struct rtw_adapter *padapter,
 
 		while (1) {
 			do_join_r = rtw_do_join(padapter);
-			if (do_join_r == _SUCCESS)
+			if (do_join_r == 0)
 				break;
 			else {
 				DBG_8723A("roaming do_join return %d\n",
@@ -680,13 +680,13 @@  rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
 		if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
 			ret = rtw_select_and_join_from_scanned_queue23a(
 				pmlmepriv);
-			if (ret != _SUCCESS)
+			if (ret != 0)
 				rtw_do_join_adhoc(adapter);
 		} else {
 			pmlmepriv->to_join = false;
 			ret = rtw_select_and_join_from_scanned_queue23a(
 				pmlmepriv);
-			if (ret != _SUCCESS) {
+			if (ret != 0) {
 				DBG_8723A("try_to_join, but select scanning "
 					  "queue fail, to_roaming:%d\n",
 					  adapter->mlmepriv.to_roaming);
@@ -695,7 +695,7 @@  rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
 					    rtw_sitesurvey_cmd23a(
 						    adapter,
 						    &pmlmepriv->assoc_ssid, 1,
-						    NULL, 0) != _SUCCESS) {
+						    NULL, 0) != 0) {
 						rtw_set_roaming(adapter, 0);
 						rtw_free_assoc_resources23a(
 							adapter, 1);
@@ -1432,7 +1432,7 @@  void rtw23a_join_to_handler (unsigned long data)
 				/* try another */
 				DBG_8723A("%s try another roaming\n", __func__);
 				do_join_r = rtw_do_join(adapter);
-				if (do_join_r != _SUCCESS) {
+				if (do_join_r != 0) {
 					DBG_8723A("%s roaming do_join return "
 						  "%d\n", __func__ , do_join_r);
 					continue;
@@ -1625,19 +1625,19 @@  static int rtw_do_join(struct rtw_adapter *padapter)
 	pmlmepriv->to_join = true;
 
 	ret = rtw_select_and_join_from_scanned_queue23a(pmlmepriv);
-	if (ret == _SUCCESS) {
+	if (ret == 0) {
 		pmlmepriv->to_join = false;
 	} else {
 		if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
 			/* switch to ADHOC_MASTER */
 			ret = rtw_do_join_adhoc(padapter);
-			if (ret != _SUCCESS)
+			if (ret != 0)
 				goto exit;
 		} else {
 			/*  can't associate ; reset under-linking */
 			_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
 
-			ret = _FAIL;
+			ret = -EOPNOTSUPP;
 			pmlmepriv->to_join = false;
 		}
 	}
@@ -1698,7 +1698,7 @@  int rtw_do_join_adhoc(struct rtw_adapter *adapter)
 	pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
 
 	ret = rtw_createbss_cmd23a(adapter);
-	if (ret != _SUCCESS) {
+	if (ret != 0) {
 		RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
 			 ("Error =>rtw_createbss_cmd23a status FAIL\n"));
 	} else  {
@@ -1725,7 +1725,7 @@  int rtw_do_join_network(struct rtw_adapter *adapter,
 
 	ret = rtw_joinbss_cmd23a(adapter, candidate);
 
-	if (ret == _SUCCESS)
+	if (ret == 0)
 		mod_timer(&adapter->mlmepriv.assoc_timer,
 			  jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
 
@@ -1743,7 +1743,7 @@  int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv)
 	candidate = rtw_select_candidate_from_queue(pmlmepriv);
 	if (!candidate) {
 		DBG_8723A("%s: return _FAIL(candidate == NULL)\n", __func__);
-		ret = _FAIL;
+		ret = -EINVAL;
 		goto exit;
 	} else {
 		DBG_8723A("%s: candidate: %s("MAC_FMT", ch:%u)\n", __func__,
@@ -1764,18 +1764,18 @@  int rtw_set_auth23a(struct rtw_adapter *adapter,
 	struct cmd_obj *pcmd;
 	struct setauth_parm *psetauthparm;
 	struct cmd_priv *pcmdpriv = &adapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
 	if (!pcmd) {
-		res = _FAIL;  /* try again */
+		res = -ENOMEM;  /* try again */
 		goto exit;
 	}
 
 	psetauthparm = kzalloc(sizeof(struct setauth_parm), GFP_KERNEL);
 	if (!psetauthparm) {
 		kfree(pcmd);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -1806,22 +1806,22 @@  int rtw_set_key23a(struct rtw_adapter *adapter,
 	struct setkey_parm *psetkeyparm;
 	struct cmd_priv *pcmdpriv = &adapter->cmdpriv;
 	struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	if (keyid >= 4) {
-		res = _FAIL;
+		res = -EINVAL;
 		goto exit;
 	}
 
 	pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
 	if (!pcmd) {
-		res = _FAIL;  /* try again */
+		res = -ENOMEM;  /* try again */
 		goto exit;
 	}
 	psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL);
 	if (!psetkeyparm) {
 		kfree(pcmd);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -1879,7 +1879,7 @@  int rtw_set_key23a(struct rtw_adapter *adapter,
 			 ("\n rtw_set_key23a:psecuritypriv->dot11PrivacyAlgrthm"
 			  " = %x (must be 1 or 2 or 4 or 5)\n",
 			  psecuritypriv->dot11PrivacyAlgrthm));
-		res = _FAIL;
+		res = -EINVAL;
 		kfree(pcmd);
 		kfree(psetkeyparm);
 		goto exit;
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;
 	}
diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c
index e2d51af..a6e7091 100644
--- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c
@@ -58,7 +58,7 @@  int ips_leave23a(struct rtw_adapter *padapter)
 	struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
 	struct security_priv *psecuritypriv = &padapter->securitypriv;
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-	int result = _SUCCESS;
+	int result = 0;
 	int keyid;
 
 	down(&pwrpriv->lock);
@@ -71,7 +71,7 @@  int ips_leave23a(struct rtw_adapter *padapter)
 			  pwrpriv->ips_leave23a_cnts);
 
 		result = rtw_ips_pwr_up23a(padapter);
-		if (result == _SUCCESS)
+		if (result == 0)
 			pwrpriv->rf_pwrstate = rf_on;
 
 		DBG_8723A_LEVEL(_drv_always_, "nolinked power save leave\n");
@@ -477,14 +477,14 @@  inline void rtw_set_ips_deny23a(struct rtw_adapter *padapter, u32 ms)
 * rtw_pwr_wakeup - Wake the NIC up from: 1)IPS. 2)USB autosuspend
 * @adapter: pointer to _adapter structure
 * @ips_deffer_ms: the ms will prevent from falling into IPS after wakeup
-* Return _SUCCESS or _FAIL
+* Return 0 for success or negative value for failure
 */
 
 int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const char *caller)
 {
 	struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-	int ret = _SUCCESS;
+	int ret = 0;
 	unsigned long start = jiffies;
 	unsigned long new_deny_time;
 
@@ -530,21 +530,21 @@  int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch
 
 	/* System suspend is not allowed to wakeup */
 	if (pwrpriv->bInSuspend) {
-		ret = _FAIL;
+		ret = -EPERM;
 		goto exit;
 	}
 
 	/* I think this should be check in IPS, LPS, autosuspend functions... */
 	if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-		ret = _SUCCESS;
+		ret = 0;
 		goto exit;
 	}
 
 	if (rf_off == pwrpriv->rf_pwrstate) {
 		DBG_8723A("%s call ips_leave23a....\n", __func__);
-		if (ips_leave23a(padapter)== _FAIL) {
+		ret = ips_leave23a(padapter);
+		if (ret < 0) {
 			DBG_8723A("======> ips_leave23a fail.............\n");
-			ret = _FAIL;
 			goto exit;
 		}
 	}
@@ -555,7 +555,7 @@  int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch
 		DBG_8723A("%s: bDriverStopped =%d, bup =%d, hw_init_completed "
 			  "=%u\n", caller, padapter->bDriverStopped,
 			  padapter->bup, padapter->hw_init_completed);
-		ret = _FAIL;
+		ret = -EINVAL;
 		goto exit;
 	}
 
@@ -599,7 +599,7 @@  int rtw_pm_set_ips23a(struct rtw_adapter *padapter, u8 mode)
 	if (mode == IPS_NONE) {
 		DBG_8723A("%s %s\n", __func__, "IPS_NONE");
 		if (padapter->bSurpriseRemoved == 0 &&
-		    rtw_pwr_wakeup(padapter) == _FAIL)
+		    rtw_pwr_wakeup(padapter) < 0)
 			return -EFAULT;
 	}
 
diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c
index de98da5..29d4bc6 100644
--- a/drivers/staging/rtl8723au/core/rtw_recv.c
+++ b/drivers/staging/rtl8723au/core/rtw_recv.c
@@ -47,7 +47,7 @@  int _rtw_init_recv_priv23a(struct recv_priv *precvpriv,
 {
 	struct recv_frame *precvframe;
 	int i;
-	int res = _SUCCESS;
+	int res = 0;
 
 	spin_lock_init(&precvpriv->lock);
 
@@ -159,9 +159,7 @@  int rtw_free_recvframe23a(struct recv_frame *precvframe)
 
 	spin_unlock_bh(&pfree_recv_queue->lock);
 
-
-
-	return _SUCCESS;
+	return 0;
 }
 
 int rtw_enqueue_recvframe23a(struct recv_frame *precvframe, struct rtw_queue *queue)
@@ -182,7 +180,7 @@  int rtw_enqueue_recvframe23a(struct recv_frame *precvframe, struct rtw_queue *qu
 
 	spin_unlock_bh(&queue->lock);
 
-	return _SUCCESS;
+	return 0;
 }
 
 /*
@@ -234,7 +232,7 @@  int rtw_enqueue_recvbuf23a_to_head(struct recv_buf *precvbuf, struct rtw_queue *
 
 	spin_unlock_bh(&queue->lock);
 
-	return _SUCCESS;
+	return 0;
 }
 
 int rtw_enqueue_recvbuf23a(struct recv_buf *precvbuf, struct rtw_queue *queue)
@@ -247,7 +245,7 @@  int rtw_enqueue_recvbuf23a(struct recv_buf *precvbuf, struct rtw_queue *queue)
 
 	list_add_tail(&precvbuf->list, get_list_head(queue));
 	spin_unlock_irqrestore(&queue->lock, irqL);
-	return _SUCCESS;
+	return 0;
 }
 
 struct recv_buf *rtw_dequeue_recvbuf23a (struct rtw_queue *queue)
@@ -280,7 +278,7 @@  int recvframe_chkmic(struct rtw_adapter *adapter,
 int recvframe_chkmic(struct rtw_adapter *adapter,
 		     struct recv_frame *precvframe) {
 
-	int	i, res = _SUCCESS;
+	int	i, res = 0;
 	u32	datalen;
 	u8	miccode[8];
 	u8	bmic_err = false, brpt_micerror = true;
@@ -315,7 +313,7 @@  int recvframe_chkmic(struct rtw_adapter *adapter,
 					 ("\n recvframe_chkmic: bcmc key\n"));
 
 				if (!psecuritypriv->binstallGrpkey) {
-					res = _FAIL;
+					res = -EINVAL;
 					RT_TRACE(_module_rtl871x_recv_c_,
 						 _drv_err_,
 						 ("\n recvframe_chkmic:didn't "
@@ -441,7 +439,7 @@  int recvframe_chkmic(struct rtw_adapter *adapter,
 						  prxattrib->bdecrypted);
 				}
 
-				res = _FAIL;
+				res = -EINVAL;
 			} else {
 				/* mic checked ok */
 				if (!psecuritypriv->bcheck_grpkey &&
@@ -463,9 +461,6 @@  int recvframe_chkmic(struct rtw_adapter *adapter,
 	}
 
 exit:
-
-
-
 	return res;
 }
 
@@ -478,7 +473,7 @@  struct recv_frame *decryptor(struct rtw_adapter *padapter,
 	struct rx_pkt_attrib *prxattrib = &precv_frame->attrib;
 	struct security_priv *psecuritypriv = &padapter->securitypriv;
 	struct recv_frame *return_packet = precv_frame;
-	int res = _SUCCESS;
+	int res = 0;
 
 	RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
 		 ("prxstat->decrypted =%x prxattrib->encrypt = 0x%03x\n",
@@ -531,13 +526,11 @@  struct recv_frame *decryptor(struct rtw_adapter *padapter,
 			psecuritypriv->hw_decrypted = 1;
 	}
 
-	if (res == _FAIL) {
+	if (res < 0) {
 		rtw_free_recvframe23a(return_packet);
 		return_packet = NULL;
 	}
 
-
-
 	return return_packet;
 }
 
@@ -636,14 +629,12 @@  int recv_decache(struct recv_frame *precv_frame, u8 bretry,
 	u16 seq_ctrl = ((precv_frame->attrib.seq_num & 0xffff) << 4) |
 		(precv_frame->attrib.frag_num & 0xf);
 
-
-
 	if (tid > 15) {
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_,
 			 ("recv_decache, (tid>15)! seq_ctrl = 0x%x, tid = 0x%x\n",
 			  seq_ctrl, tid));
 
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	if (1) { /* if (bretry) */
@@ -653,15 +644,13 @@  int recv_decache(struct recv_frame *precv_frame, u8 bretry,
 				  "tid_rxseq = 0x%x\n",
 				  seq_ctrl, tid, prxcache->tid_rxseq[tid]));
 
-			return _FAIL;
+			return -EINVAL;
 		}
 	}
 
 	prxcache->tid_rxseq[tid] = seq_ctrl;
 
-
-
-	return _SUCCESS;
+	return 0;
 }
 
 void process23a_pwrbit_data(struct rtw_adapter *padapter,
@@ -792,7 +781,7 @@  static int sta2sta_data_frame(struct rtw_adapter *adapter,
 {
 	struct sk_buff *skb = precv_frame->pkt;
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
-	int ret = _SUCCESS;
+	int ret = 0;
 	struct rx_pkt_attrib *pattrib = & precv_frame->attrib;
 	struct sta_priv *pstapriv = &adapter->stapriv;
 	struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
@@ -810,19 +799,19 @@  static int sta2sta_data_frame(struct rtw_adapter *adapter,
 		if (ether_addr_equal(myhwaddr, pattrib->src)) {
 			RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 				 (" SA == myself\n"));
-			ret = _FAIL;
+			ret = -EINVAL;
 			goto exit;
 		}
 
 		if (!ether_addr_equal(myhwaddr, pattrib->dst) && !bmcast) {
-			ret = _FAIL;
+			ret = -EINVAL;
 			goto exit;
 		}
 
 		if (ether_addr_equal(pattrib->bssid, "\x0\x0\x0\x0\x0\x0") ||
 		    ether_addr_equal(mybssid, "\x0\x0\x0\x0\x0\x0") ||
 		    !ether_addr_equal(pattrib->bssid, mybssid)) {
-			ret = _FAIL;
+			ret = -EINVAL;
 			goto exit;
 		}
 
@@ -834,7 +823,7 @@  static int sta2sta_data_frame(struct rtw_adapter *adapter,
 			RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 				 ("bssid != TA under STATION_MODE; drop "
 				  "pkt\n"));
-			ret = _FAIL;
+			ret = -EINVAL;
 			goto exit;
 		}
 
@@ -844,14 +833,14 @@  static int sta2sta_data_frame(struct rtw_adapter *adapter,
 		if (bmcast) {
 			/*  For AP mode, if DA == MCAST, then BSSID should be also MCAST */
 			if (!is_multicast_ether_addr(pattrib->bssid)) {
-				ret = _FAIL;
+				ret = -EINVAL;
 				goto exit;
 			}
 		} else { /*  not mc-frame */
 			/*  For AP mode, if DA is non-MCAST, then it must
 			    be BSSID, and bssid == BSSID */
 			if (!ether_addr_equal(pattrib->bssid, pattrib->dst)) {
-				ret = _FAIL;
+				ret = -EINVAL;
 				goto exit;
 			}
 
@@ -866,7 +855,7 @@  static int sta2sta_data_frame(struct rtw_adapter *adapter,
 
 		sta_addr = mybssid;
 	} else {
-		ret  = _FAIL;
+		ret  = -EINVAL;
 	}
 
 	if (bmcast)
@@ -876,7 +865,7 @@  static int sta2sta_data_frame(struct rtw_adapter *adapter,
 
 	if (*psta == NULL) {
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under sta2sta_data_frame ; drop pkt\n"));
-		ret = _FAIL;
+		ret = -EINVAL;
 		goto exit;
 	}
 
@@ -895,7 +884,7 @@  int ap2sta_data_frame(struct rtw_adapter *adapter,
 	struct sk_buff *skb = precv_frame->pkt;
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
 	struct rx_pkt_attrib *pattrib = & precv_frame->attrib;
-	int ret = _SUCCESS;
+	int ret = 0;
 	struct sta_priv *pstapriv = &adapter->stapriv;
 	struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
 	u8 *mybssid  = get_bssid(pmlmepriv);
@@ -912,7 +901,7 @@  int ap2sta_data_frame(struct rtw_adapter *adapter,
 		if (ether_addr_equal(myhwaddr, pattrib->src)) {
 			RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 				 (" SA == myself\n"));
-			ret = _FAIL;
+			ret = -EINVAL;
 			goto exit;
 		}
 
@@ -921,7 +910,7 @@  int ap2sta_data_frame(struct rtw_adapter *adapter,
 			RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
 				(" ap2sta_data_frame:  compare DA fail; DA ="
 				 MAC_FMT"\n", MAC_ARG(pattrib->dst)));
-			ret = _FAIL;
+			ret = -EINVAL;
 			goto exit;
 		}
 
@@ -943,7 +932,7 @@  int ap2sta_data_frame(struct rtw_adapter *adapter,
 					     WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
 			}
 
-			ret = _FAIL;
+			ret = -EINVAL;
 			goto exit;
 		}
 
@@ -957,7 +946,7 @@  int ap2sta_data_frame(struct rtw_adapter *adapter,
 			RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 				 ("ap2sta: can't get psta under STATION_MODE ;"
 				  " drop pkt\n"));
-			ret = _FAIL;
+			ret = -EINVAL;
 			goto exit;
 		}
 
@@ -985,7 +974,7 @@  int ap2sta_data_frame(struct rtw_adapter *adapter,
 		if (*psta == NULL) {
 			RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 				 ("can't get psta under MP_MODE ; drop pkt\n"));
-			ret = _FAIL;
+			ret = -EINVAL;
 			goto exit;
 		}
 	} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
@@ -1005,7 +994,7 @@  int ap2sta_data_frame(struct rtw_adapter *adapter,
 			}
 		}
 
-		ret = _FAIL;
+		ret = -EINVAL;
 	}
 
 exit:
@@ -1028,14 +1017,14 @@  int sta2ap_data_frame(struct rtw_adapter *adapter,
 	struct sta_priv *pstapriv = &adapter->stapriv;
 	struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
 	unsigned char *mybssid = get_bssid(pmlmepriv);
-	int ret = _SUCCESS;
+	int ret = 0;
 
 
 
 	if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
 		/* For AP mode, RA = BSSID, TX = STA(SRC_ADDR), A3 = DST_ADDR */
 		if (!ether_addr_equal(pattrib->bssid, mybssid)) {
-			ret = _FAIL;
+			ret = -EINVAL;
 			goto exit;
 		}
 
@@ -1100,11 +1089,11 @@  static int validate_recv_ctrl_frame(struct rtw_adapter *padapter,
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
 
 	if (!ieee80211_is_ctl(hdr->frame_control))
-		return _FAIL;
+		return -EINVAL;
 
 	/* receive the frames that ra(a1) is my address */
 	if (!ether_addr_equal(hdr->addr1, myid(&padapter->eeprompriv)))
-		return _FAIL;
+		return -EINVAL;
 
 	/* only handle ps-poll */
 	if (ieee80211_is_pspoll(hdr->frame_control)) {
@@ -1117,7 +1106,7 @@  static int validate_recv_ctrl_frame(struct rtw_adapter *padapter,
 		psta = rtw_get_stainfo23a(pstapriv, hdr->addr2);
 
 		if (!psta || psta->aid != aid)
-			return _FAIL;
+			return -EINVAL;
 
 		/* for rx pkt statistics */
 		psta->sta_stats.rx_ctrl_pkts++;
@@ -1143,7 +1132,7 @@  static int validate_recv_ctrl_frame(struct rtw_adapter *padapter,
 		}
 
 		if (wmmps_ac)
-			return _FAIL;
+			return -EINVAL;
 
 		if (psta->state & WIFI_STA_ALIVE_CHK_STATE) {
 			DBG_8723A("%s alive check-rx ps-poll\n", __func__);
@@ -1232,7 +1221,7 @@  static int validate_recv_ctrl_frame(struct rtw_adapter *padapter,
 	}
 
 #endif
-	return _FAIL;
+	return -EINVAL;
 }
 
 struct recv_frame *recvframe_chk_defrag23a(struct rtw_adapter *padapter,
@@ -1252,7 +1241,7 @@  static int validate_recv_mgnt_frame(struct rtw_adapter *padapter,
 	if (precv_frame == NULL) {
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_,
 			 ("%s: fragment packet\n", __func__));
-		return _SUCCESS;
+		return 0;
 	}
 
 	skb = precv_frame->pkt;
@@ -1281,7 +1270,7 @@  static int validate_recv_mgnt_frame(struct rtw_adapter *padapter,
 
 	mgt_dispatcher23a(padapter, precv_frame);
 
-	return _SUCCESS;
+	return 0;
 }
 
 static int validate_recv_data_frame(struct rtw_adapter *adapter,
@@ -1292,7 +1281,7 @@  static int validate_recv_data_frame(struct rtw_adapter *adapter,
 	struct sta_info *psta = NULL;
 	struct rx_pkt_attrib *pattrib = & precv_frame->attrib;
 	struct security_priv *psecuritypriv = &adapter->securitypriv;
-	int ret = _SUCCESS;
+	int ret = 0;
 	struct sk_buff *skb = precv_frame->pkt;
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
 
@@ -1336,18 +1325,18 @@  static int validate_recv_data_frame(struct rtw_adapter *adapter,
 		ether_addr_copy(pattrib->bssid, hdr->addr1);
 		ether_addr_copy(pattrib->ra, hdr->addr1);
 		ether_addr_copy(pattrib->ta, hdr->addr2);
-		ret = _FAIL;
+		ret = -EINVAL;
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" case 3\n"));
 		break;
 	}
 
-	if ((ret == _FAIL) || (ret == RTW_RX_HANDLED))
+	if ((ret < 0) || (ret == RTW_RX_HANDLED))
 		goto exit;
 
 	if (!psta) {
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 			 (" after to_fr_ds_chk; psta == NULL\n"));
-		ret = _FAIL;
+		ret = -EINVAL;
 		goto exit;
 	}
 
@@ -1386,11 +1375,10 @@  static int validate_recv_data_frame(struct rtw_adapter *adapter,
 	precv_frame->preorder_ctrl = &psta->recvreorder_ctrl[pattrib->priority];
 
 	/*  decache, drop duplicate recv packets */
-	if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) ==
-	    _FAIL) {
+	if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) < 0) {
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 			 ("decache : drop pkt\n"));
-		ret = _FAIL;
+		ret = -EINVAL;
 		goto exit;
 	}
 
@@ -1473,7 +1461,7 @@  static int validate_recv_frame(struct rtw_adapter *adapter,
 	/* then call check if rx seq/frag. duplicated. */
 	u8 type;
 	u8 subtype;
-	int retval = _SUCCESS;
+	int retval = 0;
 	struct rx_pkt_attrib *pattrib = & precv_frame->attrib;
 	struct sk_buff *skb = precv_frame->pkt;
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
@@ -1490,7 +1478,7 @@  static int validate_recv_frame(struct rtw_adapter *adapter,
 	if (ver != 0) {
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 			 ("validate_recv_data_frame fail! (ver!= 0)\n"));
-		retval = _FAIL;
+		retval = -EINVAL;
 		goto exit;
 	}
 
@@ -1512,25 +1500,25 @@  static int validate_recv_frame(struct rtw_adapter *adapter,
 	switch (type) {
 	case IEEE80211_FTYPE_MGMT:
 		retval = validate_recv_mgnt_frame(adapter, precv_frame);
-		if (retval == _FAIL) {
+		if (retval < 0) {
 			RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 				 ("validate_recv_mgnt_frame fail\n"));
 		}
-		retval = _FAIL; /*  only data frame return _SUCCESS */
+		retval = -EINVAL; /*  only data frame return _SUCCESS */
 		break;
 	case IEEE80211_FTYPE_CTL:
 		retval = validate_recv_ctrl_frame(adapter, precv_frame);
-		if (retval == _FAIL) {
+		if (retval < 0) {
 			RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 				 ("validate_recv_ctrl_frame fail\n"));
 		}
-		retval = _FAIL; /*  only data frame return _SUCCESS */
+		retval = -EINVAL; /*  only data frame return _SUCCESS */
 		break;
 	case IEEE80211_FTYPE_DATA:
 		rtw_led_control(adapter, LED_CTL_RX);
 		pattrib->qos = (subtype & IEEE80211_STYPE_QOS_DATA) ? 1 : 0;
 		retval = validate_recv_data_frame(adapter, precv_frame);
-		if (retval == _FAIL) {
+		if (retval < 0) {
 			struct recv_priv *precvpriv = &adapter->recvpriv;
 			/* RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail\n")); */
 			precvpriv->rx_drop++;
@@ -1539,7 +1527,7 @@  static int validate_recv_frame(struct rtw_adapter *adapter,
 	default:
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 			 ("validate_recv_data_frame fail! type = 0x%x\n", type));
-		retval = _FAIL;
+		retval = -EINVAL;
 		break;
 	}
 
@@ -1614,7 +1602,7 @@  static int wlanhdr_to_ethhdr (struct recv_frame *precvframe)
 	}
 
 
-	return _SUCCESS;
+	return 0;
 }
 
 /* perform defrag */
@@ -1814,7 +1802,7 @@  struct recv_frame *recvframe_chk_defrag23a(struct rtw_adapter *padapter,
 
 	if ((prtnframe != NULL) && (prtnframe->attrib.privacy))	{
 		/* after defrag we must check tkip mic code */
-		if (recvframe_chkmic(padapter,  prtnframe) == _FAIL) {
+		if (recvframe_chkmic(padapter,  prtnframe) < 0) {
 			RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 				 ("recvframe_chkmic(padapter,  prtnframe) =="
 				  "_FAIL\n"));
@@ -1856,7 +1844,7 @@  int amsdu_to_msdu(struct rtw_adapter *padapter, struct recv_frame *prframe)
 
 	prframe->pkt = NULL;
 	rtw_free_recvframe23a(prframe);
-	return _SUCCESS;
+	return 0;
 }
 
 int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num);
@@ -2009,8 +1997,7 @@  int recv_indicatepkts_in_order(struct rtw_adapter *padapter,
 					rtw_recv_indicatepkt23a(padapter, prframe);
 				}
 			} else {
-				if (amsdu_to_msdu(padapter, prframe) !=
-				    _SUCCESS)
+				if (amsdu_to_msdu(padapter, prframe) != 0)
 					rtw_free_recvframe23a(prframe);
 			}
 
@@ -2036,7 +2023,7 @@  int recv_indicatepkt_reorder(struct rtw_adapter *padapter,
 int recv_indicatepkt_reorder(struct rtw_adapter *padapter,
 			     struct recv_frame *prframe)
 {
-	int retval = _SUCCESS;
+	int retval = 0;
 	struct rx_pkt_attrib *pattrib;
 	struct recv_reorder_ctrl *preorder_ctrl;
 	struct rtw_queue *ppending_recvframe_queue;
@@ -2058,10 +2045,10 @@  int recv_indicatepkt_reorder(struct rtw_adapter *padapter,
 					  "recv_func recv_indicatepkt\n"));
 
 				rtw_recv_indicatepkt23a(padapter, prframe);
-				return _SUCCESS;
+				return 0;
 			}
 
-			return _FAIL;
+			return -EINVAL;
 		}
 
 		if (preorder_ctrl->enable == false) {
@@ -2071,7 +2058,7 @@  int recv_indicatepkt_reorder(struct rtw_adapter *padapter,
 
 			preorder_ctrl->indicate_seq =
 				(preorder_ctrl->indicate_seq + 1) % 4096;
-			return _SUCCESS;
+			return 0;
 		}
 	} else {
 		 /* temp filter -> means didn't support A-MSDUs in a A-MPDU */
@@ -2122,12 +2109,12 @@  int recv_indicatepkt_reorder(struct rtw_adapter *padapter,
 		spin_unlock_bh(&ppending_recvframe_queue->lock);
 		del_timer_sync(&preorder_ctrl->reordering_ctrl_timer);
 	}
-	return _SUCCESS;
+	return 0;
 
 _err_exit:
 
 	spin_unlock_bh(&ppending_recvframe_queue->lock);
-	return _FAIL;
+	return -EINVAL;
 }
 
 void rtw_reordering_ctrl_timeout_handler23a(unsigned long pcontext)
@@ -2161,7 +2148,7 @@  int process_recv_indicatepkts(struct rtw_adapter *padapter,
 int process_recv_indicatepkts(struct rtw_adapter *padapter,
 			      struct recv_frame *prframe)
 {
-	int retval = _SUCCESS;
+	int retval = 0;
 	/* struct recv_priv *precvpriv = &padapter->recvpriv; */
 	/* struct rx_pkt_attrib *pattrib = &prframe->attrib; */
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -2171,16 +2158,16 @@  int process_recv_indicatepkts(struct rtw_adapter *padapter,
 		/* prframe->preorder_ctrl = &precvpriv->recvreorder_ctrl[pattrib->priority]; */
 
 		/*  including perform A-MPDU Rx Ordering Buffer Control */
-		if (recv_indicatepkt_reorder(padapter, prframe) != _SUCCESS) {
+		if (recv_indicatepkt_reorder(padapter, prframe) != 0) {
 			if ((padapter->bDriverStopped == false) &&
 			    (padapter->bSurpriseRemoved == false)) {
-				retval = _FAIL;
+				retval = -EINVAL;
 				return retval;
 			}
 		}
 	} else { /* B/G mode */
 		retval = wlanhdr_to_ethhdr(prframe);
-		if (retval != _SUCCESS) {
+		if (retval != 0) {
 			RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 				 ("wlanhdr_to_ethhdr: drop pkt\n"));
 			return retval;
@@ -2203,7 +2190,7 @@  int process_recv_indicatepkts(struct rtw_adapter *padapter,
 				  "bSurpriseRemoved(%d)",
 				  padapter->bDriverStopped,
 				  padapter->bSurpriseRemoved));
-			retval = _FAIL;
+			retval = -EINVAL;
 			return retval;
 		}
 
@@ -2215,11 +2202,11 @@  int process_recv_indicatepkts(struct rtw_adapter *padapter,
 static int recv_func_prehandle(struct rtw_adapter *padapter,
 			       struct recv_frame *rframe)
 {
-	int ret = _SUCCESS;
+	int ret = 0;
 
 	/* check the frame crtl field and decache */
 	ret = validate_recv_frame(padapter, rframe);
-	if (ret != _SUCCESS) {
+	if (ret != 0) {
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
 			 ("recv_func: validate_recv_frame fail! drop pkt\n"));
 		rtw_free_recvframe23a(rframe);
@@ -2233,7 +2220,7 @@  exit:
 static int recv_func_posthandle(struct rtw_adapter *padapter,
 				struct recv_frame *prframe)
 {
-	int ret = _SUCCESS;
+	int ret = 0;
 	struct recv_frame *orig_prframe = prframe;
 	struct recv_priv *precvpriv = &padapter->recvpriv;
 
@@ -2244,7 +2231,7 @@  static int recv_func_posthandle(struct rtw_adapter *padapter,
 	if (prframe == NULL) {
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 			 ("decryptor: drop pkt\n"));
-		ret = _FAIL;
+		ret = -EINVAL;
 		goto _recv_data_drop;
 	}
 
@@ -2271,14 +2258,14 @@  static int recv_func_posthandle(struct rtw_adapter *padapter,
 	if (!prframe) {
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 			 ("portctrl: drop pkt\n"));
-		ret = _FAIL;
+		ret = -EINVAL;
 		goto _recv_data_drop;
 	}
 
 	count_rx_stats(padapter, prframe, NULL);
 
 	ret = process_recv_indicatepkts(padapter, prframe);
-	if (ret != _SUCCESS) {
+	if (ret != 0) {
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 			 ("recv_func: process_recv_indicatepkts fail!\n"));
 		rtw_free_recvframe23a(orig_prframe);/* free this recv_frame */
@@ -2307,14 +2294,14 @@  int rtw_recv_entry23a(struct recv_frame *rframe)
 
 		while ((pending_frame = rtw_alloc_recvframe23a(&padapter->recvpriv.uc_swdec_pending_queue))) {
 			r = recv_func_posthandle(padapter, pending_frame);
-			if (r == _SUCCESS)
+			if (r == 0)
 				DBG_8723A("%s: dequeue uc_swdec_pending_queue\n", __func__);
 		}
 	}
 
 	ret = recv_func_prehandle(padapter, rframe);
 
-	if (ret == _SUCCESS) {
+	if (ret == 0) {
 		/* check if need to enqueue into uc_swdec_pending_queue*/
 		if (check_fwstate(mlmepriv, WIFI_STATION_STATE) &&
 		    !is_multicast_ether_addr(prxattrib->ra) &&
diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c
index 715a474..a1131f9 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -619,10 +619,10 @@  int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
 	struct	pkt_attrib	 *pattrib = &pxmitframe->attrib;
 	struct	security_priv	*psecuritypriv = &padapter->securitypriv;
 	struct	xmit_priv		*pxmitpriv = &padapter->xmitpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	if (!pxmitframe->buf_addr)
-		return _FAIL;
+		return -EFAULT;
 
 	hw_hdr_offset = TXDESC_OFFSET;
 
@@ -641,7 +641,7 @@  int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
 
 			if (!(stainfo->state &_FW_LINKED)) {
 				DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, stainfo->state);
-				return _FAIL;
+				return -EINVAL;
 			}
 
 			RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt23a: stainfo!= NULL!!!\n"));
@@ -692,7 +692,7 @@  int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
 		else{
 			RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt23a: stainfo == NULL!!!\n"));
 			DBG_8723A("%s, psta == NUL\n", __func__);
-			res = _FAIL;
+			res = -EINVAL;
 		}
 
 	}
@@ -718,7 +718,7 @@  int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
 	struct	rx_pkt_attrib *prxattrib = &precvframe->attrib;
 	struct	security_priv *psecuritypriv = &padapter->securitypriv;
 	struct sk_buff *skb = precvframe->pkt;
-	int res = _SUCCESS;
+	int res = 0;
 
 	pframe = skb->data;
 
@@ -731,7 +731,7 @@  int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
 
 			if (is_multicast_ether_addr(prxattrib->ra)) {
 				if (psecuritypriv->binstallGrpkey == 0) {
-					res = _FAIL;
+					res = -EINVAL;
 					DBG_8723A("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__);
 					goto exit;
 				}
@@ -765,11 +765,11 @@  int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
 			{
 			    RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_wep_decrypt23a:icv error crc[3](%x)!= payload[length-1](%x) || crc[2](%x)!= payload[length-2](%x) || crc[1](%x)!= payload[length-3](%x) || crc[0](%x)!= payload[length-4](%x)\n",
 						crc[3], payload[length-1], crc[2], payload[length-2], crc[1], payload[length-3], crc[0], payload[length-4]));
-				res = _FAIL;
+				res = -EINVAL;
 			}
 		} else {
 			RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt23a: stainfo == NULL!!!\n"));
-			res = _FAIL;
+			res = -EINVAL;
 		}
 	}
 exit:
@@ -1267,7 +1267,7 @@  static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
 	for (j = 0; j < 8;j++)
 		pframe[payload_index++] = chain_buffer[j];
 
-	return _SUCCESS;
+	return 0;
 }
 
 int rtw_aes_encrypt23a(struct rtw_adapter *padapter,
@@ -1282,10 +1282,10 @@  int rtw_aes_encrypt23a(struct rtw_adapter *padapter,
 	struct pkt_attrib *pattrib = &pxmitframe->attrib;
 	struct security_priv *psecuritypriv = &padapter->securitypriv;
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	if (!pxmitframe->buf_addr)
-		return _FAIL;
+		return -EFAULT;
 
 	hw_hdr_offset = TXDESC_OFFSET;
 
@@ -1293,7 +1293,7 @@  int rtw_aes_encrypt23a(struct rtw_adapter *padapter,
 
 	/* 4 start to encrypt each fragment */
 	if (pattrib->encrypt != WLAN_CIPHER_SUITE_CCMP)
-		return _FAIL;
+		return -EINVAL;
 
 	if (pattrib->psta) {
 		stainfo = pattrib->psta;
@@ -1306,13 +1306,13 @@  int rtw_aes_encrypt23a(struct rtw_adapter *padapter,
 		RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
 			 ("rtw_aes_encrypt23a: stainfo == NULL!!!\n"));
 		DBG_8723A("%s, psta == NUL\n", __func__);
-		res = _FAIL;
+		res = -EINVAL;
 		goto out;
 	}
 	if (!(stainfo->state &_FW_LINKED)) {
 		DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n",
 			  __func__, stainfo->state);
-		return _FAIL;
+		return -EINVAL;
 	}
 	RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
 		 ("rtw_aes_encrypt23a: stainfo!= NULL!!!\n"));
@@ -1351,7 +1351,7 @@  static int aes_decipher(u8 *key, uint	hdrlen,
 	static u8	message[MAX_MSG_SIZE];
 	uint	qc_exists, a4_exists, i, j, payload_remainder,
 			num_blocks, payload_index;
-	int res = _SUCCESS;
+	int res = 0;
 	u8 pn_vector[6];
 	u8 mic_iv[16];
 	u8 mic_header1[16];
@@ -1548,7 +1548,7 @@  static int aes_decipher(u8 *key, uint	hdrlen,
 				 i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i]));
 			DBG_8723A("aes_decipher:mic check error mic[%d]: pframe(%x) != message(%x)\n",
 				  i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i]);
-			res = _FAIL;
+			res = -EINVAL;
 		}
 	}
 	return res;
@@ -1563,18 +1563,18 @@  int rtw_aes_decrypt23a(struct rtw_adapter *padapter,
 	struct sk_buff *skb = precvframe->pkt;
 	int length;
 	u8 *pframe, *prwskey;	/*  *payload,*iv */
-	int res = _SUCCESS;
+	int res = 0;
 
 	pframe = skb->data;
 	/* 4 start to encrypt each fragment */
 	if (prxattrib->encrypt != WLAN_CIPHER_SUITE_CCMP)
-		return _FAIL;
+		return -EINVAL;
 
 	stainfo = rtw_get_stainfo23a(&padapter->stapriv, &prxattrib->ta[0]);
 	if (!stainfo) {
 		RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
 			 ("rtw_aes_encrypt23a: stainfo == NULL!!!\n"));
-		res = _FAIL;
+		res = -EINVAL;
 		goto exit;
 	}
 
@@ -1585,7 +1585,7 @@  int rtw_aes_decrypt23a(struct rtw_adapter *padapter,
 		/* in concurrent we should use sw decrypt in group key,
 		   so we remove this message */
 		if (!psecuritypriv->binstallGrpkey) {
-			res = _FAIL;
+			res = -EINVAL;
 			DBG_8723A("%s:rx bc/mc packets, but didn't install "
 				  "group key!!!!!!!!!!\n", __func__);
 			goto exit;
@@ -1595,7 +1595,7 @@  int rtw_aes_decrypt23a(struct rtw_adapter *padapter,
 			DBG_8723A("not match packet_index =%d, install_index ="
 				  "%d\n", prxattrib->key_index,
 				  psecuritypriv->dot118021XGrpKeyid);
-			res = _FAIL;
+			res = -EINVAL;
 			goto exit;
 		}
 	} else {
diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c
index d17998d..0aeceb0 100644
--- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c
@@ -78,7 +78,7 @@  int _rtw_init_sta_priv23a(struct sta_priv *pstapriv)
 	pstapriv->expire_to = 3; /*  3*2 = 6 sec */
 	pstapriv->max_num_sta = NUM_STA;
 #endif
-	return _SUCCESS;
+	return 0;
 }
 
 int _rtw_free_sta_priv23a(struct sta_priv *pstapriv)
@@ -108,7 +108,7 @@  int _rtw_free_sta_priv23a(struct sta_priv *pstapriv)
 		spin_unlock_bh(&pstapriv->sta_hash_lock);
 		/*===============================*/
 	}
-	return _SUCCESS;
+	return 0;
 }
 
 struct sta_info *
@@ -321,7 +321,7 @@  int rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta)
 
 	kfree(psta);
 exit:
-	return _SUCCESS;
+	return 0;
 }
 
 /*  free all stainfo which in sta_hash[all] */
@@ -391,20 +391,18 @@  int rtw_init_bcmc_stainfo23a(struct rtw_adapter *padapter)
 	struct	sta_priv *pstapriv = &padapter->stapriv;
 	struct sta_info		*psta;
 	struct tx_servq	*ptxservq;
-	int res = _SUCCESS;
 
 	psta = rtw_alloc_stainfo23a(pstapriv, bc_addr, GFP_KERNEL);
 	if (psta == NULL) {
-		res = _FAIL;
 		RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_,
 			 ("rtw_alloc_stainfo23a fail"));
-		return res;
+		return -ENOMEM;
 	}
 	/*  default broadcast & multicast use macid 1 */
 	psta->mac_id = 1;
 
 	ptxservq = &psta->sta_xmitpriv.be_q;
-	return _SUCCESS;
+	return 0;
 }
 
 struct sta_info *rtw_get_bcmc_stainfo23a(struct rtw_adapter *padapter)
diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c
index 69d9e0f..235d436 100644
--- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c
@@ -492,13 +492,13 @@  int WMM_param_handler23a(struct rtw_adapter *padapter, const u8 *p)
 
 	if (pmlmepriv->qos_option == 0) {
 		pmlmeinfo->WMM_enable = 0;
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	pmlmeinfo->WMM_enable = 1;
 	memcpy(&pmlmeinfo->WMM_param, p + 2 + 6,
 	       sizeof(struct WMM_para_element));
-	return true;
+	return 0;
 }
 
 void WMMOnAssocRsp23a(struct rtw_adapter *padapter)
@@ -867,19 +867,19 @@  int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
 	const u8 *p, *ssid;
 
 	if (!is_client_associated_to_ap23a(Adapter))
-		return _SUCCESS;
+		return 0;
 
 	if (unlikely(!ieee80211_is_beacon(mgmt->frame_control))) {
 		printk(KERN_WARNING "%s: received a non beacon frame!\n",
 		       __func__);
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	if (!ether_addr_equal(cur_network->network.MacAddress, mgmt->bssid)) {
 		DBG_8723A("%s: linked but recv other bssid bcn"
 			  MAC_FMT MAC_FMT "\n", __func__, MAC_ARG(mgmt->bssid),
 			  MAC_ARG(cur_network->network.MacAddress));
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	/* check bw and channel offset */
@@ -960,7 +960,7 @@  int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
 		if (p && p[1]) {
 			r = rtw_parse_wpa2_ie23a(p, p[1] + 2, &group_cipher,
 						 &pairwise_cipher, &is_8021x);
-			if (r == _SUCCESS)
+			if (r == 0)
 				RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
 					 ("%s pnetwork->pairwise_cipher: %d, "
 					  "pnetwork->group_cipher: %d, is_802x "
@@ -975,7 +975,7 @@  int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
 			crypto = ENCRYP_PROTOCOL_WPA;
 			r = rtw_parse_wpa_ie23a(p, p[1] + 2, &group_cipher,
 						&pairwise_cipher, &is_8021x);
-			if (r == _SUCCESS)
+			if (r == 0)
 				RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
 					 ("%s pnetwork->pairwise_cipher: %d, "
 					  "group_cipher is %d, is_8021x is "
@@ -1016,11 +1016,11 @@  int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
 		}
 	}
 
-	return _SUCCESS;
+	return 0;
 
 _mismatch:
 
-	return _FAIL;
+	return -EINVAL;
 }
 
 void update_beacon23a_info(struct rtw_adapter *padapter,
@@ -1237,15 +1237,14 @@  int support_short_GI23a(struct rtw_adapter *padapter,
 	unsigned char bit_offset;
 
 	if (!pmlmeinfo->HT_enable)
-		return _FAIL;
+		return -EINVAL;
 	if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK)
-		return _FAIL;
+		return -EINVAL;
 	bit_offset = (pmlmeext->cur_bwmode & HT_CHANNEL_WIDTH_40)? 6: 5;
 
 	if (pHT_caps->cap_info & cpu_to_le16(0x1 << bit_offset))
-		return _SUCCESS;
-	else
-		return _FAIL;
+		return 0;
+	return -EINVAL;
 }
 
 unsigned char get_highest_rate_idx23a(u32 mask)
@@ -1515,7 +1514,7 @@  int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie,
 
 	p = cfg80211_find_ie(WLAN_EID_SUPP_RATES, pvar_ie, var_ie_len);
 	if (!p)
-		return _FAIL;
+		return -EINVAL;
 
 	memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, p + 2, p[1]);
 	supportRateNum = p[1];
@@ -1524,7 +1523,7 @@  int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie,
 	if (p)
 		memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates +
 		       supportRateNum, p + 2, p[1]);
-	return _SUCCESS;
+	return 0;
 }
 
 void process_addba_req23a(struct rtw_adapter *padapter,
diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
index 4c2f0a1..11cdc22 100644
--- a/drivers/staging/rtl8723au/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
@@ -57,7 +57,7 @@  int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv,
 	int i;
 	struct xmit_buf *pxmitbuf;
 	struct xmit_frame *pxframe;
-	int res = _SUCCESS;
+	int res = 0;
 	u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ;
 	u32 num_xmit_extbuf = NR_XMIT_EXTBUFF;
 
@@ -110,9 +110,8 @@  int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv,
 		/* Tx buf allocation may fail sometimes, so sleep and retry. */
 		res = rtw_os_xmit_resource_alloc23a(padapter, pxmitbuf,
 						 (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ));
-		if (res == _FAIL) {
+		if (res < 0)
 			goto fail;
-		}
 
 		list_add_tail(&pxmitbuf->list,
 			      &pxmitpriv->free_xmitbuf_queue.queue);
@@ -162,9 +161,8 @@  int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv,
 		/* Tx buf allocation may fail sometimes, so sleep and retry. */
 		res = rtw_os_xmit_resource_alloc23a(padapter, pxmitbuf,
 						 max_xmit_extbuf_size + XMITBUF_ALIGN_SZ);
-		if (res == _FAIL) {
+		if (res < 0)
 			goto exit;
-		}
 
 		list_add_tail(&pxmitbuf->list,
 			      &pxmitpriv->free_xmit_extbuf_queue.queue);
@@ -426,7 +424,7 @@  static int update_attrib(struct rtw_adapter *padapter,
 	struct sta_priv	*pstapriv = &padapter->stapriv;
 	struct security_priv *psecuritypriv = &padapter->securitypriv;
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-	int res = _SUCCESS;
+	int res = 0;
 	struct ethhdr *ehdr = (struct ethhdr *) skb->data;
 
 	pattrib->ether_type = ntohs(ehdr->h_proto);
@@ -500,11 +498,11 @@  static int update_attrib(struct rtw_adapter *padapter,
 			RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_,
 				 ("\nupdate_attrib => get sta_info fail, ra:"
 				  MAC_FMT"\n", MAC_ARG(pattrib->ra)));
-			res = _FAIL;
+			res = -EINVAL;
 			goto exit;
 		} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) &&
 			   (!(psta->state & _FW_LINKED))) {
-			res = _FAIL;
+			res = -EINVAL;
 			goto exit;
 		}
 	}
@@ -518,7 +516,7 @@  static int update_attrib(struct rtw_adapter *padapter,
 		RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_,
 			 ("\nupdate_attrib => get sta_info fail, ra:" MAC_FMT
 			  "\n", MAC_ARG(pattrib->ra)));
-		res = _FAIL;
+		res = -EINVAL;
 		goto exit;
 	}
 
@@ -559,7 +557,7 @@  static int update_attrib(struct rtw_adapter *padapter,
 				 ("\npsta->ieee8021x_blocked == true,  "
 				  "pattrib->ether_type(%.4x) != 0x888e\n",
 				  pattrib->ether_type));
-			res = _FAIL;
+			res = -EINVAL;
 			goto exit;
 		}
 	} else {
@@ -602,7 +600,7 @@  static int update_attrib(struct rtw_adapter *padapter,
 				 ("\npadapter->securitypriv.busetkip"
 				  "key(%d) == false drop packet\n",
 				  padapter->securitypriv.busetkipkey));
-			res = _FAIL;
+			res = -EINVAL;
 			goto exit;
 		}
 
@@ -663,13 +661,13 @@  static int xmitframe_addmic(struct rtw_adapter *padapter,
 
 	if (!stainfo) {
 		DBG_8723A("%s, psta == NUL\n", __func__);
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	if (!(stainfo->state &_FW_LINKED)) {
 		DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n",
 			  __func__, stainfo->state);
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	hw_hdr_offset = TXDESC_OFFSET;
@@ -686,14 +684,14 @@  static int xmitframe_addmic(struct rtw_adapter *padapter,
 
 			if (bmcst) {
 				if (!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) {
-					return _FAIL;
+					return -EINVAL;
 				}
 				/* start to calculate the mic code */
 				rtw_secmicsetkey23a(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey);
 			} else {
 				if (!memcmp(&stainfo->dot11tkiptxmickey.skey[0],
 					    null_key, 16)) {
-					return _FAIL;
+					return -EINVAL;
 				}
 				/* start to calculate the mic code */
 				rtw_secmicsetkey23a(&micdata, &stainfo->dot11tkiptxmickey.skey[0]);
@@ -814,7 +812,7 @@  static int xmitframe_addmic(struct rtw_adapter *padapter,
 		}
 	}
 
-	return _SUCCESS;
+	return 0;
 }
 
 static int xmitframe_swencrypt(struct rtw_adapter *padapter,
@@ -847,7 +845,7 @@  static int xmitframe_swencrypt(struct rtw_adapter *padapter,
 			 ("### xmitframe_hwencrypt\n"));
 	}
 
-	return _SUCCESS;
+	return 0;
 }
 
 static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr,
@@ -857,7 +855,7 @@  static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr,
 	struct ieee80211_qos_hdr *qoshdr;
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 	u8 qos_option = false;
-	int res = _SUCCESS;
+	int res = 0;
 
 	struct sta_info *psta;
 
@@ -876,12 +874,12 @@  static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr,
 
 	if (psta == NULL) {
 		DBG_8723A("%s, psta == NUL\n", __func__);
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	if (!(psta->state &_FW_LINKED)) {
 		DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	memset(hdr, 0, WLANHDR_OFFSET);
@@ -922,7 +920,7 @@  static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr,
 		}
 		else {
 			RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("fw_state:%x is not allowed to xmit frame\n", get_fwstate(pmlmepriv)));
-			res = _FAIL;
+			res = -EINVAL;
 			goto exit;
 		}
 		if (pattrib->mdata)
@@ -1087,7 +1085,7 @@  int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb,
 	u8 *pdata = skb->data;
 	int data_len = skb->len;
 	s32 bmcst = is_multicast_ether_addr(pattrib->ra);
-	int res = _SUCCESS;
+	int res = 0;
 
 	if (pattrib->psta)
 		psta = pattrib->psta;
@@ -1098,18 +1096,18 @@  int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb,
 
 	if (!psta) {
 		DBG_8723A("%s, psta == NUL\n", __func__);
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	if (!(psta->state &_FW_LINKED)) {
 		DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n",
 			  __func__, psta->state);
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	if (!pxmitframe->buf_addr) {
 		DBG_8723A("==> %s buf_addr == NULL\n", __func__);
-		return _FAIL;
+		return -EFAULT;
 	}
 
 	pbuf_start = pxmitframe->buf_addr;
@@ -1118,10 +1116,10 @@  int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb,
 
 	mem_start = pbuf_start + hw_hdr_offset;
 
-	if (rtw_make_wlanhdr(padapter, mem_start, pattrib) == _FAIL) {
+	if (rtw_make_wlanhdr(padapter, mem_start, pattrib) < 0) {
 		RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
 			 ("%s: rtw_make_wlanhdr fail; drop pkt\n", __func__));
-		res = _FAIL;
+		res = -EINVAL;
 		goto exit;
 	}
 
@@ -1235,11 +1233,11 @@  int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb,
 		memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen);
 	}
 
-	if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) {
+	if (xmitframe_addmic(padapter, pxmitframe) < 0) {
 		RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-			 ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n"));
-		DBG_8723A("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n");
-		res = _FAIL;
+			 ("xmitframe_addmic(padapter, pxmitframe) failed\n"));
+		DBG_8723A("xmitframe_addmic(padapter, pxmitframe) failed\n");
+		res = -EINVAL;
 		goto exit;
 	}
 
@@ -1373,7 +1371,7 @@  int rtw_free_xmitbuf_ext23a(struct xmit_priv *pxmitpriv,
 	struct rtw_queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue;
 
 	if (pxmitbuf == NULL)
-		return _FAIL;
+		return -EINVAL;
 
 	spin_lock_irqsave(&pfree_queue->lock, irqL);
 
@@ -1384,7 +1382,7 @@  int rtw_free_xmitbuf_ext23a(struct xmit_priv *pxmitpriv,
 
 	spin_unlock_irqrestore(&pfree_queue->lock, irqL);
 
-	return _SUCCESS;
+	return 0;
 }
 
 struct xmit_buf *rtw_alloc_xmitbuf23a(struct xmit_priv *pxmitpriv)
@@ -1429,7 +1427,7 @@  int rtw_free_xmitbuf23a(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
 	/* DBG_8723A("+rtw_free_xmitbuf23a\n"); */
 
 	if (pxmitbuf == NULL)
-		return _FAIL;
+		return -EINVAL;
 
 	if (pxmitbuf->sctx) {
 		DBG_8723A("%s pxmitbuf->sctx is not NULL\n", __func__);
@@ -1450,7 +1448,7 @@  int rtw_free_xmitbuf23a(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
 		spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irqL);
 	}
 
-	return _SUCCESS;
+	return 0;
 }
 
 static void rtw_init_xmitframe(struct xmit_frame *pxframe)
@@ -1589,7 +1587,7 @@  check_pkt_complete:
 
 exit:
 
-	return _SUCCESS;
+	return 0;
 }
 
 void rtw_free_xmitframe_queue23a(struct xmit_priv *pxmitpriv,
@@ -1614,14 +1612,14 @@  void rtw_free_xmitframe_queue23a(struct xmit_priv *pxmitpriv,
 int rtw_xmitframe_enqueue23a(struct rtw_adapter *padapter,
 			     struct xmit_frame *pxmitframe)
 {
-	if (rtw_xmit23a_classifier(padapter, pxmitframe) == _FAIL) {
+	if (rtw_xmit23a_classifier(padapter, pxmitframe) < 0) {
 		RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
 			 ("rtw_xmitframe_enqueue23a: drop xmit pkt for "
 			  "classifier fail\n"));
-		return _FAIL;
+		return -EINVAL;
 	}
 
-	return _SUCCESS;
+	return 0;
 }
 
 static struct xmit_frame *
@@ -1744,7 +1742,7 @@  int rtw_xmit23a_classifier(struct rtw_adapter *padapter,
 	struct sta_priv	*pstapriv = &padapter->stapriv;
 	struct hw_xmit	*phwxmits =  padapter->xmitpriv.hwxmits;
 	u8	ac_index;
-	int res = _SUCCESS;
+	int res = 0;
 
 	if (pattrib->psta) {
 		psta = pattrib->psta;
@@ -1753,7 +1751,7 @@  int rtw_xmit23a_classifier(struct rtw_adapter *padapter,
 		psta = rtw_get_stainfo23a(pstapriv, pattrib->ra);
 	}
 	if (psta == NULL) {
-		res = _FAIL;
+		res = -EINVAL;
 		DBG_8723A("rtw_xmit23a_classifier: psta == NULL\n");
 		RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
 			 ("rtw_xmit23a_classifier: psta == NULL\n"));
@@ -1762,7 +1760,7 @@  int rtw_xmit23a_classifier(struct rtw_adapter *padapter,
 	if (!(psta->state & _FW_LINKED)) {
 		DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__,
 			  psta->state);
-		return _FAIL;
+		return -EINVAL;
 	}
 	ptxservq = rtw_get_sta_pending23a(padapter, psta, pattrib->priority,
 				       (u8 *)(&ac_index));
@@ -1925,7 +1923,7 @@  int rtw_xmit23a(struct rtw_adapter *padapter, struct sk_buff *skb)
 
 	res = update_attrib(padapter, skb, &pxmitframe->attrib);
 
-	if (res == _FAIL) {
+	if (res < 0) {
 		RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit23a: update attrib fail\n"));
 		rtw_free_xmitframe23a(pxmitpriv, pxmitframe);
 		return -1;
@@ -2362,7 +2360,7 @@  void rtw_sctx_init23a(struct submit_ctx *sctx, int timeout_ms)
 
 int rtw_sctx_wait23a(struct submit_ctx *sctx)
 {
-	int ret = _FAIL;
+	int ret;
 	unsigned long expire;
 	int status = 0;
 
@@ -2377,9 +2375,9 @@  int rtw_sctx_wait23a(struct submit_ctx *sctx)
 	}
 
 	if (status == RTW_SCTX_DONE_SUCCESS)
-		ret = _SUCCESS;
+		ret = 0;
 
-	return ret;
+	return -1;
 }
 
 static bool rtw_sctx_chk_waring_status(int status)