Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2870378rwb; Mon, 19 Sep 2022 11:11:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ppsIo/TV3lg6KwlZjmBqp/mUECp5T+DsJXmW3Woqy4cpK1EWG3LZHOVLRBXNFHxjnZ/AN X-Received: by 2002:a05:6a00:17a1:b0:542:be09:7b23 with SMTP id s33-20020a056a0017a100b00542be097b23mr20037574pfg.12.1663611099948; Mon, 19 Sep 2022 11:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663611099; cv=none; d=google.com; s=arc-20160816; b=UUi6PGMjB2hhB4lCYWErBNekI/K2H0Ob/UMumaQfB3rAck4Xp4IpvicqH80N6l8fUz NinO2eiSIRD2US54Ig9sgr1IuoSohcr2QZHUyFZP4fC0ZzYwGdFqcRGXsQEFUrmxd0FI T32R7/okixbSYktVKetzRXRaD135M91gBe3hgqI40M8bBSPPVHDbsoQmx9gDnAggr8VT JmpZTmCY1+G5Y8sMeucAXnjV5mjJdlfDZe4fFC7uhS/tQFhFvEM2lP6JheWfq6m8sWD9 KWlfhtvDRC+3ShaZQYdI+fOS3r5Pw8Gbzn10ChKy7fQjxAl9tzO/KU2W/Y+haKNZcRYq rCJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=dEokQm5n7CvZvcm2/TuaTTXN7aMhR9oWpeaOPSUYU4I=; b=HhbRUIRrhQDF8j3p6Zyvz/h60G4Z/9dur9oQwdeEsjKACAdeRR5AKWUNVDAtCnhihq UpOHAxKAVJoM40dbQv1NVVrOFgdVxztbvwXznOjXrt/8317xzNl8OHlZPgrBp+ogD9S7 qSgaoagPqt/2H/2j1wZt7ie1OQ6Q2yZoQBvv8Lk5rLl27FuKFEE3xdKKxNFeUyAXi137 kW9ep3/JIdF7vqpybyQfN0dP9aBKahwNSTfgRCuzjbjRJqt4yz52XawpD3TS99ABwNJ2 cJxc6uuTMK+bmBT9zr7cKkYH7Bqa173Rpu2T+f0aGNj/UrLaUBoQJAfrbMJMqRNF18Sd ZjBA== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a637547000000b004344757f354si348451pgn.668.2022.09.19.11.11.27; Mon, 19 Sep 2022 11:11:39 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229926AbiISQ1j (ORCPT + 99 others); Mon, 19 Sep 2022 12:27:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229663AbiISQ1h (ORCPT ); Mon, 19 Sep 2022 12:27:37 -0400 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 484F33B955; Mon, 19 Sep 2022 09:27:36 -0700 (PDT) Received: by mail-qk1-f177.google.com with SMTP id d17so20075054qko.13; Mon, 19 Sep 2022 09:27:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=dEokQm5n7CvZvcm2/TuaTTXN7aMhR9oWpeaOPSUYU4I=; b=2VB1+Tr3QCxgJH8CMgvGesRM8iys/5TAkWesrqMfkx2TTD+lFfC81RWae/u3/sgiqi u5IM7ISnTFLG6Pc3hTlDpEqf51p5QgoJ8yNm/1RaKrOwnVBw+BDIddCHeYS7DiTnNT+K 0ILoxd1n/2jMvghPUuXCkQ5MTbksVxl9cJVMLIuD6l5GKsXQZGRFQa5/ZlWqRm++h3Y7 vV4dti/OmiUT8LRIImLwY0O1LIARe7cCIYJs+txCUnQyhNcGK+S3NyOMhPSAj3PaMZcg /2h5Ws3tnxssuwkj6hrlWw4uvG0WPg0vjimRST7fLdd9mvsSryo8SjUbMHPx+blPTEFE PSvQ== X-Gm-Message-State: ACrzQf0rj2RXm/fckP1O+OoVg5RVUgF8eiAkxSYYNC3Ugi4E4iQlEcGB DDkbT3mKLHfHRY3WFPWAJQVUixF1+R7GEGGKEAPGZzQaBV8= X-Received: by 2002:a05:620a:2988:b0:6ce:cc3f:73b9 with SMTP id r8-20020a05620a298800b006cecc3f73b9mr10917915qkp.9.1663604855357; Mon, 19 Sep 2022 09:27:35 -0700 (PDT) MIME-Version: 1.0 References: <20220912125342.7395-1-W_Armin@gmx.de> <20220912125342.7395-2-W_Armin@gmx.de> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 19 Sep 2022 18:27:24 +0200 Message-ID: Subject: Re: [PATCH 1/5] ACPI: battery: Do not unload battery hooks on single error To: Hans de Goede Cc: Armin Wolf , Mark Gross , "Rafael J. Wysocki" , Len Brown , Henrique de Moraes Holschuh , Matan Ziv-Av , Corentin Chary , Jeremy Soller , productdev@system76.com, Platform Driver , ACPI Devel Maling List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Mon, Sep 19, 2022 at 12:42 PM Hans de Goede wrote: > > Hi, > > On 9/12/22 13:53, Armin Wolf wrote: > > 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 > > Maybe instead of removing all error checking, allow -ENODEV > and behave as before when the error is not -ENODEV ? > > Otherwise we should probably make the add / remove callbacks > void to indicate that any errors are ignored. > > Rafael, do you have any opinion on this? IMV this is not a completely safe change, because things may simply not work in the cases in which an error is returned. It would be somewhat better to use a special error code to indicate "no support" (eg. -ENOTSUPP) and ignore that one only. > > --- > > 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 > > --- 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_battery *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); > > } > > -- > > 2.30.2 > > >