Skip to content

Commit 8c5dc2a

Browse files
MrVanlinusw
authored andcommitted
pinctrl: spear: Use scope based of_node_put() cleanups
Use scope based of_node_put() cleanup to simplify code. Signed-off-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 794e5dc commit 8c5dc2a

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

drivers/pinctrl/spear/pinctrl-spear.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,24 +151,19 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
151151
unsigned *num_maps)
152152
{
153153
struct spear_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
154-
struct device_node *np;
155154
struct property *prop;
156155
const char *function, *group;
157156
int ret, index = 0, count = 0;
158157

159158
/* calculate number of maps required */
160-
for_each_child_of_node(np_config, np) {
159+
for_each_child_of_node_scoped(np_config, np) {
161160
ret = of_property_read_string(np, "st,function", &function);
162-
if (ret < 0) {
163-
of_node_put(np);
161+
if (ret < 0)
164162
return ret;
165-
}
166163

167164
ret = of_property_count_strings(np, "st,pins");
168-
if (ret < 0) {
169-
of_node_put(np);
165+
if (ret < 0)
170166
return ret;
171-
}
172167

173168
count += ret;
174169
}
@@ -182,7 +177,7 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
182177
if (!*map)
183178
return -ENOMEM;
184179

185-
for_each_child_of_node(np_config, np) {
180+
for_each_child_of_node_scoped(np_config, np) {
186181
of_property_read_string(np, "st,function", &function);
187182
of_property_for_each_string(np, "st,pins", prop, group) {
188183
(*map)[index].type = PIN_MAP_TYPE_MUX_GROUP;

0 commit comments

Comments
 (0)