From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758470AbcGKKzF (ORCPT ); Mon, 11 Jul 2016 06:55:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40765 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752821AbcGKKzC (ORCPT ); Mon, 11 Jul 2016 06:55:02 -0400 Date: Mon, 11 Jul 2016 12:54:56 +0200 From: Benjamin Tissoires To: Bastien Nocera Cc: Peter Hutterer , Jiri Kosina , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Nestor Lopez Casado Subject: Re: [PATCH 1/2] HID: logitech-hidpp: add battery support for HID++ 2.0 devices Message-ID: <20160711105456.GA4663@mail.corp.redhat.com> References: <1467192482-2723-1-git-send-email-peter.hutterer@who-t.net> <1467988545.2317.4.camel@hadess.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1467988545.2317.4.camel@hadess.net> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 11 Jul 2016 10:55:02 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Jul 08 2016 or thereabouts, Bastien Nocera wrote: > 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. > > From 8fbfcfd411a4b2c55ec24adc8b8ecc0bca2db5e3 Mon Sep 17 00:00:00 2001 > From: Bastien Nocera > Date: Fri, 8 Jul 2016 16:34:18 +0200 > Subject: [PATCH] HID: logitech-hidpp: Add scope to battery > > Without a scope defined, UPower assumes that the battery is provide > power to the computer it's connected to, like a laptop battery or a UPS. > > Signed-off-by: Bastien Nocera FWIW, the following patch is: Reviewed-by: Benjamin Tissoires > --- > drivers/hid/hid-logitech-hidpp.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c > index 4eeb550..4aaf237 100644 > --- a/drivers/hid/hid-logitech-hidpp.c > +++ b/drivers/hid/hid-logitech-hidpp.c > @@ -761,6 +761,7 @@ static int hidpp20_battery_event(struct hidpp_device *hidpp, > static enum power_supply_property hidpp_battery_props[] = { > POWER_SUPPLY_PROP_STATUS, > POWER_SUPPLY_PROP_CAPACITY, > + POWER_SUPPLY_PROP_SCOPE, > }; > > static int hidpp_battery_get_property(struct power_supply *psy, > @@ -777,6 +778,9 @@ static int hidpp_battery_get_property(struct power_supply *psy, > case POWER_SUPPLY_PROP_CAPACITY: > val->intval = hidpp->battery.level; > break; > + case POWER_SUPPLY_PROP_SCOPE: > + val->intval = POWER_SUPPLY_SCOPE_DEVICE; > + break; > default: > ret = -EINVAL; > break; > -- > 2.7.4 >