Skip to content

Commit 69b8600

Browse files
Zhang Zekunrobherring
authored andcommitted
of: property: Do some clean up with use of __free()
__free() provides a scoped of_node_put() functionality to put the device_node automatically, and we don't need to call of_node_put() directly. Let's simplify the code a bit with the use of __free(). Signed-off-by: Zhang Zekun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring (Arm) <[email protected]>
1 parent 0a543ac commit 69b8600

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

drivers/of/property.c

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -773,16 +773,11 @@ EXPORT_SYMBOL(of_graph_get_port_parent);
773773
struct device_node *of_graph_get_remote_port_parent(
774774
const struct device_node *node)
775775
{
776-
struct device_node *np, *pp;
777-
778776
/* Get remote endpoint node. */
779-
np = of_graph_get_remote_endpoint(node);
780-
781-
pp = of_graph_get_port_parent(np);
777+
struct device_node *np __free(device_node) =
778+
of_graph_get_remote_endpoint(node);
782779

783-
of_node_put(np);
784-
785-
return pp;
780+
return of_graph_get_port_parent(np);
786781
}
787782
EXPORT_SYMBOL(of_graph_get_remote_port_parent);
788783

@@ -1064,19 +1059,15 @@ static void of_link_to_phandle(struct device_node *con_np,
10641059
struct device_node *sup_np,
10651060
u8 flags)
10661061
{
1067-
struct device_node *tmp_np = of_node_get(sup_np);
1062+
struct device_node *tmp_np __free(device_node) = of_node_get(sup_np);
10681063

10691064
/* Check that sup_np and its ancestors are available. */
10701065
while (tmp_np) {
1071-
if (of_fwnode_handle(tmp_np)->dev) {
1072-
of_node_put(tmp_np);
1066+
if (of_fwnode_handle(tmp_np)->dev)
10731067
break;
1074-
}
10751068

1076-
if (!of_device_is_available(tmp_np)) {
1077-
of_node_put(tmp_np);
1069+
if (!of_device_is_available(tmp_np))
10781070
return;
1079-
}
10801071

10811072
tmp_np = of_get_next_parent(tmp_np);
10821073
}
@@ -1440,16 +1431,13 @@ static int of_link_property(struct device_node *con_np, const char *prop_name)
14401431
}
14411432

14421433
while ((phandle = s->parse_prop(con_np, prop_name, i))) {
1443-
struct device_node *con_dev_np;
1434+
struct device_node *con_dev_np __free(device_node) =
1435+
s->get_con_dev ? s->get_con_dev(con_np) : of_node_get(con_np);
14441436

1445-
con_dev_np = s->get_con_dev
1446-
? s->get_con_dev(con_np)
1447-
: of_node_get(con_np);
14481437
matched = true;
14491438
i++;
14501439
of_link_to_phandle(con_dev_np, phandle, s->fwlink_flags);
14511440
of_node_put(phandle);
1452-
of_node_put(con_dev_np);
14531441
}
14541442
s++;
14551443
}

0 commit comments

Comments
 (0)