diff mbox series

[7/8] iio: adc: ad7292: Use for_each_available_child_of_node_scoped()

Message ID 20240211174237.182947-8-jic23@kernel.org
State New
Headers show
Series of: automate of_node_put() - new approach to loops. | expand

Commit Message

Jonathan Cameron Feb. 11, 2024, 5:42 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Avoids the need for manual cleanup of_node_put() in early exits from
the loop.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/adc/ad7292.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/iio/adc/ad7292.c b/drivers/iio/adc/ad7292.c
index cccacec5db6d..a9354bd1ce54 100644
--- a/drivers/iio/adc/ad7292.c
+++ b/drivers/iio/adc/ad7292.c
@@ -260,7 +260,6 @@  static int ad7292_probe(struct spi_device *spi)
 {
 	struct ad7292_state *st;
 	struct iio_dev *indio_dev;
-	struct device_node *child;
 	bool diff_channels = false;
 	int ret;
 
@@ -305,12 +304,10 @@  static int ad7292_probe(struct spi_device *spi)
 	indio_dev->modes = INDIO_DIRECT_MODE;
 	indio_dev->info = &ad7292_info;
 
-	for_each_available_child_of_node(spi->dev.of_node, child) {
+	for_each_available_child_of_node_scoped(spi->dev.of_node, child) {
 		diff_channels = of_property_read_bool(child, "diff-channels");
-		if (diff_channels) {
-			of_node_put(child);
+		if (diff_channels)
 			break;
-		}
 	}
 
 	if (diff_channels) {