[PATCH v3 6/8] net: dsa: fix of_device_ensure_probed*() for switch ports

Johannes Zink j.zink at pengutronix.de
Mon Nov 7 05:05:06 PST 2022


Hi Oleksij,

On Mon, 2022-11-07 at 12:16 +0100, Oleksij Rempel wrote:
> Crete ports by using of_platform_device_create() in the same way as

another nitpick: s/Crete/Create/

Best regards
Johannes

> it
> is used by of_device_ensure_probed*(). Otherwise we are creating
> multiple devices for the same node.
> 
> At same time we need to link dummy driver to make this logic work.
> 
> Signed-off-by: Oleksij Rempel <o.rempel at pengutronix.de>
> ---
>  drivers/net/dsa.c | 18 +++++-------------
>  include/dsa.h     |  2 +-
>  2 files changed, 6 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/dsa.c b/drivers/net/dsa.c
> index 124059ee3c..bc33892f39 100644
> --- a/drivers/net/dsa.c
> +++ b/drivers/net/dsa.c
> @@ -59,7 +59,7 @@ static int dsa_port_probe(struct eth_device *edev)
>         int ret;
>  
>         if (ops->port_probe) {
> -               interface = of_get_phy_mode(dp->dev.device_node);
> +               interface = of_get_phy_mode(dp->dev->device_node);
>                 ret = ops->port_probe(dp, dp->index, interface);
>                 if (ret)
>                         return ret;
> @@ -93,7 +93,7 @@ static int dsa_port_start(struct eth_device *edev)
>         if (dp->enabled)
>                 return -EBUSY;
>  
> -       interface = of_get_phy_mode(dp->dev.device_node);
> +       interface = of_get_phy_mode(dp->dev->device_node);
>  
>         if (ops->port_pre_enable) {
>                 /* In case of RMII interface we need to enable RMII
> clock
> @@ -241,21 +241,13 @@ static int dsa_switch_register_edev(struct
> dsa_switch *ds,
>         struct eth_device *edev;
>         struct device_d *dev;
>         struct dsa_port *dp;
> -       int ret;
>  
>         ds->dp[port] = xzalloc(sizeof(*dp));
> -
>         dp = ds->dp[port];
> -       dev = &dp->dev;
> -
> -       dev_set_name(dev, "dsa_port");
> -       dev->id = DEVICE_ID_DYNAMIC;
> -       dev->parent = ds->dev;
> -       dev->device_node = dn;
>  
> -       ret = register_device(dev);
> -       if (ret)
> -               return ret;
> +       dev = of_platform_device_create(dn, ds->dev);
> +       of_platform_device_dummy_drv(dev);
> +       dp->dev = dev;
>  
>         dp->rx_buf = xmalloc(DSA_PKTSIZE);
>         dp->ds = ds;
> diff --git a/include/dsa.h b/include/dsa.h
> index 75a939f2cb..f428aa74a5 100644
> --- a/include/dsa.h
> +++ b/include/dsa.h
> @@ -58,7 +58,7 @@ struct dsa_ops {
>  };
>  
>  struct dsa_port {
> -       struct device_d dev;
> +       struct device_d *dev;
>         struct dsa_switch *ds;
>         unsigned int index;
>         struct eth_device edev;

-- 
Pengutronix e.K.                | Johannes Zink                  |
Steuerwalder Str. 21            | https://www.pengutronix.de/    |
31137 Hildesheim, Germany       | Phone: +49-5121-206917-0       |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-5555    |




More information about the barebox mailing list