[PATCH v6 03/11] iio: dac: mcp47feb02: use field_get() instead of custom dynamic macros
From: Ariana Lazar
Date: Wed Sep 16 2026 - 10:52:21 EST
Replace manual bit operations which select channel corresponding bits
from a control register in mcp47feb02_init_ctrl_regs() with field_get()
macro used with masks already defined for regmap operations within the
driver.
Reported-by: Jonathan Cameron <jic23@xxxxxxxxxx>
Link: https://lore.kernel.org/all/20260913224339.490d89ba@jic23-hlaptop/
Signed-off-by: Ariana Lazar <ariana.lazar@xxxxxxxxxxxxx>
---
drivers/iio/dac/mcp47feb02.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/dac/mcp47feb02.c b/drivers/iio/dac/mcp47feb02.c
index fa4bd1df954844da35a8496758489189aeceb60d..81aa9063fcf730342d4af114da73ac2fc550243f 100644
--- a/drivers/iio/dac/mcp47feb02.c
+++ b/drivers/iio/dac/mcp47feb02.c
@@ -1025,7 +1025,7 @@ static int mcp47feb02_init_ctrl_regs(struct mcp47feb02_data *data)
return ret;
data->chdata[i].dac_data = dac_val;
- data->chdata[i].ref_mode = (vref_ch >> (2 * i)) & MCP47FEB02_DAC_CTRL_MASK;
+ data->chdata[i].ref_mode = field_get(DAC_CTRL_MASK(i), vref_ch);
data->chdata[i].use_2x_gain = field_get(DAC_GAIN_MASK(i), gain_ch);
/*
@@ -1069,7 +1069,7 @@ static int mcp47feb02_init_ctrl_regs(struct mcp47feb02_data *data)
break;
}
- pd_tmp = (pd_ch >> (2 * i)) & MCP47FEB02_DAC_CTRL_MASK;
+ pd_tmp = field_get(DAC_CTRL_MASK(i), pd_ch);
data->chdata[i].powerdown_mode = pd_tmp ? (pd_tmp - 1) : pd_tmp;
data->chdata[i].powerdown = !!(data->chdata[i].powerdown_mode);
}
--
2.43.0