From patchwork Wed Nov 30 18:41:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 27955 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1090068wrr; Wed, 30 Nov 2022 10:42:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf5U/mljtuCIHJR9B1QDL07/8C6z9SDGRPWCB92Ck472m6XaEo6xIbTzCLgUlUg6T43+IS2x X-Received: by 2002:a05:6a00:2181:b0:574:5c9e:c1f2 with SMTP id h1-20020a056a00218100b005745c9ec1f2mr37537380pfi.52.1669833733031; Wed, 30 Nov 2022 10:42:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669833733; cv=none; d=google.com; s=arc-20160816; b=vfvu/wtfdT+D/cBkQiSNEEFjTcJQVcU6OEYSd2EYPtUgpeAer42MOwZ9sfuW/R9w56 pDS+TvmnB0IXBVpnyK2e4QDyE37p3A1Fr/BK9iF0X3ixJt0wxTADncdZmZv97Dus6P6O QYJ6XfbJRdOlPFoIiDcJI4e3mK5J199u52/IpMAX0k3QwGGXE6dgJYIY2oiT2IEmUaEP 1KT10o4+GWRuaOPSGXAGOCfrhKXl+6///LNP/zTf7a8XCCwI/4tKCTcqxNCrK0/wx6Dm yF4/irHVEHlBsGypyn1DFon3FBfGD/dUvH5DMNfe1E8elhQWMAcdp6Xhk+pv+JN4VUcG yAgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=vzHW9Gtum4bZG3cREv3RQpTlZ6p75JySURMrzW0Mlhg=; b=LBqOS2WCplULnt9BcivzqY+jD9uZoxpnlrkdGUF7RIIzF4O3KaCE4KrQGYN3/uO9Zm cMkuRZwL6tZaz0ZRShMd1rFHELb60fcKm1GQMB3LEkaZEaPaFh3EHTkXXh1mjDwv5rwt IgkxOiQpXbIvL3Vow+HfyaB1ibaDOS7mP992vlPVXlTs3nChiaJP2ciPwlUnu9f9pE+N zTJkVQxrGSga63CxLbeFy/3ynjDFh049iHnP7D9s6+B4zJPigaGjKAiBXTTRwcqiXKnA iNupJPVLvsoWtrRZDyt3MJVx6VolSIfS1oDVTnYZgGfDQ6y6kkNaeu+sNiTP6SrFdVTx n7bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=eLTGK2Cr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a056a0010c800b0057610dcbdbbsi284704pfu.37.2022.11.30.10.41.59; Wed, 30 Nov 2022 10:42:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=eLTGK2Cr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231199AbiK3Slc (ORCPT + 99 others); Wed, 30 Nov 2022 13:41:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231201AbiK3SlU (ORCPT ); Wed, 30 Nov 2022 13:41:20 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6117A98947; Wed, 30 Nov 2022 10:41:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1669833667; bh=vgKVPXmvYqutJBkLIGS/n+sdxLzPLkmkKPGB9sgdkpE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=eLTGK2Crx7cXcz72ruhuZmROWdSjeQL/tU6MqQ2/ltbrLWebl/By1SoGSWw5dDrT6 d/HsUWWiDNuYfY1c1Di0y+Rzjkjr0UYdGIpe976fqNeyPOCOQagUoxfom2U7JuL0CR RpYvI0Amu+1GwoFh+MzX6WsDeYZyOt8P0QF7bIi01UbUo3JAv9pnUONlMX1rAVibPs GgFfqBXlveNQXbKhnXJAPmNc0cj5InLXCaVAFv7jmfBMsFhXCbHJZLhjoZslTG/r2u BcHlDEPQV4H42DfqXMdGnEUMBLT3kmENSpxGXrEAq9sgNCxsDLx4z+q97vd17sjQwd NTfpRXDAZfHfg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N3siG-1orY150AVs-00zl5t; Wed, 30 Nov 2022 19:41:07 +0100 From: Armin Wolf To: rafael@kernel.org, hdegoede@redhat.com Cc: lenb@kernel.org, markgross@kernel.org, linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ACPI: battery: Call power_supply_changed() when adding hooks Date: Wed, 30 Nov 2022 19:41:01 +0100 Message-Id: <20221130184101.357899-1-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Provags-ID: V03:K1:v2Ti+bj8vLJsIA+n83Ulg5oP9sdjSkk1OPNXdaafMgk/8ZrVwh2 S+E+4dEVKzZ2jX9/oZGnbbLkLWZJ/vlR7ICG1Z/m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3Jvj9xHHa8OXR1g4vbCqXLUG9JdvZbN8lmoWbuIp24NWuEJ2uQxZ+Qb8ajypW1m1M 7kSVUpUQGDEa/8ATFqUzzGn5CCI= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750947576464134881?= X-GMAIL-MSGID: =?utf-8?q?1750947576464134881?= If a battery hook is added to a battery, userspace software is not informed that the available properties of the battery might have changed. This for example causes upower to react slowly if a new battery hook is added during runtime. Fix this by calling power_supply_changed() if a battery hook was successfully added/removed. Tested on a Dell Inspiron 3505. Signed-off-by: Armin Wolf --- drivers/acpi/battery.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.30.2 diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 9482b0b6eadc..bf99053e5021 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -696,7 +696,8 @@ static void __battery_hook_unregister(struct acpi_battery_hook *hook, int lock) if (lock) mutex_lock(&hook_mutex); list_for_each_entry(battery, &acpi_battery_list, list) { - hook->remove_battery(battery->bat, hook); + if (!hook->remove_battery(battery->bat, hook)) + power_supply_changed(battery->bat); } list_del(&hook->list); if (lock) @@ -735,6 +736,8 @@ void battery_hook_register(struct acpi_battery_hook *hook) __battery_hook_unregister(hook, 0); goto end; } + + power_supply_changed(battery->bat); } pr_info("new extension: %s\n", hook->name); end: