Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: th1520: Convert dt child node loop to scoped iterator

Convert th1520_pinctrl_dt_node_to_map() to use a scoped iterator with
for_each_available_child_of_node_scoped(). As a result, there is no need
to call of_node_put() anymore. The put_child label has been renamed to
free_map which is now a more accurate description.

Suggested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Drew Fustini <dfustini@tenstorrent.com>
Link: https://lore.kernel.org/20241008-th1520-pinctrl-fixes-v3-3-5b60db446a49@tenstorrent.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Drew Fustini and committed by
Linus Walleij
573cba28 f3a3d006

+5 -8
+5 -8
drivers/pinctrl/pinctrl-th1520.c
··· 417 417 unsigned int *num_maps) 418 418 { 419 419 struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev); 420 - struct device_node *child; 421 420 struct pinctrl_map *map; 422 421 unsigned long *configs; 423 422 unsigned int nconfigs; ··· 424 425 int ret; 425 426 426 427 nmaps = 0; 427 - for_each_available_child_of_node(np, child) { 428 + for_each_available_child_of_node_scoped(np, child) { 428 429 int npins = of_property_count_strings(child, "pins"); 429 430 430 431 if (npins <= 0) { 431 - of_node_put(child); 432 432 dev_err(thp->pctl->dev, "no pins selected for %pOFn.%pOFn\n", 433 433 np, child); 434 434 return -EINVAL; ··· 443 445 444 446 nmaps = 0; 445 447 guard(mutex)(&thp->mutex); 446 - for_each_available_child_of_node(np, child) { 448 + for_each_available_child_of_node_scoped(np, child) { 447 449 unsigned int rollback = nmaps; 448 450 enum th1520_muxtype muxtype; 449 451 struct property *prop; ··· 456 458 if (ret) { 457 459 dev_err(thp->pctl->dev, "%pOFn.%pOFn: error parsing pin config\n", 458 460 np, child); 459 - goto put_child; 461 + goto free_map; 460 462 } 461 463 462 464 if (!of_property_read_string(child, "function", &funcname)) { ··· 522 524 npins, (void *)muxtype); 523 525 if (ret < 0) { 524 526 dev_err(thp->pctl->dev, "error adding function %s\n", funcname); 525 - goto put_child; 527 + goto free_map; 526 528 } 527 529 } 528 530 } ··· 533 535 534 536 free_configs: 535 537 kfree(configs); 536 - put_child: 537 - of_node_put(child); 538 + free_map: 538 539 th1520_pinctrl_dt_free_map(pctldev, map, nmaps); 539 540 return ret; 540 541 }