]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
hwmon: ina230: fix negative power readings
authorDeepak Nibade <dnibade@nvidia.com>
Mon, 26 Aug 2013 13:47:33 +0000 (19:17 +0530)
committerDan Willemsen <dwillemsen@nvidia.com>
Tue, 17 Sep 2013 00:42:15 +0000 (17:42 -0700)
- show_power2 api calculates power using shunt voltage
- if shunt voltage is negative, power and current readings
  are also calculated negative
- fix this by taking absolute value of shunt voltage

Bug 1353426

Change-Id: I10deb33a0297af52da88385b105edd9bc2649d94
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/266129
(cherry picked from commit bdfa16243edcac9b07bbbe7133374494f4ef3b6f)
Reviewed-on: http://git-master/r/273608
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
drivers/hwmon/ina230.c

index 5766938996ea3e69a89eaf6589dbe70838616b84..b4788135ef03b1a52ba26866bd516801cf9bdbfe 100644 (file)
@@ -505,6 +505,7 @@ static s32 show_current2(struct device *dev,
        mutex_unlock(&data->mutex);
 
        voltage_uV = shuntv_register_to_uv(voltage_uV);
+       voltage_uV = abs(voltage_uV);
 
        inverse_shunt_resistor = 1000 / data->pdata->resistor;
        current_mA = voltage_uV * inverse_shunt_resistor / 1000;
@@ -594,6 +595,7 @@ static s32 show_power2(struct device *dev,
        voltage_mV = busv_register_to_mv(voltage_mV);
 
        voltage_uV = shuntv_register_to_uv(voltage_uV);
+       voltage_uV = abs(voltage_uV);
 
        inverse_shunt_resistor = 1000 / data->pdata->resistor;
        current_mA = voltage_uV * inverse_shunt_resistor / 1000;