Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: Shawn Lin <shawn.lin@linux.dev>
To: Hans Zhang <18255117159@163.com>
Cc: shawn.lin@linux.dev, linux-mmc@vger.kernel.org,
	linux-kernel@vger.kernel.org, ulf.hansson@linaro.org
Subject: Re: [PATCH] mmc: Simplify with scoped for each OF child loop
Date: Wed, 8 Apr 2026 10:43:58 +0800	[thread overview]
Message-ID: <3c81c802-ecdc-85e5-fcdf-aecf295f90b7@linux.dev> (raw)
In-Reply-To: <20260407014033.1305033-1-18255117159@163.com>

在 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

  reply	other threads:[~2026-04-08  2:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07  1:40 [PATCH] mmc: Simplify with scoped for each OF child loop Hans Zhang
2026-04-08  2:43 ` Shawn Lin [this message]
2026-04-09 15:52 ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3c81c802-ecdc-85e5-fcdf-aecf295f90b7@linux.dev \
    --to=shawn.lin@linux.dev \
    --cc=18255117159@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox