All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] net: ftgmac100: Hold reference returned by  of_get_child_by_name()
@ 2022-07-12  6:14 Liang He
  2022-07-13 13:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Liang He @ 2022-07-12  6:14 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, netdev, windhl

In ftgmac100_probe(), we should hold the refernece returned by
of_get_child_by_name() and use it to call of_node_put() for
reference balance.

Fixes: 39bfab8844a0 ("net: ftgmac100: Add support for DT phy-handle property")
Signed-off-by: Liang He <windhl@126.com>
---
 changelog:

 v3: make the helper return 'bool' and remove 'inline'
 v2: (1) use a helper advised by Jakub (2) add fix tag
 v1: directly hold the reference returned by of_get_xx

 v1 link: https://lore.kernel.org/all/20220704151819.279513-1-windhl@126.com/
 v2 link: https://lore.kernel.org/all/20220710020728.317086-1-windhl@126.com/

 drivers/net/ethernet/faraday/ftgmac100.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 5231818943c6..c03663785a8d 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1764,6 +1764,19 @@ static int ftgmac100_setup_clk(struct ftgmac100 *priv)
 	return rc;
 }
 
+static bool ftgmac100_has_child_node(struct device_node *np, const char *name)
+{
+	struct device_node *child_np = of_get_child_by_name(np, name);
+	bool ret = false;
+
+	if (child_np) {
+		ret = true;
+		of_node_put(child_np);
+	}
+
+	return ret;
+}
+
 static int ftgmac100_probe(struct platform_device *pdev)
 {
 	struct resource *res;
@@ -1883,7 +1896,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
 
 		/* Display what we found */
 		phy_attached_info(phy);
-	} else if (np && !of_get_child_by_name(np, "mdio")) {
+	} else if (np && !ftgmac100_has_child_node(np, "mdio")) {
 		/* Support legacy ASPEED devicetree descriptions that decribe a
 		 * MAC with an embedded MDIO controller but have no "mdio"
 		 * child node. Automatically scan the MDIO bus for available
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] net: ftgmac100: Hold reference returned by of_get_child_by_name()
  2022-07-12  6:14 [PATCH v3] net: ftgmac100: Hold reference returned by of_get_child_by_name() Liang He
@ 2022-07-13 13:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-13 13:20 UTC (permalink / raw)
  To: Liang He; +Cc: davem, edumazet, kuba, pabeni, netdev

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Tue, 12 Jul 2022 14:14:17 +0800 you wrote:
> In ftgmac100_probe(), we should hold the refernece returned by
> of_get_child_by_name() and use it to call of_node_put() for
> reference balance.
> 
> Fixes: 39bfab8844a0 ("net: ftgmac100: Add support for DT phy-handle property")
> Signed-off-by: Liang He <windhl@126.com>
> 
> [...]

Here is the summary with links:
  - [v3] net: ftgmac100: Hold reference returned by of_get_child_by_name()
    https://git.kernel.org/netdev/net/c/49b9f431ff0d

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] 2+ messages in thread

end of thread, other threads:[~2022-07-13 13:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-12  6:14 [PATCH v3] net: ftgmac100: Hold reference returned by of_get_child_by_name() Liang He
2022-07-13 13:20 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.