Message ID | 20240401-ad4111-v1-2-34618a9cc502@analog.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | Add support for AD411x | expand |
On Mon, Apr 1, 2024 at 10:10 AM Dumitru Ceclan via B4 Relay <devnull+dumitru.ceclan.analog.com@kernel.org> wrote: > > From: Dumitru Ceclan <dumitru.ceclan@analog.com> > > AD7176-2 does not feature input buffers, enable buffers only on > supported models. > > Fixes: cff259bf7274 ("iio: adc: ad7173: fix buffers enablement for ad7176-2") > Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com> > --- To be consistent with has_temp, maybe add `.has_input_buf = false,` to ID_AD7176_2. But either way: Reviewed-by: David Lechner <dlechner@baylibre.com>
On Mon, 01 Apr 2024 18:32:20 +0300 Dumitru Ceclan via B4 Relay <devnull+dumitru.ceclan.analog.com@kernel.org> wrote: > From: Dumitru Ceclan <dumitru.ceclan@analog.com> > > AD7176-2 does not feature input buffers, enable buffers only on > supported models. > > Fixes: cff259bf7274 ("iio: adc: ad7173: fix buffers enablement for ad7176-2") > Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com> How bad is this? If you can find out if writing those bits does anything harmful (they are reserved and datasheet says should be written 0 I think) That will help people decide whether to backport the fix? > --- > drivers/iio/adc/ad7173.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c > index f6d29abe1d04..8a95b1391826 100644 > --- a/drivers/iio/adc/ad7173.c > +++ b/drivers/iio/adc/ad7173.c > @@ -145,6 +145,7 @@ struct ad7173_device_info { > unsigned int id; > char *name; > bool has_temp; > + bool has_input_buf; > bool has_int_ref; > bool has_ref2; > u8 num_gpios; > @@ -212,6 +213,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { > .num_configs = 4, > .num_gpios = 2, > .has_temp = true, > + .has_input_buf = true, > .has_int_ref = true, > .clock = 2 * HZ_PER_MHZ, > .sinc5_data_rates = ad7173_sinc5_data_rates, > @@ -224,6 +226,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { > .num_configs = 8, > .num_gpios = 4, > .has_temp = false, > + .has_input_buf = true, > .has_ref2 = true, > .clock = 2 * HZ_PER_MHZ, > .sinc5_data_rates = ad7173_sinc5_data_rates, > @@ -237,6 +240,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { > .num_configs = 8, > .num_gpios = 4, > .has_temp = true, > + .has_input_buf = true, > .has_int_ref = true, > .has_ref2 = true, > .clock = 2 * HZ_PER_MHZ, > @@ -251,6 +255,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { > .num_configs = 4, > .num_gpios = 2, > .has_temp = true, > + .has_input_buf = true, > .has_int_ref = true, > .clock = 16 * HZ_PER_MHZ, > .sinc5_data_rates = ad7175_sinc5_data_rates, > @@ -263,6 +268,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { > .num_configs = 8, > .num_gpios = 4, > .has_temp = true, > + .has_input_buf = true, > .has_int_ref = true, > .has_ref2 = true, > .clock = 16 * HZ_PER_MHZ, > @@ -289,6 +295,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { > .num_configs = 4, > .num_gpios = 2, > .has_temp = true, > + .has_input_buf = true, > .has_int_ref = true, > .clock = 16 * HZ_PER_MHZ, > .odr_start_value = AD7177_ODR_START_VALUE, > @@ -932,7 +939,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev) > AD7173_CH_ADDRESS(chan_arr[chan_index].channel, > chan_arr[chan_index].channel2); > chan_st_priv->cfg.bipolar = false; > - chan_st_priv->cfg.input_buf = true; > + chan_st_priv->cfg.input_buf = st->info->has_input_buf; > chan_st_priv->cfg.ref_sel = AD7173_SETUP_REF_SEL_INT_REF; > st->adc_mode |= AD7173_ADC_MODE_REF_EN; > > @@ -989,7 +996,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev) > > chan_st_priv->ain = AD7173_CH_ADDRESS(ain[0], ain[1]); > chan_st_priv->chan_reg = chan_index; > - chan_st_priv->cfg.input_buf = true; > + chan_st_priv->cfg.input_buf = st->info->has_input_buf; > chan_st_priv->cfg.odr = 0; > > chan_st_priv->cfg.bipolar = fwnode_property_read_bool(child, "bipolar"); >
On 06/04/2024 17:56, Jonathan Cameron wrote: > On Mon, 01 Apr 2024 18:32:20 +0300 > Dumitru Ceclan via B4 Relay <devnull+dumitru.ceclan.analog.com@kernel.org> wrote: > >> From: Dumitru Ceclan <dumitru.ceclan@analog.com> >> >> AD7176-2 does not feature input buffers, enable buffers only on >> supported models. >> >> Fixes: cff259bf7274 ("iio: adc: ad7173: fix buffers enablement for ad7176-2") >> Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com> > How bad is this? If you can find out if writing those bits does anything > harmful (they are reserved and datasheet says should be written 0 I think) > That will help people decide whether to backport the fix? The bits are marked as read-only and there does not seem to be any effect on the ADC. So drop this one?
On Mon, 8 Apr 2024 19:40:26 +0300 "Ceclan, Dumitru" <mitrutzceclan@gmail.com> wrote: > On 06/04/2024 17:56, Jonathan Cameron wrote: > > On Mon, 01 Apr 2024 18:32:20 +0300 > > Dumitru Ceclan via B4 Relay <devnull+dumitru.ceclan.analog.com@kernel.org> wrote: > > > >> From: Dumitru Ceclan <dumitru.ceclan@analog.com> > >> > >> AD7176-2 does not feature input buffers, enable buffers only on > >> supported models. > >> > >> Fixes: cff259bf7274 ("iio: adc: ad7173: fix buffers enablement for ad7176-2") > >> Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com> > > How bad is this? If you can find out if writing those bits does anything > > harmful (they are reserved and datasheet says should be written 0 I think) > > That will help people decide whether to backport the fix? > > The bits are marked as read-only and there does not seem to be any effect on the ADC. > So drop this one? Patch is good as makes the driver more consistent, just drop the Fixes tag so we don't end up backporting this. That is basically treat it as code improvement rather than a fix. Add a note on the bits being read only so this not fixing a bug, just an inconsistency. Thanks, Jonathan
diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c index f6d29abe1d04..8a95b1391826 100644 --- a/drivers/iio/adc/ad7173.c +++ b/drivers/iio/adc/ad7173.c @@ -145,6 +145,7 @@ struct ad7173_device_info { unsigned int id; char *name; bool has_temp; + bool has_input_buf; bool has_int_ref; bool has_ref2; u8 num_gpios; @@ -212,6 +213,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { .num_configs = 4, .num_gpios = 2, .has_temp = true, + .has_input_buf = true, .has_int_ref = true, .clock = 2 * HZ_PER_MHZ, .sinc5_data_rates = ad7173_sinc5_data_rates, @@ -224,6 +226,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { .num_configs = 8, .num_gpios = 4, .has_temp = false, + .has_input_buf = true, .has_ref2 = true, .clock = 2 * HZ_PER_MHZ, .sinc5_data_rates = ad7173_sinc5_data_rates, @@ -237,6 +240,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { .num_configs = 8, .num_gpios = 4, .has_temp = true, + .has_input_buf = true, .has_int_ref = true, .has_ref2 = true, .clock = 2 * HZ_PER_MHZ, @@ -251,6 +255,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { .num_configs = 4, .num_gpios = 2, .has_temp = true, + .has_input_buf = true, .has_int_ref = true, .clock = 16 * HZ_PER_MHZ, .sinc5_data_rates = ad7175_sinc5_data_rates, @@ -263,6 +268,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { .num_configs = 8, .num_gpios = 4, .has_temp = true, + .has_input_buf = true, .has_int_ref = true, .has_ref2 = true, .clock = 16 * HZ_PER_MHZ, @@ -289,6 +295,7 @@ static const struct ad7173_device_info ad7173_device_info[] = { .num_configs = 4, .num_gpios = 2, .has_temp = true, + .has_input_buf = true, .has_int_ref = true, .clock = 16 * HZ_PER_MHZ, .odr_start_value = AD7177_ODR_START_VALUE, @@ -932,7 +939,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev) AD7173_CH_ADDRESS(chan_arr[chan_index].channel, chan_arr[chan_index].channel2); chan_st_priv->cfg.bipolar = false; - chan_st_priv->cfg.input_buf = true; + chan_st_priv->cfg.input_buf = st->info->has_input_buf; chan_st_priv->cfg.ref_sel = AD7173_SETUP_REF_SEL_INT_REF; st->adc_mode |= AD7173_ADC_MODE_REF_EN; @@ -989,7 +996,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev) chan_st_priv->ain = AD7173_CH_ADDRESS(ain[0], ain[1]); chan_st_priv->chan_reg = chan_index; - chan_st_priv->cfg.input_buf = true; + chan_st_priv->cfg.input_buf = st->info->has_input_buf; chan_st_priv->cfg.odr = 0; chan_st_priv->cfg.bipolar = fwnode_property_read_bool(child, "bipolar");