mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-08 07:38:10 +00:00
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>
This commit is contained in:
parent
a0de56c81f
commit
001e2e730c
1 changed files with 12 additions and 13 deletions
|
@ -420,7 +420,6 @@ static const struct attribute_group ina226_group = {
|
||||||
static int ina2xx_probe(struct i2c_client *client,
|
static int ina2xx_probe(struct i2c_client *client,
|
||||||
const struct i2c_device_id *id)
|
const struct i2c_device_id *id)
|
||||||
{
|
{
|
||||||
struct ina2xx_platform_data *pdata;
|
|
||||||
struct device *dev = &client->dev;
|
struct device *dev = &client->dev;
|
||||||
struct ina2xx_data *data;
|
struct ina2xx_data *data;
|
||||||
struct device *hwmon_dev;
|
struct device *hwmon_dev;
|
||||||
|
@ -431,24 +430,24 @@ static int ina2xx_probe(struct i2c_client *client,
|
||||||
if (!data)
|
if (!data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (dev_get_platdata(dev)) {
|
|
||||||
pdata = dev_get_platdata(dev);
|
|
||||||
data->rshunt = pdata->shunt_uohms;
|
|
||||||
} else if (!of_property_read_u32(dev->of_node,
|
|
||||||
"shunt-resistor", &val)) {
|
|
||||||
data->rshunt = val;
|
|
||||||
} else {
|
|
||||||
data->rshunt = INA2XX_RSHUNT_DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set the device type */
|
/* set the device type */
|
||||||
data->kind = id->driver_data;
|
data->kind = id->driver_data;
|
||||||
data->config = &ina2xx_config[data->kind];
|
data->config = &ina2xx_config[data->kind];
|
||||||
|
|
||||||
if (data->rshunt <= 0 ||
|
if (of_property_read_u32(dev->of_node, "shunt-resistor", &val) < 0) {
|
||||||
data->rshunt > data->config->calibration_factor)
|
struct ina2xx_platform_data *pdata = dev_get_platdata(dev);
|
||||||
|
|
||||||
|
if (pdata)
|
||||||
|
val = pdata->shunt_uohms;
|
||||||
|
else
|
||||||
|
val = INA2XX_RSHUNT_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val <= 0 || val > data->config->calibration_factor)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
data->rshunt = val;
|
||||||
|
|
||||||
ina2xx_regmap_config.max_register = data->config->registers;
|
ina2xx_regmap_config.max_register = data->config->registers;
|
||||||
|
|
||||||
data->regmap = devm_regmap_init_i2c(client, &ina2xx_regmap_config);
|
data->regmap = devm_regmap_init_i2c(client, &ina2xx_regmap_config);
|
||||||
|
|
Loading…
Add table
Reference in a new issue