* [PATCH net-next v1] net: macb: avoid redundant lookup for "mdio" child node in MDIO setup
@ 2024-10-30 8:52 Oleksij Rempel
2024-10-30 13:36 ` Andrew Lunn
2024-11-03 23:45 ` Jakub Kicinski
0 siblings, 2 replies; 3+ messages in thread
From: Oleksij Rempel @ 2024-10-30 8:52 UTC (permalink / raw)
To: Nicolas Ferre, Claudiu Beznea, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Oleksij Rempel, kernel, linux-kernel, netdev, havasi
Pass the "mdio" child node directly to `macb_mdiobus_register` to avoid
performing the node lookup twice.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
drivers/net/ethernet/cadence/macb_main.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index ebe886b988917..daa416fb1724e 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -915,20 +915,15 @@ static int macb_mii_probe(struct net_device *dev)
return 0;
}
-static int macb_mdiobus_register(struct macb *bp)
+static int macb_mdiobus_register(struct macb *bp, struct device_node *mdio_np)
{
struct device_node *child, *np = bp->pdev->dev.of_node;
/* If we have a child named mdio, probe it instead of looking for PHYs
* directly under the MAC node
*/
- child = of_get_child_by_name(np, "mdio");
- if (child) {
- int ret = of_mdiobus_register(bp->mii_bus, child);
-
- of_node_put(child);
- return ret;
- }
+ if (mdio_np)
+ return of_mdiobus_register(bp->mii_bus, mdio_np);
/* Only create the PHY from the device tree if at least one PHY is
* described. Otherwise scan the entire MDIO bus. We do this to support
@@ -950,17 +945,15 @@ static int macb_mdiobus_register(struct macb *bp)
static int macb_mii_init(struct macb *bp)
{
- struct device_node *child, *np = bp->pdev->dev.of_node;
+ struct device_node *mdio_np, *np = bp->pdev->dev.of_node;
int err = -ENXIO;
/* With fixed-link, we don't need to register the MDIO bus,
* except if we have a child named "mdio" in the device tree.
* In that case, some devices may be attached to the MACB's MDIO bus.
*/
- child = of_get_child_by_name(np, "mdio");
- if (child)
- of_node_put(child);
- else if (of_phy_is_fixed_link(np))
+ mdio_np = of_get_child_by_name(np, "mdio");
+ if (!mdio_np && of_phy_is_fixed_link(np))
return macb_mii_probe(bp->dev);
/* Enable management port */
@@ -984,7 +977,7 @@ static int macb_mii_init(struct macb *bp)
dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
- err = macb_mdiobus_register(bp);
+ err = macb_mdiobus_register(bp, mdio_np);
if (err)
goto err_out_free_mdiobus;
@@ -999,6 +992,8 @@ static int macb_mii_init(struct macb *bp)
err_out_free_mdiobus:
mdiobus_free(bp->mii_bus);
err_out:
+ of_node_put(mdio_np);
+
return err;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next v1] net: macb: avoid redundant lookup for "mdio" child node in MDIO setup
2024-10-30 8:52 [PATCH net-next v1] net: macb: avoid redundant lookup for "mdio" child node in MDIO setup Oleksij Rempel
@ 2024-10-30 13:36 ` Andrew Lunn
2024-11-03 23:45 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2024-10-30 13:36 UTC (permalink / raw)
To: Oleksij Rempel
Cc: Nicolas Ferre, Claudiu Beznea, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, kernel, linux-kernel,
netdev, havasi
On Wed, Oct 30, 2024 at 09:52:24AM +0100, Oleksij Rempel wrote:
> Pass the "mdio" child node directly to `macb_mdiobus_register` to avoid
> performing the node lookup twice.
>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-next v1] net: macb: avoid redundant lookup for "mdio" child node in MDIO setup
2024-10-30 8:52 [PATCH net-next v1] net: macb: avoid redundant lookup for "mdio" child node in MDIO setup Oleksij Rempel
2024-10-30 13:36 ` Andrew Lunn
@ 2024-11-03 23:45 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2024-11-03 23:45 UTC (permalink / raw)
To: Oleksij Rempel
Cc: Nicolas Ferre, Claudiu Beznea, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, kernel, linux-kernel, netdev, havasi
On Wed, 30 Oct 2024 09:52:24 +0100 Oleksij Rempel wrote:
> Pass the "mdio" child node directly to `macb_mdiobus_register` to avoid
> performing the node lookup twice.
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-03 23:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-30 8:52 [PATCH net-next v1] net: macb: avoid redundant lookup for "mdio" child node in MDIO setup Oleksij Rempel
2024-10-30 13:36 ` Andrew Lunn
2024-11-03 23:45 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).