Re: [PATCH] mmc: Simplify with scoped for each OF child loop
From: Shawn Lin
Date: Tue Apr 07 2026 - 22:44:25 EST
在 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@xxxxxxxxx>
Signed-off-by: Hans Zhang <18255117159@xxxxxxx>
---
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