aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Titinger <mtitinger@baylibre.com>2015-10-27 05:51:08 -0400
committerGuenter Roeck <linux@roeck-us.net>2015-10-29 00:53:15 -0400
commit001e2e730ce4e6dc2cd97fcb169097febfc7b200 (patch)
treeb35a1685846d33889e454f81541a377edaeb77e7
parenta0de56c81fcf9f1a691e22e519b0dff21c48c645 (diff)
hwmon: (ina2xx) give precedence to DT over checking for platform data.
when checking for the value of the shunt resistor. Signed-off-by: Marc Titinger <mtitinger@baylibre.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/ina2xx.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index 96862c6eae74..1ba0c72c2b8f 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -420,7 +420,6 @@ static const struct attribute_group ina226_group = {
420static int ina2xx_probe(struct i2c_client *client, 420static int ina2xx_probe(struct i2c_client *client,
421 const struct i2c_device_id *id) 421 const struct i2c_device_id *id)
422{ 422{
423 struct ina2xx_platform_data *pdata;
424 struct device *dev = &client->dev; 423 struct device *dev = &client->dev;
425 struct ina2xx_data *data; 424 struct ina2xx_data *data;
426 struct device *hwmon_dev; 425 struct device *hwmon_dev;
@@ -431,24 +430,24 @@ static int ina2xx_probe(struct i2c_client *client,
431 if (!data) 430 if (!data)
432 return -ENOMEM; 431 return -ENOMEM;
433 432
434 if (dev_get_platdata(dev)) {
435 pdata = dev_get_platdata(dev);
436 data->rshunt = pdata->shunt_uohms;
437 } else if (!of_property_read_u32(dev->of_node,
438 "shunt-resistor", &val)) {
439 data->rshunt = val;
440 } else {
441 data->rshunt = INA2XX_RSHUNT_DEFAULT;
442 }
443
444 /* set the device type */ 433 /* set the device type */
445 data->kind = id->driver_data; 434 data->kind = id->driver_data;
446 data->config = &ina2xx_config[data->kind]; 435 data->config = &ina2xx_config[data->kind];
447 436
448 if (data->rshunt <= 0 || 437 if (of_property_read_u32(dev->of_node, "shunt-resistor", &val) < 0) {
449 data->rshunt > data->config->calibration_factor) 438 struct ina2xx_platform_data *pdata = dev_get_platdata(dev);
439
440 if (pdata)
441 val = pdata->shunt_uohms;
442 else
443 val = INA2XX_RSHUNT_DEFAULT;
444 }
445
446 if (val <= 0 || val > data->config->calibration_factor)
450 return -ENODEV; 447 return -ENODEV;
451 448
449 data->rshunt = val;
450
452 ina2xx_regmap_config.max_register = data->config->registers; 451 ina2xx_regmap_config.max_register = data->config->registers;
453 452
454 data->regmap = devm_regmap_init_i2c(client, &ina2xx_regmap_config); 453 data->regmap = devm_regmap_init_i2c(client, &ina2xx_regmap_config);