]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mmc: core: Simplify with scoped for each OF child loop
authorHans Zhang <18255117159@163.com>
Tue, 7 Apr 2026 01:40:33 +0000 (09:40 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Thu, 9 Apr 2026 15:51:21 +0000 (17:51 +0200)
Use scoped for-each loop when iterating over device nodes to simplify the
code, but also to ensure the device node reference is automatically
released when the loop scope ends.

Signed-off-by: Hans Zhang <18255117159@163.com>
Reviewed-by: Shawn Lin <shawn.lin@linux.dev>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/quirks.h

index 6f727b4a60a527f42ccbd386f3e5819b1069e386..940549d3b95d548bc46facc0490d421cf6ef77be 100644 (file)
@@ -225,14 +225,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;
 }