From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753783AbdC0PBu (ORCPT ); Mon, 27 Mar 2017 11:01:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37290 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753732AbdC0PB2 (ORCPT ); Mon, 27 Mar 2017 11:01:28 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A4CE36AADE Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=benjamin.tissoires@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A4CE36AADE From: Benjamin Tissoires To: Jiri Kosina , Bastien Nocera Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 13/19] HID: logitech-hidpp: notify battery on connect Date: Mon, 27 Mar 2017 16:59:33 +0200 Message-Id: <20170327145939.29824-14-benjamin.tissoires@redhat.com> In-Reply-To: <20170327145939.29824-1-benjamin.tissoires@redhat.com> References: <20170327145939.29824-1-benjamin.tissoires@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 27 Mar 2017 15:00:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a device reconnects, there is a high chance its power supply has been changed (for a battery replacement for instance). Just forward the battery state here. Signed-off-by: Benjamin Tissoires --- changes in v3: - moved up in the series no changes in v2 --- drivers/hid/hid-logitech-hidpp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 22129dd..0781d2b 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -2463,6 +2463,13 @@ static void hidpp_connect_event(struct hidpp_device *hidpp) hidpp_initialize_battery(hidpp); + /* forward current battery state */ + if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { + hidpp20_query_battery_info(hidpp); + if (hidpp->battery.ps) + power_supply_changed(hidpp->battery.ps); + } + if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input) /* if the input nodes are already created, we can stop now */ return; -- 2.9.3