Skip to content

Commit 78184f6

Browse files
Jinjie Ruanthierryreding
authored andcommitted
gpu: host1x: Use for_each_available_child_of_node_scoped()
Avoids the need for manual cleanup of_node_put() in early exits from the loop. Signed-off-by: Jinjie Ruan <[email protected]> Signed-off-by: Thierry Reding <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 780351a commit 78184f6

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

drivers/gpu/host1x/bus.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ static int host1x_subdev_add(struct host1x_device *device,
4141
struct device_node *np)
4242
{
4343
struct host1x_subdev *subdev;
44-
struct device_node *child;
4544
int err;
4645

4746
subdev = kzalloc(sizeof(*subdev), GFP_KERNEL);
@@ -56,13 +55,12 @@ static int host1x_subdev_add(struct host1x_device *device,
5655
mutex_unlock(&device->subdevs_lock);
5756

5857
/* recursively add children */
59-
for_each_child_of_node(np, child) {
58+
for_each_child_of_node_scoped(np, child) {
6059
if (of_match_node(driver->subdevs, child) &&
6160
of_device_is_available(child)) {
6261
err = host1x_subdev_add(device, driver, child);
6362
if (err < 0) {
6463
/* XXX cleanup? */
65-
of_node_put(child);
6664
return err;
6765
}
6866
}
@@ -90,17 +88,14 @@ static void host1x_subdev_del(struct host1x_subdev *subdev)
9088
static int host1x_device_parse_dt(struct host1x_device *device,
9189
struct host1x_driver *driver)
9290
{
93-
struct device_node *np;
9491
int err;
9592

96-
for_each_child_of_node(device->dev.parent->of_node, np) {
93+
for_each_child_of_node_scoped(device->dev.parent->of_node, np) {
9794
if (of_match_node(driver->subdevs, np) &&
9895
of_device_is_available(np)) {
9996
err = host1x_subdev_add(device, driver, np);
100-
if (err < 0) {
101-
of_node_put(np);
97+
if (err < 0)
10298
return err;
103-
}
10499
}
105100
}
106101

0 commit comments

Comments
 (0)