Commit 002d546f authored by Biju Das's avatar Biju Das Committed by Jonathan Cameron

iio: dac: mcp4725: Replace variable 'id' from struct mcp4725_data

Replace the variable 'id' from struct mcp4725_data with local variable
chip_id in probe() as the id variable is not used elsewhere in the
driver.
Signed-off-by: default avatarBiju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20230903115548.59306-2-biju.das.jz@bp.renesas.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent dcc3ac13
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
struct mcp4725_data { struct mcp4725_data {
struct i2c_client *client; struct i2c_client *client;
int id;
unsigned ref_mode; unsigned ref_mode;
bool vref_buffered; bool vref_buffered;
u16 dac_value; u16 dac_value;
...@@ -387,6 +386,7 @@ static int mcp4725_probe(struct i2c_client *client) ...@@ -387,6 +386,7 @@ static int mcp4725_probe(struct i2c_client *client)
struct mcp4725_data *data; struct mcp4725_data *data;
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
struct mcp4725_platform_data *pdata, pdata_dt; struct mcp4725_platform_data *pdata, pdata_dt;
int chip_id;
u8 inbuf[4]; u8 inbuf[4];
u8 pd; u8 pd;
u8 ref; u8 ref;
...@@ -399,9 +399,9 @@ static int mcp4725_probe(struct i2c_client *client) ...@@ -399,9 +399,9 @@ static int mcp4725_probe(struct i2c_client *client)
i2c_set_clientdata(client, indio_dev); i2c_set_clientdata(client, indio_dev);
data->client = client; data->client = client;
if (dev_fwnode(&client->dev)) if (dev_fwnode(&client->dev))
data->id = (uintptr_t)device_get_match_data(&client->dev); chip_id = (uintptr_t)device_get_match_data(&client->dev);
else else
data->id = id->driver_data; chip_id = id->driver_data;
pdata = dev_get_platdata(&client->dev); pdata = dev_get_platdata(&client->dev);
if (!pdata) { if (!pdata) {
...@@ -414,7 +414,7 @@ static int mcp4725_probe(struct i2c_client *client) ...@@ -414,7 +414,7 @@ static int mcp4725_probe(struct i2c_client *client)
pdata = &pdata_dt; pdata = &pdata_dt;
} }
if (data->id == MCP4725 && pdata->use_vref) { if (chip_id == MCP4725 && pdata->use_vref) {
dev_err(&client->dev, dev_err(&client->dev,
"external reference is unavailable on MCP4725"); "external reference is unavailable on MCP4725");
return -EINVAL; return -EINVAL;
...@@ -455,12 +455,12 @@ static int mcp4725_probe(struct i2c_client *client) ...@@ -455,12 +455,12 @@ static int mcp4725_probe(struct i2c_client *client)
indio_dev->name = id->name; indio_dev->name = id->name;
indio_dev->info = &mcp4725_info; indio_dev->info = &mcp4725_info;
indio_dev->channels = &mcp472x_channel[id->driver_data]; indio_dev->channels = &mcp472x_channel[chip_id];
indio_dev->num_channels = 1; indio_dev->num_channels = 1;
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, data->id == MCP4725 ? 3 : 4); err = i2c_master_recv(client, inbuf, chip_id == MCP4725 ? 3 : 4);
if (err < 0) { if (err < 0) {
dev_err(&client->dev, "failed to read DAC value"); dev_err(&client->dev, "failed to read DAC value");
...@@ -470,10 +470,10 @@ static int mcp4725_probe(struct i2c_client *client) ...@@ -470,10 +470,10 @@ static int mcp4725_probe(struct i2c_client *client)
data->powerdown = pd > 0; data->powerdown = pd > 0;
data->powerdown_mode = pd ? pd - 1 : 2; /* largest resistor to gnd */ data->powerdown_mode = pd ? pd - 1 : 2; /* largest resistor to gnd */
data->dac_value = (inbuf[1] << 4) | (inbuf[2] >> 4); data->dac_value = (inbuf[1] << 4) | (inbuf[2] >> 4);
if (data->id == MCP4726) if (chip_id == MCP4726)
ref = (inbuf[3] >> 3) & 0x3; ref = (inbuf[3] >> 3) & 0x3;
if (data->id == MCP4726 && ref != data->ref_mode) { if (chip_id == MCP4726 && ref != data->ref_mode) {
dev_info(&client->dev, dev_info(&client->dev,
"voltage reference mode differs (conf: %u, eeprom: %u), setting %u", "voltage reference mode differs (conf: %u, eeprom: %u), setting %u",
data->ref_mode, ref, data->ref_mode); data->ref_mode, ref, data->ref_mode);
......
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