diff mbox series

[v2] net: ethernet: actions: Use of_get_available_child_by_name()

Message ID 20250201172745.56627-1-biju.das.jz@bp.renesas.com (mailing list archive)
State New
Headers show
Series [v2] net: ethernet: actions: Use of_get_available_child_by_name() | expand

Commit Message

Biju Das Feb. 1, 2025, 5:27 p.m. UTC
Use the helper of_get_available_child_by_name() to simplify
owl_emac_mdio_init().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v1->v3:
 * Dropped duplicate mdio_node declaration.

This patch is only compile tested and depend upon[1]
[1] https://lore.kernel.org/all/20250201093126.7322-1-biju.das.jz@bp.renesas.com/
---
 drivers/net/ethernet/actions/owl-emac.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

Comments

Andrew Lunn Feb. 1, 2025, 6:54 p.m. UTC | #1
On Sat, Feb 01, 2025 at 05:27:40PM +0000, Biju Das wrote:
> Use the helper of_get_available_child_by_name() to simplify
> owl_emac_mdio_init().
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v1->v3:
>  * Dropped duplicate mdio_node declaration.

And version 2?

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

Also

1.6.7. Resending after review

Allow at least 24 hours to pass between postings. This will ensure
reviewers from all geographical locations have a chance to chime in.

and section

1.6.6. Clean-up patches

Netdev discourages patches which perform simple clean-ups, which are
not in the context of other work. For example:

o Addressing checkpatch.pl warnings
o Addressing Local variable ordering issues
o Conversions to device-managed APIs (devm_ helpers)

This is because it is felt that the churn that such changes produce
comes at a greater cost than the value of such clean-ups.

    Andrew

---
pw-bot: cr
Biju Das Feb. 2, 2025, 10:16 a.m. UTC | #2
Hi Andrew,

> -----Original Message-----
> From: Andrew Lunn <andrew@lunn.ch>
> Sent: 01 February 2025 18:55
> To: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Andrew Lunn <andrew+netdev@lunn.ch>; David S. Miller <davem@davemloft.net>; Eric Dumazet
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Andreas
> Färber <afaerber@suse.de>; Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>;
> netdev@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-actions@lists.infradead.org; Geert
> Uytterhoeven <geert+renesas@glider.be>; biju.das.au <biju.das.au@gmail.com>
> Subject: Re: [PATCH v2] net: ethernet: actions: Use of_get_available_child_by_name()
> 
> On Sat, Feb 01, 2025 at 05:27:40PM +0000, Biju Das wrote:
> > Use the helper of_get_available_child_by_name() to simplify
> > owl_emac_mdio_init().
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> > v1->v3:
> >  * Dropped duplicate mdio_node declaration.
> 
> And version 2?

It is typo. Actually it is v1->v2:

> 
> https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
> 
> Also
> 
> 1.6.7. Resending after review
> 
> Allow at least 24 hours to pass between postings. This will ensure reviewers from all geographical
> locations have a chance to chime in.
> 

Sorry for that.

> and section
> 
> 1.6.6. Clean-up patches
> 
> Netdev discourages patches which perform simple clean-ups, which are not in the context of other work.
> For example:
> 
> o Addressing checkpatch.pl warnings
> o Addressing Local variable ordering issues o Conversions to device-managed APIs (devm_ helpers)
> 
> This is because it is felt that the churn that such changes produce comes at a greater cost than the
> value of such clean-ups.

OK, Will send next version with simpler readable code, once
dependency patch hits on net-next.

Cheers,
Biju
diff mbox series

Patch

diff --git a/drivers/net/ethernet/actions/owl-emac.c b/drivers/net/ethernet/actions/owl-emac.c
index 115f48b3342c..c5a00c09b1ea 100644
--- a/drivers/net/ethernet/actions/owl-emac.c
+++ b/drivers/net/ethernet/actions/owl-emac.c
@@ -1322,23 +1322,15 @@  static int owl_emac_mdio_init(struct net_device *netdev)
 {
 	struct owl_emac_priv *priv = netdev_priv(netdev);
 	struct device *dev = owl_emac_get_dev(priv);
-	struct device_node *mdio_node;
-	int ret;
+	struct device_node *mdio_node _free(device_node) =
+		of_get_available_child_by_name(dev->of_node, "mdio");
 
-	mdio_node = of_get_child_by_name(dev->of_node, "mdio");
 	if (!mdio_node)
 		return -ENODEV;
 
-	if (!of_device_is_available(mdio_node)) {
-		ret = -ENODEV;
-		goto err_put_node;
-	}
-
 	priv->mii = devm_mdiobus_alloc(dev);
-	if (!priv->mii) {
-		ret = -ENOMEM;
-		goto err_put_node;
-	}
+	if (!priv->mii)
+		return -ENOMEM;
 
 	snprintf(priv->mii->id, MII_BUS_ID_SIZE, "%s", dev_name(dev));
 	priv->mii->name = "owl-emac-mdio";
@@ -1348,11 +1340,7 @@  static int owl_emac_mdio_init(struct net_device *netdev)
 	priv->mii->phy_mask = ~0; /* Mask out all PHYs from auto probing. */
 	priv->mii->priv = priv;
 
-	ret = devm_of_mdiobus_register(dev, priv->mii, mdio_node);
-
-err_put_node:
-	of_node_put(mdio_node);
-	return ret;
+	return devm_of_mdiobus_register(dev, priv->mii, mdio_node);
 }
 
 static int owl_emac_phy_init(struct net_device *netdev)