Linux kernel staging patches
 help / color / mirror / Atom feed
* [PATCH 0/4] staging: rtl8723bs: convert update_attrib path to errno
@ 2026-06-14 18:23 Hungyu Lin
  2026-06-14 18:23 ` [PATCH 1/4] staging: rtl8723bs: simplify update_attrib_sec_info control flow Hungyu Lin
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Hungyu Lin @ 2026-06-14 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: error27, linux-staging, linux-kernel, Hungyu Lin

Convert the update_attrib path to use standard kernel return
conventions: 0 on success and negative errno on failure.

The series first simplifies control flow in
update_attrib_sec_info() and update_attrib() by replacing
goto-based error handling with direct returns. It then converts
both functions to return errno values and propagates the
returned error codes through callers.

Hungyu Lin (4):
  staging: rtl8723bs: simplify update_attrib_sec_info control flow
  staging: rtl8723bs: simplify update_attrib control flow
  staging: rtl8723bs: convert update_attrib_sec_info to return errno
  staging: rtl8723bs: convert update_attrib to return errno

 drivers/staging/rtl8723bs/core/rtw_xmit.c | 54 ++++++++---------------
 1 file changed, 19 insertions(+), 35 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] staging: rtl8723bs: simplify update_attrib_sec_info control flow
  2026-06-14 18:23 [PATCH 0/4] staging: rtl8723bs: convert update_attrib path to errno Hungyu Lin
@ 2026-06-14 18:23 ` Hungyu Lin
  2026-06-14 18:23 ` [PATCH 2/4] staging: rtl8723bs: simplify update_attrib " Hungyu Lin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Hungyu Lin @ 2026-06-14 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: error27, linux-staging, linux-kernel, Hungyu Lin

Replace goto-based error handling with direct returns and
remove the temporary res variable.

No functional change.

Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 444966c0de7f..6ab91de472b0 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -507,7 +507,6 @@ static void update_attrib_phy_info(struct adapter *padapter, struct pkt_attrib *
 
 static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *pattrib, struct sta_info *psta)
 {
-	signed int res = _SUCCESS;
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 	struct security_priv *psecuritypriv = &padapter->securitypriv;
 	signed int bmcast = is_multicast_ether_addr(pattrib->ra);
@@ -519,10 +518,8 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p
 	if (psta->ieee8021x_blocked) {
 		pattrib->encrypt = 0;
 
-		if ((pattrib->ether_type != 0x888e) && !check_fwstate(pmlmepriv, WIFI_MP_STATE)) {
-			res = _FAIL;
-			goto exit;
-		}
+		if ((pattrib->ether_type != 0x888e) && !check_fwstate(pmlmepriv, WIFI_MP_STATE))
+			return _FAIL;
 	} else {
 		GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast);
 
@@ -560,10 +557,8 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p
 		pattrib->iv_len = 8;
 		pattrib->icv_len = 4;
 
-		if (psecuritypriv->busetkipkey == _FAIL) {
-			res = _FAIL;
-			goto exit;
-		}
+		if (psecuritypriv->busetkipkey == _FAIL)
+			return _FAIL;
 
 		if (bmcast)
 			TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
@@ -601,9 +596,7 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p
 	else
 		pattrib->bswenc = false;
 
-exit:
-
-	return res;
+	return _SUCCESS;
 }
 
 u8 qos_acm(u8 acm_mask, u8 priority)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] staging: rtl8723bs: simplify update_attrib control flow
  2026-06-14 18:23 [PATCH 0/4] staging: rtl8723bs: convert update_attrib path to errno Hungyu Lin
  2026-06-14 18:23 ` [PATCH 1/4] staging: rtl8723bs: simplify update_attrib_sec_info control flow Hungyu Lin
