power_supply: max17042: Add OF support for setting thresholds

The commit edd4ab0559 ("power: max17042_battery: add HEALTH and TEMP_*
properties support") added support for setting voltage and temperature
thresholds with platform data. For DeviceTree default of 0 was always
used.

This caused reporting battery health always as over voltage or
over heated.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
Fixes: edd4ab0559 ("power: max17042_battery: add HEALTH and TEMP_* properties support")
Signed-off-by: Sebastian Reichel <[email protected]>
This commit is contained in:
Krzysztof Kozlowski 2015-06-08 10:11:38 +09:00 • committed by Sebastian Reichel
commit a6e6b63ee2
2 changed files with 22 additions and 0 deletions

View file

@ -809,6 +809,15 @@ max17042_get_pdata(struct device *dev)
pdata->enable_current_sense = true;
}
if (of_property_read_s32(np, "maxim,cold-temp", &pdata->temp_min))
pdata->temp_min = INT_MIN;
if (of_property_read_s32(np, "maxim,over-heat-temp", &pdata->temp_max))
pdata->temp_max = INT_MAX;
if (of_property_read_s32(np, "maxim,dead-volt", &pdata->vmin))
pdata->vmin = INT_MIN;
if (of_property_read_s32(np, "maxim,over-volt", &pdata->vmax))
pdata->vmax = INT_MAX;
return pdata;
}
#else