Skip to content

Commit 873cc55

Browse files
Hans ZhangUlf Hansson
authored andcommitted
mmc: core: Simplify with scoped for each OF child loop
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>
1 parent 5fa0e32 commit 873cc55

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

drivers/mmc/core/quirks.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,9 @@ static const struct mmc_fixup __maybe_unused sdio_card_init_methods[] = {
225225
static inline bool mmc_fixup_of_compatible_match(struct mmc_card *card,
226226
const char *compatible)
227227
{
228-
struct device_node *np;
229-
230-
for_each_child_of_node(mmc_dev(card->host)->of_node, np) {
231-
if (of_device_is_compatible(np, compatible)) {
232-
of_node_put(np);
228+
for_each_child_of_node_scoped(mmc_dev(card->host)->of_node, np)
229+
if (of_device_is_compatible(np, compatible))
233230
return true;
234-
}
235-
}
236231

237232
return false;
238233
}

0 commit comments

Comments
 (0)