Incorrect power supply type detection in upower

Vojtech Bocek vbocek at gmail.com
Wed Jun 4 15:56:12 PDT 2014


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 <hadess at hadess.net>:
> 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.
>


More information about the devkit-devel mailing list