staging: rtl8723bs: remove thread wraper functions and add IS_ERR() check

The rtl8723b_start_thread() and rtl8723b_stop_thread() functions are
wrappers that are only called from one place each. Remove these wrapper
functions and inline the thread handling directly in
rtw_start_drv_threads() and rtw_stop_drv_threads().

This also fixes a bug where kthread_run() was not checked for errors
using IS_ERR(). kthread_run() returns ERR_PTR(-ENOMEM) on failure, not
NULL. Without this check, the SdioXmitThread pointer could contain an
error value, causing issues when rtw_stop_drv_threads() later attempts
to use it.

The inlined code now follows the same pattern as xmitThread and
cmdThread in rtw_start_drv_threads(), with proper IS_ERR() checking.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Samasth Norway Ananda <samasth.norway.ananda@oracle.com>
Link: https://patch.msgid.link/20260130001641.17941-4-samasth.norway.ananda@oracle.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Samasth Norway Ananda 2026-01-29 16:16:41 -08:00 committed by Greg Kroah-Hartman
parent 4dba9d6c69
commit c41ac35307
5 changed files with 14 additions and 38 deletions

View File

@ -218,17 +218,6 @@ void rtw_hal_add_ra_tid(struct adapter *padapter, u32 bitmap, u8 *arg, u8 rssi_l
rtl8723b_Add_RateATid(padapter, bitmap, arg, rssi_level);
}
/*Start specifical interface thread */
void rtw_hal_start_thread(struct adapter *padapter)
{
rtl8723b_start_thread(padapter);
}
/*Start specifical interface thread */
void rtw_hal_stop_thread(struct adapter *padapter)
{
rtl8723b_stop_thread(padapter);
}
u32 rtw_hal_read_bbreg(struct adapter *padapter, u32 RegAddr, u32 BitMask)
{
return PHY_QueryBBReg_8723B(padapter, RegAddr, BitMask);

View File

@ -2916,22 +2916,3 @@ u8 GetHalDefVar8723B(struct adapter *padapter, enum hal_def_variable variable, v
return bResult;
}
void rtl8723b_start_thread(struct adapter *padapter)
{
struct xmit_priv *xmitpriv = &padapter->xmitpriv;
xmitpriv->SdioXmitThread = kthread_run(rtl8723bs_xmit_thread, padapter, "RTWHALXT");
}
void rtl8723b_stop_thread(struct adapter *padapter)
{
struct xmit_priv *xmitpriv = &padapter->xmitpriv;
/* stop xmit_buf_thread */
if (xmitpriv->SdioXmitThread) {
complete(&xmitpriv->SdioXmitStart);
wait_for_completion(&xmitpriv->SdioXmitTerminate);
xmitpriv->SdioXmitThread = NULL;
}
}

View File

@ -221,9 +221,6 @@ void rtw_hal_free_recv_priv(struct adapter *padapter);
void rtw_hal_update_ra_mask(struct sta_info *psta, u8 rssi_level);
void rtw_hal_add_ra_tid(struct adapter *padapter, u32 bitmap, u8 *arg, u8 rssi_level);
void rtw_hal_start_thread(struct adapter *padapter);
void rtw_hal_stop_thread(struct adapter *padapter);
void beacon_timing_control(struct adapter *padapter);
u32 rtw_hal_read_bbreg(struct adapter *padapter, u32 RegAddr, u32 BitMask);

View File

@ -231,9 +231,6 @@ void rtl8723b_InitBeaconParameters(struct adapter *padapter);
void _InitBurstPktLen_8723BS(struct adapter *adapter);
void _8051Reset8723(struct adapter *padapter);
void rtl8723b_start_thread(struct adapter *padapter);
void rtl8723b_stop_thread(struct adapter *padapter);
int FirmwareDownloadBT(struct adapter *adapter, struct rt_firmware *firmware);
void CCX_FwC2HTxRpt_8723b(struct adapter *padapter, u8 *pdata, u8 len);

View File

@ -6,6 +6,7 @@
******************************************************************************/
#include <drv_types.h>
#include <hal_data.h>
#include <rtl8723b_xmit.h>
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Realtek Wireless Lan Driver");
@ -477,7 +478,13 @@ u32 rtw_start_drv_threads(struct adapter *padapter)
else
wait_for_completion(&padapter->cmdpriv.terminate_cmdthread_comp); /* wait for cmd_thread to run */
rtw_hal_start_thread(padapter);
padapter->xmitpriv.SdioXmitThread = kthread_run(rtl8723bs_xmit_thread,
padapter, "RTWHALXT");
if (IS_ERR(padapter->xmitpriv.SdioXmitThread)) {
padapter->xmitpriv.SdioXmitThread = NULL;
_status = _FAIL;
}
return _status;
}
@ -489,7 +496,12 @@ void rtw_stop_drv_threads(struct adapter *padapter)
complete(&padapter->xmitpriv.xmit_comp);
wait_for_completion(&padapter->xmitpriv.terminate_xmitthread_comp);
rtw_hal_stop_thread(padapter);
/* stop SdioXmitThread */
if (padapter->xmitpriv.SdioXmitThread) {
complete(&padapter->xmitpriv.SdioXmitStart);
wait_for_completion(&padapter->xmitpriv.SdioXmitTerminate);
padapter->xmitpriv.SdioXmitThread = NULL;
}
}
static void rtw_init_default_value(struct adapter *padapter)