Linux IIO development
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>,
	linux-iio@vger.kernel.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Alisa-Dariana Roman" <alisa.roman@analog.com>,
	"Haibo Chen" <haibo.chen@nxp.com>,
	"Sean Nyekjaer" <sean@geanix.com>,
	"Andreas Klinger" <ak@it-klinger.de>,
	"Jonathan Cameron" <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH 3/8] iio: adc: ad7124: Switch from of specific to fwnode based property handling
Date: Mon, 19 Feb 2024 10:24:59 +0100	[thread overview]
Message-ID: <7f4f569b9e8edd017f92d1fb583bdbe419fe4e87.camel@gmail.com> (raw)
In-Reply-To: <20240218172731.1023367-4-jic23@kernel.org>

On Sun, 2024-02-18 at 17:27 +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Using the generic firmware data access functions from property.h
> provides a number of advantages:
>  1) Works with different firmware types.
>  2) Doesn't provide a 'bad' example for new IIO drivers.
>  3) Lets us use the new _scoped() loops with automatic reference count
>     cleanup for fwnode_handle
> 
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Michael Hennerich <Michael.Hennerich@analog.com>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---

Just one minor nit from me... Still, fell free to add:

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

>  drivers/iio/adc/ad7124.c | 55 +++++++++++++++++-----------------------
>  1 file changed, 23 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
> index b9b206fcd748..e7b1d517d3de 100644
> --- a/drivers/iio/adc/ad7124.c
> +++ b/drivers/iio/adc/ad7124.c
> @@ -14,7 +14,8 @@
>  #include <linux/kernel.h>
>  #include <linux/kfifo.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>
>  
> @@ -807,22 +808,19 @@ static int ad7124_check_chip_id(struct ad7124_state *st)
>  	return 0;
>  }
>  
> -static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
> -					  struct device_node *np)
> +static int ad7124_parse_channel_config(struct iio_dev *indio_dev,
> +				       struct device *dev)
>  {
>  	struct ad7124_state *st = iio_priv(indio_dev);
>  	struct ad7124_channel_config *cfg;
>  	struct ad7124_channel *channels;
> -	struct device_node *child;
>  	struct iio_chan_spec *chan;
>  	unsigned int ain[2], channel = 0, tmp;
>  	int ret;
>  
> -	st->num_channels = of_get_available_child_count(np);
> -	if (!st->num_channels) {
> -		dev_err(indio_dev->dev.parent, "no channel children\n");
> -		return -ENODEV;
> -	}
> +	st->num_channels = device_get_child_node_count(dev);
> +	if (!st->num_channels)
> +		return dev_err_probe(dev, -ENODEV, "no channel children\n");
>  
>  	chan = devm_kcalloc(indio_dev->dev.parent, st->num_channels,
>  			    sizeof(*chan), GFP_KERNEL);
> @@ -838,39 +836,38 @@ static int ad7124_of_parse_channel_config(struct iio_dev
> *indio_dev,
>  	indio_dev->num_channels = st->num_channels;
>  	st->channels = channels;
>  
> -	for_each_available_child_of_node(np, child) {
> +	device_for_each_child_node_scoped(dev, child) {
>  		cfg = &st->channels[channel].cfg;
>  
> -		ret = of_property_read_u32(child, "reg", &channel);
> +		ret = fwnode_property_read_u32(child, "reg", &channel);
>  		if (ret)
> -			goto err;
> +			return ret;
>  
> -		if (channel >= indio_dev->num_channels) {
> -			dev_err(indio_dev->dev.parent,
> +		if (channel >= indio_dev->num_channels)
> +			return dev_err_probe(dev, -EINVAL,
>  				"Channel index >= number of channels\n");
> -			ret = -EINVAL;
> -			goto err;
> -		}
>  
> -		ret = of_property_read_u32_array(child, "diff-channels",
> -						 ain, 2);
> +		ret = fwnode_property_read_u32_array(child, "diff-channels",
> +						     ain, 2);
>  		if (ret)
> -			goto err;
> +			return ret;
>  
>  		st->channels[channel].nr = channel;
>  		st->channels[channel].ain = AD7124_CHANNEL_AINP(ain[0]) |
>  						 
> AD7124_CHANNEL_AINM(ain[1]);
>  
> -		cfg->bipolar = of_property_read_bool(child, "bipolar");
> +		cfg->bipolar = fwnode_property_read_bool(child, "bipolar");
>  
> -		ret = of_property_read_u32(child, "adi,reference-select",
> &tmp);
> +		ret = fwnode_property_read_u32(child, "adi,reference-select",
> &tmp);
>  		if (ret)
>  			cfg->refsel = AD7124_INT_REF;
>  		else
>  			cfg->refsel = tmp;
>  
> -		cfg->buf_positive = of_property_read_bool(child,
> "adi,buffered-positive");
> -		cfg->buf_negative = of_property_read_bool(child,
> "adi,buffered-negative");
> +		cfg->buf_positive =
> +			fwnode_property_read_bool(child, "adi,buffered-
> positive");
> +		cfg->buf_negative =
> +			fwnode_property_read_bool(child, "adi,buffered-
> negative");

I think this is one of those cases where 80col limit hurts readability...

- Nuno Sá



  reply	other threads:[~2024-02-19  9:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-18 17:27 [PATCH 0/8] IIO: Convert DT specific handling over to fwnode Jonathan Cameron
2024-02-18 17:27 ` [PATCH 1/8] iio: adc: fsl-imx25-gcq: Switch from of specific handing to fwnode based Jonathan Cameron
2024-02-18 17:27 ` [PATCH 2/8] iio: adc: fsl-imx25-gcq: Use devm_* and dev_err_probe() to simplify probe Jonathan Cameron
2024-02-18 17:27 ` [PATCH 3/8] iio: adc: ad7124: Switch from of specific to fwnode based property handling Jonathan Cameron
2024-02-19  9:24   ` Nuno Sá [this message]
2024-02-19 11:59     ` Andy Shevchenko
2024-02-19 11:58   ` Andy Shevchenko
2024-02-24 15:19     ` Jonathan Cameron
2024-02-18 17:27 ` [PATCH 4/8] iio: adc: ad7292: Switch from of specific to fwnode " Jonathan Cameron
2024-02-19  9:26   ` Nuno Sá
2024-02-18 17:27 ` [PATCH 5/8] iio: adc: ad7192: Convert " Jonathan Cameron
2024-02-19  9:30   ` Nuno Sá
2024-02-19 12:02   ` Andy Shevchenko
2024-02-18 17:27 ` [PATCH 6/8] iio: accel: mma8452: Switch " Jonathan Cameron
2024-02-23 11:10   ` Bough Chen
2024-02-18 17:27 ` [PATCH 7/8] iio: accel: fxls8962af: Switch from of specific to fwnode based properties Jonathan Cameron
2024-02-19 12:03   ` Andy Shevchenko
2024-02-18 17:27 ` [PATCH 8/8] iio: adc: hx711: Switch from of specific to fwnode property handling Jonathan Cameron
2024-02-19 12:06   ` Andy Shevchenko
2024-02-19 12:06 ` [PATCH 0/8] IIO: Convert DT specific handling over to fwnode Andy Shevchenko
2024-02-24 15:31   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7f4f569b9e8edd017f92d1fb583bdbe419fe4e87.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=ak@it-klinger.de \
    --cc=alisa.roman@analog.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=haibo.chen@nxp.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=sean@geanix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox