All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Nicolae-Daniel Deaconescu <Nicolae-daniel.Deaconescu@analog.com>
Cc: "Uwe Kleine-König" <ukleinek@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Michael Hennerich" <michael.hennerich@analog.com>,
	"Trevor Gamblin" <tgamblin@baylibre.com>,
	"Joshua Crofts" <crofts@kernel.org>,
	"Sergiu Cuciurean" <sergiu.cuciurean@analog.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-pwm@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 4/6] iio: adc: ad7625: move initial mode setup
Date: Sat, 21 Nov 2026 23:40:15 +0000	[thread overview]
Message-ID: <20261121234015.6cbb4bef@jic23-hlaptop> (raw)
In-Reply-To: <20261119112437.197306-5-Nicolae-daniel.Deaconescu@analog.com>

On Thu, 19 Nov 2026 13:24:18 +0200
Nicolae-Daniel Deaconescu <Nicolae-daniel.Deaconescu@analog.com> wrote:

Rather than move, I'd say 'factor out' for the title and in this text.

> Move the EN pin mode setup from ad7625_probe() into
> ad7625_set_initial_mode(). Pick the mode first and check the result of
> setting it once, returning its error instead of -EINVAL. A following patch

It was only ever set once.  Anyhow the only bit of this paragraph I'd
keep is.  "Return error if reported by ad7960_set_mode() rather than
replacing it with -EINVAL"

> adds parts without EN pins that skip it.
This last bit is fine but I'd put it first as the 'why' answer for the
whole patch.


> 
> Signed-off-by: Nicolae-Daniel Deaconescu <Nicolae-daniel.Deaconescu@analog.com>
> ---
>  drivers/iio/adc/ad7625.c | 52 ++++++++++++++++++++++------------------
>  1 file changed, 29 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7625.c b/drivers/iio/adc/ad7625.c
> index ade2f2368bd8..127441050687 100644
> --- a/drivers/iio/adc/ad7625.c
> +++ b/drivers/iio/adc/ad7625.c
> @@ -561,6 +561,32 @@ static int devm_ad7625_regulator_setup(struct device *dev,
>  	return 0;
>  }
>  
> +static int ad7625_set_initial_mode(struct device *dev, struct ad7625_state *st)
> +{
> +	enum ad7960_mode mode;
> +	int ret;
> +
> +	/* Set the device mode based on detected EN configuration. */
> +	if (!st->info->has_bandwidth_control) {
> +		ad7625_set_en_gpios_for_vref(st, st->have_refin, st->vref_mv);
> +		return 0;
> +	}
> +
> +	if (st->can_wide_bandwidth)
> +		mode = AD7960_MODE_WIDE_BANDWIDTH;
> +	else if (st->can_narrow_bandwidth)
> +		mode = AD7960_MODE_NARROW_BANDWIDTH;
> +	else
> +		return dev_err_probe(dev, -EINVAL,
> +			"couldn't set device to wide or narrow bandwidth modes\n");
> +
> +	ret = ad7960_set_mode(st, mode, st->have_refin, st->vref_mv);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to set EN pins\n");
> +
> +	return 0;
> +}
> +
>  static int ad7625_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> @@ -595,29 +621,9 @@ static int ad7625_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> -	/* Set the device mode based on detected EN configuration. */
> -	if (!st->info->has_bandwidth_control) {
> -		ad7625_set_en_gpios_for_vref(st, st->have_refin, st->vref_mv);
> -	} else {
> -		/*
> -		 * If neither sampling mode is available, then report an error,
> -		 * since the other modes are not useful defaults.
> -		 */
> -		if (st->can_wide_bandwidth) {
> -			ret = ad7960_set_mode(st, AD7960_MODE_WIDE_BANDWIDTH,
> -					      st->have_refin, st->vref_mv);
> -		} else if (st->can_narrow_bandwidth) {
> -			ret = ad7960_set_mode(st, AD7960_MODE_NARROW_BANDWIDTH,
> -					      st->have_refin, st->vref_mv);
> -		} else {
> -			return dev_err_probe(dev, -EINVAL,
> -				"couldn't set device to wide or narrow bandwidth modes\n");
> -		}
> -
> -		if (ret)
> -			return dev_err_probe(dev, -EINVAL,
> -					     "failed to set EN pins\n");
> -	}
> +	ret = ad7625_set_initial_mode(dev, st);
> +	if (ret)
> +		return ret;
>  
>  	ret = devm_ad7625_pwm_get(dev, st);
>  	if (ret)


  reply	other threads:[~2026-11-21 23:40 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 11:24 [PATCH v4 0/6] iio: adc: ad7625: add LTC2387 and ADAQ2387x support Nicolae-Daniel Deaconescu
2026-11-19 11:24 ` [PATCH v4 1/6] pwm: core: add pwm_get_waveform_step_might_sleep() Nicolae-Daniel Deaconescu
2026-11-21 23:35   ` Jonathan Cameron
2026-11-23 13:41   ` Uwe Kleine-König
2026-11-23 16:55     ` Nicolae-Daniel Deaconescu
2026-11-24 11:08       ` Uwe Kleine-König
2026-11-24 11:47         ` Nicolae-Daniel Deaconescu
2026-11-24 13:20           ` Uwe Kleine-König
2026-11-24 18:34           ` Conor Dooley
2026-11-25 14:42             ` Nicolae-Daniel Deaconescu
2026-11-26 10:11             ` Uwe Kleine-König
2026-11-26 18:06               ` Conor Dooley
2026-11-19 11:24 ` [PATCH v4 2/6] pwm: axi-pwmgen: report the waveform step Nicolae-Daniel Deaconescu
2026-11-19 11:24 ` [PATCH v4 3/6] iio: adc: ad7625: fix sampling frequency handling Nicolae-Daniel Deaconescu
2026-11-19 11:24 ` [PATCH v4 4/6] iio: adc: ad7625: move initial mode setup Nicolae-Daniel Deaconescu
2026-11-21 23:40   ` Jonathan Cameron [this message]
2026-11-19 11:24 ` [PATCH v4 5/6] dt-bindings: iio: adc: add adi,ltc2387 Nicolae-Daniel Deaconescu
2026-11-19 11:24 ` [PATCH v4 6/6] iio: adc: ad7625: add LTC2387 and ADAQ2387x support Nicolae-Daniel Deaconescu
2026-11-21 23:48   ` Jonathan Cameron
2026-11-23 11:53     ` Nicolae-Daniel Deaconescu
2026-11-29  0:40       ` 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=20261121234015.6cbb4bef@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=Nicolae-daniel.Deaconescu@analog.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=crofts@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    --cc=sergiu.cuciurean@analog.com \
    --cc=tgamblin@baylibre.com \
    --cc=ukleinek@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.