staging: rtl8723bs: use errno in rtw_register_tx_alive()
PATCH v2 1/1 staging: rtl8723bs: use errno in rtw_register_tx_alive()
rtw_register_tx_alive() uses the driver-specific _SUCCESS and _FAIL values to report whether the transmit path can continue.
Use the usual kernel convention of returning 0 on success and -EAGAIN when the transmit path cannot proceed yet. Update the caller accordingly.
No functional change.
---
Changes in v2:
- Use the standard 0/-errno return convention instead of bool, as suggested by Greg.
- Return -EAGAIN when the transmit path cannot proceed yet.
drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 13 ++++++------- drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 3 +-- drivers/staging/rtl8723bs/include/rtw_pwrctrl.h | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-)
drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +6 -7
@@ -771,13 +771,12 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task)* _SUCCESS rtw_xmit_thread can write fifo/txcmd afterwards. * _FAIL rtw_xmit_thread can not do anything. */ -s32 rtw_register_tx_alive (struct adapter *padapter) +int rtw_register_tx_alive (struct adapter *padapter) { -s32 res; +int ret =0 ;struct pwrctrl_priv *pwrctrl;u8 pslv; - res = _SUCCESS; pwrctrl =adapter_to_pwrctl (padapter); pslv =PS_STATE_S2 ;
@@ -788,7 +787,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter)if (pwrctrl->fw_current_in_ps_mode) {if (pwrctrl->cpwm < pslv) {if (pwrctrl->cpwm <PS_STATE_S2 ) - res = _FAIL; + ret = -EAGAIN ;if (pwrctrl->rpwm < pslv)rtw_set_rpwm (padapter, pslv); }
@@ -796,11 +795,11 @@ s32 rtw_register_tx_alive(struct adapter *padapter)mutex_unlock (&pwrctrl->lock); -if (res == _FAIL) +if (ret)if (pwrctrl->cpwm >=PS_STATE_S2 ) - res = _SUCCESS; + ret =0 ; -return res; +return ret; }/*
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +1 -2
@@ -140,9 +140,8 @@ s32 rtl8723bs_xmit_buf_handler(struct adapter *padapter)return _SUCCESS; ret =rtw_register_tx_alive (padapter); -if (ret != _SUCCESS) { +if (ret)return _SUCCESS; - } do { queue_empty = rtl8723_dequeue_writeport(padapter);
drivers/staging/rtl8723bs/include/rtw_pwrctrl.h +1 -1
@@ -217,7 +217,7 @@ void rtw_free_pwrctrl_priv(struct adapter *adapter);s32 rtw_register_task_alive (struct adapter *adapter,u32 task);void rtw_unregister_task_alive (struct adapter *adapter,u32 task); -s32 rtw_register_tx_alive (struct adapter *padapter); +int rtw_register_tx_alive (struct adapter *padapter);void rtw_unregister_tx_alive (struct adapter *padapter);s32 rtw_register_cmd_alive (struct adapter *padapter);void rtw_unregister_cmd_alive (struct adapter *padapter);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerQuoted 70 lines · Hungyu Lin
rtw_register_tx_alive()uses the driver-specific_SUCCESSand_FAILvalues to report whether the transmit path can continue.Use the usual kernel convention of returning 0 on success and
-EAGAINwhen the transmit path cannot proceed yet. Update the caller accordingly.No functional change.
Signed-off-by Hungyu Lin <[email protected]>---
Changes in v2:
- Use the standard 0/-errno return convention instead of bool, as suggested by Greg.
- Return-EAGAINwhen the transmit path cannot proceed yet.drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 13 ++++++------- drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 3 +-- drivers/staging/rtl8723bs/include/rtw_pwrctrl.h | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-)drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +6
-7@@ -771,13 +771,12 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task)* _SUCCESS rtw_xmit_thread can write fifo/txcmd afterwards. * _FAIL rtw_xmit_thread can not do anything. */ -s32 rtw_register_tx_alive (struct adapter *padapter) +int rtw_register_tx_alive (struct adapter *padapter) { -s32 res; +int ret =0 ;struct pwrctrl_priv *pwrctrl;u8 pslv; - res = _SUCCESS; pwrctrl =adapter_to_pwrctl (padapter); pslv =PS_STATE_S2 ;@@ -788,7 +787,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter)if (pwrctrl->fw_current_in_ps_mode) {if (pwrctrl->cpwm < pslv) {if (pwrctrl->cpwm <PS_STATE_S2 ) - res = _FAIL; + ret = -EAGAIN ;if (pwrctrl->rpwm < pslv)rtw_set_rpwm (padapter, pslv); }@@ -796,11 +795,11 @@ s32 rtw_register_tx_alive(struct adapter *padapter)mutex_unlock (&pwrctrl->lock); -if (res == _FAIL) +if (ret)if (pwrctrl->cpwm >=PS_STATE_S2 ) - res = _SUCCESS; + ret =0 ; -return res; +return ret; }/* drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +0
-0
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c s32 rtl8723bs_xmit_buf_handler(struct adapter *padapter) · line 145
Quoted 7 lines
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +1
-2@@ -140,9 +140,8 @@ s32 rtl8723bs_xmit_buf_handler(struct adapter *padapter)return _SUCCESS; ret =rtw_register_tx_alive (padapter); -if (ret != _SUCCESS) { +if (ret)return _SUCCESS; - }
Why are we returning success if there is an error?
thanks,
greg k-h
Quoted 1 line
Why are we returning success if there is an error?
The original _FAIL means the firmware is not ready for TX yet. XMIT_ALIVE has already been set, and the buffers stay queued. cpwm_int_hdl() uses that bit to wake the TX thread once the power state reaches S2.
_SUCCESS here lets rtw_xmit_thread() go back to waiting on xmit_comp. Returning -EAGAIN instead would stop the thread.
I should have explained this in the commit message. Would handling -EAGAIN explicitly here, with a comment explaining the retry, be appropriate?
Thanks,
Hungyu Lin
Greg Kroah-Hartman
maintainerQuoted 7 lines · Hungyu Lin
Quoted 1 line
Why are we returning success if there is an error?
The original
_FAILmeans the firmware is not ready for TX yet.XMIT_ALIVEhas already been set, and the buffers stay queued.cpwm_int_hdl()uses that bit to wake the TX thread once the power state reaches S2.
Quoted 6 lines
_SUCCESShere letsrtw_xmit_thread()go back to waiting onxmit_comp. Returning-EAGAINinstead would stop the thread.I should have explained this in the commit message. Would handling
-EAGAINexplicitly here, with a comment explaining the retry, be appropriate?
Please do.