@ 2026-06-14 18:23 ` Hungyu Lin
  2026-06-14 18:23 ` [PATCH 3/4] staging: rtl8723bs: convert update_attrib_sec_info to return errno Hungyu Lin
  2026-06-14 18:23 ` [PATCH 4/4] staging: rtl8723bs: convert update_attrib " Hungyu Lin
  3 siblings, 0 replies; 7+ messages in thread
From: Hungyu Lin @ 2026-06-14 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: error27, linux-staging, linux-kernel, Hungyu Lin

Replace goto-based error handling with direct returns and
remove the temporary res variable.

No functional change.

Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 25 ++++++++---------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 6ab91de472b0..7d10caf8cbfe 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -664,7 +664,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
 	struct sta_priv *pstapriv = &padapter->stapriv;
 	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 	struct qos_priv *pqospriv = &pmlmepriv->qospriv;
-	signed int res = _SUCCESS;
 	int ret;
 
 	_rtw_open_pktfile(pkt, &pktfile);
@@ -741,20 +740,15 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
 		psta = rtw_get_bcmc_stainfo(padapter);
 	} else {
 		psta = rtw_get_stainfo(pstapriv, pattrib->ra);
-		if (!psta)	{ /*  if we cannot get psta => drop the pkt */
-			res = _FAIL;
-			goto exit;
-		} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) && !(psta->state & _FW_LINKED)) {
-			res = _FAIL;
-			goto exit;
-		}
+		if (!psta)	/*  if we cannot get psta => drop the pkt */
+			return _FAIL;
+		else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) && !(psta->state & _FW_LINKED))
+			return _FAIL;
 	}
 
-	if (!psta) {
+	if (!psta)
 		/*  if we cannot get psta => drop the pkt */
-		res = _FAIL;
-		goto exit;
-	}
+		return _FAIL;
 
 	if (!(psta->state & _FW_LINKED))
 		return _FAIL;
@@ -762,8 +756,7 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
 	spin_lock_bh(&psta->lock);
 	if (update_attrib_sec_info(padapter, pattrib, psta) == _FAIL) {
 		spin_unlock_bh(&psta->lock);
-		res = _FAIL;
-		goto exit;
+		return _FAIL;
 	}
 
 	update_attrib_phy_info(padapter, pattrib, psta);
@@ -799,9 +792,7 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
 	}
 
 	/* pattrib->priority = 5; force to used VI queue, for testing */
-
-exit:
-	return res;
+	return _SUCCESS;
 }
 
 static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitframe)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] staging: rtl8723bs: convert update_attrib_sec_info to return errno
  2026-06-14 18:23 [PATCH 0/4] staging: rtl8723bs: convert update_attrib path to errno Hungyu Lin
  2026-06-14 18:23 ` [PATCH 1/4] staging: rtl8723bs: simplify update_attrib_sec_info control flow Hungyu Lin
  2026-06-14 18:23 ` [PATCH 2/4] staging: rtl8723bs: simplify update_attrib " Hungyu Lin
@ 2026-06-14 18:23 ` Hungyu Lin
  2026-06-15  7:42   ` Dan Carpenter
  2026-06-14 18:23 ` [PATCH 4/4] staging: rtl8723bs: convert update_attrib " Hungyu Lin
  3 siblings, 1 reply; 7+ messages in thread
From: Hungyu Lin @ 2026-06-14 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: error27, linux-staging, linux-kernel, Hungyu Lin

Convert update_attrib_sec_info() to return 0 on success and
a negative errno on failure. Update update_attrib() to
propagate the returned error code.

No functional change intended.

Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 7d10caf8cbfe..b6d9332958f5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -519,7 +519,7 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p
 		pattrib->encrypt = 0;
 
 		if ((pattrib->ether_type != 0x888e) && !check_fwstate(pmlmepriv, WIFI_MP_STATE))
-			return _FAIL;
+			return -EINVAL;
 	} else {
 		GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast);
 
@@ -558,7 +558,7 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p
 		pattrib->icv_len = 4;
 
 		if (psecuritypriv->busetkipkey == _FAIL)
-			return _FAIL;
+			return -EINVAL;
 
 		if (bmcast)
 			TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
@@ -596,7 +596,7 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p
 	else
 		pattrib->bswenc = false;
 
-	return _SUCCESS;
+	return 0;
 }
 
 u8 qos_acm(u8 acm_mask, u8 priority)
@@ -754,9 +754,10 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
 		return _FAIL;
 
 	spin_lock_bh(&psta->lock);
-	if (update_attrib_sec_info(padapter, pattrib, psta) == _FAIL) {
+	ret = update_attrib_sec_info(padapter, pattrib, psta);
+	if (ret) {
 		spin_unlock_bh(&psta->lock);
-		return _FAIL;
+		return ret;
 	}
 
 	update_attrib_phy_info(padapter, pattrib, psta);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] staging: rtl8723bs: convert update_attrib to return errno
  2026-06-14 18:23 [PATCH 0/4] staging: rtl8723bs: convert update_attrib path to errno Hungyu Lin
                   ` (2 preceding siblings ...)
  2026-06-14 18:23 ` [PATCH 3/4] staging: rtl8723bs: convert update_attrib_sec_info to return errno Hungyu Lin
@ 2026-06-14 18:23 ` Hungyu Lin
  2026-06-15  7:43   ` Dan Carpenter
  3 siblings, 1 reply; 7+ messages in thread
From: Hungyu Lin @ 2026-06-14 18:23 UTC (permalink / raw)
  To: gregkh; +Cc: error27, linux-staging, linux-kernel, Hungyu Lin

Convert update_attrib() to return 0 on success and a
negative errno on failure. Update rtw_xmit() to handle
the returned error code.

No functional change intended.

Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index b6d9332958f5..fb2fd3f5de77 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -741,17 +741,17 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
 	} else {
 		psta = rtw_get_stainfo(pstapriv, pattrib->ra);
 		if (!psta)	/*  if we cannot get psta => drop the pkt */
-			return _FAIL;
+			return -EINVAL;
 		else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) && !(psta->state & _FW_LINKED))
-			return _FAIL;
+			return -EINVAL;
 	}
 
 	if (!psta)
 		/*  if we cannot get psta => drop the pkt */
