]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: dsa: rzn1_a5psw: Use of_get_available_child_by_name()
authorBiju Das <biju.das.jz@bp.renesas.com>
Wed, 5 Feb 2025 12:42:22 +0000 (12:42 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 7 Feb 2025 13:43:55 +0000 (13:43 +0000)
Simplify a5psw_probe() by using of_get_available_child_by_name().

While at it, move of_node_put(mdio) inside the if block to avoid code
duplication.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/rzn1_a5psw.c

index 66974379334a463dac9019958b691de3945f540d..31ea8130a495ff2e72247f1fda4cec5a85aeedae 100644 (file)
@@ -1248,18 +1248,16 @@ static int a5psw_probe(struct platform_device *pdev)
        if (ret)
                goto clk_disable;
 
-       mdio = of_get_child_by_name(dev->of_node, "mdio");
-       if (of_device_is_available(mdio)) {
+       mdio = of_get_available_child_by_name(dev->of_node, "mdio");
+       if (mdio) {
                ret = a5psw_probe_mdio(a5psw, mdio);
+               of_node_put(mdio);
                if (ret) {
-                       of_node_put(mdio);
                        dev_err(dev, "Failed to register MDIO: %d\n", ret);
                        goto hclk_disable;
                }
        }
 
-       of_node_put(mdio);
-
        ds = &a5psw->ds;
        ds->dev = dev;
        ds->num_ports = A5PSW_PORTS_NUM;