Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <ruanjinjie@huawei.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20240830073824.3539690-1-ruanjinjie@huawei.com

authored by

Jinjie Ruan and committed by
Thierry Reding
78184f6e 780351a5

+3 -8
+3 -8
drivers/gpu/host1x/bus.c
··· 41 41 struct device_node *np) 42 42 { 43 43 struct host1x_subdev *subdev; 44 - struct device_node *child; 45 44 int err; 46 45 47 46 subdev = kzalloc(sizeof(*subdev), GFP_KERNEL); ··· 55 56 mutex_unlock(&device->subdevs_lock); 56 57 57 58 /* recursively add children */ 58 - for_each_child_of_node(np, child) { 59 + for_each_child_of_node_scoped(np, child) { 59 60 if (of_match_node(driver->subdevs, child) && 60 61 of_device_is_available(child)) { 61 62 err = host1x_subdev_add(device, driver, child); 62 63 if (err < 0) { 63 64 /* XXX cleanup? */ 64 - of_node_put(child); 65 65 return err; 66 66 } 67 67 } ··· 88 90 static int host1x_device_parse_dt(struct host1x_device *device, 89 91 struct host1x_driver *driver) 90 92 { 91 - struct device_node *np; 92 93 int err; 93 94 94 - for_each_child_of_node(device->dev.parent->of_node, np) { 95 + for_each_child_of_node_scoped(device->dev.parent->of_node, np) { 95 96 if (of_match_node(driver->subdevs, np) && 96 97 of_device_is_available(np)) { 97 98 err = host1x_subdev_add(device, driver, np); 98 - if (err < 0) { 99 - of_node_put(np); 99 + if (err < 0) 100 100 return err; 101 - } 102 101 } 103 102 } 104 103