* [PATCH net-next v2 1/7] of: base: Add of_get_available_child_by_name()
2025-02-05 12:42 [PATCH net-next v2 0/7] Add of_get_available_child_by_name() Biju Das
@ 2025-02-05 12:42 ` Biju Das
2025-02-07 9:45 ` Simon Horman
2025-02-05 12:42 ` [PATCH net-next v2 2/7] net: dsa: rzn1_a5psw: Use of_get_available_child_by_name() Biju Das
` (6 subsequent siblings)
7 siblings, 1 reply; 18+ messages in thread
From: Biju Das @ 2025-02-05 12:42 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Matthias Brugger, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
AngeloGioacchino Del Regno
Cc: Biju Das, devicetree, linux-arm-kernel, netdev,
Geert Uytterhoeven, Prabhakar Mahadev Lad, Biju Das,
linux-renesas-soc
There are lot of drivers using of_get_child_by_name() followed by
of_device_is_available() to find the available child node by name for a
given parent. Provide a helper for these users to simplify the code.
Suggested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
previous v2->v2
* Added Rb tag from Rob.
v1->previous v2:
* Updated commit description.
* Updated kerneldoc comment block
* Avoided code duplication by using of_get_child_by_name().
---
drivers/of/base.c | 27 +++++++++++++++++++++++++++
include/linux/of.h | 9 +++++++++
2 files changed, 36 insertions(+)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index af6c68bbb427..e37b088f1fad 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -824,6 +824,33 @@ struct device_node *of_get_child_by_name(const struct device_node *node,
}
EXPORT_SYMBOL(of_get_child_by_name);
+/**
+ * of_get_available_child_by_name - Find the available child node by name for a given parent
+ * @node: parent node
+ * @name: child name to look for.
+ *
+ * This function looks for child node for given matching name and checks the
+ * device's availability for use.
+ *
+ * Return: A node pointer if found, with refcount incremented, use
+ * of_node_put() on it when done.
+ * Returns NULL if node is not found.
+ */
+struct device_node *of_get_available_child_by_name(const struct device_node *node,
+ const char *name)
+{
+ struct device_node *child;
+
+ child = of_get_child_by_name(node, name);
+ if (child && !of_device_is_available(child)) {
+ of_node_put(child);
+ return NULL;
+ }
+
+ return child;
+}
+EXPORT_SYMBOL(of_get_available_child_by_name);
+
struct device_node *__of_find_node_by_path(const struct device_node *parent,
const char *path)
{
diff --git a/include/linux/of.h b/include/linux/of.h
index eaf0e2a2b75c..9d6b8a61607f 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -301,6 +301,8 @@ extern struct device_node *of_get_compatible_child(const struct device_node *par
const char *compatible);
extern struct device_node *of_get_child_by_name(const struct device_node *node,
const char *name);
+extern struct device_node *of_get_available_child_by_name(const struct device_node *node,
+ const char *name);
/* cache lookup */
extern struct device_node *of_find_next_cache_node(const struct device_node *);
@@ -578,6 +580,13 @@ static inline struct device_node *of_get_child_by_name(
return NULL;
}
+static inline struct device_node *of_get_available_child_by_name(
+ const struct device_node *node,
+ const char *name)
+{
+ return NULL;
+}
+
static inline int of_device_is_compatible(const struct device_node *device,
const char *name)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH net-next v2 1/7] of: base: Add of_get_available_child_by_name()
2025-02-05 12:42 ` [PATCH net-next v2 1/7] of: base: " Biju Das
@ 2025-02-07 9:45 ` Simon Horman
0 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2025-02-07 9:45 UTC (permalink / raw)
To: Biju Das
Cc: Rob Herring, Saravana Kannan, Matthias Brugger, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
AngeloGioacchino Del Regno, devicetree, linux-arm-kernel, netdev,
Geert Uytterhoeven, Prabhakar Mahadev Lad, Biju Das,
linux-renesas-soc
On Wed, Feb 05, 2025 at 12:42:21PM +0000, Biju Das wrote:
> There are lot of drivers using of_get_child_by_name() followed by
> of_device_is_available() to find the available child node by name for a
> given parent. Provide a helper for these users to simplify the code.
>
> Suggested-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Reviewed-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> previous v2->v2
> * Added Rb tag from Rob.
> v1->previous v2:
> * Updated commit description.
> * Updated kerneldoc comment block
> * Avoided code duplication by using of_get_child_by_name().
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH net-next v2 2/7] net: dsa: rzn1_a5psw: Use of_get_available_child_by_name()
2025-02-05 12:42 [PATCH net-next v2 0/7] Add of_get_available_child_by_name() Biju Das
2025-02-05 12:42 ` [PATCH net-next v2 1/7] of: base: " Biju Das
@ 2025-02-05 12:42 ` Biju Das
2025-02-07 9:47 ` Simon Horman
2025-02-07 17:41 ` Vladimir Oltean
2025-02-05 12:42 ` [PATCH net-next v2 3/7] net: dsa: sja1105: " Biju Das
` (5 subsequent siblings)
7 siblings, 2 replies; 18+ messages in thread
From: Biju Das @ 2025-02-05 12:42 UTC (permalink / raw)
To: Clément Léger, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Biju Das, linux-renesas-soc, netdev, Geert Uytterhoeven,
Prabhakar Mahadev Lad, Biju Das
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(-)
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;
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH net-next v2 2/7] net: dsa: rzn1_a5psw: Use of_get_available_child_by_name()
2025-02-05 12:42 ` [PATCH net-next v2 2/7] net: dsa: rzn1_a5psw: Use of_get_available_child_by_name() Biju Das
@ 2025-02-07 9:47 ` Simon Horman
2025-02-07 17:41 ` Vladimir Oltean
1 sibling, 0 replies; 18+ messages in thread
From: Simon Horman @ 2025-02-07 9:47 UTC (permalink / raw)
To: Biju Das
Cc: Clément Léger, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-renesas-soc, netdev, Geert Uytterhoeven,
Prabhakar Mahadev Lad, Biju Das
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>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH net-next v2 2/7] net: dsa: rzn1_a5psw: Use of_get_available_child_by_name()
2025-02-05 12:42 ` [PATCH net-next v2 2/7] net: dsa: rzn1_a5psw: Use of_get_available_child_by_name() Biju Das
2025-02-07 9:47 ` Simon Horman
@ 2025-02-07 17:41 ` Vladimir Oltean
1 sibling, 0 replies; 18+ messages in thread
From: Vladimir Oltean @ 2025-02-07 17:41 UTC (permalink / raw)
To: Biju Das
Cc: Clément Léger, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-renesas-soc,
netdev, Geert Uytterhoeven, Prabhakar Mahadev Lad, Biju Das
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>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH net-next v2 3/7] net: dsa: sja1105: Use of_get_available_child_by_name()
2025-02-05 12:42 [PATCH net-next v2 0/7] Add of_get_available_child_by_name() Biju Das
2025-02-05 12:42 ` [PATCH net-next v2 1/7] of: base: " Biju Das
2025-02-05 12:42 ` [PATCH net-next v2 2/7] net: dsa: rzn1_a5psw: Use of_get_available_child_by_name() Biju Das
@ 2025-02-05 12:42 ` Biju Das
2025-02-07 9:47 ` Simon Horman
2025-02-07 17:43 ` Vladimir Oltean
2025-02-05 12:42 ` [PATCH net-next v2 4/7] net: ethernet: mtk-star-emac: " Biju Das
` (4 subsequent siblings)
7 siblings, 2 replies; 18+ messages in thread
From: Biju Das @ 2025-02-05 12:42 UTC (permalink / raw)
To: Vladimir Oltean, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Biju Das, netdev, Geert Uytterhoeven, Biju Das
Use the helper of_get_available_child_by_name() to simplify
sja1105_mdiobus_register().
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v1->v2:
* Dropped using _free().
---
drivers/net/dsa/sja1105/sja1105_mdio.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/net/dsa/sja1105/sja1105_mdio.c b/drivers/net/dsa/sja1105/sja1105_mdio.c
index 84b7169f2974..8d535c033cef 100644
--- a/drivers/net/dsa/sja1105/sja1105_mdio.c
+++ b/drivers/net/dsa/sja1105/sja1105_mdio.c
@@ -468,13 +468,10 @@ int sja1105_mdiobus_register(struct dsa_switch *ds)
if (rc)
return rc;
- mdio_node = of_get_child_by_name(switch_node, "mdios");
+ mdio_node = of_get_available_child_by_name(switch_node, "mdios");
if (!mdio_node)
return 0;
- if (!of_device_is_available(mdio_node))
- goto out_put_mdio_node;
-
if (regs->mdio_100base_tx != SJA1105_RSV_ADDR) {
rc = sja1105_mdiobus_base_tx_register(priv, mdio_node);
if (rc)
@@ -487,7 +484,6 @@ int sja1105_mdiobus_register(struct dsa_switch *ds)
goto err_free_base_tx_mdiobus;
}
-out_put_mdio_node:
of_node_put(mdio_node);
return 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH net-next v2 3/7] net: dsa: sja1105: Use of_get_available_child_by_name()
2025-02-05 12:42 ` [PATCH net-next v2 3/7] net: dsa: sja1105: " Biju Das
@ 2025-02-07 9:47 ` Simon Horman
2025-02-07 17:43 ` Vladimir Oltean
1 sibling, 0 replies; 18+ messages in thread
From: Simon Horman @ 2025-02-07 9:47 UTC (permalink / raw)
To: Biju Das
Cc: Vladimir Oltean, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, Geert Uytterhoeven, Biju Das
On Wed, Feb 05, 2025 at 12:42:23PM +0000, Biju Das wrote:
> Use the helper of_get_available_child_by_name() to simplify
> sja1105_mdiobus_register().
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v1->v2:
> * Dropped using _free().
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH net-next v2 3/7] net: dsa: sja1105: Use of_get_available_child_by_name()
2025-02-05 12:42 ` [PATCH net-next v2 3/7] net: dsa: sja1105: " Biju Das
2025-02-07 9:47 ` Simon Horman
@ 2025-02-07 17:43 ` Vladimir Oltean
1 sibling, 0 replies; 18+ messages in thread
From: Vladimir Oltean @ 2025-02-07 17:43 UTC (permalink / raw)
To: Biju Das
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, Geert Uytterhoeven, Biju Das
On Wed, Feb 05, 2025 at 12:42:23PM +0000, Biju Das wrote:
> Use the helper of_get_available_child_by_name() to simplify
> sja1105_mdiobus_register().
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH net-next v2 4/7] net: ethernet: mtk-star-emac: Use of_get_available_child_by_name()
2025-02-05 12:42 [PATCH net-next v2 0/7] Add of_get_available_child_by_name() Biju Das
` (2 preceding siblings ...)
2025-02-05 12:42 ` [PATCH net-next v2 3/7] net: dsa: sja1105: " Biju Das
@ 2025-02-05 12:42 ` Biju Das
2025-02-07 9:51 ` Simon Horman
2025-02-05 12:42 ` [PATCH net-next v2 5/7] net: ethernet: mtk_eth_soc: " Biju Das
` (3 subsequent siblings)
7 siblings, 1 reply; 18+ messages in thread
From: Biju Das @ 2025-02-05 12:42 UTC (permalink / raw)
To: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno
Cc: Biju Das, netdev, linux-arm-kernel, linux-mediatek,
Geert Uytterhoeven, Biju Das
Use the helper of_get_available_child_by_name() to simplify
mtk_star_mdio_init().
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v1->v2:
* Dropped using _free()
---
drivers/net/ethernet/mediatek/mtk_star_emac.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c
index 25989c79c92e..76f202d7f055 100644
--- a/drivers/net/ethernet/mediatek/mtk_star_emac.c
+++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c
@@ -1427,15 +1427,10 @@ static int mtk_star_mdio_init(struct net_device *ndev)
of_node = dev->of_node;
- mdio_node = of_get_child_by_name(of_node, "mdio");
+ mdio_node = of_get_available_child_by_name(of_node, "mdio");
if (!mdio_node)
return -ENODEV;
- if (!of_device_is_available(mdio_node)) {
- ret = -ENODEV;
- goto out_put_node;
- }
-
priv->mii = devm_mdiobus_alloc(dev);
if (!priv->mii) {
ret = -ENOMEM;
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH net-next v2 4/7] net: ethernet: mtk-star-emac: Use of_get_available_child_by_name()
2025-02-05 12:42 ` [PATCH net-next v2 4/7] net: ethernet: mtk-star-emac: " Biju Das
@ 2025-02-07 9:51 ` Simon Horman
0 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2025-02-07 9:51 UTC (permalink / raw)
To: Biju Das
Cc: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, netdev,
linux-arm-kernel, linux-mediatek, Geert Uytterhoeven, Biju Das
On Wed, Feb 05, 2025 at 12:42:24PM +0000, Biju Das wrote:
> Use the helper of_get_available_child_by_name() to simplify
> mtk_star_mdio_init().
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v1->v2:
> * Dropped using _free()
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH net-next v2 5/7] net: ethernet: mtk_eth_soc: Use of_get_available_child_by_name()
2025-02-05 12:42 [PATCH net-next v2 0/7] Add of_get_available_child_by_name() Biju Das
` (3 preceding siblings ...)
2025-02-05 12:42 ` [PATCH net-next v2 4/7] net: ethernet: mtk-star-emac: " Biju Das
@ 2025-02-05 12:42 ` Biju Das
2025-02-07 9:52 ` Simon Horman
2025-02-05 12:42 ` [PATCH net-next v2 6/7] net: ethernet: actions: " Biju Das
` (2 subsequent siblings)
7 siblings, 1 reply; 18+ messages in thread
From: Biju Das @ 2025-02-05 12:42 UTC (permalink / raw)
To: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno
Cc: Biju Das, netdev, linux-arm-kernel, linux-mediatek,
Geert Uytterhoeven, Biju Das
Use the helper of_get_available_child_by_name() to simplify
mtk_mdio_init().
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v1->v2:
* Dropped using _free().
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 53485142938c..0ad965ced5ef 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -830,17 +830,12 @@ static int mtk_mdio_init(struct mtk_eth *eth)
int ret;
u32 val;
- mii_np = of_get_child_by_name(eth->dev->of_node, "mdio-bus");
+ mii_np = of_get_available_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;
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH net-next v2 5/7] net: ethernet: mtk_eth_soc: Use of_get_available_child_by_name()
2025-02-05 12:42 ` [PATCH net-next v2 5/7] net: ethernet: mtk_eth_soc: " Biju Das
@ 2025-02-07 9:52 ` Simon Horman
0 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2025-02-07 9:52 UTC (permalink / raw)
To: Biju Das
Cc: Felix Fietkau, Sean Wang, Lorenzo Bianconi, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno, netdev,
linux-arm-kernel, linux-mediatek, Geert Uytterhoeven, Biju Das
On Wed, Feb 05, 2025 at 12:42:25PM +0000, Biju Das wrote:
> Use the helper of_get_available_child_by_name() to simplify
> mtk_mdio_init().
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v1->v2:
> * Dropped using _free().
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH net-next v2 6/7] net: ethernet: actions: Use of_get_available_child_by_name()
2025-02-05 12:42 [PATCH net-next v2 0/7] Add of_get_available_child_by_name() Biju Das
` (4 preceding siblings ...)
2025-02-05 12:42 ` [PATCH net-next v2 5/7] net: ethernet: mtk_eth_soc: " Biju Das
@ 2025-02-05 12:42 ` Biju Das
2025-02-07 9:53 ` Simon Horman
2025-02-05 12:42 ` [PATCH net-next v2 7/7] net: ibm: emac: " Biju Das
2025-02-07 13:50 ` [PATCH net-next v2 0/7] Add of_get_available_child_by_name() patchwork-bot+netdevbpf
7 siblings, 1 reply; 18+ messages in thread
From: Biju Das @ 2025-02-05 12:42 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Andreas Färber, Manivannan Sadhasivam
Cc: Biju Das, netdev, linux-arm-kernel, linux-actions,
Geert Uytterhoeven, Biju Das
Use the helper of_get_available_child_by_name() to simplify
owl_emac_mdio_init().
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
previous v2->v2:
* Dropped using _free().
v1-> previous v2:
* Dropped duplicate mdio_node declaration.
---
drivers/net/ethernet/actions/owl-emac.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/actions/owl-emac.c b/drivers/net/ethernet/actions/owl-emac.c
index 115f48b3342c..0a08da799255 100644
--- a/drivers/net/ethernet/actions/owl-emac.c
+++ b/drivers/net/ethernet/actions/owl-emac.c
@@ -1325,15 +1325,10 @@ static int owl_emac_mdio_init(struct net_device *netdev)
struct device_node *mdio_node;
int ret;
- mdio_node = of_get_child_by_name(dev->of_node, "mdio");
+ mdio_node = of_get_available_child_by_name(dev->of_node, "mdio");
if (!mdio_node)
return -ENODEV;
- if (!of_device_is_available(mdio_node)) {
- ret = -ENODEV;
- goto err_put_node;
- }
-
priv->mii = devm_mdiobus_alloc(dev);
if (!priv->mii) {
ret = -ENOMEM;
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH net-next v2 6/7] net: ethernet: actions: Use of_get_available_child_by_name()
2025-02-05 12:42 ` [PATCH net-next v2 6/7] net: ethernet: actions: " Biju Das
@ 2025-02-07 9:53 ` Simon Horman
0 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2025-02-07 9:53 UTC (permalink / raw)
To: Biju Das
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Andreas Färber, Manivannan Sadhasivam, netdev,
linux-arm-kernel, linux-actions, Geert Uytterhoeven, Biju Das
On Wed, Feb 05, 2025 at 12:42:26PM +0000, Biju Das wrote:
> Use the helper of_get_available_child_by_name() to simplify
> owl_emac_mdio_init().
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> previous v2->v2:
> * Dropped using _free().
> v1-> previous v2:
> * Dropped duplicate mdio_node declaration.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH net-next v2 7/7] net: ibm: emac: Use of_get_available_child_by_name()
2025-02-05 12:42 [PATCH net-next v2 0/7] Add of_get_available_child_by_name() Biju Das
` (5 preceding siblings ...)
2025-02-05 12:42 ` [PATCH net-next v2 6/7] net: ethernet: actions: " Biju Das
@ 2025-02-05 12:42 ` Biju Das
2025-02-07 9:53 ` Simon Horman
2025-02-07 13:50 ` [PATCH net-next v2 0/7] Add of_get_available_child_by_name() patchwork-bot+netdevbpf
7 siblings, 1 reply; 18+ messages in thread
From: Biju Das @ 2025-02-05 12:42 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Biju Das, Rosen Penev, Shannon Nelson, Uwe Kleine-König,
Simon Horman, netdev, Geert Uytterhoeven, Biju Das
Use the helper of_get_available_child_by_name() to simplify
emac_dt_mdio_probe().
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v1->v2:
* Dropped using _free()
---
drivers/net/ethernet/ibm/emac/core.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index 25b8a3556004..417dfa18daae 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -2554,17 +2554,12 @@ static int emac_dt_mdio_probe(struct emac_instance *dev)
struct mii_bus *bus;
int res;
- mii_np = of_get_child_by_name(dev->ofdev->dev.of_node, "mdio");
+ mii_np = of_get_available_child_by_name(dev->ofdev->dev.of_node, "mdio");
if (!mii_np) {
dev_err(&dev->ofdev->dev, "no mdio definition found.");
return -ENODEV;
}
- if (!of_device_is_available(mii_np)) {
- res = -ENODEV;
- goto put_node;
- }
-
bus = devm_mdiobus_alloc(&dev->ofdev->dev);
if (!bus) {
res = -ENOMEM;
--
2.43.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH net-next v2 7/7] net: ibm: emac: Use of_get_available_child_by_name()
2025-02-05 12:42 ` [PATCH net-next v2 7/7] net: ibm: emac: " Biju Das
@ 2025-02-07 9:53 ` Simon Horman
0 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2025-02-07 9:53 UTC (permalink / raw)
To: Biju Das
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rosen Penev, Shannon Nelson, Uwe Kleine-König,
netdev, Geert Uytterhoeven, Biju Das
On Wed, Feb 05, 2025 at 12:42:27PM +0000, Biju Das wrote:
> Use the helper of_get_available_child_by_name() to simplify
> emac_dt_mdio_probe().
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v1->v2:
> * Dropped using _free()
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH net-next v2 0/7] Add of_get_available_child_by_name()
2025-02-05 12:42 [PATCH net-next v2 0/7] Add of_get_available_child_by_name() Biju Das
` (6 preceding siblings ...)
2025-02-05 12:42 ` [PATCH net-next v2 7/7] net: ibm: emac: " Biju Das
@ 2025-02-07 13:50 ` patchwork-bot+netdevbpf
7 siblings, 0 replies; 18+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-07 13:50 UTC (permalink / raw)
To: Biju Das
Cc: robh, saravanak, matthias.bgg, davem, edumazet, kuba, pabeni,
andrew, angelogioacchino.delregno, devicetree, linux-arm-kernel,
netdev, geert+renesas, prabhakar.mahadev-lad.rj, biju.das.au,
linux-renesas-soc
Hello:
This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Wed, 5 Feb 2025 12:42:20 +0000 you wrote:
> There are lot of net drivers using of_get_child_by_name() followed by
> of_device_is_available() to find the available child node by name for a
> given parent. Provide a helper for these users to simplify the code.
>
> v1->v2:
> * Make it as a series as per [1] to cover the dependency.
> * Added Rb tag from Rob for patch#1 and this patch can be merged through
> net as it is the main user.
> * Updated all the patches with patch suffix net-next
> * Dropped _free() usage.
>
> [...]
Here is the summary with links:
- [net-next,v2,1/7] of: base: Add of_get_available_child_by_name()
https://git.kernel.org/netdev/net-next/c/8d3bbe4355ad
- [net-next,v2,2/7] net: dsa: rzn1_a5psw: Use of_get_available_child_by_name()
https://git.kernel.org/netdev/net-next/c/46df19a8dfdf
- [net-next,v2,3/7] net: dsa: sja1105: Use of_get_available_child_by_name()
https://git.kernel.org/netdev/net-next/c/a76568865c15
- [net-next,v2,4/7] net: ethernet: mtk-star-emac: Use of_get_available_child_by_name()
https://git.kernel.org/netdev/net-next/c/876e52b2d3f4
- [net-next,v2,5/7] net: ethernet: mtk_eth_soc: Use of_get_available_child_by_name()
https://git.kernel.org/netdev/net-next/c/1364004b5b91
- [net-next,v2,6/7] net: ethernet: actions: Use of_get_available_child_by_name()
https://git.kernel.org/netdev/net-next/c/76c82eb04332
- [net-next,v2,7/7] net: ibm: emac: Use of_get_available_child_by_name()
https://git.kernel.org/netdev/net-next/c/0584a917a209
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 18+ messages in thread