diff mbox series

[4/8] iio: adc: ad7292: Switch from of specific to fwnode property handling

Message ID 20240218172731.1023367-5-jic23@kernel.org (mailing list archive)
State Accepted
Headers show
Series IIO: Convert DT specific handling over to fwnode | expand

Commit Message

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

This reduces the wrong of device tree only IIO drivers that might
be copied by converting over this simple case.
Makes use of the new _scoped() handling to automatically release
the fwnode_handle on early exit from the loop.

Cc: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/adc/ad7292.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Nuno Sá Feb. 19, 2024, 9:26 a.m. UTC | #1
On Sun, 2024-02-18 at 17:27 +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> This reduces the wrong of device tree only IIO drivers that might
> be copied by converting over this simple case.
> Makes use of the new _scoped() handling to automatically release
> the fwnode_handle on early exit from the loop.
> 
> Cc: Nuno Sá <nuno.sa@analog.com>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---

Reviewed-by: Nuno Sa <nuno.sa@analog.com>

>  drivers/iio/adc/ad7292.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7292.c b/drivers/iio/adc/ad7292.c
> index cccacec5db6d..6aadd14f459d 100644
> --- a/drivers/iio/adc/ad7292.c
> +++ b/drivers/iio/adc/ad7292.c
> @@ -8,7 +8,8 @@
>  #include <linux/bitfield.h>
>  #include <linux/device.h>
>  #include <linux/module.h>
> -#include <linux/of.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/property.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/spi/spi.h>
>  
> @@ -260,7 +261,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 +305,11 @@ 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) {
> -		diff_channels = of_property_read_bool(child, "diff-
> channels");
> -		if (diff_channels) {
> -			of_node_put(child);
> +	device_for_each_child_node_scoped(&spi->dev, child) {
> +		diff_channels = fwnode_property_read_bool(child,
> +							  "diff-channels");
> +		if (diff_channels)
>  			break;
> -		}
>  	}
>  
>  	if (diff_channels) {
diff mbox series

Patch

diff --git a/drivers/iio/adc/ad7292.c b/drivers/iio/adc/ad7292.c
index cccacec5db6d..6aadd14f459d 100644
--- a/drivers/iio/adc/ad7292.c
+++ b/drivers/iio/adc/ad7292.c
@@ -8,7 +8,8 @@ 
 #include <linux/bitfield.h>
 #include <linux/device.h>
 #include <linux/module.h>
-#include <linux/of.h>
+#include <linux/mod_devicetable.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
 
@@ -260,7 +261,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 +305,11 @@  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) {
-		diff_channels = of_property_read_bool(child, "diff-channels");
-		if (diff_channels) {
-			of_node_put(child);
+	device_for_each_child_node_scoped(&spi->dev, child) {
+		diff_channels = fwnode_property_read_bool(child,
+							  "diff-channels");
+		if (diff_channels)
 			break;
-		}
 	}
 
 	if (diff_channels) {