[PATCH] iio: adc: ad7173: fix setting ODR in probe

David Lechner posted 1 patch 2 months, 4 weeks ago
drivers/iio/adc/ad7173.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] iio: adc: ad7173: fix setting ODR in probe
Posted by David Lechner 2 months, 4 weeks ago
Fix the setting of the ODR register value in the probe function for
AD7177. The AD7177 chip has a different ODR value after reset than the
other chips (0x7 vs. 0x0) and 0 is a reserved value on that chip.

The driver already has this information available in odr_start_value
and uses it when checking valid values when writing to the
sampling_frequency attribute, but failed to set the correct initial
value in the probe function.

Fixes: 37ae8381ccda ("iio: adc: ad7173: add support for additional models")
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
 drivers/iio/adc/ad7173.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c
index dd9fa35555c79ead5a1b88d1dc6cc3db122502be..ef074b41332ed912fb281c0903f6cc52077accb4 100644
--- a/drivers/iio/adc/ad7173.c
+++ b/drivers/iio/adc/ad7173.c
@@ -1574,6 +1574,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
 		chan_st_priv->cfg.bipolar = false;
 		chan_st_priv->cfg.input_buf = st->info->has_input_buf;
 		chan_st_priv->cfg.ref_sel = AD7173_SETUP_REF_SEL_INT_REF;
+		chan_st_priv->cfg.odr = st->info->odr_start_value;
 		chan_st_priv->cfg.openwire_comp_chan = -1;
 		st->adc_mode |= AD7173_ADC_MODE_REF_EN;
 		if (st->info->data_reg_only_16bit)
@@ -1640,7 +1641,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
 		chan->scan_index = chan_index;
 		chan->channel = ain[0];
 		chan_st_priv->cfg.input_buf = st->info->has_input_buf;
-		chan_st_priv->cfg.odr = 0;
+		chan_st_priv->cfg.odr = st->info->odr_start_value;
 		chan_st_priv->cfg.openwire_comp_chan = -1;
 
 		chan_st_priv->cfg.bipolar = fwnode_property_read_bool(child, "bipolar");

---
base-commit: f8f559752d573a051a984adda8d2d1464f92f954
change-id: 20250710-iio-adc-ad7173-fix-setting-odr-in-probe-915972070e8a

Best regards,
-- 
David Lechner <dlechner@baylibre.com>
Re: [PATCH] iio: adc: ad7173: fix setting ODR in probe
Posted by Jonathan Cameron 2 months, 3 weeks ago
On Thu, 10 Jul 2025 15:43:40 -0500
David Lechner <dlechner@baylibre.com> wrote:

> Fix the setting of the ODR register value in the probe function for
> AD7177. The AD7177 chip has a different ODR value after reset than the
> other chips (0x7 vs. 0x0) and 0 is a reserved value on that chip.
> 
> The driver already has this information available in odr_start_value
> and uses it when checking valid values when writing to the
> sampling_frequency attribute, but failed to set the correct initial
> value in the probe function.
> 
> Fixes: 37ae8381ccda ("iio: adc: ad7173: add support for additional models")
> Signed-off-by: David Lechner <dlechner@baylibre.com>
Applied and marked for stable.

