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

Message ID 1414668396-4093-3-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.

It also changes the return type of rtw_init_evt_priv23a function
(both declaration and definition) from u32 to int, since it returns 0
for success or -Exxx for failure.

Signed-off-by: Roberta Dobrescu <roberta.dobrescu@gmail.com>
---
 drivers/staging/rtl8723au/core/rtw_cmd.c    | 130 ++++++++++++++--------------
 drivers/staging/rtl8723au/include/rtw_cmd.h |   2 +-
 2 files changed, 65 insertions(+), 67 deletions(-)

Patch
diff mbox

diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c
index 424d96a..85dd531 100644
--- a/drivers/staging/rtl8723au/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723au/core/rtw_cmd.c
@@ -170,30 +170,28 @@  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 */
 
 static void rtw_irq_work(struct work_struct *work);
 
-u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv)
+int rtw_init_evt_priv23a(struct evt_priv *pevtpriv)
 {
 	pevtpriv->wq = alloc_workqueue("rtl8723au_evt", 0, 1);
 
 	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/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h
index 8ffe5de..f948037 100644
--- a/drivers/staging/rtl8723au/include/rtw_cmd.h
+++ b/drivers/staging/rtl8723au/include/rtw_cmd.h
@@ -98,7 +98,7 @@  int rtw_cmd_thread23a(void *context);
 
 int rtw_init_cmd_priv23a(struct cmd_priv *pcmdpriv);
 
-u32 rtw_init_evt_priv23a (struct evt_priv *pevtpriv);
+int rtw_init_evt_priv23a(struct evt_priv *pevtpriv);
 void rtw_free_evt_priv23a (struct evt_priv *pevtpriv);
 void rtw_cmd_clr_isr23a(struct cmd_priv *pcmdpriv);
 void rtw_evt_notify_isr(struct evt_priv *pevtpriv);