Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: ad7476: Use mV for internal reference

The ad7476 supports some ICs with an internal reference voltage. For
those ICs the reference voltage has been hard-coded as micro volts, but
the value which is later used in code needs to be milli volts. This
results the need to divide hard coded voltage by 1000 before using it.

Simplify code by changing the hard-coded voltage to millivolts and by
dropping the division.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://patch.msgid.link/1c26529fcc039a3ce8b5a336948229ec727ee281.1754901948.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Matti Vaittinen and committed by
Jonathan Cameron
1003d539 72e42b48

+6 -6
+6 -6
drivers/iio/adc/ad7476.c
··· 27 27 struct ad7476_state; 28 28 29 29 struct ad7476_chip_info { 30 - unsigned int int_vref_uv; 30 + unsigned int int_vref_mv; 31 31 struct iio_chan_spec channel[2]; 32 32 /* channels used when convst gpio is defined */ 33 33 struct iio_chan_spec convst_channel[2]; ··· 172 172 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), 173 173 .convst_channel[0] = AD7091R_CONVST_CHAN(12), 174 174 .convst_channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), 175 - .int_vref_uv = 2500000, 175 + .int_vref_mv = 2500, 176 176 .has_vref = true, 177 177 .reset = ad7091_reset, 178 178 }; ··· 229 229 static const struct ad7476_chip_info ad7495_chip_info = { 230 230 .channel[0] = AD7476_CHAN(12), 231 231 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), 232 - .int_vref_uv = 2500000, 232 + .int_vref_mv = 2500, 233 233 .has_vdrive = true, 234 234 }; 235 235 ··· 295 295 return -ENODEV; 296 296 297 297 /* Use VCC for reference voltage if vref / internal vref aren't used */ 298 - if (!st->chip_info->int_vref_uv && !st->chip_info->has_vref) { 298 + if (!st->chip_info->int_vref_mv && !st->chip_info->has_vref) { 299 299 ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vcc"); 300 300 if (ret < 0) 301 301 return ret; ··· 310 310 ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref"); 311 311 if (ret < 0) { 312 312 /* Vref is optional if a device has an internal reference */ 313 - if (!st->chip_info->int_vref_uv || ret != -ENODEV) 313 + if (!st->chip_info->int_vref_mv || ret != -ENODEV) 314 314 return ret; 315 315 } else { 316 316 st->scale_mv = ret / 1000; ··· 318 318 } 319 319 320 320 if (!st->scale_mv) 321 - st->scale_mv = st->chip_info->int_vref_uv / 1000; 321 + st->scale_mv = st->chip_info->int_vref_mv; 322 322 323 323 if (st->chip_info->has_vdrive) { 324 324 ret = devm_regulator_get_enable(&spi->dev, "vdrive");