Re: [PATCH v6 3/5] iio: adc: ad7192: Add aincom supply
From: Andy Shevchenko
Date: Wed Apr 17 2024 - 13:09:24 EST
On Wed, Apr 17, 2024 at 8:01 PM Alisa-Dariana Roman
<alisadariana@xxxxxxxxx> wrote:
>
> AINCOM should actually be a supply. AINx inputs are referenced to AINCOM
> in pseduo-differential operation mode. AINCOM voltage represets the
pseudo
> offset of corresponding channels.
..
> + case IIO_VOLTAGE:
> + if (st->aincom_mv && !chan->differential)
> + *val += DIV_ROUND_CLOSEST_ULL((u64)st->aincom_mv * 1000000000,
It's quite easy to make a mistake in this long constant. Can you use
an appropriate one from units.h?
> + st->scale_avail[gain][1]);
> + return IIO_VAL_INT;
..
> + aincom = devm_regulator_get_optional(&spi->dev, "aincom");
> + if (!IS_ERR(aincom)) {
Why not a positive condition?
> + ret = regulator_enable(aincom);
> + if (ret) {
> + dev_err(&spi->dev, "Failed to enable specified AINCOM supply\n");
return dev_err_probe();
> + return ret;
> + }
> +
> + ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, aincom);
> + if (ret)
> + return ret;
> +
> + ret = regulator_get_voltage(aincom);
> + if (ret < 0)
> + return dev_err_probe(&spi->dev, ret,
> + "Device tree error, AINCOM voltage undefined\n");
> + st->aincom_mv = ret / 1000;
> + } else {
> + st->aincom_mv = 0;
> + }
..
> @@ -1113,6 +1145,7 @@ static int ad7192_probe(struct spi_device *spi)
> st->int_vref_mv = ret / 1000;
>
> st->chip_info = spi_get_device_match_data(spi);
> +
> indio_dev->name = st->chip_info->name;
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->channels = st->chip_info->channels;
Stray change.
--
With Best Regards,
Andy Shevchenko