Skip to contentSkip to conversation

power: bq20z75: Update return value of CURRENT NOW

PATCH In review rklein 3 participants 4 messages Dec 15, 2010 – Dec 21, 2010 1 message not in the archive

lore
Share & tools
lore

rklein

author
#0 lore raw

PATCH 1/1 power: bq20z75: Update return value of CURRENT NOW

The BQ20Z75 will return a negative value for current if the battery is discharging and a positive value if charging. This should always be exported
as a positive number.

---
 drivers/power/bq20z75.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/power/bq20z75.c +0 -0
index 492da27..a039ea0 100644
@@ -220,6 +220,10 @@ static int bq20z75_get_battery_property(struct

i2c_client *client,

        if (bq20z75_data[reg_offset].min_value < 0)
                ret = (s16)ret;

+ /* for current, it shoud be always positive */
+ if (psp == POWER_SUPPLY_PROP_CURRENT_NOW)
+ ret = abs(ret);
+

        if (ret >= bq20z75_data[reg_offset].min_value &&
            ret <= bq20z75_data[reg_offset].max_value) {
                val->intval = ret;

A message that is not in the archive (sent off-list or not yet received): 1292892862.12618.1.camel@rklein-linux2

#3 lore raw
Quoted 7 lines · rklein
Quoted 6 lines · Olof Johansson
Quoted 5 lines · rklein

The BQ20Z75 will return a negative value for current if the battery is discharging and a positive value if charging. This should always be exported
as a positive number.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

-Olof

Anton, is this patch ok to get put in?

I'm not sure. Probably not. Why would you think that the current should always be positive? For ds2760 it isn't, for example. If some driver assumes always positive current, I think it should be fixed instead.

If the battery is discharging, let it be negative. That's what happens on wires anyway. :-)

Signature · 2 lines
Anton Vorontsov
Email: [email protected]
author
#4 lore raw
Quoted 16 lines · Anton Vorontsov
Quoted 7 lines · rklein
Quoted 6 lines · Olof Johansson
Quoted 5 lines · rklein

The BQ20Z75 will return a negative value for current if the battery is discharging and a positive value if charging. This should always be exported
as a positive number.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

-Olof

Anton, is this patch ok to get put in?

Quoted 8 lines

I'm not sure. Probably not. Why would you think that the current should always be positive? For ds2760 it isn't, for example. If some driver assumes always positive current, I think it should be fixed instead.

If the battery is discharging, let it be negative. That's what happens on wires anyway. :-)

That makes sense to me, I will propose the change to the sw that was expecting the positive value.

-rhyland