Re: [PATCH 1/2] HID: logitech-hidpp: add battery support for HID++ 2.0 devices
From: Bastien Nocera
Date: Fri Jul 08 2016 - 10:36:21 EST
On Wed, 2016-06-29 at 19:28 +1000, Peter Hutterer wrote:
> +static int hidpp_battery_get_property(struct power_supply *psy,
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ enum power_supply_property psp,
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ union power_supply_propval
> *val)
> +{
> +ÂÂÂÂÂÂÂstruct hidpp_device *hidpp = power_supply_get_drvdata(psy);
> +ÂÂÂÂÂÂÂint ret = 0;
> +
> +ÂÂÂÂÂÂÂswitch(psp) {
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂcase POWER_SUPPLY_PROP_STATUS:
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂval->intval = hidpp->battery.status;
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbreak;
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂcase POWER_SUPPLY_PROP_CAPACITY:
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂval->intval = hidpp->battery.level;
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbreak;
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂdefault:
You forgot to handle POWER_SUPPLY_PROP_SCOPE. This means that UPower
thinks it's supplying power to the computer to which it is connected.
Should be set to "POWER_SUPPLY_SCOPE_DEVICE". This should fix it.