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

Message ID 1414607161-591-3-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/os_dep/ioctl_cfg80211.c | 79 +++++++++++------------
 drivers/staging/rtl8723au/os_dep/os_intfs.c       | 64 +++++++++---------
 drivers/staging/rtl8723au/os_dep/recv_linux.c     |  4 +-
 drivers/staging/rtl8723au/os_dep/usb_intf.c       | 52 +++++++++------
 drivers/staging/rtl8723au/os_dep/usb_ops_linux.c  |  7 +-
 drivers/staging/rtl8723au/os_dep/xmit_linux.c     |  6 +-
 6 files changed, 109 insertions(+), 103 deletions(-)

Patch
diff mbox

diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
index e154de9..ce4dc0f 100644
--- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
@@ -390,18 +390,18 @@  static int set_pairwise_key(struct rtw_adapter *padapter, struct sta_info *psta)
 	struct cmd_obj *ph2c;
 	struct set_stakey_parm *psetstakey_para;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
 	if (ph2c == NULL) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
 	psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL);
 	if (psetstakey_para == NULL) {
 		kfree(ph2c);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -425,24 +425,25 @@  static int set_group_key(struct rtw_adapter *padapter, struct key_params *parms,
 	struct cmd_obj *pcmd;
 	struct setkey_parm *psetkeyparm;
 	struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
-	int res = _SUCCESS;
+	int res = 0;
 
 	DBG_8723A("%s\n", __func__);
 
 	if (keyid >= 4) {
-		res = _FAIL;
+		res = -EINVAL;
 		goto exit;
 	}
 
 	pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
 	if (!pcmd) {
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
+
 	psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL);
 	if (!psetkeyparm) {
 		kfree(pcmd);
-		res = _FAIL;
+		res = -ENOMEM;
 		goto exit;
 	}
 
@@ -1202,7 +1203,7 @@  static int cfg80211_infrastructure_mode(struct rtw_adapter *padapter,
 		spin_unlock_bh(&pmlmepriv->lock);
 	}
 
-	return _SUCCESS;
+	return 0;
 }
 
 static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
@@ -1241,7 +1242,7 @@  static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
 
 	rtw_wdev->iftype = type;
 
-	if (cfg80211_infrastructure_mode(padapter, type) != _SUCCESS) {
+	if (cfg80211_infrastructure_mode(padapter, type) != 0) {
 		rtw_wdev->iftype = old_type;
 		ret = -EPERM;
 		goto exit;
@@ -1342,7 +1343,6 @@  static int cfg80211_rtw_scan(struct wiphy *wiphy,
 			     struct cfg80211_scan_request *request)
 {
 	int i;
-	u8 _status = false;
 	int ret = 0;
 	struct rtw_adapter *padapter = wiphy_to_adapter(wiphy);
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -1364,7 +1364,7 @@  static int cfg80211_rtw_scan(struct wiphy *wiphy,
 		/* goto check_need_indicate_scan_done; */
 	}
 
-	if (rtw_pwr_wakeup(padapter) == _FAIL) {
+	if (rtw_pwr_wakeup(padapter) < 0) {
 		need_indicate_scan_done = true;
 		goto check_need_indicate_scan_done;
 	}
@@ -1422,17 +1422,14 @@  static int cfg80211_rtw_scan(struct wiphy *wiphy,
 	if (request->n_channels == 1) {
 		memcpy(&ch[1], &ch[0], sizeof(struct rtw_ieee80211_channel));
 		memcpy(&ch[2], &ch[0], sizeof(struct rtw_ieee80211_channel));
-		_status = rtw_sitesurvey_cmd23a(padapter, ssid,
+		ret = rtw_sitesurvey_cmd23a(padapter, ssid,
 					     RTW_SSID_SCAN_AMOUNT, ch, 3);
 	} else {
-		_status = rtw_sitesurvey_cmd23a(padapter, ssid,
+		ret = rtw_sitesurvey_cmd23a(padapter, ssid,
 					     RTW_SSID_SCAN_AMOUNT, NULL, 0);
 	}
 	spin_unlock_bh(&pmlmepriv->lock);
 
-	if (_status == false)
-		ret = -1;
-
 check_need_indicate_scan_done:
 	if (need_indicate_scan_done)
 		rtw_cfg80211_surveydone_event_callback(padapter);
@@ -1605,7 +1602,7 @@  static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
 	if (ielen < RSN_HEADER_LEN) {
 		RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_,
 			 ("Ie len too short %d\n", (int)ielen));
-		ret = -1;
+		ret = -EINVAL;
 		goto exit;
 	}
 
@@ -1614,7 +1611,7 @@  static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
 				       pie, ielen);
 	if (pwpa && pwpa[1] > 0) {
 		if (rtw_parse_wpa_ie23a(pwpa, pwpa[1] + 2, &group_cipher,
-					&pairwise_cipher, NULL) == _SUCCESS) {
+					&pairwise_cipher, NULL) == 0) {
 			padapter->securitypriv.dot11AuthAlgrthm =
 				dot11AuthAlgrthm_8021X;
 			padapter->securitypriv.ndisauthtype =
@@ -1629,7 +1626,7 @@  static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
 	pwpa2 = cfg80211_find_ie(WLAN_EID_RSN, pie, ielen);
 	if (pwpa2 && pwpa2[1] > 0) {
 		if (rtw_parse_wpa2_ie23a (pwpa2, pwpa2[1] + 2, &group_cipher,
-					  &pairwise_cipher, NULL) == _SUCCESS) {
+					  &pairwise_cipher, NULL) == 0) {
 			padapter->securitypriv.dot11AuthAlgrthm =
 				dot11AuthAlgrthm_8021X;
 			padapter->securitypriv.ndisauthtype =
@@ -1748,7 +1745,7 @@  static int rtw_cfg80211_add_wep(struct rtw_adapter *padapter,
 	if (keyid >= NUM_WEP_KEYS) {
 		RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
 			 ("%s:keyid>4 =>fail\n", __func__));
-		res = _FAIL;
+		res = -EINVAL;
 		goto exit;
 	}
 
@@ -1767,7 +1764,7 @@  static int rtw_cfg80211_add_wep(struct rtw_adapter *padapter,
 		psecuritypriv->dot11PrivacyAlgrthm = 0;
 		RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
 			 ("%s:wep->KeyLength!= 5 or 13\n", __func__));
-		res = _FAIL;
+		res = -EINVAL;
 		goto exit;
 	}
 
@@ -1808,7 +1805,7 @@  static int rtw_set_ssid(struct rtw_adapter *padapter,
 {
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 	struct wlan_network *pnetwork = &pmlmepriv->cur_network;
-	int status = _SUCCESS;
+	int status = 0;
 	u32 cur_time = 0;
 
 	DBG_8723A_LEVEL(_drv_always_, "set ssid [%s] fw_state = 0x%08x\n",
@@ -1817,7 +1814,7 @@  static int rtw_set_ssid(struct rtw_adapter *padapter,
 	if (padapter->hw_init_completed == false) {
 		RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
 			 ("set_ssid: hw_init_completed == false =>exit!!!\n"));
-		status = _FAIL;
+		status = -EINVAL;
 		goto exit;
 	}
 
@@ -1911,7 +1908,7 @@  handle_tkip_countermeasure:
 			padapter->securitypriv.btkip_countermeasure = false;
 			padapter->securitypriv.btkip_countermeasure_time = 0;
 		} else {
-			status = _FAIL;
+			status = -EINVAL;
 			goto release_mlme_lock;
 		}
 	}
@@ -1927,18 +1924,18 @@  handle_tkip_countermeasure:
 		pmlmepriv->cur_network.join_res = -2;
 
 		status = rtw_do_join_network(padapter, newnetwork);
-		if (status == _SUCCESS) {
+		if (status == 0) {
 			pmlmepriv->to_join = false;
 		} else {
 			if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
 				/* switch to ADHOC_MASTER */
 				status = rtw_do_join_adhoc(padapter);
-				if (status != _SUCCESS)
+				if (status != 0)
 					goto release_mlme_lock;
 			} else {
 				/* can't associate ; reset under-linking */
 				_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
-				status = _FAIL;
+				status = -EOPNOTSUPP;
 				pmlmepriv->to_join = false;
 			}
 		}
@@ -1971,7 +1968,7 @@  static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 	DBG_8723A("privacy =%d, key =%p, key_len =%d, key_idx =%d\n",
 		  sme->privacy, sme->key, sme->key_len, sme->key_idx);
 
-	if (_FAIL == rtw_pwr_wakeup(padapter)) {
+	if (rtw_pwr_wakeup(padapter) < 0) {
 		ret = -EPERM;
 		goto exit;
 	}
@@ -2051,7 +2048,7 @@  static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 	}
 
 	if (cfg80211_infrastructure_mode(
-		    padapter, pnetwork->network.ifmode) != _SUCCESS) {
+		    padapter, pnetwork->network.ifmode) != 0) {
 		ret = -EPERM;
 		goto exit;
 	}
@@ -2123,8 +2120,7 @@  static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 
 		memcpy(wep_key.key, (void *)sme->key, wep_key.keylen);
 
-		if (rtw_cfg80211_add_wep(padapter, &wep_key, wep_key_idx) !=
-		    _SUCCESS)
+		if (rtw_cfg80211_add_wep(padapter, &wep_key, wep_key_idx) != 0)
 			ret = -EOPNOTSUPP;
 
 		if (ret < 0)
@@ -2146,7 +2142,7 @@  static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 	if (psecuritypriv->ndisauthtype > 3)
 		psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
 
-	if (rtw_set_auth23a(padapter, psecuritypriv) != _SUCCESS) {
+	if (rtw_set_auth23a(padapter, psecuritypriv) != 0) {
 		ret = -EBUSY;
 		goto exit;
 	}
@@ -2154,7 +2150,7 @@  static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 	/* rtw_set_802_11_encryption_mode(padapter,
 	   padapter->securitypriv.ndisencryptstatus); */
 
-	if (rtw_set_ssid(padapter, pnetwork) != _SUCCESS) {
+	if (rtw_set_ssid(padapter, pnetwork) != 0) {
 		ret = -EBUSY;
 		goto exit;
 	}
@@ -2772,7 +2768,7 @@  static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head,
 			     WLAN_EID_VENDOR_SPECIFIC, WFD_OUI23A, 4);
 
 	len = ielen + offsetof(struct ieee80211_mgmt, u.beacon.variable);
-	if (rtw_check_beacon_data23a(adapter, tmpmgmt, len) == _SUCCESS) {
+	if (rtw_check_beacon_data23a(adapter, tmpmgmt, len) == 0) {
 		ret = 0;
 	} else {
 		ret = -EINVAL;
@@ -2956,12 +2952,12 @@  static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch,
 	struct xmit_frame *pmgntframe;
 	struct pkt_attrib *pattrib;
 	unsigned char *pframe;
-	int ret = _FAIL;
+	int ret;
 	struct ieee80211_hdr *pwlanhdr;
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 
-	if (_FAIL == rtw_pwr_wakeup(padapter)) {
+	if (rtw_pwr_wakeup(padapter) < 0) {
 		ret = -EFAULT;
 		goto exit;
 	}
@@ -2981,8 +2977,7 @@  static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch,
 	/* starting alloc mgmt frame to dump it */
 	pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
 	if (!pmgntframe) {
-		/* ret = -ENOMEM; */
-		ret = _FAIL;
+		ret = -ENOMEM;
 		goto exit;
 	}
 
@@ -3008,7 +3003,7 @@  static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch,
 
 	ret = dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe);
 
-	if (ret  != _SUCCESS)
+	if (ret != 0)
 		DBG_8723A("%s, ack == false\n", __func__);
 	else
 		DBG_8723A("%s, ack == true\n", __func__);
@@ -3061,12 +3056,12 @@  static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
 	do {
 		dump_cnt++;
 		tx_ret = _cfg80211_rtw_mgmt_tx(padapter, tx_ch, buf, len);
-	} while (dump_cnt < dump_limit && tx_ret != _SUCCESS);
+	} while (dump_cnt < dump_limit && tx_ret != 0);
 
-	if (tx_ret != _SUCCESS || dump_cnt > 1) {
+	if (tx_ret != 0 || dump_cnt > 1) {
 		DBG_8723A("%s(%s): %s (%d/%d) in %d ms\n",
 			  __func__, padapter->pnetdev->name,
-			  tx_ret == _SUCCESS ? "OK" : "FAIL", dump_cnt,
+			  tx_ret == 0 ? "OK" : "FAIL", dump_cnt,
 			  dump_limit, jiffies_to_msecs(jiffies - start));
 	}
 
diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c
index d001003..82dd7aa 100644
--- a/drivers/staging/rtl8723au/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c
@@ -233,7 +233,7 @@  static int loadparam(struct rtw_adapter *padapter,  struct net_device *pnetdev)
 	snprintf(registry_par->if2name, 16, "%s", if2name);
 	registry_par->notch_filter = (u8)rtw_notch_filter;
 	registry_par->regulatory_tid = (u8)rtw_regulatory_id;
-	return _SUCCESS;
+	return 0;
 }
 
 static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
@@ -421,7 +421,7 @@  static int rtw_init_default_value(struct rtw_adapter *padapter)
 	/* misc. */
 	padapter->bReadPortCancel = false;
 	padapter->bWritePortCancel = false;
-	return _SUCCESS;
+	return 0;
 }
 
 int rtw_reset_drv_sw23a(struct rtw_adapter *padapter)
@@ -449,61 +449,61 @@  int rtw_reset_drv_sw23a(struct rtw_adapter *padapter)
 	padapter->mlmeextpriv.sitesurvey_res.state = SCAN_DISABLE;
 
 	rtw_set_signal_stat_timer(&padapter->recvpriv);
-	return _SUCCESS;
+	return 0;
 }
 
 int rtw_init_drv_sw23a(struct rtw_adapter *padapter)
 {
-	int ret8 = _SUCCESS;
+	int ret8 = 0;
 
 	RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw23a\n"));
 
-	if (rtw_init_cmd_priv23a(&padapter->cmdpriv) == _FAIL) {
+	if (rtw_init_cmd_priv23a(&padapter->cmdpriv) < 0) {
 		RT_TRACE(_module_os_intfs_c_, _drv_err_,
 			 ("\n Can't init cmd_priv\n"));
-		ret8 = _FAIL;
+		ret8 = -EINVAL;
 		goto exit;
 	}
 
 	padapter->cmdpriv.padapter = padapter;
 
-	if (rtw_init_evt_priv23a(&padapter->evtpriv) == _FAIL) {
+	if (rtw_init_evt_priv23a(&padapter->evtpriv) < 0) {
 		RT_TRACE(_module_os_intfs_c_, _drv_err_,
 			 ("\n Can't init evt_priv\n"));
-		ret8 = _FAIL;
+		ret8 = -EINVAL;
 		goto exit;
 	}
 
-	if (rtw_init_mlme_priv23a(padapter) == _FAIL) {
+	if (rtw_init_mlme_priv23a(padapter) < 0) {
 		RT_TRACE(_module_os_intfs_c_, _drv_err_,
 			 ("\n Can't init mlme_priv\n"));
-		ret8 = _FAIL;
+		ret8 = -EINVAL;
 		goto exit;
 	}
 
 
-	if (init_mlme_ext_priv23a(padapter) == _FAIL) {
+	if (init_mlme_ext_priv23a(padapter) < 0) {
 		RT_TRACE(_module_os_intfs_c_, _drv_err_,
 			 ("\n Can't init mlme_ext_priv\n"));
-		ret8 = _FAIL;
+		ret8 = -EINVAL;
 		goto exit;
 	}
 
-	if (_rtw_init_xmit_priv23a(&padapter->xmitpriv, padapter) == _FAIL) {
+	if (_rtw_init_xmit_priv23a(&padapter->xmitpriv, padapter) < 0) {
 		DBG_8723A("Can't _rtw_init_xmit_priv23a\n");
-		ret8 = _FAIL;
+		ret8 = -EINVAL;
 		goto exit;
 	}
 
-	if (_rtw_init_recv_priv23a(&padapter->recvpriv, padapter) == _FAIL) {
+	if (_rtw_init_recv_priv23a(&padapter->recvpriv, padapter) < 0) {
 		DBG_8723A("Can't _rtw_init_recv_priv23a\n");
-		ret8 = _FAIL;
+		ret8 = -EINVAL;
 		goto exit;
 	}
 
-	if (_rtw_init_sta_priv23a(&padapter->stapriv) == _FAIL) {
+	if (_rtw_init_sta_priv23a(&padapter->stapriv) < 0) {
 		DBG_8723A("Can't _rtw_init_sta_priv23a\n");
-		ret8 = _FAIL;
+		ret8 = -EINVAL;
 		goto exit;
 	}
 
@@ -578,13 +578,13 @@  int rtw_free_drv_sw23a(struct rtw_adapter *padapter)
 	padapter->HalData = NULL;
 
 	RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_free_drv_sw23a\n"));
-	return _SUCCESS;
+	return 0;
 }
 
 static int _rtw_drv_register_netdev(struct rtw_adapter *padapter, char *name)
 {
 	struct net_device *pnetdev = padapter->pnetdev;
-	int ret = _SUCCESS;
+	int ret = 0;
 
 	/* alloc netdev name */
 	rtw_init_netdev23a_name23a(pnetdev, name);
@@ -594,7 +594,7 @@  static int _rtw_drv_register_netdev(struct rtw_adapter *padapter, char *name)
 	/* Tell the network stack we exist */
 	if (register_netdev(pnetdev)) {
 		DBG_8723A("%s(%s): Failed!\n", __func__, pnetdev->name);
-		ret = _FAIL;
+		ret = -EINVAL;
 		goto error_register_netdev;
 	}
 	DBG_8723A("%s, MAC Address (if%d) = " MAC_FMT "\n", __func__,
@@ -614,10 +614,10 @@  error_register_netdev:
 int rtw_drv_register_netdev(struct rtw_adapter *if1)
 {
 	struct dvobj_priv *dvobj = if1->dvobj;
-	int i, status = _SUCCESS;
+	int i, status = 0;
 
 	if (dvobj->iface_nums >= IFACE_ID_MAX) {
-		status = _FAIL; /* -EINVAL */
+		status = -EINVAL;
 		goto exit;
 	}
 
@@ -634,7 +634,7 @@  int rtw_drv_register_netdev(struct rtw_adapter *if1)
 			else
 				name = "wlan%d";
 			status = _rtw_drv_register_netdev(padapter, name);
-			if (status != _SUCCESS)
+			if (status != 0)
 				break;
 		}
 	}
@@ -663,7 +663,7 @@  int netdev_open23a(struct net_device *pnetdev)
 		padapter->bCardDisableWOHSM = false;
 
 		status = rtl8723au_hal_init(padapter);
-		if (status == _FAIL) {
+		if (status < 0) {
 			RT_TRACE(_module_os_intfs_c_, _drv_err_,
 				 ("rtl871x_hal_init(): Can't init h/w!\n"));
 			goto netdev_open23a_error;
@@ -672,7 +672,7 @@  int netdev_open23a(struct net_device *pnetdev)
 		DBG_8723A("MAC Address = "MAC_FMT"\n",
 			  MAC_ARG(pnetdev->dev_addr));
 
-		if (init_hw_mlme_ext23a(padapter) == _FAIL) {
+		if (init_hw_mlme_ext23a(padapter) < 0) {
 			DBG_8723A("can't init mlme_ext_priv\n");
 			goto netdev_open23a_error;
 		}
@@ -716,13 +716,13 @@  netdev_open23a_error:
 		 ("-871x_drv - dev_open, fail!\n"));
 	DBG_8723A("-871x_drv - drv_open fail, bup =%d\n", padapter->bup);
 
-	ret = -1;
+	ret = -EPERM;
 	goto exit;
 }
 
 static int ips_netdrv_open(struct rtw_adapter *padapter)
 {
-	int status = _SUCCESS;
+	int status = 0;
 
 	padapter->net_closed = false;
 	DBG_8723A("===> %s.........\n", __func__);
@@ -732,7 +732,7 @@  static int ips_netdrv_open(struct rtw_adapter *padapter)
 	padapter->bCardDisableWOHSM = false;
 
 	status = rtl8723au_hal_init(padapter);
-	if (status == _FAIL) {
+	if (status < 0) {
 		RT_TRACE(_module_os_intfs_c_, _drv_err_,
 			 ("ips_netdrv_open(): Can't init h/w!\n"));
 		goto netdev_open23a_error;
@@ -744,14 +744,14 @@  static int ips_netdrv_open(struct rtw_adapter *padapter)
 	mod_timer(&padapter->mlmepriv.dynamic_chk_timer,
 		  jiffies + msecs_to_jiffies(5000));
 
-	return _SUCCESS;
+	return 0;
 
 netdev_open23a_error:
 	/* padapter->bup = false; */
 	DBG_8723A("-ips_netdrv_open - drv_open failure, bup =%d\n",
 		  padapter->bup);
 
-	return _FAIL;
+	return -EINVAL;
 }
 
 int rtw_ips_pwr_up23a(struct rtw_adapter *padapter)
@@ -806,7 +806,7 @@  int pm_netdev_open23a(struct net_device *pnetdev, u8 bnormal)
 	if (bnormal)
 		status = netdev_open23a(pnetdev);
 	else
-		status = (_SUCCESS == ips_netdrv_open(netdev_priv(pnetdev))) ?
+		status = (0 == ips_netdrv_open(netdev_priv(pnetdev))) ?
 			 (0) : (-1);
 
 	return status;
diff --git a/drivers/staging/rtl8723au/os_dep/recv_linux.c b/drivers/staging/rtl8723au/os_dep/recv_linux.c
index bcd970b..e60d9db 100644
--- a/drivers/staging/rtl8723au/os_dep/recv_linux.c
+++ b/drivers/staging/rtl8723au/os_dep/recv_linux.c
@@ -149,12 +149,12 @@  _recv_indicatepkt_end:
 
 	RT_TRACE(_module_recv_osdep_c_, _drv_info_,
 		 ("\n rtw_recv_indicatepkt23a :after netif_rx!!!!\n"));
-	return _SUCCESS;
+	return 0;
 
 _recv_indicatepkt_drop:
 
 	 rtw_free_recvframe23a(precv_frame);
-	 return _FAIL;
+	 return -EINVAL;
 }
 
 void rtw_init_recv_timer23a(struct recv_reorder_ctrl *preorder_ctrl)
diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c
index 08424d4..c3dca28 100644
--- a/drivers/staging/rtl8723au/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c
@@ -63,14 +63,14 @@  static int rtw_init_intf_priv(struct dvobj_priv *dvobj)
 {
 	mutex_init(&dvobj->usb_vendor_req_mutex);
 
-	return _SUCCESS;
+	return 0;
 }
 
 static int rtw_deinit_intf_priv(struct dvobj_priv *dvobj)
 {
 	mutex_destroy(&dvobj->usb_vendor_req_mutex);
 
-	return _SUCCESS;
+	return 0;
 }
 
 static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
@@ -84,7 +84,7 @@  static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
 	struct usb_endpoint_descriptor *pendp_desc;
 	struct usb_device		 *pusbd;
 	int	i;
-	int	status = _FAIL;
+	int	status;
 
 	pdvobjpriv = kzalloc(sizeof(*pdvobjpriv), GFP_KERNEL);
 	if (!pdvobjpriv)
@@ -163,17 +163,18 @@  static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
 		DBG_8723A("NON USB_SPEED_HIGH\n");
 	}
 
-	if (rtw_init_intf_priv(pdvobjpriv) == _FAIL) {
+	if (rtw_init_intf_priv(pdvobjpriv) < 0) {
 		RT_TRACE(_module_os_intfs_c_, _drv_err_,
 			 ("\n Can't INIT rtw_init_intf_priv\n"));
+		status = -EPERM;
 		goto free_dvobj;
 	}
 	/* 3 misc */
 	rtw_reset_continual_urb_error(pdvobjpriv);
 	usb_get_dev(pusbd);
-	status = _SUCCESS;
+	status = 0;
 free_dvobj:
-	if (status != _SUCCESS && pdvobjpriv) {
+	if (status != 0 && pdvobjpriv) {
 		usb_set_intfdata(usb_intf, NULL);
 		mutex_destroy(&pdvobjpriv->hw_init_mutex);
 		mutex_destroy(&pdvobjpriv->h2c_fwcmd_mutex);
@@ -502,11 +503,13 @@  static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
 {
 	struct rtw_adapter *padapter = NULL;
 	struct net_device *pnetdev = NULL;
-	int status = _FAIL;
+	int status;
 
 	pnetdev = rtw_init_netdev23a(padapter);
-	if (!pnetdev)
+	if (!pnetdev) {
+		status = -ENOMEM;
 		goto free_adapter;
+	}
 	padapter = netdev_priv(pnetdev);
 
 	padapter->dvobj = dvobj;
@@ -519,13 +522,17 @@  static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
 
 	SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj));
 
-	if (rtw_wdev_alloc(padapter, dvobj_to_dev(dvobj)))
+	if (rtw_wdev_alloc(padapter, dvobj_to_dev(dvobj))) {
+		status = -ENOMEM;
 		goto free_adapter;
+	}
 
 	/* step 2. allocate HalData */
 	padapter->HalData = kzalloc(sizeof(struct hal_data_8723a), GFP_KERNEL);
-	if (!padapter->HalData)
+	if (!padapter->HalData) {
+		status = -ENOMEM;
 		goto free_wdev;
+	}
 
 	/* step read_chip_version */
 	rtl8723a_read_chip_version(padapter);
@@ -537,9 +544,10 @@  static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
 	rtl8723a_read_adapter_info(padapter);
 
 	/* step 5. */
-	if (rtw_init_drv_sw23a(padapter) == _FAIL) {
+	if (rtw_init_drv_sw23a(padapter) < 0) {
 		RT_TRACE(_module_hci_intfs_c_, _drv_err_,
 			 ("Initialize driver software resource Failed!\n"));
+		status = -EFAULT;
 		goto free_hal_data;
 	}
 
@@ -571,18 +579,18 @@  static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
 		  padapter->bDriverStopped, padapter->bSurpriseRemoved,
 		  padapter->bup, padapter->hw_init_completed
 	);
-	status = _SUCCESS;
+	status = 0;
 
 free_hal_data:
-	if (status != _SUCCESS)
+	if (status != 0)
 		kfree(padapter->HalData);
 free_wdev:
-	if (status != _SUCCESS) {
+	if (status != 0) {
 		rtw_wdev_unregister(padapter->rtw_wdev);
 		rtw_wdev_free(padapter->rtw_wdev);
 	}
 free_adapter:
-	if (status != _SUCCESS) {
+	if (status != 0) {
 		if (pnetdev)
 			free_netdev(pnetdev);
 		padapter = NULL;
@@ -635,7 +643,7 @@  static int rtw_drv_init(struct usb_interface *pusb_intf,
 {
 	struct rtw_adapter *if1 = NULL;
 	struct dvobj_priv *dvobj;
-	int status = _FAIL;
+	int status;
 
 	RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_init\n"));
 
@@ -644,32 +652,34 @@  static int rtw_drv_init(struct usb_interface *pusb_intf,
 	if (!dvobj) {
 		RT_TRACE(_module_hci_intfs_c_, _drv_err_,
 			 ("initialize device object priv Failed!\n"));
+		status = -EFAULT;
 		goto exit;
 	}
 
 	if1 = rtw_usb_if1_init(dvobj, pusb_intf, pdid);
 	if (!if1) {
 		DBG_8723A("rtw_init_primary_adapter Failed!\n");
+		status = -EFAULT;
 		goto free_dvobj;
 	}
 
 	/* dev_alloc_name && register_netdev */
 	status = rtw_drv_register_netdev(if1);
-	if (status != _SUCCESS)
+	if (status != 0)
 		goto free_if1;
 	RT_TRACE(_module_hci_intfs_c_, _drv_err_,
 		 ("-871x_drv - drv_init, success!\n"));
 
-	status = _SUCCESS;
+	status = 0;
 
 free_if1:
-	if (status != _SUCCESS && if1)
+	if (status != 0 && if1)
 		rtw_usb_if1_deinit(if1);
 free_dvobj:
-	if (status != _SUCCESS)
+	if (status != 0)
 		usb_dvobj_deinit(pusb_intf);
 exit:
-	return status == _SUCCESS ? 0 : -ENODEV;
+	return status == 0 ? 0 : -ENODEV;
 }
 
 /* dev_remove() - our device is being removed */
diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c
index 3e19b3b..b7f547b 100644
--- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c
+++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c
@@ -130,7 +130,7 @@  int rtl8723au_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt,
 	unsigned long irqL;
 	unsigned int pipe, ep_num;
 	int status;
-	int ret = _FAIL;
+	int ret;
 
 	RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port23a\n"));
 
@@ -139,6 +139,7 @@  int rtl8723au_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt,
 			 ("%s:(padapter->bDriverStopped || "
 			  "padapter->bSurpriseRemoved)!!!\n", __func__));
 		rtw23a_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_TX_DENY);
+		ret = -EINVAL;
 		goto exit;
 	}
 
@@ -200,11 +201,11 @@  int rtl8723au_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt,
 		}
 		goto exit;
 	}
-	ret = _SUCCESS;
+	ret = 0;
 	RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("-usb_write_port23a\n"));
 
 exit:
-	if (ret != _SUCCESS)
+	if (ret != 0)
 		rtw_free_xmitbuf23a(pxmitpriv, pxmitbuf);
 
 	return ret;
diff --git a/drivers/staging/rtl8723au/os_dep/xmit_linux.c b/drivers/staging/rtl8723au/os_dep/xmit_linux.c
index 69f8884..8abb037 100644
--- a/drivers/staging/rtl8723au/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8723au/os_dep/xmit_linux.c
@@ -31,7 +31,7 @@  int rtw_os_xmit_resource_alloc23a(struct rtw_adapter *padapter,
 
 	pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL);
 	if (pxmitbuf->pallocated_buf == NULL)
-		return _FAIL;
+		return -ENOMEM;
 
 	pxmitbuf->pbuf = PTR_ALIGN(pxmitbuf->pallocated_buf, XMITBUF_ALIGN_SZ);
 
@@ -39,10 +39,10 @@  int rtw_os_xmit_resource_alloc23a(struct rtw_adapter *padapter,
 		pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
 		if (pxmitbuf->pxmit_urb[i] == NULL) {
 			DBG_8723A("pxmitbuf->pxmit_urb[i]==NULL");
-			return _FAIL;
+			return -ENOMEM;
 		}
 	}
-	return _SUCCESS;
+	return 0;
 }
 
 void rtw_os_xmit_resource_free23a(struct rtw_adapter *padapter,