-		return _FAIL;
+		return -EINVAL;
 
 	if (!(psta->state & _FW_LINKED))
-		return _FAIL;
+		return -EINVAL;
 
 	spin_lock_bh(&psta->lock);
 	ret = update_attrib_sec_info(padapter, pattrib, psta);
@@ -793,7 +793,7 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
 	}
 
 	/* pattrib->priority = 5; force to used VI queue, for testing */
-	return _SUCCESS;
+	return 0;
 }
 
 static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitframe)
@@ -1954,7 +1954,7 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt)
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
 	struct xmit_frame *pxmitframe = NULL;
 
-	s32 res;
+	int ret;
 
 	if (start == 0)
 		start = jiffies;
@@ -1967,9 +1967,8 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt)
 	if (!pxmitframe)
 		return -1;
 
-	res = update_attrib(padapter, *ppkt, &pxmitframe->attrib);
-
-	if (res != _SUCCESS) {
+	ret = update_attrib(padapter, *ppkt, &pxmitframe->attrib);
+	if (ret) {
 		rtw_free_xmitframe(pxmitpriv, pxmitframe);
 		return -1;
 	}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/4] staging: rtl8723bs: convert update_attrib_sec_info to return errno
  2026-06-14 18:23 ` [PATCH 3/4] staging: rtl8723bs: convert update_attrib_sec_info to return errno Hungyu Lin
@ 2026-06-15  7:42   ` Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2026-06-15  7:42 UTC (permalink / raw)
  To: Hungyu Lin; +Cc: gregkh, linux-staging, linux-kernel

On Sun, Jun 14, 2026 at 06:23:08PM +0000, Hungyu Lin wrote:
> Convert update_attrib_sec_info() to return 0 on success and
> a negative errno on failure. Update update_attrib() to
> propagate the returned error code.
> 
> No functional change intended.
> 
> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_xmit.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
> index 7d10caf8cbfe..b6d9332958f5 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
> @@ -519,7 +519,7 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p
                             ^^^
Change this to int.  I wouldn't have commented on this except for the
change to update_attrib()...

>  		pattrib->encrypt = 0;
>  
>  		if ((pattrib->ether_type != 0x888e) && !check_fwstate(pmlmepriv, WIFI_MP_STATE))
> -			return _FAIL;
> +			return -EINVAL;
>  	} else {
>  		GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast);
>  
> @@ -558,7 +558,7 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p
>  		pattrib->icv_len = 4;
>  
>  		if (psecuritypriv->busetkipkey == _FAIL)
> -			return _FAIL;
> +			return -EINVAL;
>  
>  		if (bmcast)
>  			TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
> @@ -596,7 +596,7 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p
>  	else
>  		pattrib->bswenc = false;
>  
> -	return _SUCCESS;
> +	return 0;
>  }
>  
>  u8 qos_acm(u8 acm_mask, u8 priority)
> @@ -754,9 +754,10 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
>  		return _FAIL;
>  
>  	spin_lock_bh(&psta->lock);
> -	if (update_attrib_sec_info(padapter, pattrib, psta) == _FAIL) {
> +	ret = update_attrib_sec_info(padapter, pattrib, psta);
> +	if (ret) {
>  		spin_unlock_bh(&psta->lock);
> -		return _FAIL;
> +		return ret;

This should have stayed as _FAIL and then been updated in the next
patch.  It doesn't break anything, but lets still do it that way.
Let's never mix _FAIL and standard error codes.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] staging: rtl8723bs: convert update_attrib to return errno
  2026-06-14 18:23 ` [PATCH 4/4] staging: rtl8723bs: convert update_attrib " Hungyu Lin
@ 2026-06-15  7:43   ` Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2026-06-15  7:43 UTC (permalink / raw)
  To: Hungyu Lin; +Cc: gregkh, linux-staging, linux-kernel

On Sun, Jun 14, 2026 at 06:23:09PM +0000, Hungyu Lin wrote:
> Convert update_attrib() to return 0 on success and a
> negative errno on failure. Update rtw_xmit() to handle
> the returned error code.
> 
> No functional change intended.
> 
> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_xmit.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
> index b6d9332958f5..fb2fd3f5de77 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
> @@ -741,17 +741,17 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p

Change this to int as well.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-06-15  7:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-14 18:23 [PATCH 0/4] staging: rtl8723bs: convert update_attrib path to errno Hungyu Lin
2026-06-14 18:23 ` [PATCH 1/4] staging: rtl8723bs: simplify update_attrib_sec_info control flow Hungyu Lin
2026-06-14 18:23 ` [PATCH 2/4] staging: rtl8723bs: simplify update_attrib " Hungyu Lin
2026-06-14 18:23 ` [PATCH 3/4] staging: rtl8723bs: convert update_attrib_sec_info to return errno Hungyu Lin
2026-06-15  7:42   ` Dan Carpenter
2026-06-14 18:23 ` [PATCH 4/4] staging: rtl8723bs: convert update_attrib " Hungyu Lin
2026-06-15  7:43   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox