[PATCH 1/4] net: dsa: return early if there is no master

Ramon Fried rfried.dev at gmail.com
Thu Feb 25 20:12:34 CET 2021


On Wed, Feb 24, 2021 at 6:40 PM Michael Walle <michael at walle.cc> wrote:
>
> It doesn't make sense to have DSA without a master port. Error out early
> if there is no master port.
>
> Fixes: fc054d563bfb ("net: Introduce DSA class for Ethernet switches")
> Signed-off-by: Michael Walle <michael at walle.cc>
> Reviewed-by: Vladimir Oltean <vladimir.oltean at nxp.com>
> ---
>  net/dsa-uclass.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
> index 2ce9ddb90d..88a8ea9352 100644
> --- a/net/dsa-uclass.c
> +++ b/net/dsa-uclass.c
> @@ -280,6 +280,10 @@ static int dsa_port_probe(struct udevice *pdev)
>         if (!port_pdata->phy)
>                 return -ENODEV;
>
> +       master = dsa_get_master(dev);
> +       if (!master)
> +               return -ENODEV;
> +
>         /*
>          * Inherit port's hwaddr from the DSA master, unless the port already
>          * has a unique MAC address specified in the environment.
> @@ -288,10 +292,6 @@ static int dsa_port_probe(struct udevice *pdev)
>         if (!is_zero_ethaddr(env_enetaddr))
>                 return 0;
>
> -       master = dsa_get_master(dev);
> -       if (!master)
> -               return 0;
> -
>         master_pdata = dev_get_plat(master);
>         eth_pdata = dev_get_plat(pdev);
>         memcpy(eth_pdata->enetaddr, master_pdata->enetaddr, ARP_HLEN);
> --
> 2.20.1
>
Reviewed-By: Ramon Fried <rfried.dev at gmail.com>


More information about the U-Boot mailing list