[OPW,kernel,3/5] staging: rtl8723: hal: Replace non-standard return values
diff mbox

Message ID 1414545296-23986-4-git-send-email-roberta.dobrescu@gmail.com
State New, archived
Headers show

Commit Message

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

While at it, it removes some goto labels which are no longer needed.

Signed-off-by: Roberta Dobrescu <roberta.dobrescu@gmail.com>
---
 drivers/staging/rtl8723au/hal/hal_com.c           | 15 +++--
 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c      | 19 +++---
 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 70 +++++++++++------------
 drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c   | 10 ++--
 drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c   |  6 +-
 drivers/staging/rtl8723au/hal/rtl8723au_recv.c    |  4 +-
 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c    | 22 +++----
 drivers/staging/rtl8723au/hal/usb_halinit.c       | 40 ++++++-------
 drivers/staging/rtl8723au/hal/usb_ops_linux.c     | 37 ++++++------
 9 files changed, 111 insertions(+), 112 deletions(-)

Patch
diff mbox

diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c
index bf4cae2..e15a8d8 100644
--- a/drivers/staging/rtl8723au/hal/hal_com.c
+++ b/drivers/staging/rtl8723au/hal/hal_com.c
@@ -358,20 +358,25 @@  void c2h_evt_clear23a(struct rtw_adapter *adapter)
 
 int c2h_evt_read23a(struct rtw_adapter *adapter, u8 *buf)
 {
-	int ret = _FAIL;
+	int ret;
 	struct c2h_evt_hdr *c2h_evt;
 	int i;
 	u8 trigger;
 
-	if (buf == NULL)
+	if (buf == NULL) {
+		ret = -EINVAL;
 		goto exit;
+	}
 
 	trigger = rtl8723au_read8(adapter, REG_C2HEVT_CLEAR);
 
-	if (trigger == C2H_EVT_HOST_CLOSE)
+	if (trigger == C2H_EVT_HOST_CLOSE) {
+		ret = -EBUSY;
 		goto exit;	/* Not ready */
-	else if (trigger != C2H_EVT_FW_CLOSE)
+	} else if (trigger != C2H_EVT_FW_CLOSE) {
+		ret = -EFAULT;
 		goto clear_evt;	/* Not a valid value */
+	}
 
 	c2h_evt = (struct c2h_evt_hdr *)buf;
 
@@ -399,7 +404,7 @@  int c2h_evt_read23a(struct rtw_adapter *adapter, u8 *buf)
 		      "c2h_evt_read23a(): Command Content:\n", c2h_evt->payload,
 		      c2h_evt->plen);
 
-	ret = _SUCCESS;
+	ret = 0;
 
 clear_evt:
 	/*
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
index 7b56411..c497d36 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
@@ -58,19 +58,22 @@  int FillH2CCmd(struct rtw_adapter *padapter, u8 ElementID, u32 CmdLen,
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
 	u32 h2c_cmd = 0;
 	u16 h2c_cmd_ex = 0;
-	int ret = _FAIL;
+	int ret;
 
 	padapter = GET_PRIMARY_ADAPTER(padapter);
 	pHalData = GET_HAL_DATA(padapter);
 
 	mutex_lock(&adapter_to_dvobj(padapter)->h2c_fwcmd_mutex);
 
-	if (!pCmdBuffer)
+	if (!pCmdBuffer || CmdLen > RTL92C_MAX_CMD_LEN) {
+		ret = -EINVAL;
 		goto exit;
-	if (CmdLen > RTL92C_MAX_CMD_LEN)
-		goto exit;
-	if (padapter->bSurpriseRemoved == true)
+	}
+
+	if (padapter->bSurpriseRemoved == true) {
+		ret = -ENODEV;
 		goto exit;
+	}
 
 	/* pay attention to if  race condition happened in  H2C cmd setting. */
 	do {
@@ -106,7 +109,7 @@  int FillH2CCmd(struct rtw_adapter *padapter, u8 ElementID, u32 CmdLen,
 
 	} while ((!bcmd_down) && (retry_cnts--));
 
-	ret = _SUCCESS;
+	ret = 0;
 
 exit:
 	mutex_unlock(&adapter_to_dvobj(padapter)->h2c_fwcmd_mutex);
@@ -119,7 +122,7 @@  int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u8 *param)
 
 	FillH2CCmd(padapter, RSSI_SETTING_EID, 3, param);
 
-	return _SUCCESS;
+	return 0;
 }
 
 int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
@@ -133,7 +136,7 @@  int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
 
 	FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf);
 
-	return _SUCCESS;
+	return 0;
 }
 
 /* bitmap[0:27] = tx_rate_bitmap */
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
index 9a75eb6..2bfd5d7 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
@@ -52,7 +52,7 @@  static int _BlockWrite(struct rtw_adapter *padapter, void *buffer, u32 buffSize)
 	int ret;
 
 	if (buffSize > MAX_PAGE_SIZE)
-		return _FAIL;
+		return -EINVAL;
 
 	ret = rtl8723au_writeN(padapter, FW_8723A_START_ADDRESS,
 			       buffSize, buffer);
@@ -77,7 +77,7 @@  static int _WriteFW(struct rtw_adapter *padapter, void *buffer, u32 size)
 	/*  Since we need dynamic decide method of dwonload fw, so we
 	    call this function to get chip version. */
 	/*  We can remove _ReadChipVersion from ReadpadapterInfo8192C later. */
-	int ret = _SUCCESS;
+	int ret = 0;
 	u32 pageNums, remainSize;
 	u32 page, offset;
 	u8 *bufferPtr = (u8 *) buffer;
@@ -92,7 +92,7 @@  static int _WriteFW(struct rtw_adapter *padapter, void *buffer, u32 size)
 		ret = _PageWrite(padapter, page, bufferPtr + offset,
 				 MAX_PAGE_SIZE);
 
-		if (ret == _FAIL)
+		if (ret < 0)
 			goto exit;
 	}
 	if (remainSize) {
@@ -101,7 +101,7 @@  static int _WriteFW(struct rtw_adapter *padapter, void *buffer, u32 size)
 		ret = _PageWrite(padapter, page, bufferPtr + offset,
 				 remainSize);
 
-		if (ret == _FAIL)
+		if (ret < 0)
 			goto exit;
 	}
 	RT_TRACE(_module_hal_init_c_, _drv_info_,
@@ -127,7 +127,7 @@  static int _FWFreeToGo(struct rtw_adapter *padapter)
 		RT_TRACE(_module_hal_init_c_, _drv_err_,
 			 ("%s: chksum report fail! REG_MCUFWDL:0x%08x\n",
 			  __func__, value32));
-		return _FAIL;
+		return -EINVAL;
 	}
 	RT_TRACE(_module_hal_init_c_, _drv_info_,
 		 ("%s: Checksum report OK! REG_MCUFWDL:0x%08x\n", __func__,
@@ -147,7 +147,7 @@  static int _FWFreeToGo(struct rtw_adapter *padapter)
 				 ("%s: Polling FW ready success!! "
 				  "REG_MCUFWDL:0x%08x\n",
 				  __func__, value32));
-			return _SUCCESS;
+			return 0;
 		}
 		udelay(5);
 	} while (counter++ < POLLING_READY_TIMEOUT_COUNT);
@@ -155,7 +155,7 @@  static int _FWFreeToGo(struct rtw_adapter *padapter)
 	RT_TRACE(_module_hal_init_c_, _drv_err_,
 		 ("%s: Polling FW ready fail!! REG_MCUFWDL:0x%08x\n",
 		  __func__, value32));
-	return _FAIL;
+	return -EIO;
 }
 
 #define IS_FW_81xxC(padapter)	(((GET_HAL_DATA(padapter))->FirmwareSignature & 0xFFF0) == 0x88C0)
@@ -202,7 +202,7 @@  void rtl8723a_FirmwareSelfReset(struct rtw_adapter *padapter)
 /*  */
 int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter)
 {
-	int rtStatus = _SUCCESS;
+	int rtStatus = 0;
 	u8 writeFW_retry = 0;
 	unsigned long fwdl_start_time;
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
@@ -245,24 +245,24 @@  int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter)
 		    to match the ROM code. */
 		RT_TRACE(_module_hal_init_c_, _drv_err_,
 			 ("%s: unknow version!\n", __func__));
-		rtStatus = _FAIL;
+		rtStatus = -EINVAL;
 		goto Exit;
 	}
 
 	pr_info("rtl8723au: Loading firmware %s\n", fw_name);
 	if (request_firmware(&fw, fw_name, device)) {
 		pr_err("rtl8723au: request_firmware load failed\n");
-		rtStatus = _FAIL;
+		rtStatus = -EBUSY;
 		goto Exit;
 	}
 	if (!fw) {
 		pr_err("rtl8723au: Firmware %s not available\n", fw_name);
-		rtStatus = _FAIL;
+		rtStatus = -EBUSY;
 		goto Exit;
 	}
 	firmware_buf = kmemdup(fw->data, fw->size, GFP_KERNEL);
 	if (!firmware_buf) {
-		rtStatus = _FAIL;
+		rtStatus = -ENOMEM;
 		goto Exit;
 	}
 	buf = firmware_buf;