> ---
>  drivers/iio/adc/ad7173.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c
> index dd9fa35555c79ead5a1b88d1dc6cc3db122502be..ef074b41332ed912fb281c0903f6cc52077accb4 100644
> --- a/drivers/iio/adc/ad7173.c
> +++ b/drivers/iio/adc/ad7173.c
> @@ -1574,6 +1574,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
>  		chan_st_priv->cfg.bipolar = false;
>  		chan_st_priv->cfg.input_buf = st->info->has_input_buf;
>  		chan_st_priv->cfg.ref_sel = AD7173_SETUP_REF_SEL_INT_REF;
> +		chan_st_priv->cfg.odr = st->info->odr_start_value;
>  		chan_st_priv->cfg.openwire_comp_chan = -1;
>  		st->adc_mode |= AD7173_ADC_MODE_REF_EN;
>  		if (st->info->data_reg_only_16bit)
> @@ -1640,7 +1641,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
>  		chan->scan_index = chan_index;
>  		chan->channel = ain[0];
>  		chan_st_priv->cfg.input_buf = st->info->has_input_buf;
> -		chan_st_priv->cfg.odr = 0;
> +		chan_st_priv->cfg.odr = st->info->odr_start_value;
>  		chan_st_priv->cfg.openwire_comp_chan = -1;
>  
>  		chan_st_priv->cfg.bipolar = fwnode_property_read_bool(child, "bipolar");
> 
> ---
> base-commit: f8f559752d573a051a984adda8d2d1464f92f954
> change-id: 20250710-iio-adc-ad7173-fix-setting-odr-in-probe-915972070e8a
> 
> Best regards,
Re: [PATCH] iio: adc: ad7173: fix setting ODR in probe
Posted by Jonathan Cameron 2 months, 3 weeks ago
On Sun, 13 Jul 2025 15:14:50 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> On Thu, 10 Jul 2025 15:43:40 -0500
> David Lechner <dlechner@baylibre.com> wrote:
> 
> > Fix the setting of the ODR register value in the probe function for
> > AD7177. The AD7177 chip has a different ODR value after reset than the
> > other chips (0x7 vs. 0x0) and 0 is a reserved value on that chip.
> > 
> > The driver already has this information available in odr_start_value
> > and uses it when checking valid values when writing to the
> > sampling_frequency attribute, but failed to set the correct initial
> > value in the probe function.
> > 
> > Fixes: 37ae8381ccda ("iio: adc: ad7173: add support for additional models")
> > Signed-off-by: David Lechner <dlechner@baylibre.com>  
> Applied and marked for stable.
>
 
Given I've been very slow to send a final fixes pull and the cross dependencies
with some of the stuff for the merge window + all the fixes I currently have
queued are for the ad7173 or ad_sigma_delta, I plan to drag the lot across
to my pull request for the coming merge window (so the togreg branch).

Sorry for the hassle that might occur in getting these backported and the
delay in getting the fixes merged. Crazy period for one reason and another
so I've had less time to focus on IIO for a few weeks than I'd normally like.

Jonathan

> > ---
> >  drivers/iio/adc/ad7173.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c
> > index dd9fa35555c79ead5a1b88d1dc6cc3db122502be..ef074b41332ed912fb281c0903f6cc52077accb4 100644
> > --- a/drivers/iio/adc/ad7173.c
> > +++ b/drivers/iio/adc/ad7173.c
> > @@ -1574,6 +1574,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
> >  		chan_st_priv->cfg.bipolar = false;
> >  		chan_st_priv->cfg.input_buf = st->info->has_input_buf;
> >  		chan_st_priv->cfg.ref_sel = AD7173_SETUP_REF_SEL_INT_REF;
> > +		chan_st_priv->cfg.odr = st->info->odr_start_value;
> >  		chan_st_priv->cfg.openwire_comp_chan = -1;
> >  		st->adc_mode |= AD7173_ADC_MODE_REF_EN;
> >  		if (st->info->data_reg_only_16bit)
> > @@ -1640,7 +1641,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
> >  		chan->scan_index = chan_index;
> >  		chan->channel = ain[0];
> >  		chan_st_priv->cfg.input_buf = st->info->has_input_buf;
> > -		chan_st_priv->cfg.odr = 0;
> > +		chan_st_priv->cfg.odr = st->info->odr_start_value;
> >  		chan_st_priv->cfg.openwire_comp_chan = -1;
> >  
> >  		chan_st_priv->cfg.bipolar = fwnode_property_read_bool(child, "bipolar");
> > 
> > ---
> > base-commit: f8f559752d573a051a984adda8d2d1464f92f954
> > change-id: 20250710-iio-adc-ad7173-fix-setting-odr-in-probe-915972070e8a
> > 
> > Best regards,  
> 
>