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>
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;
}