Message ID | c13fb8284b68cf3dbe309941d767aa7701aa4c3a.1566310292.git.michal.simek@xilinx.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | iio: adc: ina2xx: Improve device identification | expand |
On 20/08/2019 22:11, Michal Simek wrote: > There is no reason to c&p full client->dev.of_node link when simple > variable can keep it. One comment > > Signed-off-by: Michal Simek <michal.simek@xilinx.com> > --- > > drivers/iio/adc/ina2xx-adc.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c > index bdd7cba6f6b0..37058d9c2054 100644 > --- a/drivers/iio/adc/ina2xx-adc.c > +++ b/drivers/iio/adc/ina2xx-adc.c > @@ -951,6 +951,7 @@ static int ina2xx_probe(struct i2c_client *client, > struct ina2xx_chip_info *chip; > struct iio_dev *indio_dev; > struct iio_buffer *buffer; > + struct device_node *np = client->dev.of_node; > unsigned int val; > enum ina2xx_ids type; > int ret; > @@ -970,7 +971,7 @@ static int ina2xx_probe(struct i2c_client *client, > return PTR_ERR(chip->regmap); > } > > - if (client->dev.of_node) > + if (np) > type = (enum ina2xx_ids)of_device_get_match_data(&client->dev); > else > type = id->driver_data; > @@ -978,7 +979,7 @@ static int ina2xx_probe(struct i2c_client *client, > > mutex_init(&chip->state_lock); > > - if (of_property_read_u32(client->dev.of_node, > + if (of_property_read_u32(np, > "shunt-resistor", &val) < 0) { This will fit on one line <80 now. > struct ina2xx_platform_data *pdata = > dev_get_platdata(&client->dev); > @@ -1016,7 +1017,7 @@ static int ina2xx_probe(struct i2c_client *client, > > indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE; > indio_dev->dev.parent = &client->dev; > - indio_dev->dev.of_node = client->dev.of_node; > + indio_dev->dev.of_node = np; > if (id->driver_data == ina226) { > indio_dev->channels = ina226_channels; > indio_dev->num_channels = ARRAY_SIZE(ina226_channels); >
diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index bdd7cba6f6b0..37058d9c2054 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -951,6 +951,7 @@ static int ina2xx_probe(struct i2c_client *client, struct ina2xx_chip_info *chip; struct iio_dev *indio_dev; struct iio_buffer *buffer; + struct device_node *np = client->dev.of_node; unsigned int val; enum ina2xx_ids type; int ret; @@ -970,7 +971,7 @@ static int ina2xx_probe(struct i2c_client *client, return PTR_ERR(chip->regmap); } - if (client->dev.of_node) + if (np) type = (enum ina2xx_ids)of_device_get_match_data(&client->dev); else type = id->driver_data; @@ -978,7 +979,7 @@ static int ina2xx_probe(struct i2c_client *client, mutex_init(&chip->state_lock); - if (of_property_read_u32(client->dev.of_node, + if (of_property_read_u32(np, "shunt-resistor", &val) < 0) { struct ina2xx_platform_data *pdata = dev_get_platdata(&client->dev); @@ -1016,7 +1017,7 @@ static int ina2xx_probe(struct i2c_client *client, indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE; indio_dev->dev.parent = &client->dev; - indio_dev->dev.of_node = client->dev.of_node; + indio_dev->dev.of_node = np; if (id->driver_data == ina226) { indio_dev->channels = ina226_channels; indio_dev->num_channels = ARRAY_SIZE(ina226_channels);
There is no reason to c&p full client->dev.of_node link when simple variable can keep it. Signed-off-by: Michal Simek <michal.simek@xilinx.com> --- drivers/iio/adc/ina2xx-adc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)