* [PATCH 1/1] power: bq20z75: Update return value of CURRENT NOW @ 2010-12-15 1:01 rklein 2010-12-15 3:04 ` Olof Johansson 0 siblings, 1 reply; 4+ messages in thread From: rklein @ 2010-12-15 1:01 UTC (permalink / raw) To: Anton Vorontsov; +Cc: Andrew Chew, olof@lixom.net, linux-kernel@vger.kernel.org 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. Signed-off-by: Rhyland Klein <rklein@nvidia.com> --- drivers/power/bq20z75.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/power/bq20z75.c b/drivers/power/bq20z75.c index 492da27..a039ea0 100644 --- a/drivers/power/bq20z75.c +++ b/drivers/power/bq20z75.c @@ -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; ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] power: bq20z75: Update return value of CURRENT NOW 2010-12-15 1:01 [PATCH 1/1] power: bq20z75: Update return value of CURRENT NOW rklein @ 2010-12-15 3:04 ` Olof Johansson [not found] ` <1292892862.12618.1.camel@rklein-linux2> 0 siblings, 1 reply; 4+ messages in thread From: Olof Johansson @ 2010-12-15 3:04 UTC (permalink / raw) To: rklein; +Cc: Anton Vorontsov, Andrew Chew, linux-kernel@vger.kernel.org On Tue, Dec 14, 2010 at 05:01:25PM -0800, rklein wrote: > 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. > > Signed-off-by: Rhyland Klein <rklein@nvidia.com> Reviewed-by: Olof Johansson <olof@lixom.net> -Olof ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <1292892862.12618.1.camel@rklein-linux2>]
* Re: [PATCH 1/1] power: bq20z75: Update return value of CURRENT NOW [not found] ` <1292892862.12618.1.camel@rklein-linux2> @ 2010-12-21 23:22 ` Anton Vorontsov 2010-12-21 23:41 ` rklein 0 siblings, 1 reply; 4+ messages in thread From: Anton Vorontsov @ 2010-12-21 23:22 UTC (permalink / raw) To: rklein; +Cc: linux-kernel@vger.kernel.org, Andrew Chew, Olof Johansson On Mon, Dec 20, 2010 at 04:54:22PM -0800, rklein wrote: > On Tue, 2010-12-14 at 19:04 -0800, Olof Johansson wrote: > > On Tue, Dec 14, 2010 at 05:01:25PM -0800, rklein wrote: > > > 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. > > > > > > Signed-off-by: Rhyland Klein <rklein@nvidia.com> > > > > Reviewed-by: Olof Johansson <olof@lixom.net> > > > > -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. :-) -- Anton Vorontsov Email: cbouatmailru@gmail.com ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] power: bq20z75: Update return value of CURRENT NOW 2010-12-21 23:22 ` Anton Vorontsov @ 2010-12-21 23:41 ` rklein 0 siblings, 0 replies; 4+ messages in thread From: rklein @ 2010-12-21 23:41 UTC (permalink / raw) To: Anton Vorontsov; +Cc: linux-kernel@vger.kernel.org, Andrew Chew, Olof Johansson On Tue, 2010-12-21 at 15:22 -0800, Anton Vorontsov wrote: > On Mon, Dec 20, 2010 at 04:54:22PM -0800, rklein wrote: > > On Tue, 2010-12-14 at 19:04 -0800, Olof Johansson wrote: > > > On Tue, Dec 14, 2010 at 05:01:25PM -0800, rklein wrote: > > > > 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. > > > > > > > > Signed-off-by: Rhyland Klein <rklein@nvidia.com> > > > > > > Reviewed-by: Olof Johansson <olof@lixom.net> > > > > > > -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. :-) > That makes sense to me, I will propose the change to the sw that was expecting the positive value. -rhyland ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-12-21 23:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-15 1:01 [PATCH 1/1] power: bq20z75: Update return value of CURRENT NOW rklein
2010-12-15 3:04 ` Olof Johansson
[not found] ` <1292892862.12618.1.camel@rklein-linux2>
2010-12-21 23:22 ` Anton Vorontsov
2010-12-21 23:41 ` rklein
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox