Incorrect power supply type detection in upower

2014-06-04 Thread Vojtech Bocek
Hello,
on Google Nexus 5, there is a Linux kernel driver used to change
charging current according to battery's temperature (too hot -> lower
the current)[1]. This driver exports as type "BMS" (battery management
system, not present in vanilla kernel) in sysfs, and because upower
considers any unknown device which doesn't have an "online" file in
sysfs a battery, it thinks the device has two batteries. This causes
the GUI to report wrong battery percentage, because it adds values
from both "batteries" (one of which is always 0) and divides them by
two.

The point is I don't think defaulting to battery is a good idea. But I
don't know if it is okay not to - will it break stuff like UPS if
upower won't default to battery? What if we check for presence of
"capacity" file in sysfs (which that temperature driver doesn't have),
is that okay?

Basically, I'd like to get this properly fixed, but I don't know
enough about power supply devices to post a patch, so I'd be glad for
any input on this issue.

Thank you,
Vojtěch Boček

PS: This is a re-post of the same e-mail, because I wasn't registered
when I sent the first one and it doesn't seem to have made it to the
mailing list.

[1]: 
https://android.googlesource.com/kernel/msm/+/android-msm-hammerhead-3.4-kitkat-mr1/drivers/power/battery_temp_ctrl.c
___
devkit-devel mailing list
devkit-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/devkit-devel


Re: Incorrect power supply type detection in upower

2014-06-04 Thread Bastien Nocera
On Wed, 2014-06-04 at 22:34 +0200, Vojtech Bocek wrote:
> Hello,
> on Google Nexus 5, there is a Linux kernel driver used to change
> charging current according to battery's temperature (too hot -> lower
> the current)[1]. This driver exports as type "BMS" (battery management
> system, not present in vanilla kernel) in sysfs, and because upower
> considers any unknown device which doesn't have an "online" file in
> sysfs a battery, it thinks the device has two batteries. This causes
> the GUI to report wrong battery percentage, because it adds values
> from both "batteries" (one of which is always 0) and divides them by
> two.
> 
> The point is I don't think defaulting to battery is a good idea. But I
> don't know if it is okay not to - will it break stuff like UPS if
> upower won't default to battery? What if we check for presence of
> "capacity" file in sysfs (which that temperature driver doesn't have),
> is that okay?
> 
> Basically, I'd like to get this properly fixed, but I don't know
> enough about power supply devices to post a patch, so I'd be glad for
> any input on this issue.

Simply fix the driver to export a "type". That's the way you'd fix it
for any of the in-kernel drivers.

___
devkit-devel mailing list
devkit-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/devkit-devel


Re: Incorrect power supply type detection in upower

2014-06-04 Thread Vojtech Bocek
The driver exports type. It reads "BMS" (Battery Management System).
But upower doesn't know that type (it isn't in vanilla kernel) and
while detecting the power supply type[1], it defaults to battery for
any unknown power supply device type[2].

[1]: http://cgit.freedesktop.org/upower/tree/src/linux/up-device-supply.c#n955
[2]: http://cgit.freedesktop.org/upower/tree/src/linux/up-device-supply.c#n1019

2014-06-05 0:42 GMT+02:00 Bastien Nocera :
> On Wed, 2014-06-04 at 22:34 +0200, Vojtech Bocek wrote:
>> Hello,
>> on Google Nexus 5, there is a Linux kernel driver used to change
>> charging current according to battery's temperature (too hot -> lower
>> the current)[1]. This driver exports as type "BMS" (battery management
>> system, not present in vanilla kernel) in sysfs, and because upower
>> considers any unknown device which doesn't have an "online" file in
>> sysfs a battery, it thinks the device has two batteries. This causes
>> the GUI to report wrong battery percentage, because it adds values
>> from both "batteries" (one of which is always 0) and divides them by
>> two.
>>
>> The point is I don't think defaulting to battery is a good idea. But I
>> don't know if it is okay not to - will it break stuff like UPS if
>> upower won't default to battery? What if we check for presence of
>> "capacity" file in sysfs (which that temperature driver doesn't have),
>> is that okay?
>>
>> Basically, I'd like to get this properly fixed, but I don't know
>> enough about power supply devices to post a patch, so I'd be glad for
>> any input on this issue.
>
> Simply fix the driver to export a "type". That's the way you'd fix it
> for any of the in-kernel drivers.
>
___
devkit-devel mailing list
devkit-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/devkit-devel