devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: dumitru.ceclan@analog.com
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	David Lechner <dlechner@baylibre.com>,
	 linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Dumitru Ceclan <mitrutzceclan@gmail.com>
Subject: Re: [PATCH v7 5/9] iio: adc: ad7173: refactor ain and vref selection
Date: Mon, 10 Jun 2024 09:23:49 +0200	[thread overview]
Message-ID: <8cb3752a46f83fbadbc6d33105004f2986a470f5.camel@gmail.com> (raw)
In-Reply-To: <20240607-ad4111-v7-5-97e3855900a0@analog.com>

On Fri, 2024-06-07 at 17:53 +0300, Dumitru Ceclan via B4 Relay wrote:
> From: Dumitru Ceclan <dumitru.ceclan@analog.com>
> 
> Move validation of analog inputs and reference voltage selection to
> separate functions to reduce the size of the channel config parsing
> function and improve readability.
> Add defines for the number of analog inputs in a channel.
> 
> Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com>
> ---

One minor nit that maybe can be tweaked while applying. Anyways, no need for v8
just because of it:

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

>  drivers/iio/adc/ad7173.c | 62 +++++++++++++++++++++++++++++++++--------------
> -
>  1 file changed, 43 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c
> index 8631f218b69e..1257303b0cf6 100644
> --- a/drivers/iio/adc/ad7173.c
> +++ b/drivers/iio/adc/ad7173.c
> @@ -60,6 +60,7 @@
>  #define AD7173_CH_SETUP_AINPOS_MASK	GENMASK(9, 5)
>  #define AD7173_CH_SETUP_AINNEG_MASK	GENMASK(4, 0)
>  
> +#define AD7173_NO_AINS_PER_CHANNEL	2
>  #define AD7173_CH_ADDRESS(pos, neg) \
>  	(FIELD_PREP(AD7173_CH_SETUP_AINPOS_MASK, pos) | \
>  	 FIELD_PREP(AD7173_CH_SETUP_AINNEG_MASK, neg))
> @@ -906,13 +907,48 @@ static int ad7173_register_clk_provider(struct iio_dev
> *indio_dev)
>  					   &st->int_clk_hw);
>  }
>  
> +static int ad7173_validate_voltage_ain_inputs(struct ad7173_state *st,
> +					      unsigned int ain0, unsigned int
> ain1)
> +{
> +	struct device *dev = &st->sd.spi->dev;
> +
> +	if (ain0 >= st->info->num_inputs ||
> +	    ain1 >= st->info->num_inputs)
> +		return dev_err_probe(dev, -EINVAL,
> +				     "Input pin number out of range for pair
> (%d %d).\n",
> +				     ain0, ain1);
> +
> +	return 0;
> +}
> +
> +static int ad7173_validate_reference(struct ad7173_state *st, int ref_sel)
> +{
> +	struct device *dev = &st->sd.spi->dev;
> +	int ret;
> +
> +	if (ref_sel == AD7173_SETUP_REF_SEL_INT_REF && !st->info-
> >has_int_ref)
> +		return dev_err_probe(dev, -EINVAL,
> +			"Internal reference is not available on current
> model.\n");
> +
> +	if (ref_sel == AD7173_SETUP_REF_SEL_EXT_REF2 && !st->info->has_ref2)
> +		return dev_err_probe(dev, -EINVAL,
> +			"External reference 2 is not available on current
> model.\n");
> +
> +	ret = ad7173_get_ref_voltage_milli(st, ref_sel);
> +	if (ret < 0)
> +		return dev_err_probe(dev, ret, "Cannot use reference %u\n",
> +				     ref_sel);
> +
> +	return 0;

could be return ad7173_get_ref_voltage_milli()...

- Nuno Sá



  reply	other threads:[~2024-06-10  7:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07 14:53 [PATCH v7 0/9] Add support for AD411x Dumitru Ceclan via B4 Relay
2024-06-07 14:53 ` [PATCH v7 1/9] dt-bindings: iio: adc: Add common-mode-channel property Dumitru Ceclan via B4 Relay
2024-06-07 14:53 ` [PATCH v7 2/9] dt-bindings: adc: ad7173: add support for ad411x Dumitru Ceclan via B4 Relay
2024-06-07 14:53 ` [PATCH v7 3/9] iio: adc: ad_sigma_delta: add disable_one callback Dumitru Ceclan via B4 Relay
2024-06-07 14:53 ` [PATCH v7 4/9] iio: adc: ad7173: refactor channel configuration parsing Dumitru Ceclan via B4 Relay
2024-06-07 14:53 ` [PATCH v7 5/9] iio: adc: ad7173: refactor ain and vref selection Dumitru Ceclan via B4 Relay
2024-06-10  7:23   ` Nuno Sá [this message]
2024-06-10 14:35     ` Nuno Sá
2024-06-07 14:53 ` [PATCH v7 6/9] iio: adc: ad7173: add support for special inputs Dumitru Ceclan via B4 Relay
2024-06-10  7:24   ` Nuno Sá
2024-06-07 14:53 ` [PATCH v7 7/9] iio: adc: ad7173: refactor device info structs Dumitru Ceclan via B4 Relay
2024-06-07 14:53 ` [PATCH v7 8/9] iio: adc: ad7173: document sampling frequency behaviour Dumitru Ceclan via B4 Relay
2024-06-07 14:53 ` [PATCH v7 9/9] iio: adc: ad7173: Add support for AD411x devices Dumitru Ceclan via B4 Relay
2024-06-10  7:27   ` Nuno Sá
2024-07-12 18:23   ` Rob Herring
2024-07-13 10:12   ` Krzysztof Kozlowski
2024-07-15 17:17     ` Ceclan, Dumitru
2024-07-16  6:31       ` Krzysztof Kozlowski
2024-07-22  7:14         ` Ceclan, Dumitru
2024-06-08 16:37 ` [PATCH v7 0/9] Add support for AD411x Jonathan Cameron
2024-06-13 18:30   ` Jonathan Cameron
2024-06-17 18:02     ` Jonathan Cameron
2024-06-10 13:40 ` David Lechner
2024-07-13 10:11 ` Krzysztof Kozlowski

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=8cb3752a46f83fbadbc6d33105004f2986a470f5.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=dumitru.ceclan@analog.com \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mitrutzceclan@gmail.com \
    --cc=robh@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).