Re: [PATCH] mmc: Simplify with scoped for each OF child loop
From: Ulf Hansson
Date: Thu Apr 09 2026 - 12:01:55 EST
On Tue, 7 Apr 2026 at 03:40, Hans Zhang <18255117159@xxxxxxx> wrote:
>
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
>
> Signed-off-by: Hans Zhang <18255117159@xxxxxxx>
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
>