[OPW,kernel,v3,15/28] staging: rtl8723au: hal: rtl8723a_hal_init.c: Replace non-standard return values
diff mbox

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

Commit Message

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

Signed-off-by: Roberta Dobrescu <roberta.dobrescu@gmail.com>
---
 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 70 +++++++++++------------
 1 file changed, 32 insertions(+), 38 deletions(-)

Patch
diff mbox

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)