From patchwork Fri Jul 8 14:35:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 9221079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6537C6044F for ; Fri, 8 Jul 2016 14:36:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 567CD287F7 for ; Fri, 8 Jul 2016 14:36:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B5CB28834; Fri, 8 Jul 2016 14:36:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B22C28838 for ; Fri, 8 Jul 2016 14:36:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755796AbcGHOgL (ORCPT ); Fri, 8 Jul 2016 10:36:11 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:48070 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755171AbcGHOf5 (ORCPT ); Fri, 8 Jul 2016 10:35:57 -0400 Received: from mfilter37-d.gandi.net (mfilter37-d.gandi.net [217.70.178.168]) by relay6-d.mail.gandi.net (Postfix) with ESMTP id 514CAFB8CA; Fri, 8 Jul 2016 16:35:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter37-d.gandi.net Received: from relay6-d.mail.gandi.net ([IPv6:::ffff:217.70.183.198]) by mfilter37-d.gandi.net (mfilter37-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id l-U6HxSBG0Fj; Fri, 8 Jul 2016 16:35:48 +0200 (CEST) X-Originating-IP: 83.155.44.161 Received: from classic (mon69-7-83-155-44-161.fbx.proxad.net [83.155.44.161]) (Authenticated sender: hadess@hadess.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 10561FB8CE; Fri, 8 Jul 2016 16:35:45 +0200 (CEST) Message-ID: <1467988545.2317.4.camel@hadess.net> Subject: Re: [PATCH 1/2] HID: logitech-hidpp: add battery support for HID++ 2.0 devices From: Bastien Nocera To: Peter Hutterer , Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Nestor Lopez Casado Date: Fri, 08 Jul 2016 16:35:45 +0200 In-Reply-To: <1467192482-2723-1-git-send-email-peter.hutterer@who-t.net> References: <1467192482-2723-1-git-send-email-peter.hutterer@who-t.net> X-Mailer: Evolution 3.20.3 (3.20.3-1.fc24) Mime-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Benjamin Tissoires Tested-by: Peter Hutterer --- 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;