@@ -311,7 +311,7 @@  int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter)
 
 		rtStatus = _WriteFW(padapter, buf, fw_size);
 
-		if (rtStatus == _SUCCESS ||
+		if (rtStatus == 0 ||
 		    (jiffies_to_msecs(jiffies - fwdl_start_time) > 500 &&
 		     writeFW_retry++ >= 3))
 			break;
@@ -321,13 +321,13 @@  int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter)
 			  jiffies_to_msecs(jiffies - fwdl_start_time));
 	}
 	_FWDownloadEnable(padapter, false);
-	if (_SUCCESS != rtStatus) {
+	if (rtStatus != 0) {
 		DBG_8723A("DL Firmware failed!\n");
 		goto Exit;
 	}
 
 	rtStatus = _FWFreeToGo(padapter);
-	if (_SUCCESS != rtStatus) {
+	if (rtStatus != 0) {
 		RT_TRACE(_module_hal_init_c_, _drv_err_,
 			 ("DL Firmware failed!\n"));
 		goto Exit;
@@ -626,8 +626,7 @@  u16 rtl8723a_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter)
 	hal_EfuseSwitchToBank(padapter, 0);
 
 	while (AVAILABLE_EFUSE_ADDR(efuse_addr)) {
-		if (efuse_OneByteRead23a(padapter, efuse_addr, &efuse_data) ==
-		    _FAIL) {
+		if (efuse_OneByteRead23a(padapter, efuse_addr, &efuse_data) < 0) {
 			DBG_8723A(KERN_ERR "%s: efuse_OneByteRead23a Fail! "
 				  "addr = 0x%X !!\n", __func__, efuse_addr);
 			break;
@@ -698,7 +697,7 @@  u16 rtl8723a_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter)
 
 		while (AVAILABLE_EFUSE_ADDR(efuse_addr)) {
 			if (efuse_OneByteRead23a(padapter, efuse_addr,
-					      &efuse_data) == _FAIL) {
+					      &efuse_data) < 0) {
 				DBG_8723A(KERN_ERR "%s: efuse_OneByteRead23a Fail!"
 					  " addr = 0x%X !!\n",
 					  __func__, efuse_addr);
@@ -774,8 +773,7 @@  rtl8723a_EfusePgPacketRead(struct rtw_adapter *padapter, u8 offset, u8 *data)
 	/*  By pass right now. 2009.02.19. */
 	/*  */
 	while (AVAILABLE_EFUSE_ADDR(efuse_addr)) {
-		if (efuse_OneByteRead23a(padapter, efuse_addr++, &efuse_data) ==
-		    _FAIL) {
+		if (efuse_OneByteRead23a(padapter, efuse_addr++, &efuse_data) < 0) {
 			ret = false;
 			break;
 		}
@@ -1071,12 +1069,12 @@  bool c2h_id_filter_ccx_8723a(u8 id)
 
 int c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt)
 {
-	int ret = _SUCCESS;
+	int ret = 0;
 	u8 i = 0;
 
 	if (c2h_evt == NULL) {
 		DBG_8723A("%s c2h_evt is NULL\n", __func__);
-		ret = _FAIL;
+		ret = -EINVAL;
 		goto exit;
 	}
 
@@ -1118,7 +1116,7 @@  int c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt)
 		break;
 
 	default:
-		ret = _FAIL;
+		ret = -EINVAL;
 		break;
 	}
 
@@ -1211,7 +1209,7 @@  u8 GetEEPROMSize8723A(struct rtw_adapter *padapter)
 /*  */
 static int _LLTWrite(struct rtw_adapter *padapter, u32 address, u32 data)
 {
-	int status = _SUCCESS;
+	int status = 0;
 	s32 count = 0;
 	u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) |
 		    _LLT_OP(_LLT_WRITE_ACCESS);
@@ -1230,7 +1228,7 @@  static int _LLTWrite(struct rtw_adapter *padapter, u32 address, u32 data)
 			RT_TRACE(_module_hal_init_c_, _drv_err_,
 				 ("Failed to polling write LLT done at "
 				  "address %d!\n", address));
-			status = _FAIL;
+			status = -EIO;
 			break;
 		}
 	} while (count++);
@@ -1240,23 +1238,21 @@  static int _LLTWrite(struct rtw_adapter *padapter, u32 address, u32 data)
 
 int InitLLTTable23a(struct rtw_adapter *padapter, u32 boundary)
 {
-	int status = _SUCCESS;
+	int status = 0;
 	u32 i;
 	u32 txpktbuf_bndy = boundary;
 	u32 Last_Entry_Of_TxPktBuf = LAST_ENTRY_OF_TX_PKT_BUFFER;
 
 	for (i = 0; i < (txpktbuf_bndy - 1); i++) {
 		status = _LLTWrite(padapter, i, i + 1);
-		if (status != _SUCCESS) {
+		if (status != 0)
 			return status;
-		}
 	}
 
 	/*  end of list */
 	status = _LLTWrite(padapter, (txpktbuf_bndy - 1), 0xFF);
-	if (status != _SUCCESS) {
+	if (status != 0)
 		return status;
-	}
 
 	/*  Make the other pages as ring buffer */
 	/*  This ring buffer is used as beacon buffer if we config this
@@ -1264,16 +1260,14 @@  int InitLLTTable23a(struct rtw_adapter *padapter, u32 boundary)
 	/*  Otherwise used as local loopback buffer. */
 	for (i = txpktbuf_bndy; i < Last_Entry_Of_TxPktBuf; i++) {
 		status = _LLTWrite(padapter, i, (i + 1));
-		if (_SUCCESS != status) {
+		if (status != 0)
 			return status;
-		}
 	}
 
 	/*  Let last entry point to the start entry of ring buffer */
 	status = _LLTWrite(padapter, Last_Entry_Of_TxPktBuf, txpktbuf_bndy);
-	if (status != _SUCCESS) {
+	if (status != 0)
 		return status;
-	}
 
 	return status;
 }
@@ -1523,7 +1517,7 @@  static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM)
 int CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU)
 {
 	if (padapter->bSurpriseRemoved) {
-		return _SUCCESS;
+		return 0;
 	}
 	/*  RF Off Sequence ==== */
 	_DisableRFAFEAndResetBB(padapter);
@@ -1540,14 +1534,14 @@  int CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU)
 	RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
 		 ("======> Card disable finished.\n"));
 
