Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5192191rwn; Mon, 12 Sep 2022 05:56:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR51CXwtJ0MTMDp/cK4/krwD/RHkw290cJCuRXqx0iOugACYme70ftyfOtgKZ3NsMi9KxsuW X-Received: by 2002:a17:907:7e91:b0:77c:3704:968c with SMTP id qb17-20020a1709077e9100b0077c3704968cmr5388861ejc.390.1662987388642; Mon, 12 Sep 2022 05:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662987388; cv=none; d=google.com; s=arc-20160816; b=TzJHi8j8159xJmiDE2fZL+ZKttNAVKcSGVM5BC2TA02P4h/20C1C9XttKOhE7h1Tcu +NDo3SdkUlAkfXAX25hvat7GnT6vKIJQTtBNgGJGVmo5z2uCA1T9wBdUzmHfDy5Gxdcr 2fv+POGtZvmc8ifYs72bsnta+xr6+fLxOzlYaDzhUWLF28LCzWuBY1f9I1EHFNLsZyS5 em53FhXzNq+0d+lAVVVPU+bH0y3SLKynmpOzEwZQBbUkNsv6YsAAbrZEYJ2JHueTulvM aNRLAgXIl/Ojlc05mw53Sr+4RhvAqkIUTIS01eDObxq8F23NS5y4AQ/O72/zsIPcDzxM 8GSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yUdaav70YC9qAaycxqiHa67YvT+xAkRd3XQZqD1GrNM=; b=ul7lEmCTG7J/ROrcNoStUffi0kENHAnIArYfJpkFZhRC7kAuZiKcEa/nhfedQd09C2 NAH7MROMi0LXG0oFpVZV3nxgfc15iCS0vizPp1ivL5U56bdZqNtvN3nDh/ORXzN8/+Tc gWn8iZMzTcYj/BfAjz+4CSecV3fz3fc1Sz4Fy7KLv7XJdpJhUtZRMdyrntc2HPb1n4Je G7WzvBRQUAH+DA0wGB9/tZJpdM4uK6v21/gSj27FHfYuhH2bwRBZ7G+GSYI9/3f5UDSq LGH2IKPc8IsxM0nhgo5xOukDMOn5QkXd7WX+rG2A9RCCVaEe+osBVRoI+Pvldi99pI90 s+YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=XuVJ05IM; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd42-20020a17090796aa00b0072f1c8d0e62si8728165ejc.95.2022.09.12.05.56.02; Mon, 12 Sep 2022 05:56:28 -0700 (PDT) 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.net header.s=badeba3b8450 header.b=XuVJ05IM; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229836AbiILMyF (ORCPT + 99 others); Mon, 12 Sep 2022 08:54:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229812AbiILMyA (ORCPT ); Mon, 12 Sep 2022 08:54:00 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD89C3869B; Mon, 12 Sep 2022 05:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1662987227; bh=XSwCs2/nfGyrdpEwoz6uFQ7g22hV+iNYaBeDGLIB9X4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=XuVJ05IMBrXvd5LjEfyIBcFmMsgz4URHCk6HBpo29p4xr0Yd8V5wISfxB140FFMqN V/7M7C8mwYOhgK9Wcud3s6CxYg3FpV+tvw/YIHFY5DPHf5VGTDDGn8WArx4VJyJ9E+ 5CP6C2q58I5hgCqpyxyoLvYTW+7R+iVpejsT7wF4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MuUj2-1pOAq83BRa-00rc7V; Mon, 12 Sep 2022 14:53:46 +0200 From: Armin Wolf To: hdegoede@redhat.com, markgross@kernel.org Cc: rafael@kernel.org, lenb@kernel.org, hmh@hmh.eng.br, matan@svgalib.org, corentin.chary@gmail.com, jeremy@system76.com, productdev@system76.com, platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] ACPI: battery: Do not unload battery hooks on single error Date: Mon, 12 Sep 2022 14:53:38 +0200 Message-Id: <20220912125342.7395-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220912125342.7395-1-W_Armin@gmx.de> References: <20220912125342.7395-1-W_Armin@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:opYKxNI6ldvV9CMPDs23nnkFLRX2RWCXenJp0Fy2cZzTkhBpHHL nYOJxT1/52Em+UtIES3UHRQJ2AOYeJc0+p16gvrPwNtsMt4fy2xMfYGtzz4miyINI963nV8 2vWpg8tfTlD1sLCUYlmrgKgh0G/U4iUzDnNgd0hVpIwBcbZYJPaI71L0BXmwWNmr2S0UF70 KNqsTvrMTRRgMwNz5Lg8w== X-UI-Out-Filterresults: notjunk:1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fsEt3AeaJbo8zMOFv9DGqP3jE0eJHW15oUEluqfGMkUSfLyOu8 guUdqPnmF5rg5yJdL2dIHGr26M7hNdPzV2CtEgp32N7WGqrWuRd6pR92sxr88vQP4Sk4P1byu n6Utp9PcbF7TiR5Vybg52f60eT X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Currently, battery hooks are being unloaded if they return an error when adding a single battery. This however also causes the removal of successfully added hooks if they return -ENODEV for a single unsupported battery. Do not unload battery hooks in such cases since the hook handles any cleanup actions. Signed-off-by: Armin Wolf =2D-- drivers/acpi/battery.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 306513fec1e1..e59c261c7c59 100644 =2D-- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -724,20 +724,10 @@ void battery_hook_register(struct acpi_battery_hook = *hook) * its attributes. */ list_for_each_entry(battery, &acpi_battery_list, list) { - if (hook->add_battery(battery->bat)) { - /* - * If a add-battery returns non-zero, - * the registration of the extension has failed, - * and we will not add it to the list of loaded - * hooks. - */ - pr_err("extension failed to load: %s", hook->name); - __battery_hook_unregister(hook, 0); - goto end; - } + hook->add_battery(battery->bat); } pr_info("new extension: %s\n", hook->name); -end: + mutex_unlock(&hook_mutex); } EXPORT_SYMBOL_GPL(battery_hook_register); @@ -762,15 +752,7 @@ static void battery_hook_add_battery(struct acpi_batt= ery *battery) * during the battery module initialization. */ list_for_each_entry_safe(hook_node, tmp, &battery_hook_list, list) { - if (hook_node->add_battery(battery->bat)) { - /* - * The notification of the extensions has failed, to - * prevent further errors we will unload the extension. - */ - pr_err("error in extension, unloading: %s", - hook_node->name); - __battery_hook_unregister(hook_node, 0); - } + hook_node->add_battery(battery->bat); } mutex_unlock(&hook_mutex); } =2D- 2.30.2