[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZE5UNq9QD1tZbHGx@makrotopia.org>
Date: Sun, 30 Apr 2023 12:42:46 +0100
From: Daniel Golle <daniel@...rotopia.org>
To: David Bauer <mail@...id-bauer.net>
Cc: Sean Wang <sean.wang@...iatek.com>,
Landen Chao <Landen.Chao@...iatek.com>,
DENG Qingfang <dqfext@...il.com>, Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH 1/2] mt7530: register OF node for internal MDIO bus
On Sun, Apr 30, 2023 at 01:28:32PM +0200, David Bauer wrote:
> The MT753x switches provide a switch-internal MDIO bus for the embedded
> PHYs.
>
> Register a OF sub-node on the switch OF-node for this internal MDIO bus.
> This allows to configure the embedded PHYs using device-tree.
>
> Signed-off-by: David Bauer <mail@...id-bauer.net>
Acked-by: Daniel Golle <daniel@...rotopia.org>
I've got a similar commit in my tree for a while, yours is better
because you care to of_node_put(mnp) ;)
And yes, this will be fine also if mnp is NULL, the MDIO bus will
still be registered (just without the reference to the OF node) and
also of_node_put is fine being called for NULL.
> ---
> drivers/net/dsa/mt7530.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index c680873819b0..7e8ea5b75c3e 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -2119,10 +2119,13 @@ mt7530_setup_mdio(struct mt7530_priv *priv)
> {
> struct dsa_switch *ds = priv->ds;
> struct device *dev = priv->dev;
> + struct device_node *np, *mnp;
> struct mii_bus *bus;
> static int idx;
> int ret;
>
> + np = priv->dev->of_node;
> +
> bus = devm_mdiobus_alloc(dev);
> if (!bus)
> return -ENOMEM;
> @@ -2141,7 +2144,9 @@ mt7530_setup_mdio(struct mt7530_priv *priv)
> if (priv->irq)
> mt7530_setup_mdio_irq(priv);
>
> - ret = devm_mdiobus_register(dev, bus);
> + mnp = of_get_child_by_name(np, "mdio");
> + ret = devm_of_mdiobus_register(dev, bus, mnp);
> + of_node_put(mnp);
> if (ret) {
> dev_err(dev, "failed to register MDIO bus: %d\n", ret);
> if (priv->irq)
> --
> 2.39.2
>
Powered by blists - more mailing lists