mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] mfd: core: Simplify with scoped for each OF child loop
@ 2025-12-24 12:44 Krzysztof Kozlowski
  2025-12-24 12:44 ` [PATCH 2/2] mfd: core: Simplify storing device_node in mfd_match_of_node_to_dev() Krzysztof Kozlowski
  2026-01-09 15:33 ` (subset) [PATCH 1/2] mfd: core: Simplify with scoped for each OF child loop Lee Jones
  0 siblings, 2 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2025-12-24 12:44 UTC (permalink / raw)
  To: Lee Jones, linux-kernel; +Cc: Krzysztof Kozlowski

Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/mfd/mfd-core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 7d14a1e7631e..941e064351e7 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -144,7 +144,6 @@ static int mfd_add_device(struct device *parent, int id,
 {
 	struct resource *res;
 	struct platform_device *pdev;
-	struct device_node *np = NULL;
 	struct mfd_of_node_entry *of_entry, *tmp;
 	bool disabled = false;
 	int ret = -ENOMEM;
@@ -182,7 +181,7 @@ static int mfd_add_device(struct device *parent, int id,
 		goto fail_res;
 
 	if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) {
-		for_each_child_of_node(parent->of_node, np) {
+		for_each_child_of_node_scoped(parent->of_node, np) {
 			if (of_device_is_compatible(np, cell->of_compatible)) {
 				/* Skip 'disabled' devices */
 				if (!of_device_is_available(np)) {
@@ -193,7 +192,6 @@ static int mfd_add_device(struct device *parent, int id,
 				ret = mfd_match_of_node_to_dev(pdev, np, cell);
 				if (ret == -EAGAIN)
 					continue;
-				of_node_put(np);
 				if (ret)
 					goto fail_alias;
 
-- 
2.51.0


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

* [PATCH 2/2] mfd: core: Simplify storing device_node in mfd_match_of_node_to_dev()
  2025-12-24 12:44 [PATCH 1/2] mfd: core: Simplify with scoped for each OF child loop Krzysztof Kozlowski
@ 2025-12-24 12:44 ` Krzysztof Kozlowski
  2026-01-09 15:35   ` (subset) " Lee Jones
  2026-01-09 15:33 ` (subset) [PATCH 1/2] mfd: core: Simplify with scoped for each OF child loop Lee Jones
  1 sibling, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2025-12-24 12:44 UTC (permalink / raw)
  To: Lee Jones, linux-kernel; +Cc: Krzysztof Kozlowski

of_node_get() returns the same pointer it received and canonical form of
storing device_node is to use of_node_get() in the assignment.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/mfd/mfd-core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 941e064351e7..b51544538fa9 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -128,10 +128,9 @@ static int mfd_match_of_node_to_dev(struct platform_device *pdev,
 		return -ENOMEM;
 
 	of_entry->dev = &pdev->dev;
-	of_entry->np = np;
+	of_entry->np = of_node_get(np);
 	list_add_tail(&of_entry->list, &mfd_of_node_list);
 
-	of_node_get(np);
 	device_set_node(&pdev->dev, of_fwnode_handle(np));
 #endif
 	return 0;
-- 
2.51.0


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

* Re: (subset) [PATCH 1/2] mfd: core: Simplify with scoped for each OF child loop
  2025-12-24 12:44 [PATCH 1/2] mfd: core: Simplify with scoped for each OF child loop Krzysztof Kozlowski
  2025-12-24 12:44 ` [PATCH 2/2] mfd: core: Simplify storing device_node in mfd_match_of_node_to_dev() Krzysztof Kozlowski
@ 2026-01-09 15:33 ` Lee Jones
  1 sibling, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-01-09 15:33 UTC (permalink / raw)
  To: Lee Jones, linux-kernel, Krzysztof Kozlowski

On Wed, 24 Dec 2025 13:44:57 +0100, Krzysztof Kozlowski wrote:
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 
> 

Applied, thanks!

[1/2] mfd: core: Simplify with scoped for each OF child loop
      commit: e52ed15b1e3511c8da9c097624a07511e5235e01

--
Lee Jones [李琼斯]


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

* Re: (subset) [PATCH 2/2] mfd: core: Simplify storing device_node in mfd_match_of_node_to_dev()
  2025-12-24 12:44 ` [PATCH 2/2] mfd: core: Simplify storing device_node in mfd_match_of_node_to_dev() Krzysztof Kozlowski
@ 2026-01-09 15:35   ` Lee Jones
  0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-01-09 15:35 UTC (permalink / raw)
  To: Lee Jones, linux-kernel, Krzysztof Kozlowski

On Wed, 24 Dec 2025 13:44:58 +0100, Krzysztof Kozlowski wrote:
> of_node_get() returns the same pointer it received and canonical form of
> storing device_node is to use of_node_get() in the assignment.
> 
> 

Applied, thanks!

[2/2] mfd: core: Simplify storing device_node in mfd_match_of_node_to_dev()
      commit: f93038c79c6e1252fbe2a3f868e4c7b160ef80f0

--
Lee Jones [李琼斯]


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

end of thread, other threads:[~2026-01-09 15:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-24 12:44 [PATCH 1/2] mfd: core: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2025-12-24 12:44 ` [PATCH 2/2] mfd: core: Simplify storing device_node in mfd_match_of_node_to_dev() Krzysztof Kozlowski
2026-01-09 15:35   ` (subset) " Lee Jones
2026-01-09 15:33 ` (subset) [PATCH 1/2] mfd: core: Simplify with scoped for each OF child loop Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®