Commit c377e2fe authored by Biju Das's avatar Biju Das Committed by Jonathan Cameron

iio: dac: mcp4725: Add dac_reg_offset to struct mcp4725_chip_info

The MCP4725 has a register offset '3' for reading DAC value compared to
'4' for MCP4726. Add dac_reg_offset variable to struct mcp4725_chip_info
to handle this difference.

Drop chip_id from struct mcp4725_chip_info as it is unused.
Signed-off-by: default avatarBiju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20230903115548.59306-5-biju.das.jz@bp.renesas.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 155da070
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
struct mcp4725_chip_info { struct mcp4725_chip_info {
const struct iio_chan_spec *chan_spec; const struct iio_chan_spec *chan_spec;
unsigned int chip_id; u8 dac_reg_offset;
bool use_ext_ref_voltage; bool use_ext_ref_voltage;
}; };
...@@ -463,7 +463,7 @@ static int mcp4725_probe(struct i2c_client *client) ...@@ -463,7 +463,7 @@ static int mcp4725_probe(struct i2c_client *client)
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
/* read current DAC value and settings */ /* read current DAC value and settings */
err = i2c_master_recv(client, inbuf, info->chip_id == MCP4725 ? 3 : 4); err = i2c_master_recv(client, inbuf, info->dac_reg_offset);
if (err < 0) { if (err < 0) {
dev_err(&client->dev, "failed to read DAC value"); dev_err(&client->dev, "failed to read DAC value");
...@@ -515,13 +515,13 @@ static void mcp4725_remove(struct i2c_client *client) ...@@ -515,13 +515,13 @@ static void mcp4725_remove(struct i2c_client *client)
static const struct mcp4725_chip_info mcp4725 = { static const struct mcp4725_chip_info mcp4725 = {
.chan_spec = &mcp472x_channel[MCP4725], .chan_spec = &mcp472x_channel[MCP4725],
.chip_id = MCP4725, .dac_reg_offset = 3,
.use_ext_ref_voltage = true, .use_ext_ref_voltage = true,
}; };
static const struct mcp4725_chip_info mcp4726 = { static const struct mcp4725_chip_info mcp4726 = {
.chan_spec = &mcp472x_channel[MCP4726], .chan_spec = &mcp472x_channel[MCP4726],
.chip_id = MCP4726, .dac_reg_offset = 4,
}; };
static const struct i2c_device_id mcp4725_id[] = { static const struct i2c_device_id mcp4725_id[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment