[PATCH v7 03/11] iio: dac: mcp47feb02: use field_get() instead of custom dynamic macros

From: Ariana Lazar

Date: Fri Sep 18 2026 - 05:14:07 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.

Suggested-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 1b1a4972f77196399297b3912abe69efcbf17d75..d910a6cf9718d6c6ad68eb1bb1ff5f3b15b33e84 100644
--- a/drivers/iio/dac/mcp47feb02.c
+++ b/drivers/iio/dac/mcp47feb02.c
@@ -1024,7 +1024,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);

/*
@@ -1068,7 +1068,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