drivers/staging/rtl8723bs/core/rtw_xmit.c | 32 +++++++++---------- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 2 +- drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 4 +-- 3 files changed, 19 insertions(+), 19 deletions(-)
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>
---
v3:
- Rebase onto latest staging-next to resolve conflicts.
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 | 32 +++++++++----------
drivers/staging/rtl8723bs/os_dep/os_intfs.c | 2 +-
drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 4 +--
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 7bce0343d59f..166861f42953 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -38,7 +38,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);
@@ -75,7 +75,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);
@@ -112,7 +112,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;
}
@@ -129,10 +129,12 @@ 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) {
fsleep(10 * USEC_PER_MSEC);
+
res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ), true);
- if (res == _FAIL)
+ if (res)
goto exit;
}
@@ -162,7 +164,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);
@@ -195,7 +197,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;
}
@@ -211,10 +213,9 @@ 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) {
- res = _FAIL;
+
+ if (res)
goto exit;
- }
pxmitbuf->phead = pxmitbuf->pbuf;
pxmitbuf->pend = pxmitbuf->pbuf + MAX_XMIT_EXTBUF_SZ;
@@ -243,10 +244,9 @@ 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) {
- res = _FAIL;
+
+ if (res)
goto exit;
- }
pxmitbuf->phead = pxmitbuf->pbuf;
pxmitbuf->pend = pxmitbuf->pbuf + MAX_CMDBUF_SZ;
@@ -257,7 +257,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);
@@ -1875,7 +1875,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;
@@ -1900,7 +1900,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 e943dcea1a21..15edf97ee9e2 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -653,7 +653,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 dc0b77f38b1a..b7cb50ad14fd 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
On Sun, Apr 05, 2026 at 11:25:34PM +0000, Hungyu Lin wrote:
> 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>
> ---
Break this up into a bunch of patches:
patch 1: Change _rtw_init_xmit_priv() to use direct returns and get
rid of the exit label.
patch 2: Make rtw_alloc_hwxmits() static
patch 3: Make rtw_alloc_hwxmits() return negative error codes and update
the call site to look like this:
res = rtw_alloc_hwxmits();
if (res)
return _FAIL;
patch 4: Move rtw_os_xmit_resource_alloc() to
drivers/staging/rtl8723bs/core/rtw_xmit.c and make it static.
patch 5: Make rtw_os_xmit_resource_alloc() return -ENOMEM on failure
and update the call sites to look like:
res = rtw_os_xmit_resource_alloc();
if (res)
return _FAIL;
patch 6: Change _rtw_init_xmit_priv() to return negative error codes
and update the call sites to look like:
res = _rtw_init_xmit_priv(&padapter->xmitpriv, padapter);
if (res)
goto free_mlme_ext;
Making the functions static makes them easier to review so we don't
have to jump around between files. Doing it one function at a time
is easier to review because we don't have to remember all the
functions which were changed. Direct returns are easier to review
because we don't have to scroll to the bottom of the function.
regards,
dan carpenter
© 2016 - 2026 Red Hat, Inc.