[PATCH v2 3/3] pinctrl: th1520: Convert dt child node loop to scoped iterator
From: Drew Fustini
Date: Sun Oct 06 2024 - 13:43:49 EST
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@xxxxxxxxxx>
Signed-off-by: Drew Fustini <dfustini@xxxxxxxxxxxxxxx>
---
drivers/pinctrl/pinctrl-th1520.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-th1520.c b/drivers/pinctrl/pinctrl-th1520.c
index 7ed3f82b9339..286c6b2b0b13 100644
--- a/drivers/pinctrl/pinctrl-th1520.c
+++ b/drivers/pinctrl/pinctrl-th1520.c
@@ -425,11 +425,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 +444,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 +457,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 +523,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 +534,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;
}
--
2.34.1