Linux MultiMedia Card development
 help / color / mirror / Atom feed
* [PATCH] mmc: Simplify with scoped for each OF child loop
@ 2026-04-07  1:40 Hans Zhang
  2026-04-08  2:43 ` Shawn Lin
  2026-04-09 15:52 ` Ulf Hansson
  0 siblings, 2 replies; 3+ messages in thread
From: Hans Zhang @ 2026-04-07  1:40 UTC (permalink / raw)
  To: ulf.hansson; +Cc: linux-mmc, linux-kernel, Hans Zhang

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

Signed-off-by: Hans Zhang <18255117159@163.com>
---
 drivers/mmc/core/quirks.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h
index c417ed34c057..93bf79d79cec 100644
--- a/drivers/mmc/core/quirks.h
+++ b/drivers/mmc/core/quirks.h
@@ -213,14 +213,9 @@ static const struct mmc_fixup __maybe_unused sdio_card_init_methods[] = {
 static inline bool mmc_fixup_of_compatible_match(struct mmc_card *card,
 						 const char *compatible)
 {
-	struct device_node *np;
-
-	for_each_child_of_node(mmc_dev(card->host)->of_node, np) {
-		if (of_device_is_compatible(np, compatible)) {
-			of_node_put(np);
+	for_each_child_of_node_scoped(mmc_dev(card->host)->of_node, np)
+		if (of_device_is_compatible(np, compatible))
 			return true;
-		}
-	}
 
 	return false;
 }

base-commit: 591cd656a1bf5ea94a222af5ef2ee76df029c1d2
prerequisite-patch-id: fcb16f319f35ddb88e1668bbe7a8811d88235672
-- 
2.34.1


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

* Re: [PATCH] mmc: Simplify with scoped for each OF child loop
  2026-04-07  1:40 [PATCH] mmc: Simplify with scoped for each OF child loop Hans Zhang
@ 2026-04-08  2:43 ` Shawn Lin
  2026-04-09 15:52 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Shawn Lin @ 2026-04-08  2:43 UTC (permalink / raw)
  To: Hans Zhang; +Cc: shawn.lin, linux-mmc, linux-kernel, ulf.hansson

在 2026/04/07 星期二 9:40, Hans Zhang 写道:
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 

I think the key point to use scoped version is to ensure the
device node reference is automatically released when the loop scope
ends. It'd be better if you could highlight this in the commit msg.

Reviewed-by: Shawn Lin <shawn.lin@linux.dev>

> Signed-off-by: Hans Zhang <18255117159@163.com>
> ---
>   drivers/mmc/core/quirks.h | 9 ++-------
>   1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h
> index c417ed34c057..93bf79d79cec 100644
> --- a/drivers/mmc/core/quirks.h
> +++ b/drivers/mmc/core/quirks.h
> @@ -213,14 +213,9 @@ static const struct mmc_fixup __maybe_unused sdio_card_init_methods[] = {
>   static inline bool mmc_fixup_of_compatible_match(struct mmc_card *card,
>   						 const char *compatible)
>   {
> -	struct device_node *np;
> -
> -	for_each_child_of_node(mmc_dev(card->host)->of_node, np) {
> -		if (of_device_is_compatible(np, compatible)) {
> -			of_node_put(np);
> +	for_each_child_of_node_scoped(mmc_dev(card->host)->of_node, np)
> +		if (of_device_is_compatible(np, compatible))
>   			return true;
> -		}
> -	}
>   
>   	return false;
>   }
> 
> base-commit: 591cd656a1bf5ea94a222af5ef2ee76df029c1d2
> prerequisite-patch-id: fcb16f319f35ddb88e1668bbe7a8811d88235672

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

* Re: [PATCH] mmc: Simplify with scoped for each OF child loop
  2026-04-07  1:40 [PATCH] mmc: Simplify with scoped for each OF child loop Hans Zhang
  2026-04-08  2:43 ` Shawn Lin
@ 2026-04-09 15:52 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2026-04-09 15:52 UTC (permalink / raw)
  To: Hans Zhang; +Cc: linux-mmc, linux-kernel

On Tue, 7 Apr 2026 at 03:40, Hans Zhang <18255117159@163.com> wrote:
>
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
>
> Signed-off-by: Hans Zhang <18255117159@163.com>

Applied for next and by amending the commit message according to
Shawn's suggestion, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/core/quirks.h | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h
> index c417ed34c057..93bf79d79cec 100644
> --- a/drivers/mmc/core/quirks.h
> +++ b/drivers/mmc/core/quirks.h
> @@ -213,14 +213,9 @@ static const struct mmc_fixup __maybe_unused sdio_card_init_methods[] = {
>  static inline bool mmc_fixup_of_compatible_match(struct mmc_card *card,
>                                                  const char *compatible)
>  {
> -       struct device_node *np;
> -
> -       for_each_child_of_node(mmc_dev(card->host)->of_node, np) {
> -               if (of_device_is_compatible(np, compatible)) {
> -                       of_node_put(np);
> +       for_each_child_of_node_scoped(mmc_dev(card->host)->of_node, np)
> +               if (of_device_is_compatible(np, compatible))
>                         return true;
> -               }
> -       }
>
>         return false;
>  }
>
> base-commit: 591cd656a1bf5ea94a222af5ef2ee76df029c1d2
> prerequisite-patch-id: fcb16f319f35ddb88e1668bbe7a8811d88235672
> --
> 2.34.1
>

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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07  1:40 [PATCH] mmc: Simplify with scoped for each OF child loop Hans Zhang
2026-04-08  2:43 ` Shawn Lin
2026-04-09 15:52 ` Ulf Hansson

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