Re: libbattery was Re: [RFC PATCH 5/5] power: generic-adc-battery: Add capacity handling

From: H. Nikolaus Schaller
Date: Fri Sep 08 2017 - 09:15:51 EST


Hi,

> Am 08.09.2017 um 13:32 schrieb Pavel Machek <pavel@xxxxxx>:
>
> Hi!
>
>>> + case POWER_SUPPLY_PROP_CAPACITY:
>>> + {
>>> + 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)
expected.

BR,
Nikolaus

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail