[lkml]   [2017]   [Sep]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: libbattery was Re: [RFC PATCH 5/5] power: generic-adc-battery: Add capacity handling

> Am 08.09.2017 um 13:32 schrieb Pavel Machek <>:
> Hi!
>>> + {
>>> + int ret, curr, voltage;
>>> +
>>> + ret = read_channel(adc_bat, POWER_SUPPLY_PROP_CURRENT_NOW, &curr);
>>> + ret |= read_channel(adc_bat, POWER_SUPPLY_PROP_VOLTAGE_NOW, &voltage);
>>> + if (ret < 0)
>>> + goto err;
>>> +
>>> + val->intval = fuel_level_LiIon(voltage, curr, 10);
>>> + }
>>> + break;
>>> default:
>>> return -EINVAL;
>>> }
>> Without patch description: See Last Question in
>> Documentation/power/power_supply_class.txt

The main argument to answer with "Most likely, no" seems to be:

" as it would require floating point calculation to deal
with things like differential equations and Kalman filters."

The code shown above uses none of such things, hence the answer
could as well be "Yes, if it is simple enough to be handled by
the kernel with some lines of code and integer arithmetic".

> ...should be done in libbattery, yet to be written. :-).

For 10 years... Doesn't seem like anyone is waiting for it.

> Do you have specific guidance what you'd like to see in libbattery?

As a poor user I'd expect it to be available and widely accepted by
major distributions and battery monitoring applications in max. 3 months.

If that is not possible, I'd recommend to toss overboard a 10 years old
"maybe" rule and just fix the single problem once and for all in the
generic-adc-battery driver instead of dreaming of user space magically
solving problems where we already have a proposal for a kernel solution.

We should not forget that all this work is just to replace the pdata
based drivers/power/supply/twl4030_madc_battery.c with a proper and
more general DT based solution.

Nothing new, no rocket science (differential equations and Kalman filters)


[unhandled content-type:application/pgp-signature]
 \ /
  Last update: 2017-09-08 15:16    [W:0.053 / U:8.860 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site