]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
device property: Introduce device_for_each_child_node_scoped()
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 17 Feb 2024 16:42:38 +0000 (16:42 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Sep 2024 17:24:03 +0000 (19:24 +0200)
commitbfc8dab8c73a6cf366b6e7c15efb4f483d8cefe2
treeb1f8d8ea471df00860bd5ee838e630d1ce67b95f
parentfce8373d31537524a2b590276ad4c5c73c20943a
device property: Introduce device_for_each_child_node_scoped()

[ Upstream commit 365130fd47af6d4317aa16a407874b699ab8d8cb ]

Similar to recently propose for_each_child_of_node_scoped() this
new version of the loop macro instantiates a new local
struct fwnode_handle * that uses the __free(fwnode_handle) auto
cleanup handling so that if a reference to a node is held on early
exit from the loop the reference will be released. If the loop
runs to completion, the child pointer will be NULL and no action will
be taken.

The reason this is useful is that it removes the need for
fwnode_handle_put() on early loop exits.  If there is a need
to retain the reference, then return_ptr(child) or no_free_ptr(child)
may be used to safely disable the auto cleanup.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Link: https://lore.kernel.org/r/20240217164249.921878-5-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Stable-dep-of: 61cbfb5368dd ("iio: adc: ad7124: fix DT configuration parsing")
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/property.h