Message ID | 20250205124235.53285-3-biju.das.jz@bp.renesas.com (mailing list archive) |
---|---|
State | Under Review |
Delegated to: | Geert Uytterhoeven |
Headers | show |
Series | Add of_get_available_child_by_name() | expand |
On Wed, Feb 05, 2025 at 12:42:22PM +0000, Biju Das wrote: > 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> > --- > v1->v2: > * Rebased and added patch suffix net-next. Reviewed-by: Simon Horman <horms@kernel.org>
On Wed, Feb 05, 2025 at 12:42:22PM +0000, Biju Das wrote: > 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: Vladimir Oltean <olteanv@gmail.com>
diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c index 66974379334a..31ea8130a495 100644 --- a/drivers/net/dsa/rzn1_a5psw.c +++ b/drivers/net/dsa/rzn1_a5psw.c @@ -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;
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> --- v1->v2: * Rebased and added patch suffix net-next. --- drivers/net/dsa/rzn1_a5psw.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)