Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: macb: avoid redundant lookup for "mdio" child node in MDIO setup

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>
Link: https://patch.msgid.link/20241030085224.2632426-1-o.rempel@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Oleksij Rempel and committed by
Jakub Kicinski
8a6631f1 d847548c

+9 -14
+9 -14
drivers/net/ethernet/cadence/macb_main.c
··· 915 915 return 0; 916 916 } 917 917 918 - static int macb_mdiobus_register(struct macb *bp) 918 + static int macb_mdiobus_register(struct macb *bp, struct device_node *mdio_np) 919 919 { 920 920 struct device_node *child, *np = bp->pdev->dev.of_node; 921 921 922 922 /* If we have a child named mdio, probe it instead of looking for PHYs 923 923 * directly under the MAC node 924 924 */ 925 - child = of_get_child_by_name(np, "mdio"); 926 - if (child) { 927 - int ret = of_mdiobus_register(bp->mii_bus, child); 928 - 929 - of_node_put(child); 930 - return ret; 931 - } 925 + if (mdio_np) 926 + return of_mdiobus_register(bp->mii_bus, mdio_np); 932 927 933 928 /* Only create the PHY from the device tree if at least one PHY is 934 929 * described. Otherwise scan the entire MDIO bus. We do this to support ··· 945 950 946 951 static int macb_mii_init(struct macb *bp) 947 952 { 948 - struct device_node *child, *np = bp->pdev->dev.of_node; 953 + struct device_node *mdio_np, *np = bp->pdev->dev.of_node; 949 954 int err = -ENXIO; 950 955 951 956 /* With fixed-link, we don't need to register the MDIO bus, 952 957 * except if we have a child named "mdio" in the device tree. 953 958 * In that case, some devices may be attached to the MACB's MDIO bus. 954 959 */ 955 - child = of_get_child_by_name(np, "mdio"); 956 - if (child) 957 - of_node_put(child); 958 - else if (of_phy_is_fixed_link(np)) 960 + mdio_np = of_get_child_by_name(np, "mdio"); 961 + if (!mdio_np && of_phy_is_fixed_link(np)) 959 962 return macb_mii_probe(bp->dev); 960 963 961 964 /* Enable management port */ ··· 977 984 978 985 dev_set_drvdata(&bp->dev->dev, bp->mii_bus); 979 986 980 - err = macb_mdiobus_register(bp); 987 + err = macb_mdiobus_register(bp, mdio_np); 981 988 if (err) 982 989 goto err_out_free_mdiobus; 983 990 ··· 992 999 err_out_free_mdiobus: 993 1000 mdiobus_free(bp->mii_bus); 994 1001 err_out: 1002 + of_node_put(mdio_np); 1003 + 995 1004 return err; 996 1005 } 997 1006