diff options
author | Deepak Nibade <dnibade@nvidia.com> | 2013-08-26 19:17:33 +0530 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2013-09-16 17:42:15 -0700 |
commit | a22e9ee8257a1b9c1820af52be406ba0d158a2af (patch) | |
tree | e49e2b1c58bfe77d521c2ea32a390686ae41f117 /drivers/hwmon | |
parent | b90c3489607328a20cf54c1819ff7f0425ebb33a (diff) |
hwmon: ina230: fix negative power readings
- 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>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/ina230.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/hwmon/ina230.c b/drivers/hwmon/ina230.c index 5766938996ea..b4788135ef03 100644 --- a/drivers/hwmon/ina230.c +++ b/drivers/hwmon/ina230.c @@ -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; |