public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Omer El Idrissi <omer.e.idrissi@gmail.com>
Cc: gregkh@linuxfoundation.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] staging: rtl8723bs: change error handling to use standard errno
Date: Sun, 22 Mar 2026 00:24:35 +0300	[thread overview]
Message-ID: <ab8Mk8uOyKrNpykg@stanley.mountain> (raw)
In-Reply-To: <20260321201738.16278-1-omer.e.idrissi@gmail.com>

On Sat, Mar 21, 2026 at 09:17:38PM +0100, Omer El Idrissi wrote:
> Replace non-standard return values with descriptive linux kernel error
> codes in probe path.
> Also replace the variable name 'status' with 'ret' to be more
> consistent with other kernel code.
> 
> Signed-off-by: Omer El Idrissi <omer.e.idrissi@gmail.com>
> 
> ---
> v2:
> - Return -ENODEV instead of -ENOMEM when sdio_dvobj_init fails
> 
>  drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 30 ++++++++++++--------
>  1 file changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> index d664e254912c..47189c849b05 100644
> --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c
> @@ -345,38 +345,44 @@ static int rtw_drv_init(
>  	struct sdio_func *func,
>  	const struct sdio_device_id *id)
>  {
> -	int status = _FAIL;
> +	int ret;
>  	struct adapter *if1 = NULL;
>  	struct dvobj_priv *dvobj;
>  
>  	dvobj = sdio_dvobj_init(func);
> -	if (!dvobj)
> +	if (!dvobj) {
> +		ret = -ENODEV;
>  		goto exit;
> +	}
>  
>  	if1 = rtw_sdio_if1_init(dvobj, id);
> -	if (!if1)
> +	if (!if1) {
> +		ret = -ENOMEM;
>  		goto free_dvobj;
> +	}
>  
>  	/* dev_alloc_name && register_netdev */
> -	status = rtw_drv_register_netdev(if1);
> -	if (status != _SUCCESS)
> +	ret = rtw_drv_register_netdev(if1);
> +	if (ret) {
> +		ret = -EIO;
>  		goto free_if1;
> +	}


rtw_drv_register_netdev() doesn't return regular error codes
but when you change:

-	if (status != _SUCCESS) {
+	if (ret) {

Then you're making it look like it does, which is confusing.

You're going about this the wrong way.  You need to start with
functions like _rtw_drv_register_netdev() which are where
the _SUCCESS returns are first returned and change those first.
You have to update the callers as you go.  It's tricky because
you have to be sure you're catching all the callers.

Then eventually, you'll get back to rtw_drv_init() and all the
functions it call will return normal error codes and you can
update that.

Do it one function at a time.  Update the function and the
callers.  Something like this:

regards,
dan carpenter

[patch] update error code for rtw_init_netdev_name()

The rtw_init_netdev_name() returns 1 on failure and 0 on success
which is non-standard.  Change it to propagate the error from
dev_alloc_name() and update the only caller.

diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index 7ba689f2dfc8..92b52b1a2920 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -407,9 +407,12 @@ static const struct net_device_ops rtw_netdev_ops = {
 
 int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname)
 {
-	if (dev_alloc_name(pnetdev, ifname) < 0) {
+	int ret;
+
+	ret = dev_alloc_name(pnetdev, ifname);
+	if (ret < 0) {
 		pr_err("dev_alloc_name, fail for %s\n", ifname);
-		return 1;
+		return ret;
 	}
 	netif_carrier_off(pnetdev);
 	/* rtw_netif_stop_queue(pnetdev); */
@@ -755,7 +758,8 @@ static int _rtw_drv_register_netdev(struct adapter *padapter, char *name)
 	struct net_device *pnetdev = padapter->pnetdev;
 
 	/* alloc netdev name */
-	if (rtw_init_netdev_name(pnetdev, name))
+	ret = rtw_init_netdev_name(pnetdev, name);
+	if (ret)
 		return _FAIL;
 
 	eth_hw_addr_set(pnetdev, padapter->eeprompriv.mac_addr);

  reply	other threads:[~2026-03-21 21:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20  7:29 [PATCH] [PATCH] staging: rtl8723bs: change error handling to use standard errno Omer El Idrissi
2026-03-20  7:35 ` Greg KH
2026-03-20  7:36 ` Greg KH
     [not found]   ` <CACx49NfzUuHWdvME+850gJXLL==6x8Yw3_0yzZgJmAk089a7Aw@mail.gmail.com>
2026-03-20  8:47     ` Omer
2026-03-20  9:48 ` [PATCH v2] " Omer El Idrissi
2026-03-21  7:03   ` Greg KH
2026-03-21 20:17 ` Omer El Idrissi
2026-03-21 21:24   ` Dan Carpenter [this message]
2026-03-21 21:34     ` Omer

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=ab8Mk8uOyKrNpykg@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=omer.e.idrissi@gmail.com \
    /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