mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Artem Shelenko <artem.shelenko@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Dan Carpenter <error27@gmail.com>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH v2] staging: rtl8723bs: use standard error returns in HAL interface
Date: Sat, 26 Sep 2026 20:00:49 +0300	[thread overview]
Message-ID: <20260926170049.315302-1-Artem.Shelenko@gmail.com> (raw)
In-Reply-To: <arfBy_n6FsDI39p-@stanley.mountain>

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


      reply	other threads:[~2026-09-26 17:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-26 12:51 [PATCH] staging: rtl8723bs: use unsigned int " Artem Shelenko
2026-09-26 12:59 ` Dan Carpenter
2026-09-26 17:00   ` Artem Shelenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260926170049.315302-1-Artem.Shelenko@gmail.com \
    --to=artem.shelenko@gmail.com \
    --cc=error27@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®