diff options
author | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2024-02-25 14:27:13 +0000 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2024-03-03 11:43:02 +0000 |
commit | 05f91017c82acbf02b1190ad0fa2025eb52f8f0c (patch) | |
tree | 7a7f64c3b11cb25d3717b5877e7237e1029df43e | |
parent | 58bc4d84a711a9b4b4221fdf08d27352f6ec8423 (diff) | |
download | iio-05f91017c82acbf02b1190ad0fa2025eb52f8f0c.tar.gz |
of: unittest: Use for_each_child_of_node_scoped()
A simple example of the utility of this autocleanup approach to
handling of_node_put().
In this particular case some of the nodes needed for the test are
not available and the _available_ version would cause them to be
skipped resulting in a test failure.
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20240225142714.286440-4-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r-- | drivers/of/unittest.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index d7593bde2d02f..567904464a218 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -239,27 +239,22 @@ static void __init of_unittest_dynamic(void) static int __init of_unittest_check_node_linkage(struct device_node *np) { - struct device_node *child; int count = 0, rc; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { if (child->parent != np) { pr_err("Child node %pOFn links to wrong parent %pOFn\n", child, np); - rc = -EINVAL; - goto put_child; + return -EINVAL; } rc = of_unittest_check_node_linkage(child); if (rc < 0) - goto put_child; + return rc; count += rc; } return count + 1; -put_child: - of_node_put(child); - return rc; } static void __init of_unittest_check_tree_linkage(void) |