Skip to contentSkip to conversation

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

PATCH Superseded Omer El Idrissi 3 participants 5 messages Jan 25 – Jan 29 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8723bs: replace magic -2 error codes with proper errno

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.

---
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +3 -3
index abb6fdfe7e1f..d1a427b2ef7f 100644
@@ -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)
Signature · 1 line
2.51.0
maintainer
#1 lore raw
Quoted 20 lines · Omer El Idrissi

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.

---
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +0 -0
index abb6fdfe7e1f..d1a427b2ef7f 100644

drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv · line 208

Quoted 5 lines
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +1 -1
@@ -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

#2 lore raw

PATCH v2 1/1 staging: rtl8723bs: replace magic -2 error codes with proper errno

In reply to Omer El Idrissi

Changes since v1:
- Removed leftover comment accidentally left in previous version
- No functional changes

---
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +3 -3
index abb6fdfe7e1f..8fa823f7bab3 100644
@@ -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)
Signature · 1 line
2.51.0
#3 lore raw
Quoted 5 lines · Omer El Idrissi

Changes since v1:
- Removed leftover comment accidentally left in previous version
- No functional changes

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

#4 lore raw

Thanks for the explanation. I'll drop this change and revisit it once i'm more familiar with the driver

Quoted 24 lines · Dan Carpenter
Quoted 5 lines · Omer El Idrissi

Changes since v1:
- Removed leftover comment accidentally left in previous version
- No functional changes

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