diff mbox series

[1/2] iio: dac: mcp4725: Replace variable 'id' from struct mcp4725_data

Message ID 20230812115449.89942-2-biju.das.jz@bp.renesas.com (mailing list archive)
State Changes Requested
Headers show
Series Use i2c_get_match_data() for mcp4725 DAC | expand

Commit Message

Biju Das Aug. 12, 2023, 11:54 a.m. UTC
Replace the variable 'id' from struct mcp4725_data with local variable
chip_id in probe().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/iio/dac/mcp4725.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Marek Vasut Aug. 12, 2023, 4:18 p.m. UTC | #1
On 8/12/23 13:54, Biju Das wrote:
> Replace the variable 'id' from struct mcp4725_data with local variable
> chip_id in probe().

... because the id variable is not used elsewhere in the driver ?

It probably makes sense to add the reasoning into the commit message.
Biju Das Aug. 14, 2023, 8:18 a.m. UTC | #2
Hi Marek Vasut,

Thanks for the feedback.

> Subject: Re: [PATCH 1/2] iio: dac: mcp4725: Replace variable 'id' from
> struct mcp4725_data
> 
> On 8/12/23 13:54, Biju Das wrote:
> > Replace the variable 'id' from struct mcp4725_data with local variable
> > chip_id in probe().
> 
> ... because the id variable is not used elsewhere in the driver ?
> 
> It probably makes sense to add the reasoning into the commit message.

I thought it is understood from commit message. Ie, you are moving it from global to local, 

Jonathan, is it something you can do while applying, if it make sense?

Cheers,
Biju
diff mbox series

Patch

diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
index f4a3124d29f2..33a61f65bc25 100644
--- a/drivers/iio/dac/mcp4725.c
+++ b/drivers/iio/dac/mcp4725.c
@@ -32,7 +32,6 @@ 
 
 struct mcp4725_data {
 	struct i2c_client *client;
-	int id;
 	unsigned ref_mode;
 	bool vref_buffered;
 	u16 dac_value;
@@ -387,6 +386,7 @@  static int mcp4725_probe(struct i2c_client *client)
 	struct mcp4725_data *data;
 	struct iio_dev *indio_dev;
 	struct mcp4725_platform_data *pdata, pdata_dt;
+	int chip_id;
 	u8 inbuf[4];
 	u8 pd;
 	u8 ref;
@@ -399,9 +399,9 @@  static int mcp4725_probe(struct i2c_client *client)
 	i2c_set_clientdata(client, indio_dev);
 	data->client = client;
 	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
-		data->id = id->driver_data;
+		chip_id = id->driver_data;
 	pdata = dev_get_platdata(&client->dev);
 
 	if (!pdata) {
@@ -414,7 +414,7 @@  static int mcp4725_probe(struct i2c_client *client)
 		pdata = &pdata_dt;
 	}
 
-	if (data->id == MCP4725 && pdata->use_vref) {
+	if (chip_id == MCP4725 && pdata->use_vref) {
 		dev_err(&client->dev,
 			"external reference is unavailable on MCP4725");
 		return -EINVAL;
@@ -455,12 +455,12 @@  static int mcp4725_probe(struct i2c_client *client)
 
 	indio_dev->name = id->name;
 	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->modes = INDIO_DIRECT_MODE;
 
 	/* 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) {
 		dev_err(&client->dev, "failed to read DAC value");
@@ -470,10 +470,10 @@  static int mcp4725_probe(struct i2c_client *client)
 	data->powerdown = pd > 0;
 	data->powerdown_mode = pd ? pd - 1 : 2; /* largest resistor to gnd */
 	data->dac_value = (inbuf[1] << 4) | (inbuf[2] >> 4);
-	if (data->id == MCP4726)
+	if (chip_id == MCP4726)
 		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,
 			"voltage reference mode differs (conf: %u, eeprom: %u), setting %u",
 			data->ref_mode, ref, data->ref_mode);