[OPW,kernel,v3,12/28] staging: rtl87231u: core: rtw_xmit.c: Replace non-standard return values
diff mbox

Message ID 1414668396-4093-13-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/core/rtw_xmit.c | 90 +++++++++++++++----------------
 1 file changed, 44 insertions(+), 46 deletions(-)

Patch
diff mbox

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)