mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 11:03:43 +02:00
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>
This commit is contained in:
parent
f3a3d006a4
commit
573cba2827
|
|
@ -417,7 +417,6 @@ static int th1520_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
|
|||
unsigned int *num_maps)
|
||||
{
|
||||
struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev);
|
||||
struct device_node *child;
|
||||
struct pinctrl_map *map;
|
||||
unsigned long *configs;
|
||||
unsigned int nconfigs;
|
||||
|
|
@ -425,11 +424,10 @@ static int th1520_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
|
|||
int ret;
|
||||
|
||||
nmaps = 0;
|
||||
for_each_available_child_of_node(np, child) {
|
||||
for_each_available_child_of_node_scoped(np, child) {
|
||||
int npins = of_property_count_strings(child, "pins");
|
||||
|
||||
if (npins <= 0) {
|
||||
of_node_put(child);
|
||||
dev_err(thp->pctl->dev, "no pins selected for %pOFn.%pOFn\n",
|
||||
np, child);
|
||||
return -EINVAL;
|
||||
|
|
@ -445,7 +443,7 @@ static int th1520_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
|
|||
|
||||
nmaps = 0;
|
||||
guard(mutex)(&thp->mutex);
|
||||
for_each_available_child_of_node(np, child) {
|
||||
for_each_available_child_of_node_scoped(np, child) {
|
||||
unsigned int rollback = nmaps;
|
||||
enum th1520_muxtype muxtype;
|
||||
struct property *prop;
|
||||
|
|
@ -458,7 +456,7 @@ static int th1520_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
|
|||
if (ret) {
|
||||
dev_err(thp->pctl->dev, "%pOFn.%pOFn: error parsing pin config\n",
|
||||
np, child);
|
||||
goto put_child;
|
||||
goto free_map;
|
||||
}
|
||||
|
||||
if (!of_property_read_string(child, "function", &funcname)) {
|
||||
|
|
@ -524,7 +522,7 @@ static int th1520_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
|
|||
npins, (void *)muxtype);
|
||||
if (ret < 0) {
|
||||
dev_err(thp->pctl->dev, "error adding function %s\n", funcname);
|
||||
goto put_child;
|
||||
goto free_map;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -535,8 +533,7 @@ static int th1520_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
|
|||
|
||||
free_configs:
|
||||
kfree(configs);
|
||||
put_child:
|
||||
of_node_put(child);
|
||||
free_map:
|
||||
th1520_pinctrl_dt_free_map(pctldev, map, nmaps);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user