]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: adc: ad7173: fix setting ODR in probe
authorDavid Lechner <dlechner@baylibre.com>
Fri, 22 Aug 2025 18:08:10 +0000 (14:08 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:31:07 +0000 (16:31 +0200)
[ Upstream commit 6fa908abd19cc35c205f343b79c67ff38dbc9b76 ]

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>
Link: https://patch.msgid.link/20250710-iio-adc-ad7173-fix-setting-odr-in-probe-v1-1-78a100fec998@baylibre.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
[ Adjust context ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/adc/ad7173.c

index 2eebc6f761a632252a8f619e1d2d974d04ae0f74..19b583e00753e2109067afa2e2ebe6cc8e68ef0b 100644 (file)
@@ -1243,6 +1243,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;
                st->adc_mode |= AD7173_ADC_MODE_REF_EN;
 
                chan_index++;
@@ -1307,7 +1308,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
                chan->channel = ain[0];
                chan_st_priv->chan_reg = chan_index;
                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.bipolar = fwnode_property_read_bool(child, "bipolar");
                if (chan_st_priv->cfg.bipolar)