Skip to content

Commit 7c2aabb

Browse files
MrVanlinusw
authored andcommitted
pinctrl: at91: 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 56c42f6 commit 7c2aabb

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

drivers/pinctrl/pinctrl-at91-pio4.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,6 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
632632
struct pinctrl_map **map,
633633
unsigned int *num_maps)
634634
{
635-
struct device_node *np;
636635
unsigned int reserved_maps;
637636
int ret;
638637

@@ -648,13 +647,11 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
648647
ret = atmel_pctl_dt_subnode_to_map(pctldev, np_config, map,
649648
&reserved_maps, num_maps);
650649
if (ret) {
651-
for_each_child_of_node(np_config, np) {
650+
for_each_child_of_node_scoped(np_config, np) {
652651
ret = atmel_pctl_dt_subnode_to_map(pctldev, np, map,
653652
&reserved_maps, num_maps);
654-
if (ret < 0) {
655-
of_node_put(np);
653+
if (ret < 0)
656654
break;
657-
}
658655
}
659656
}
660657

drivers/pinctrl/pinctrl-at91.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,6 @@ static int at91_pinctrl_parse_groups(struct device_node *np,
12441244
static int at91_pinctrl_parse_functions(struct device_node *np,
12451245
struct at91_pinctrl *info, u32 index)
12461246
{
1247-
struct device_node *child;
12481247
struct at91_pmx_func *func;
12491248
struct at91_pin_group *grp;
12501249
int ret;
@@ -1267,14 +1266,12 @@ static int at91_pinctrl_parse_functions(struct device_node *np,
12671266
if (!func->groups)
12681267
return -ENOMEM;
12691268

1270-
for_each_child_of_node(np, child) {
1269+
for_each_child_of_node_scoped(np, child) {
12711270
func->groups[i] = child->name;
12721271
grp = &info->groups[grp_index++];
12731272
ret = at91_pinctrl_parse_groups(child, grp, info, i++);
1274-
if (ret) {
1275-
of_node_put(child);
1273+
if (ret)
12761274
return ret;
1277-
}
12781275
}
12791276

12801277
return 0;
@@ -1296,7 +1293,6 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
12961293
int i, j, ngpio_chips_enabled = 0;
12971294
uint32_t *tmp;
12981295
struct device_node *np = dev->of_node;
1299-
struct device_node *child;
13001296

13011297
if (!np)
13021298
return -ENODEV;
@@ -1349,14 +1345,12 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
13491345

13501346
i = 0;
13511347

1352-
for_each_child_of_node(np, child) {
1348+
for_each_child_of_node_scoped(np, child) {
13531349
if (of_device_is_compatible(child, gpio_compat))
13541350
continue;
13551351
ret = at91_pinctrl_parse_functions(child, info, i++);
1356-
if (ret) {
1357-
of_node_put(child);
1352+
if (ret)
13581353
return dev_err_probe(dev, ret, "failed to parse function\n");
1359-
}
13601354
}
13611355

13621356
return 0;

0 commit comments

Comments
 (0)