[PATCH] staging: rtl8723bs: replace magic -2 error codes with proper errno

Omer El Idrissi posted 1 patch 1 week, 5 days ago
There is a newer version of this series
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] staging: rtl8723bs: replace magic -2 error codes with proper errno
Posted by Omer El Idrissi 1 week, 5 days ago
In xmit_xmitframes function:
- Hardware busy condition previously
returned -2; changed to -EBUSY
- Transmit buffer allocation failure previously
returned -2; changed to ENOBUFS

The caller checks both errors and handles retry logic.This improves
readability and conforms to kernel error-handling
conventions.

Signed-off-by: Omer El Idrissi <omer.e.idrissi@gmail.com>
---
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
index abb6fdfe7e1f..d1a427b2ef7f 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
@@ -205,7 +205,7 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv
 			(padapter->mlmepriv.LinkDetectInfo.bHigherBusyTxTraffic)
 		) {
 			if ((phwxmit->accnt > 0) && (phwxmit->accnt < 5)) {
-				err = -2;
+				err = -EBUSY; // supposed to return -EBUSY for these conditions???
 				break;
 			}
 		}
@@ -260,7 +260,7 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv
 							   "%s: xmit_buf is not enough!\n",
 							   __func__);
 #endif
-						err = -2;
+						err = -ENOBUFS;
 						complete(&(pxmitpriv->xmit_comp));
 						break;
 					}
@@ -380,7 +380,7 @@ static s32 rtl8723bs_xmit_handler(struct adapter *padapter)
 	/*  dequeue frame and write to hardware */
 
 	ret = xmit_xmitframes(padapter, pxmitpriv);
-	if (ret == -2) {
+	if (ret == -EBUSY || ret == -ENOBUFS) {
 		/* here sleep 1ms will cause big TP loss of TX */
 		/* from 50+ to 40+ */
 		if (padapter->registrypriv.wifi_spec)
-- 
2.51.0
Re: [PATCH] staging: rtl8723bs: replace magic -2 error codes with proper errno
Posted by Greg KH 1 week, 4 days ago
On Sun, Jan 25, 2026 at 11:12:18PM +0100, Omer El Idrissi wrote:
> In xmit_xmitframes function:
> - Hardware busy condition previously
> returned -2; changed to -EBUSY
> - Transmit buffer allocation failure previously
> returned -2; changed to ENOBUFS
> 
> The caller checks both errors and handles retry logic.This improves
> readability and conforms to kernel error-handling
> conventions.
> 
> Signed-off-by: Omer El Idrissi <omer.e.idrissi@gmail.com>
> ---
>  drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
> index abb6fdfe7e1f..d1a427b2ef7f 100644
> --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
> +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
> @@ -205,7 +205,7 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv
>  			(padapter->mlmepriv.LinkDetectInfo.bHigherBusyTxTraffic)
>  		) {
>  			if ((phwxmit->accnt > 0) && (phwxmit->accnt < 5)) {
> -				err = -2;
> +				err = -EBUSY; // supposed to return -EBUSY for these conditions???

Why is this comment added?  Who is going to answer that?

thanks,

greg k-h
[PATCH v2] staging: rtl8723bs: replace magic -2 error codes with proper errno
Posted by Omer El Idrissi 1 week, 2 days ago
Changes since v1:
- Removed leftover comment accidentally left in previous version
- No functional changes

Signed-off-by: Omer El Idrissi <omer.e.idrissi@gmail.com>
---
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
index abb6fdfe7e1f..8fa823f7bab3 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
@@ -205,7 +205,7 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv
 			(padapter->mlmepriv.LinkDetectInfo.bHigherBusyTxTraffic)
 		) {
 			if ((phwxmit->accnt > 0) && (phwxmit->accnt < 5)) {
-				err = -2;
+				err = -EBUSY;
 				break;
 			}
 		}
@@ -260,7 +260,7 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv
 							   "%s: xmit_buf is not enough!\n",
 							   __func__);
 #endif
-						err = -2;
+						err = -ENOBUFS;
 						complete(&(pxmitpriv->xmit_comp));
 						break;
 					}
@@ -380,7 +380,7 @@ static s32 rtl8723bs_xmit_handler(struct adapter *padapter)
 	/*  dequeue frame and write to hardware */
 
 	ret = xmit_xmitframes(padapter, pxmitpriv);
-	if (ret == -2) {
+	if (ret == -EBUSY || ret == -ENOBUFS) {
 		/* here sleep 1ms will cause big TP loss of TX */
 		/* from 50+ to 40+ */
 		if (padapter->registrypriv.wifi_spec)
-- 
2.51.0
Re: [PATCH v2] staging: rtl8723bs: replace magic -2 error codes with proper errno
Posted by Dan Carpenter 1 week, 2 days ago
On Wed, Jan 28, 2026 at 06:21:43PM +0100, Omer El Idrissi wrote:
> Changes since v1:
> - Removed leftover comment accidentally left in previous version
> - No functional changes
> 
> Signed-off-by: Omer El Idrissi <omer.e.idrissi@gmail.com>

No commit message.

https://staticthinking.wordpress.com/2022/07/27/how-to-send-a-v2-patch/

Why is do you change -2 to both -EBUSY and -ENOBUFS?  In the original
code, the -1 and -2 return meant something custom and they weren't
kernel error codes:

 * Return:
 *0     Success
 *-1    Hardware resource(TX FIFO) not ready
 *-2    Software resource(xmitbuf) not ready

Now the documentation makes no sense.

regards,
dan carpenter
Re: [PATCH v2] staging: rtl8723bs: replace magic -2 error codes with proper errno
Posted by Omer El Idrissi 1 week, 1 day ago
Thanks for the explanation. I'll drop this change and revisit it once 
i'm more familiar with the driver

On 1/29/26 8:27 AM, Dan Carpenter wrote:
> On Wed, Jan 28, 2026 at 06:21:43PM +0100, Omer El Idrissi wrote:
>> Changes since v1:
>> - Removed leftover comment accidentally left in previous version
>> - No functional changes
>>
>> Signed-off-by: Omer El Idrissi <omer.e.idrissi@gmail.com>
> No commit message.
>
> https://staticthinking.wordpress.com/2022/07/27/how-to-send-a-v2-patch/
>
> Why is do you change -2 to both -EBUSY and -ENOBUFS?  In the original
> code, the -1 and -2 return meant something custom and they weren't
> kernel error codes:
>
>   * Return:
>   *0     Success
>   *-1    Hardware resource(TX FIFO) not ready
>   *-2    Software resource(xmitbuf) not ready
>
> Now the documentation makes no sense.
>
> regards,
> dan carpenter
>