* [PATCH] staging: rtl8723bs: use unsigned int in HAL interface
@ 2026-09-26 12:51 Artem Shelenko
2026-09-26 12:59 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Artem Shelenko @ 2026-09-26 12:51 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel
The rtl8723bs TODO asks to convert remaining unusual variable types.
Replace uses of the uint typedef with unsigned int in rtw_hal_init()
and rtw_hal_deinit(), including their local status variables and
declarations. uint is a typedef for unsigned int, so this does not
change behavior.
Assisted-by: LLM
Signed-off-by: Artem Shelenko <Artem.Shelenko@gmail.com>
---
drivers/staging/rtl8723bs/hal/hal_intf.c | 8 ++++----
drivers/staging/rtl8723bs/include/hal_intf.h | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/hal_intf.c b/drivers/staging/rtl8723bs/hal/hal_intf.c
index 1443875d1..67b21b777 100644
--- a/drivers/staging/rtl8723bs/hal/hal_intf.c
+++ b/drivers/staging/rtl8723bs/hal/hal_intf.c
@@ -27,9 +27,9 @@ static void rtw_hal_init_opmode(struct adapter *padapter)
rtw_setopmode_cmd(padapter, networkType, false);
}
-uint rtw_hal_init(struct adapter *padapter)
+unsigned int rtw_hal_init(struct adapter *padapter)
{
- uint status;
+ unsigned int status;
struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
status = rtl8723bs_hal_init(padapter);
@@ -54,9 +54,9 @@ uint rtw_hal_init(struct adapter *padapter)
return status;
}
-uint rtw_hal_deinit(struct adapter *padapter)
+unsigned int rtw_hal_deinit(struct adapter *padapter)
{
- uint status = _SUCCESS;
+ unsigned int status = _SUCCESS;
struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
status = rtl8723bs_hal_deinit(padapter);
diff --git a/drivers/staging/rtl8723bs/include/hal_intf.h b/drivers/staging/rtl8723bs/include/hal_intf.h
index 7b6311652..b43a9c86a 100644
--- a/drivers/staging/rtl8723bs/include/hal_intf.h
+++ b/drivers/staging/rtl8723bs/include/hal_intf.h
@@ -175,8 +175,8 @@ typedef s32 (*c2h_id_filter)(u8 *c2h_evt);
#define RX_PNOWakeUp 0x55
#define AP_WakeUp 0x66
-uint rtw_hal_init(struct adapter *padapter);
-uint rtw_hal_deinit(struct adapter *padapter);
+unsigned int rtw_hal_init(struct adapter *padapter);
+unsigned int rtw_hal_deinit(struct adapter *padapter);
void rtw_hal_stop(struct adapter *padapter);
void rtw_hal_set_hwreg(struct adapter *padapter, u8 variable, u8 *val);
void rtw_hal_get_hwreg(struct adapter *padapter, u8 variable, u8 *val);
base-commit: 8444548bd905f22093729065408284a6b46f7eee
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: rtl8723bs: use unsigned int in HAL interface
2026-09-26 12:51 [PATCH] staging: rtl8723bs: use unsigned int in HAL interface Artem Shelenko
@ 2026-09-26 12:59 ` Dan Carpenter
2026-09-26 17:00 ` [PATCH v2] staging: rtl8723bs: use standard error returns " Artem Shelenko
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2026-09-26 12:59 UTC (permalink / raw)
To: Artem Shelenko; +Cc: Greg Kroah-Hartman, linux-staging, linux-kernel
On Sat, Sep 26, 2026 at 03:51:50PM +0300, Artem Shelenko wrote:
> The rtl8723bs TODO asks to convert remaining unusual variable types.
>
> Replace uses of the uint typedef with unsigned int in rtw_hal_init()
> and rtw_hal_deinit(), including their local status variables and
> declarations. uint is a typedef for unsigned int, so this does not
> change behavior.
>
This sort of patch isn't the correct thing. These functions should
be changed to return zero on success and standard negative error codes
on failure.
It's actually a good thing when bad code looks bad because then there
are tools which complain about it and it motivates people to fix it
correctly. That's the whole point of static checkers to complain about
bad code, so we're working against ourselves by silencing the checkers.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] staging: rtl8723bs: use standard error returns in HAL interface
2026-09-26 12:59 ` Dan Carpenter
@ 2026-09-26 17:00 ` Artem Shelenko
0 siblings, 0 replies; 3+ messages in thread
From: Artem Shelenko @ 2026-09-26 17:00 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Dan Carpenter, linux-staging, linux-kernel
rtw_hal_init() and rtw_hal_deinit() return vendor-style status values,
with one indicating success and zero indicating failure. Convert both
interfaces to return int with zero on success and -EIO on failure. The
lower HAL functions retain their legacy status contract and do not
provide a more specific error code at this boundary.
Update the init callers to check the new return convention. Propagate
HAL errors through _netdev_open(), while preserving its existing -1
return for failure of the unrelated rtw_start_drv_threads() API. Keep
the _SUCCESS/_FAIL contract of ips_netdrv_open() for its IPS callers.
Preserve the hw_init_completed transitions, including clearing the
flag only after a successful lower-layer deinitialization. The lower
deinit function currently always reports success; this change does
not add detection of hardware teardown failures.
Suggested-by: Dan Carpenter <error27@gmail.com>
Assisted-by: LLM
Signed-off-by: Artem Shelenko <Artem.Shelenko@gmail.com>
---
Notes:
Changes in v2:
- Replace the type-only cleanup with standard 0/-errno HAL return values as suggested by Dan Carpenter.
- Update init callers for the new convention and propagate the HAL error through _netdev_open().
- Preserve the existing IPS and rtw_start_drv_threads() return conventions.
drivers/staging/rtl8723bs/hal/hal_intf.c | 14 ++++++++------
drivers/staging/rtl8723bs/include/hal_intf.h | 4 ++--
drivers/staging/rtl8723bs/os_dep/os_intfs.c | 17 ++++++++---------
3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/hal_intf.c b/drivers/staging/rtl8723bs/hal/hal_intf.c
index 1443875d1..870cfaf1d 100644
--- a/drivers/staging/rtl8723bs/hal/hal_intf.c
+++ b/drivers/staging/rtl8723bs/hal/hal_intf.c
@@ -4,6 +4,8 @@
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
******************************************************************************/
+#include <linux/errno.h>
+
#include <drv_types.h>
#include <hal_data.h>
@@ -27,9 +29,9 @@ static void rtw_hal_init_opmode(struct adapter *padapter)
rtw_setopmode_cmd(padapter, networkType, false);
}
-uint rtw_hal_init(struct adapter *padapter)
+int rtw_hal_init(struct adapter *padapter)
{
- uint status;
+ int status;
struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
status = rtl8723bs_hal_init(padapter);
@@ -51,12 +53,12 @@ uint rtw_hal_init(struct adapter *padapter)
dvobj->padapters->hw_init_completed = false;
}
- return status;
+ return status == _SUCCESS ? 0 : -EIO;
}
-uint rtw_hal_deinit(struct adapter *padapter)
+int rtw_hal_deinit(struct adapter *padapter)
{
- uint status = _SUCCESS;
+ int status;
struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
status = rtl8723bs_hal_deinit(padapter);
@@ -66,7 +68,7 @@ uint rtw_hal_deinit(struct adapter *padapter)
padapter->hw_init_completed = false;
}
- return status;
+ return status == _SUCCESS ? 0 : -EIO;
}
void rtw_hal_set_hwreg(struct adapter *padapter, u8 variable, u8 *val)
diff --git a/drivers/staging/rtl8723bs/include/hal_intf.h b/drivers/staging/rtl8723bs/include/hal_intf.h
index 7b6311652..77aed5939 100644
--- a/drivers/staging/rtl8723bs/include/hal_intf.h
+++ b/drivers/staging/rtl8723bs/include/hal_intf.h
@@ -175,8 +175,8 @@ typedef s32 (*c2h_id_filter)(u8 *c2h_evt);
#define RX_PNOWakeUp 0x55
#define AP_WakeUp 0x66
-uint rtw_hal_init(struct adapter *padapter);
-uint rtw_hal_deinit(struct adapter *padapter);
+int rtw_hal_init(struct adapter *padapter);
+int rtw_hal_deinit(struct adapter *padapter);
void rtw_hal_stop(struct adapter *padapter);
void rtw_hal_set_hwreg(struct adapter *padapter, u8 variable, u8 *val);
void rtw_hal_get_hwreg(struct adapter *padapter, u8 variable, u8 *val);
diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index c15056ee2..691dc248a 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -786,7 +786,7 @@ int rtw_drv_register_netdev(struct adapter *if1)
static int _netdev_open(struct net_device *pnetdev)
{
- unsigned int status;
+ int ret;
struct adapter *padapter = rtw_netdev_priv(pnetdev);
struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter);
@@ -802,13 +802,14 @@ static int _netdev_open(struct net_device *pnetdev)
padapter->bSurpriseRemoved = false;
padapter->bCardDisableWOHSM = false;
- status = rtw_hal_init(padapter);
- if (status == _FAIL)
+ ret = rtw_hal_init(padapter);
+ if (ret)
goto netdev_open_error;
- status = rtw_start_drv_threads(padapter);
- if (status == _FAIL)
+ if (rtw_start_drv_threads(padapter) == _FAIL) {
+ ret = -1;
goto netdev_open_error;
+ }
if (padapter->intf_start)
padapter->intf_start(padapter);
@@ -838,7 +839,7 @@ static int _netdev_open(struct net_device *pnetdev)
netif_carrier_off(pnetdev);
rtw_netif_stop_queue(pnetdev);
- return (-1);
+ return ret;
}
int netdev_open(struct net_device *pnetdev)
@@ -861,7 +862,6 @@ int netdev_open(struct net_device *pnetdev)
static int ips_netdrv_open(struct adapter *padapter)
{
- int status = _SUCCESS;
/* struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); */
padapter->net_closed = false;
@@ -870,8 +870,7 @@ static int ips_netdrv_open(struct adapter *padapter)
padapter->bCardDisableWOHSM = false;
/* padapter->bup = true; */
- status = rtw_hal_init(padapter);
- if (status == _FAIL)
+ if (rtw_hal_init(padapter))
goto netdev_open_error;
if (padapter->intf_start)
base-commit: 8444548bd905f22093729065408284a6b46f7eee
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-26 17:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-26 12:51 [PATCH] staging: rtl8723bs: use unsigned int in HAL interface Artem Shelenko
2026-09-26 12:59 ` Dan Carpenter
2026-09-26 17:00 ` [PATCH v2] staging: rtl8723bs: use standard error returns " Artem Shelenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®