[PATCH v3 4/7] iio: adc: ad7625: use standard unit names

From: Nicolae-Daniel Deaconescu

Date: Fri Nov 06 2026 - 11:06:35 EST


Use standard unit spelling and macros in existing code:

- Rename vref_mv to vref_mV and ref_mv to ref_mV, spelling the voltage unit
as mV.
- Use HZ_PER_MHZ instead of MEGA for frequencies.
- Use MICRO / MILLI instead of 1000 to convert the reference voltage from
uV to mV.

No behaviour change.

Signed-off-by: Nicolae-Daniel Deaconescu <Nicolae-daniel.Deaconescu@xxxxxxxxxx>
---
drivers/iio/adc/ad7625.c | 46 ++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/iio/adc/ad7625.c b/drivers/iio/adc/ad7625.c
index ade2f2368bd8..e699a7023b02 100644
--- a/drivers/iio/adc/ad7625.c
+++ b/drivers/iio/adc/ad7625.c
@@ -24,7 +24,7 @@
#include <linux/units.h>

#define AD7625_INTERNAL_REF_MV 4096
-#define AD7960_MAX_NBW_FREQ (2 * MEGA)
+#define AD7960_MAX_NBW_FREQ (2 * HZ_PER_MHZ)

struct ad7625_timing_spec {
/* Max conversion high time (t_{CNVH}). */
@@ -76,7 +76,7 @@ struct ad7625_state {
*/
struct pwm_waveform clk_gate_wf;
struct pwm_waveform cnv_wf;
- unsigned int vref_mv;
+ unsigned int vref_mV;
u32 sampling_freq_hz;
/*
* Optional GPIOs for controlling device state. EN0 and EN1
@@ -126,7 +126,7 @@ static const struct ad7625_timing_spec ad7960_timing_spec = {

static const struct ad7625_chip_info ad7625_chip_info = {
.name = "ad7625",
- .max_sample_freq_hz = 6 * MEGA,
+ .max_sample_freq_hz = 6 * HZ_PER_MHZ,
.timing_spec = &ad7625_timing_spec,
.chan_spec = AD7625_CHAN_SPEC(16),
.has_power_down_state = false,
@@ -136,7 +136,7 @@ static const struct ad7625_chip_info ad7625_chip_info = {

static const struct ad7625_chip_info ad7626_chip_info = {
.name = "ad7626",
- .max_sample_freq_hz = 10 * MEGA,
+ .max_sample_freq_hz = 10 * HZ_PER_MHZ,
.timing_spec = &ad7626_timing_spec,
.chan_spec = AD7625_CHAN_SPEC(16),
.has_power_down_state = true,
@@ -146,7 +146,7 @@ static const struct ad7625_chip_info ad7626_chip_info = {

static const struct ad7625_chip_info ad7960_chip_info = {
.name = "ad7960",
- .max_sample_freq_hz = 5 * MEGA,
+ .max_sample_freq_hz = 5 * HZ_PER_MHZ,
.timing_spec = &ad7960_timing_spec,
.chan_spec = AD7625_CHAN_SPEC(18),
.has_power_down_state = true,
@@ -156,7 +156,7 @@ static const struct ad7625_chip_info ad7960_chip_info = {

static const struct ad7625_chip_info ad7961_chip_info = {
.name = "ad7961",
- .max_sample_freq_hz = 5 * MEGA,
+ .max_sample_freq_hz = 5 * HZ_PER_MHZ,
.timing_spec = &ad7960_timing_spec,
.chan_spec = AD7625_CHAN_SPEC(16),
.has_power_down_state = true,
@@ -239,7 +239,7 @@ static int ad7625_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT;

case IIO_CHAN_INFO_SCALE:
- *val = st->vref_mv;
+ *val = st->vref_mV;
*val2 = chan->scan_type.realbits - 1;

return IIO_VAL_FRACTIONAL_LOG2;
@@ -346,12 +346,12 @@ static int ad7625_parse_mode(struct device *dev, struct ad7625_state *st,

/* Set EN1 and EN0 based on reference voltage source */
static void ad7625_set_en_gpios_for_vref(struct ad7625_state *st,
- bool have_refin, int ref_mv)
+ bool have_refin, int ref_mV)
{
- if (have_refin || ref_mv == 5000) {
+ if (have_refin || ref_mV == 5000) {
gpiod_set_value_cansleep(st->en_gpios[1], 0);
gpiod_set_value_cansleep(st->en_gpios[0], 1);
- } else if (ref_mv == 4096) {
+ } else if (ref_mV == 4096) {
gpiod_set_value_cansleep(st->en_gpios[1], 1);
gpiod_set_value_cansleep(st->en_gpios[0], 0);
} else {
@@ -365,7 +365,7 @@ static void ad7625_set_en_gpios_for_vref(struct ad7625_state *st,
}

static int ad7960_set_mode(struct ad7625_state *st, enum ad7960_mode mode,
- bool have_refin, int ref_mv)
+ bool have_refin, int ref_mV)
{
switch (mode) {
case AD7960_MODE_POWER_DOWN:
@@ -392,7 +392,7 @@ static int ad7960_set_mode(struct ad7625_state *st, enum ad7960_mode mode,
return -EINVAL;

gpiod_set_value_cansleep(st->en_gpios[2], 1);
- ad7625_set_en_gpios_for_vref(st, have_refin, ref_mv);
+ ad7625_set_en_gpios_for_vref(st, have_refin, ref_mV);

return 0;

@@ -401,7 +401,7 @@ static int ad7960_set_mode(struct ad7625_state *st, enum ad7960_mode mode,
return -EINVAL;

gpiod_set_value_cansleep(st->en_gpios[2], 0);
- ad7625_set_en_gpios_for_vref(st, have_refin, ref_mv);
+ ad7625_set_en_gpios_for_vref(st, have_refin, ref_mV);

return 0;

@@ -517,7 +517,7 @@ static int devm_ad7625_regulator_setup(struct device *dev,
struct ad7625_state *st)
{
static const char * const regulator_names[] = { "vio", "vdd2", "vdd1" };
- int ret, ref_mv;
+ int ret, ref_mV;

ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulator_names),
regulator_names);
@@ -528,7 +528,7 @@ static int devm_ad7625_regulator_setup(struct device *dev,
if (ret < 0 && ret != -ENODEV)
return dev_err_probe(dev, ret, "failed to get REF voltage\n");

- ref_mv = ret == -ENODEV ? 0 : ret / 1000;
+ ref_mV = ret == -ENODEV ? 0 : ret / (MICRO / MILLI);

ret = devm_regulator_get_enable_optional(dev, "refin");
if (ret < 0 && ret != -ENODEV)
@@ -540,23 +540,23 @@ static int devm_ad7625_regulator_setup(struct device *dev,
return dev_err_probe(dev, -EINVAL,
"REFIN provided in unsupported mode\n");

- if (!st->info->has_internal_vref && !st->have_refin && !ref_mv)
+ if (!st->info->has_internal_vref && !st->have_refin && !ref_mV)
return dev_err_probe(dev, -EINVAL,
"Need either REFIN or REF\n");

- if (st->have_refin && ref_mv)
+ if (st->have_refin && ref_mV)
return dev_err_probe(dev, -EINVAL,
"cannot have both REFIN and REF supplies\n");

- if (ref_mv == 4096 && !st->can_ref_4v096)
+ if (ref_mV == 4096 && !st->can_ref_4v096)
return dev_err_probe(dev, -EINVAL,
"REF is 4.096V in unsupported mode\n");

- if (ref_mv == 5000 && !st->can_ref_5v)
+ if (ref_mV == 5000 && !st->can_ref_5v)
return dev_err_probe(dev, -EINVAL,
"REF is 5V in unsupported mode\n");

- st->vref_mv = ref_mv ?: AD7625_INTERNAL_REF_MV;
+ st->vref_mV = ref_mV ?: AD7625_INTERNAL_REF_MV;

return 0;
}
@@ -597,7 +597,7 @@ static int ad7625_probe(struct platform_device *pdev)

/* Set the device mode based on detected EN configuration. */
if (!st->info->has_bandwidth_control) {
- ad7625_set_en_gpios_for_vref(st, st->have_refin, st->vref_mv);
+ ad7625_set_en_gpios_for_vref(st, st->have_refin, st->vref_mV);
} else {
/*
* If neither sampling mode is available, then report an error,
@@ -605,10 +605,10 @@ static int ad7625_probe(struct platform_device *pdev)
*/
if (st->can_wide_bandwidth) {
ret = ad7960_set_mode(st, AD7960_MODE_WIDE_BANDWIDTH,
- st->have_refin, st->vref_mv);
+ st->have_refin, st->vref_mV);
} else if (st->can_narrow_bandwidth) {
ret = ad7960_set_mode(st, AD7960_MODE_NARROW_BANDWIDTH,
- st->have_refin, st->vref_mv);
+ st->have_refin, st->vref_mV);
} else {
return dev_err_probe(dev, -EINVAL,
"couldn't set device to wide or narrow bandwidth modes\n");
--
2.56.0