-	return _SUCCESS;
+	return 0;
 }
 
 /*  without HW Auto state machine */
 int CardDisableWithoutHWSM(struct rtw_adapter *padapter)
 {
 	if (padapter->bSurpriseRemoved) {
-		return _SUCCESS;
+		return 0;
 	}
 
 	/*  RF Off Sequence ==== */
@@ -1567,7 +1561,7 @@  int CardDisableWithoutHWSM(struct rtw_adapter *padapter)
 
 	/* RT_TRACE(COMP_INIT, DBG_LOUD,
 	   ("<====== Card Disable Without HWSM .\n")); */
-	return _SUCCESS;
+	return 0;
 }
 
 void Hal_InitPGData(struct rtw_adapter *padapter, u8 *PROMContent)
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c
index 88e91cd..8ebb4a8 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c
@@ -432,7 +432,7 @@  int PHY_MACConfig8723A(struct rtw_adapter *Adapter)
 	if (is92C && (BOARD_USB_DONGLE == pHalData->BoardType))
 		rtl8723au_write8(Adapter, 0x40, 0x04);
 
-	return _SUCCESS;
+	return 0;
 }
 
 /**
@@ -716,7 +716,7 @@  phy_ConfigBBWithPgHeaderFile(struct rtw_adapter *Adapter, u8 ConfigType)
 		}
 	}
 
-	return _SUCCESS;
+	return 0;
 }	/* phy_ConfigBBWithPgHeaderFile */
 
 static void
@@ -745,7 +745,7 @@  phy_BB8723a_Config_ParaFile(struct rtw_adapter *Adapter)
 {
 	struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(Adapter);
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
-	int rtStatus = _SUCCESS;
+	int rtStatus = 0;
 
 	/*  */
 	/*  1. Read PHY_REG.TXT BB INIT!! */
@@ -772,7 +772,7 @@  phy_BB8723a_Config_ParaFile(struct rtw_adapter *Adapter)
 							BaseBand_Config_PHY_REG);
 	}
 
-	if (rtStatus != _SUCCESS)
+	if (rtStatus != 0)
 		goto phy_BB8190_Config_ParaFile_Fail;
 
 	/*  */
@@ -788,7 +788,7 @@  phy_BB8190_Config_ParaFile_Fail:
 int
 PHY_BBConfig8723A(struct rtw_adapter *Adapter)
 {
-	int rtStatus = _SUCCESS;
+	int rtStatus = 0;
 	struct hal_data_8723a	*pHalData = GET_HAL_DATA(Adapter);
 	u8 TmpU1B = 0;
 	u8 CrystalCap;
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c
index 2dc0886..2316d08 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c
@@ -417,7 +417,7 @@  static int phy_RF6052_Config_ParaFile(struct rtw_adapter *Adapter)
 	u32 u4RegValue = 0;
 	u8 eRFPath;
 	struct bb_reg_define	*pPhyReg;
-	int rtStatus = _SUCCESS;
+	int rtStatus = 0;
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
 
 	/* 3----------------------------------------------------------------- */
@@ -471,7 +471,7 @@  static int phy_RF6052_Config_ParaFile(struct rtw_adapter *Adapter)
 			break;
 		}
 
