Re: [PATCHv3 net-next] net: dsa: b53: srab: propagate errors from init helpers

Jonas Gorski <[email protected]>
Newsgroups org.kernel.vger.netdev,org.kernel.vger.linux-kernel
Message-ID <CAOiHx=mdMQ-uZCUW16ynrJcbp555tWq=2b5wMMZ8hQQm6PD31A@mail.gmail.com>
Hi,

On Wed, Jul 29, 2026 at 10:29 PM Rosen Penev <[email protected]> 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().
>
> Add error handling in probe as a result of b53_srab_prepare_irq().
>
> Move mux_config out of private struct. This was needed when devm was not used.
>
> Assisted-by: Opencode:Big-Pickle
> Signed-off-by: Rosen Penev <[email protected]>
> ---
>  v3: move mux_config to function.
>  v2: address memory leak in b53_srab_prepare_irq().

Please also mention any review comments you addressed in the
changelog. I don't see any mention of changing the condition in
b53_srab_mux_init().

>  drivers/net/dsa/b53/b53_srab.c | 46 ++++++++++++++++++++++++----------
>  1 file changed, 33 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/dsa/b53/b53_srab.c b/drivers/net/dsa/b53/b53_srab.c
> index b9939bbd2cd5..81bfd5cd1022 100644
> --- a/drivers/net/dsa/b53/b53_srab.c
> +++ b/drivers/net/dsa/b53/b53_srab.c

(snip)

> @@ -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,10 +658,23 @@ 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)
> +               goto err_irq;

Tbh, I'm not sure if it is a good idea to abort probing on error here.
The mux only applies to 2 of the 6? potential ports, so at worst those
two ports won't work, but other ports should continue to work fine.
And I think reduced functionality is preferable to no functionality;
with a non-probing switch it will likely be harder to recover the
device.

(The values read out from mux could even just be passed on via
phy-mode properties on the ports in the device tree, but that would
require changing the driver ...).

Best regards,
Jonas
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.