mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Fainelli <florian.fainelli@broadcom.com>
To: Rosen Penev <rosenp@gmail.com>, netdev@vger.kernel.org
Cc: Jonas Gorski <jonas.gorski@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next] net: dsa: b53: srab: propagate errors from init helpers
Date: Mon, 27 Jul 2026 09:27:15 -0700	[thread overview]
Message-ID: <23278c3d-04eb-410d-8e6e-1f4ca63cdee7@broadcom.com> (raw)
In-Reply-To: <20260726231924.88459-1-rosenp@gmail.com>

On 7/26/26 16:19, Rosen Penev wrote:
> Convert b53_srab_prepare_irq() and b53_srab_mux_init() from void to
> int-returning functions so probe failures are properly propagated.
> 
> b53_srab_prepare_irq() now returns -ENOMEM on allocation failure and
> -EPROBE_DEFER if any port IRQ is not yet available.
> 
> b53_srab_mux_init() now returns PTR_ERR on ioremap failure instead of
> silently ignoring it.
> 
> Check and propagate both return values in b53_srab_probe() so the
> driver core sees the real error instead of always reaching
> b53_switch_register().
> 
> Assisted-by: Opencode:Big-Pickle
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>   drivers/net/dsa/b53/b53_srab.c | 26 +++++++++++++++++++-------
>   1 file changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/dsa/b53/b53_srab.c b/drivers/net/dsa/b53/b53_srab.c
> index b9939bbd2cd5..d34e1fa10c9e 100644
> --- a/drivers/net/dsa/b53/b53_srab.c
> +++ b/drivers/net/dsa/b53/b53_srab.c
> @@ -531,7 +531,7 @@ static void b53_srab_intr_set(struct b53_srab_priv *priv, bool set)
>   	writel(reg, priv->regs + B53_SRAB_CTRLS);
>   }
>   
> -static void b53_srab_prepare_irq(struct platform_device *pdev)
> +static int b53_srab_prepare_irq(struct platform_device *pdev)
>   {
>   	struct b53_device *dev = platform_get_drvdata(pdev);
>   	struct b53_srab_priv *priv = dev->priv;
> @@ -551,18 +551,22 @@ static void b53_srab_prepare_irq(struct platform_device *pdev)
>   
>   		name = kasprintf(GFP_KERNEL, "link_state_p%d", i);
>   		if (!name)
> -			return;
> +			return -ENOMEM;
>   
>   		port->num = i;
>   		port->dev = dev;
>   		port->irq = platform_get_irq_byname_optional(pdev, name);
>   		kfree(name);
> +		if (port->irq == -EPROBE_DEFER)
> +			return port->irq;
>   	}
>   
>   	b53_srab_intr_set(priv, true);
> +
> +	return 0;
>   }
>   
> -static void b53_srab_mux_init(struct platform_device *pdev)
> +static int b53_srab_mux_init(struct platform_device *pdev)
>   {
>   	struct b53_device *dev = platform_get_drvdata(pdev);
>   	struct b53_srab_priv *priv = dev->priv;
> @@ -572,11 +576,11 @@ static void b53_srab_mux_init(struct platform_device *pdev)
>   	int ret;
>   
>   	if (dev->pdata && dev->pdata->chip_id != BCM58XX_DEVICE_ID)
> -		return;
> +		return 0;

That should be -ENODEV IMHO since we don't want the driver to be 
successfully registered and do nothing on a device it cannot support.

>   
>   	priv->mux_config = devm_platform_ioremap_resource(pdev, 1);
>   	if (IS_ERR(priv->mux_config))
> -		return;
> +		return PTR_ERR(priv->mux_config);
>   
>   	/* Obtain the port mux configuration so we know which lanes
>   	 * actually map to SerDes lanes
> @@ -613,6 +617,8 @@ static void b53_srab_mux_init(struct platform_device *pdev)
>   			dev_info(&pdev->dev, "Port %d mode: %s\n",
>   				 port, phy_modes(p->mode));
>   	}
> +
> +	return 0;
>   }
>   
>   static int b53_srab_probe(struct platform_device *pdev)
> @@ -622,6 +628,7 @@ static int b53_srab_probe(struct platform_device *pdev)
>   	const struct of_device_id *of_id = NULL;
>   	struct b53_srab_priv *priv;
>   	struct b53_device *dev;
> +	int err;
>   
>   	if (dn)
>   		of_id = of_match_node(b53_srab_of_match, dn);
> @@ -651,8 +658,13 @@ static int b53_srab_probe(struct platform_device *pdev)
>   
>   	platform_set_drvdata(pdev, dev);
>   
> -	b53_srab_prepare_irq(pdev);
> -	b53_srab_mux_init(pdev);
> +	err = b53_srab_prepare_irq(pdev);
> +	if (err)
> +		return err;
> +
> +	err = b53_srab_mux_init(pdev);
> +	if (err)
> +		return err;
>   
>   	return b53_switch_register(dev);
>   }


-- 
Florian

      reply	other threads:[~2026-07-27 16:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-26 23:19 Rosen Penev
2026-07-27 16:27 ` Florian Fainelli [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=23278c3d-04eb-410d-8e6e-1f4ca63cdee7@broadcom.com \
    --to=florian.fainelli@broadcom.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jonas.gorski@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=rosenp@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

all inboxes | Powered by JetHome®