-		if (rtStatus != _SUCCESS) {
+		if (rtStatus != 0) {
 			/* RT_TRACE(COMP_FPGA, DBG_LOUD, ("phy_RF6052_Config_ParaFile():Radio[%d] Fail!!", eRFPath)); */
 			goto phy_RF6052_Config_ParaFile_Fail;
 		}
@@ -483,7 +483,7 @@  phy_RF6052_Config_ParaFile_Fail:
 int PHY_RF6052_Config8723A(struct rtw_adapter *Adapter)
 {
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
-	int rtStatus = _SUCCESS;
+	int rtStatus = 0;
 
 	/*  Initialize general global value */
 	/*  TODO: Extend RF_PATH_C and RF_PATH_D in the future */
diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c
index 6075b6d..901e1d4 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c
@@ -26,7 +26,7 @@ 
 int rtl8723au_init_recv_priv(struct rtw_adapter *padapter)
 {
 	struct recv_priv *precvpriv = &padapter->recvpriv;
-	int i, size, res = _SUCCESS;
+	int i, size, res = 0;
 	struct recv_buf *precvbuf;
 	unsigned long tmpaddr;
 	unsigned long alignment;
@@ -46,7 +46,7 @@  int rtl8723au_init_recv_priv(struct rtw_adapter *padapter)
 	size = NR_RECVBUFF * sizeof(struct recv_buf);
 	precvpriv->precv_buf = kzalloc(size, GFP_KERNEL);
 	if (!precvpriv->precv_buf) {
-		res = _FAIL;
+		res = -ENOMEM;
 		RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
 			 ("alloc recv_buf fail!\n"));
 		goto exit;
diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c
index a67850f..d98b0eb 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c
@@ -297,8 +297,8 @@  static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag
 static int rtw_dump_xframe(struct rtw_adapter *padapter,
 			   struct xmit_frame *pxmitframe)
 {
-	int ret = _SUCCESS;
-	int inner_ret = _SUCCESS;
+	int ret = 0;
+	int inner_ret = 0;
 	int t, sz, w_sz, pull = 0;
 	u8 *mem_addr;
 	u32 ff_hwaddr;
@@ -317,8 +317,8 @@  static int rtw_dump_xframe(struct rtw_adapter *padapter,
 	RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_dump_xframe()\n"));
 
 	for (t = 0; t < pattrib->nr_frags; t++) {
-		if (inner_ret != _SUCCESS && ret == _SUCCESS)
-			ret = _FAIL;
+		if (inner_ret != 0 && ret == 0)
+			ret = -EINVAL;
 
 		if (t != (pattrib->nr_frags - 1)) {
 			RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
@@ -358,7 +358,7 @@  static int rtw_dump_xframe(struct rtw_adapter *padapter,
 
 	rtw_free_xmitframe23a(pxmitpriv, pxmitframe);
 
-	if  (ret != _SUCCESS)
+	if  (ret != 0)
 		rtw23a_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_UNKNOWN);
 
 	return ret;
@@ -371,7 +371,7 @@  bool rtl8723au_xmitframe_complete(struct rtw_adapter *padapter,
 	struct hw_xmit *phwxmits;
 	struct xmit_frame *pxmitframe;
 	int hwentry;
-	int res = _SUCCESS, xcnt = 0;
+	int res = 0, xcnt = 0;
 
 	phwxmits = pxmitpriv->hwxmits;
 	hwentry = pxmitpriv->hwxmit_entry;
@@ -401,7 +401,7 @@  bool rtl8723au_xmitframe_complete(struct rtw_adapter *padapter,
 
 		RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("xmitframe_complete(): rtw_dump_xframe\n"));
 
-		if (res == _SUCCESS) {
+		if (res == 0) {
 			rtw_dump_xframe(padapter, pxmitframe);
 		} else {
 			rtw_free_xmitbuf23a(pxmitpriv, pxmitbuf);
@@ -421,7 +421,7 @@  static int xmitframe_direct(struct rtw_adapter *padapter,
 	int res;
 
 	res = rtw_xmitframe_coalesce23a(padapter, pxmitframe->pkt, pxmitframe);
-	if (res == _SUCCESS)
+	if (res == 0)
 		rtw_dump_xframe(padapter, pxmitframe);
 	return res;
 }
@@ -480,7 +480,7 @@  bool rtl8723au_hal_xmit(struct rtw_adapter *padapter,
 	pxmitframe->buf_addr = pxmitbuf->pbuf;
 	pxmitbuf->priv_data = pxmitframe;
 
-	if (xmitframe_direct(padapter, pxmitframe) != _SUCCESS) {
+	if (xmitframe_direct(padapter, pxmitframe) != 0) {
 		rtw_free_xmitbuf23a(pxmitpriv, pxmitbuf);
 		rtw_free_xmitframe23a(pxmitpriv, pxmitframe);
 	}
@@ -490,7 +490,7 @@  enqueue:
 	res = rtw_xmitframe_enqueue23a(padapter, pxmitframe);
 	spin_unlock_bh(&pxmitpriv->lock);
 
-	if (res != _SUCCESS) {
+	if (res != 0) {
 		RT_TRACE(_module_xmit_osdep_c_, _drv_err_,
 			 ("pre_xmitframe: enqueue xmitframe fail\n"));
 		rtw_free_xmitframe23a(pxmitpriv, pxmitframe);
@@ -516,7 +516,7 @@  int rtl8723au_hal_xmitframe_enqueue(struct rtw_adapter *padapter,
 	int err;
 
 	err = rtw_xmitframe_enqueue23a(padapter, pxmitframe);
-	if (err != _SUCCESS) {
+	if (err != 0) {
 		rtw_free_xmitframe23a(pxmitpriv, pxmitframe);
 
 		/*  Trick, make the statistics correct */
diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c
index adc2953..dc25b4d 100644
--- a/drivers/staging/rtl8723au/hal/usb_halinit.c
+++ b/drivers/staging/rtl8723au/hal/usb_halinit.c
@@ -94,7 +94,7 @@  void rtl8723au_chip_configure(struct rtw_adapter *padapter)
 
 static int _InitPowerOn(struct rtw_adapter *padapter)
 {
-	int status = _SUCCESS;
+	int status = 0;
 	u16 value16 = 0;
 	u8 value8 = 0;
 
@@ -105,7 +105,7 @@  static int _InitPowerOn(struct rtw_adapter *padapter)
 	/*  HW Power on sequence */
 	if (!HalPwrSeqCmdParsing23a(padapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,
 				 PWR_INTF_USB_MSK, rtl8723AU_card_enable_flow))
-		return _FAIL;
+		return -EINVAL;
 
 	/*  0x04[19] = 1, suggest by Jackie 2011.05.09, reset 8051 */
 	value8 = rtl8723au_read8(padapter, REG_APS_FSMCO+2);
@@ -533,7 +533,7 @@  int rtl8723au_hal_init(struct rtw_adapter *Adapter)
 {
 	u8 val8 = 0;
 	u32 boundary;
-	int status = _SUCCESS;
+	int status = 0;
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
 	struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv;
 	struct registry_priv *pregistrypriv = &Adapter->registrypriv;
@@ -574,7 +574,7 @@  int rtl8723au_hal_init(struct rtw_adapter *Adapter)
 	}
 
 	status = _InitPowerOn(Adapter);
-	if (status == _FAIL) {
+	if (status < 0) {
 		RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
 			 ("Failed to init power on!\n"));
 		goto exit;
@@ -589,7 +589,7 @@  int rtl8723au_hal_init(struct rtw_adapter *Adapter)
 
 	if (!pHalData->bMACFuncEnable) {
 		status =  InitLLTTable23a(Adapter, boundary);
-		if (status == _FAIL) {
+		if (status < 0) {
 			RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
 				 ("Failed to init LLT table\n"));
 			goto exit;
@@ -600,7 +600,7 @@  int rtl8723au_hal_init(struct rtw_adapter *Adapter)
 		_InitRDGSetting(Adapter);
 
 	status = rtl8723a_FirmwareDownload(Adapter);
-	if (status != _SUCCESS) {
+	if (status != 0) {
 		Adapter->bFWReady = false;
 		pHalData->fw_ractrl = false;
 		DBG_8723A("fw download fail!\n");
@@ -631,7 +631,7 @@  int rtl8723au_hal_init(struct rtw_adapter *Adapter)
 	pHalData->CurrentChannel = 6;/* default set to 6 */
 
 	status = PHY_MACConfig8723A(Adapter);
-	if (status == _FAIL) {
+	if (status < 0) {
 		DBG_8723A("PHY_MACConfig8723A fault !!\n");
 		goto exit;
 	}
@@ -640,7 +640,7 @@  int rtl8723au_hal_init(struct rtw_adapter *Adapter)
 	/* d. Initialize BB related configurations. */
 	/*  */
 	status = PHY_BBConfig8723A(Adapter);
-	if (status == _FAIL) {
+	if (status < 0) {
 		DBG_8723A("PHY_BBConfig8723A fault !!\n");
 		goto exit;
 	}
@@ -649,7 +649,7 @@  int rtl8723au_hal_init(struct rtw_adapter *Adapter)
 	/*  Because the tx power by rate table is inited in BB config. */
 
 	status = PHY_RF6052_Config8723A(Adapter);
-	if (status == _FAIL) {
+	if (status < 0) {
 		DBG_8723A("PHY_RF6052_Config8723A failed!!\n");
 		goto exit;
 	}
@@ -793,7 +793,7 @@  int rtl8723au_hal_init(struct rtw_adapter *Adapter)
 			  rtl8723au_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12));
 
 exit:
-	if (status == _SUCCESS) {
+	if (status == 0) {
 		Adapter->hw_init_completed = true;
 
 		if (Adapter->registrypriv.notch_filter == 1)
@@ -1124,37 +1124,35 @@  int rtl8723au_hal_deinit(struct rtw_adapter *padapter)
 
 	padapter->hw_init_completed = false;
 
-	return _SUCCESS;
+	return 0;
 }
 
 int rtl8723au_inirp_init(struct rtw_adapter *Adapter)
 {
 	u8 i;
 	struct recv_buf *precvbuf;
-	int status;
+	int status = 0;
 	struct recv_priv *precvpriv = &Adapter->recvpriv;
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
 
-	status = _SUCCESS;
-
 	RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("===> usb_inirp_init\n"));
 
 	/* issue Rx irp to receive data */
 	precvbuf = (struct recv_buf *)precvpriv->precv_buf;
 	for (i = 0; i < NR_RECVBUFF; i++) {
 		if (rtl8723au_read_port(Adapter, RECV_BULK_IN_ADDR, 0,
-					precvbuf) == _FAIL) {
+					precvbuf) < 0) {
 			RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
 				 ("usb_rx_init: usb_read_port error\n"));
-			status = _FAIL;
+			status = -EIO;
 			goto exit;
 		}
 		precvbuf++;
 	}
-	if (rtl8723au_read_interrupt(Adapter, RECV_INT_IN_ADDR) == _FAIL) {
+	if (rtl8723au_read_interrupt(Adapter, RECV_INT_IN_ADDR) < 0) {
 		RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
 			 ("usb_rx_init: usb_read_interrupt error\n"));
-		status = _FAIL;
+		status = -EINTR;
 	}
 	pHalData->IntrMask[0] = rtl8723au_read32(Adapter, REG_USB_HIMR);
 	MSG_8723A("pHalData->IntrMask = 0x%04x\n", pHalData->IntrMask[0]);
@@ -1180,7 +1178,7 @@  int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter)
 	rtl8723au_write32(Adapter, REG_USB_HIMR, pHalData->IntrMask[0]);
 	RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
 		 ("\n <=== usb_rx_deinit\n"));
-	return _SUCCESS;
+	return 0;
 }
 
 static void _ReadBoardType(struct rtw_adapter *Adapter, u8 *PROMContent,
@@ -1369,7 +1367,7 @@  int GetHalDefVar8192CUsb(struct rtw_adapter *Adapter,
 			 enum hal_def_variable eVariable, void *pValue)
 {
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
-	int bResult = _SUCCESS;
+	int bResult = 0;
 
 	switch (eVariable) {
 	case HAL_DEF_UNDERCORATEDSMOOTHEDPWDB:
@@ -1407,7 +1405,7 @@  int GetHalDefVar8192CUsb(struct rtw_adapter *Adapter,
 	default:
 		/* RT_TRACE(COMP_INIT, DBG_WARNING, ("GetHalDefVar8192CUsb(): "
 		   "Unkown variable: %d!\n", eVariable)); */
-		bResult = _FAIL;
+		bResult = -EINVAL;
 		break;
 	}
 
diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c
index c1b04c1..0e4a701 100644
--- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c
+++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c
@@ -95,9 +95,9 @@  int rtl8723au_write8(struct rtw_adapter *padapter, u16 addr, u8 val)
 			      RTW_USB_CONTROL_MSG_TIMEOUT);
 
 	if (ret != sizeof(val))
-		ret = _FAIL;
+		ret = -EINVAL;
 	else
-		ret = _SUCCESS;
+		ret = 0;
 
 	mutex_unlock(&pdvobjpriv->usb_vendor_req_mutex);
 	return ret;
@@ -119,9 +119,9 @@  int rtl8723au_write16(struct rtw_adapter *padapter, u16 addr, u16 val)
 			      RTW_USB_CONTROL_MSG_TIMEOUT);
 
 	if (ret != sizeof(val))
-		ret = _FAIL;
+		ret = -EINVAL;
 	else
-		ret = _SUCCESS;
+		ret = 0;
 
 	mutex_unlock(&pdvobjpriv->usb_vendor_req_mutex);
 	return ret;
@@ -143,9 +143,9 @@  int rtl8723au_write32(struct rtw_adapter *padapter, u16 addr, u32 val)
 			      RTW_USB_CONTROL_MSG_TIMEOUT);
 
 	if (ret != sizeof(val))
-		ret = _FAIL;
+		ret = -EINVAL;
 	else
-		ret = _SUCCESS;
+		ret = 0;
 
 	mutex_unlock(&pdvobjpriv->usb_vendor_req_mutex);
 	return ret;
@@ -163,8 +163,8 @@  int rtl8723au_writeN(struct rtw_adapter *padapter, u16 addr, u16 len, u8 *buf)
 			      addr, 0, buf, len, RTW_USB_CONTROL_MSG_TIMEOUT);
 
 	if (ret != len)
-		return _FAIL;
-	return _SUCCESS;
+		return -EINVAL;
+	return 0;
 }
 
 /*
@@ -321,7 +321,7 @@  int rtl8723au_read_interrupt(struct rtw_adapter *adapter, u32 addr)
 {
 	int err;
 	unsigned int pipe;
-	int ret = _SUCCESS;
+	int ret = 0;
 	struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter);
 	struct recv_priv *precvpriv = &adapter->recvpriv;
 	struct usb_device *pusbd = pdvobj->pusbdev;
@@ -338,7 +338,7 @@  int rtl8723au_read_interrupt(struct rtw_adapter *adapter, u32 addr)
 		DBG_8723A("cannot submit interrupt in-token(err = 0x%08x),"
 			  "urb_status = %d\n", err,
 			  precvpriv->int_in_urb->status);
-		ret = _FAIL;
+		ret = -EOPNOTSUPP;
 	}
 
 	return ret;
@@ -469,10 +469,9 @@  static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb)
 			update_recvframe_phyinfo(precvframe, pphy_info);
 		}
 
-		if (rtw_recv_entry23a(precvframe) != _SUCCESS)
+		if (rtw_recv_entry23a(precvframe) != 0)
 			RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-				 ("recvbuf2recvframe: rtw_recv_entry23a"
-				  "(precvframe) != _SUCCESS\n"));
+				 ("recvbuf2recvframe: rtw_recv_entry23a(precvframe) != 0\n"));
 
 		pkt_cnt--;
 		transfer_len -= pkt_offset;
@@ -487,7 +486,7 @@  static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb)
 
 _exit_recvbuf2recvframe:
 
-	return _SUCCESS;
+	return 0;
 }
 
 void rtl8723au_recv_tasklet(void *priv)
@@ -615,7 +614,7 @@  int rtl8723au_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt,
 	unsigned int pipe;
 	unsigned long tmpaddr;
 	unsigned long alignment;
-	int ret = _SUCCESS;
+	int ret = 0;
 	struct urb *purb;
 	struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter);
 	struct recv_priv *precvpriv = &adapter->recvpriv;
@@ -625,13 +624,13 @@  int rtl8723au_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt,
 		RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
 			 ("usb_read_port:(padapter->bDriverStopped ||"
 			  "padapter->bSurpriseRemoved)!!!\n"));
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	if (!precvbuf) {
 		RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
 			 ("usb_read_port:precvbuf == NULL\n"));
-		return _FAIL;
+		return -EINVAL;
 	}
 
 	if (!precvbuf->pskb)
@@ -642,7 +641,7 @@  int rtl8723au_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt,
 		precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
 		if (precvbuf->pskb == NULL) {
 			RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n"));
-			return _FAIL;
+			return -ENOMEM;
 		}
 
 		tmpaddr = (unsigned long)precvbuf->pskb->data;
@@ -668,7 +667,7 @@  int rtl8723au_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt,
 			  "= 0x%.8x", err, purb->status));
 		DBG_8723A("cannot submit rx in-token(err = 0x%08x), urb_status "
 			  "= %d\n", err, purb->status);
-		ret = _FAIL;
+		ret = -EOPNOTSUPP;
 	}
 	return ret;
 }