[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250201172258.56148-1-biju.das.jz@bp.renesas.com>
Date: Sat, 1 Feb 2025 17:22:53 +0000
From: Biju Das <biju.das.jz@...renesas.com>
To: Felix Fietkau <nbd@....name>,
Sean Wang <sean.wang@...iatek.com>,
Lorenzo Bianconi <lorenzo@...nel.org>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
Cc: Biju Das <biju.das.jz@...renesas.com>,
netdev@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org,
Geert Uytterhoeven <geert+renesas@...der.be>,
Biju Das <biju.das.au@...il.com>
Subject: [PATCH] net: ethernet: mtk_eth_soc: Use of_get_available_child_by_name()
Use the helper of_get_available_child_by_name() to simplify
mtk_mdio_init().
Signed-off-by: Biju Das <biju.das.jz@...renesas.com>
---
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/mediatek/mtk_eth_soc.c | 25 +++++----------------
1 file changed, 6 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 53485142938c..b318a5b58608 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -826,26 +826,18 @@ static const struct phylink_mac_ops mtk_phylink_ops = {
static int mtk_mdio_init(struct mtk_eth *eth)
{
unsigned int max_clk = 2500000, divider;
- struct device_node *mii_np;
- int ret;
+ struct device_node *mii_np _free(device_node) =
+ of_get_available_child_by_name(eth->dev->of_node, "mdio-bus");
u32 val;
- mii_np = of_get_child_by_name(eth->dev->of_node, "mdio-bus");
if (!mii_np) {
dev_err(eth->dev, "no %s child node found", "mdio-bus");
return -ENODEV;
}
- if (!of_device_is_available(mii_np)) {
- ret = -ENODEV;
- goto err_put_node;
- }
-
eth->mii_bus = devm_mdiobus_alloc(eth->dev);
- if (!eth->mii_bus) {
- ret = -ENOMEM;
- goto err_put_node;
- }
+ if (!eth->mii_bus)
+ return -ENOMEM;
eth->mii_bus->name = "mdio";
eth->mii_bus->read = mtk_mdio_read_c22;
@@ -860,8 +852,7 @@ static int mtk_mdio_init(struct mtk_eth *eth)
if (!of_property_read_u32(mii_np, "clock-frequency", &val)) {
if (val > MDC_MAX_FREQ || val < MDC_MAX_FREQ / MDC_MAX_DIVIDER) {
dev_err(eth->dev, "MDIO clock frequency out of range");
- ret = -EINVAL;
- goto err_put_node;
+ return -EINVAL;
}
max_clk = val;
}
@@ -879,11 +870,7 @@ static int mtk_mdio_init(struct mtk_eth *eth)
dev_dbg(eth->dev, "MDC is running on %d Hz\n", MDC_MAX_FREQ / divider);
- ret = of_mdiobus_register(eth->mii_bus, mii_np);
-
-err_put_node:
- of_node_put(mii_np);
- return ret;
+ return of_mdiobus_register(eth->mii_bus, mii_np);
}
static void mtk_mdio_cleanup(struct mtk_eth *eth)
--
2.43.0
Powered by blists - more mailing lists