[PATCH v2] staging: rtl8723bs: use standard error codes in xmit init path

Hungyu Lin
2026-04-05T11:58:02Z

Replace the use of _SUCCESS/_FAIL return values with standard
kernel return conventions (0 on success, negative errno on failure)
in the xmit initialization path.

Specifically:
- rtw_os_xmit_resource_alloc() now returns 0 or -ENOMEM
- rtw_alloc_hwxmits() now returns 0 or -ENOMEM
- _rtw_init_xmit_priv() updated to propagate error codes and use
direct truth checks instead of comparing with _FAIL
- caller in os_intfs.c updated accordingly

This improves error propagation and aligns the driver with
kernel coding style.

Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
v2:
- Rework xmit init path to remove _SUCCESS/_FAIL usage
- Convert allocation helpers to return standard error codes
- Update caller to use direct failure checks
- Address review feedback from Ethan Tidmore
---
drivers/staging/rtl8723bs/core/rtw_xmit.c | 24 +++++++++----------
drivers/staging/rtl8723bs/os_dep/os_intfs.c | 2 +-
drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 4 ++--
3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index ea1923023caa..e10592d969e7 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -36,7 +36,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
int i;
struct xmit_buf *pxmitbuf;
struct xmit_frame *pxframe;
- signed int res = _SUCCESS;
+ signed int res = 0;

spin_lock_init(&pxmitpriv->lock);
spin_lock_init(&pxmitpriv->lock_sctx);
@@ -73,7 +73,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)

if (!pxmitpriv->pallocated_frame_buf) {
pxmitpriv->pxmit_frame_buf = NULL;
- res = _FAIL;
+ res = -ENOMEM;
goto exit;
}
pxmitpriv->pxmit_frame_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitpriv->pallocated_frame_buf), 4);
@@ -110,7 +110,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4);

if (!pxmitpriv->pallocated_xmitbuf) {
- res = _FAIL;
+ res = -ENOMEM;
goto exit;
}

@@ -127,10 +127,10 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)

/* Tx buf allocation may fail sometimes, so sleep and retry. */
res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ), true);
- if (res == _FAIL) {
+ if (res) {
msleep(10);
res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ), true);
- if (res == _FAIL)
+ if (res)
goto exit;
}

@@ -160,7 +160,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)

if (!pxmitpriv->xframe_ext_alloc_addr) {
pxmitpriv->xframe_ext = NULL;
- res = _FAIL;
+ res = -ENOMEM;
goto exit;
}
pxmitpriv->xframe_ext = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitpriv->xframe_ext_alloc_addr), 4);
@@ -193,7 +193,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
pxmitpriv->pallocated_xmit_extbuf = vzalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_buf) + 4);

if (!pxmitpriv->pallocated_xmit_extbuf) {
- res = _FAIL;
+ res = -ENOMEM;
goto exit;
}

@@ -209,7 +209,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
pxmitbuf->buf_tag = XMITBUF_MGNT;

res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, MAX_XMIT_EXTBUF_SZ + XMITBUF_ALIGN_SZ, true);
- if (res == _FAIL)
+ if (res)
goto exit;

pxmitbuf->phead = pxmitbuf->pbuf;
@@ -239,7 +239,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf,
MAX_CMDBUF_SZ + XMITBUF_ALIGN_SZ,
true);
- if (res == _FAIL)
+ if (res)
goto exit;

pxmitbuf->phead = pxmitbuf->pbuf;
@@ -251,7 +251,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
}

res = rtw_alloc_hwxmits(padapter);
- if (res == _FAIL)
+ if (res)
goto exit;
rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry);

@@ -1868,7 +1868,7 @@ s32 rtw_alloc_hwxmits(struct adapter *padapter)
pxmitpriv->hwxmits = kzalloc_objs(*hwxmits, pxmitpriv->hwxmit_entry,
GFP_ATOMIC);
if (!pxmitpriv->hwxmits)
- return _FAIL;
+ return -ENOMEM;

hwxmits = pxmitpriv->hwxmits;

@@ -1893,7 +1893,7 @@ s32 rtw_alloc_hwxmits(struct adapter *padapter)
} else {
}

- return _SUCCESS;
+ return 0;
}

void rtw_free_hwxmits(struct adapter *padapter)
diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index 29939bf5a156..bad2dba73eb6 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -654,7 +654,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter)

init_mlme_ext_priv(padapter);

- if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter) == _FAIL)
+ if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter))
goto free_mlme_ext;

if (_rtw_init_recv_priv(&padapter->recvpriv, padapter) == _FAIL)
diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
index 0be3143fffe5..a8b8545ed25e 100644
--- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
@@ -51,12 +51,12 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb
if (alloc_sz > 0) {
pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL);
if (!pxmitbuf->pallocated_buf)
- return _FAIL;
+ return -ENOMEM;

pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
}

- return _SUCCESS;
+ return 0;
}

void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 free_sz, u8 flag)
--
2.34.1