Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2940874rwb; Mon, 19 Sep 2022 12:20:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66pT4OkQeWJG52M71FceK+6m3/tDp7f+zADdq+X+SYrIiUFknKwyZgAEjbNUBWrxEKa/NS X-Received: by 2002:a17:906:6a07:b0:77c:936d:5092 with SMTP id qw7-20020a1709066a0700b0077c936d5092mr14173813ejc.167.1663615201719; Mon, 19 Sep 2022 12:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663615201; cv=none; d=google.com; s=arc-20160816; b=sMX29FOs76HpHKlhwjHk4WoUTH+BqjBJXWx8oQAqx7U7PgJFipiZ5lPnNsOoGvxWNC IUgULM0eh80zPxZgkxLvacqryHCa1Pgfp/Gice3kKqK5ozrfOwh+W5Ivr2ggEe3wo+9T X4w+RChM2N4OECA63WG/DnoI7q4ZOGgl13ixXw2ohU9vCZsaaQNYmW9GUXsWvzTbNkyd iS+gma3QPqz7/ryP1BbFMdXFh8UrHlC2WZAQrHDXhxnp3kEkGRriFS9bgHFMyBw+s0TA 9MJ8nNXIDy5z37bGCESDMGY3jAuLXMWRfbcyBh4d3zyPa0M6E3I0/6gXCuPqlwLC02dj O4Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=b1uKvq9W9dLsq8VQGdDpOz5/XIPg4EYTq9Za3LGqptc=; b=VsrQ7w6fA9Dm2QdoYncd7CT8poyKbD6uwBye7NIF3Xab5D8g3bdDFliLdiwWAFU/iw 5hJnYgQqrVk2FoKPXaX/l+PEdwxfbwfmqT5tcbBKWig2ssMQNFSNKYxcuOS0JODP1I/U 9gEeg7e8q5dtVk3H4QUvSVGJc4n2epg9WOBMOPbti86l+G9oWcAo4COdXlL1USV33UvS 7umbSHaFooilM0Il71pQrKbEVUSvdQ+wh4haY+jt46fePLFjoSqXNMwd+Xl3JhSOj9Lj cHZios3O7kbDNZYnYNAj74JuzEemnXF+dU0k7X1sS/e3wRVRjJbbSyINVYyjM9Vi/jtx i0ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=DtWw9Duy; 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 nb42-20020a1709071caa00b0073d9daaf4f3si30874827ejc.693.2022.09.19.12.19.36; Mon, 19 Sep 2022 12:20:01 -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=DtWw9Duy; 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 S229505AbiISTMT (ORCPT + 99 others); Mon, 19 Sep 2022 15:12:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbiISTMR (ORCPT ); Mon, 19 Sep 2022 15:12:17 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B37315724; Mon, 19 Sep 2022 12:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1663614722; bh=vsxyNPqECA66yaOhsz2gXtpE/um3nthTtnFhYLNOFPU=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=DtWw9DuyAWeKHjLe1m+BKX1gt189BUrk/Ksxh0glH1tQ6X50p74Y30Qu2fI8a7Yq6 W2bqn9RHidiav6l75RMLdt12F8skoGVyw4/E/aTrXu+0P89vEnXuBvVgN4F5/ny7tV LOuIZ4N9ZsKmbHhVp4avWE+J9rfw7kW9XPC4yGKM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [141.30.226.129] ([141.30.226.129]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MNsw4-1ouCOP3aiu-00OIt0; Mon, 19 Sep 2022 21:12:01 +0200 Subject: Re: [PATCH 1/5] ACPI: battery: Do not unload battery hooks on single error To: "Rafael J. Wysocki" , Hans de Goede Cc: Mark Gross , 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 References: <20220912125342.7395-1-W_Armin@gmx.de> <20220912125342.7395-2-W_Armin@gmx.de> From: Armin Wolf Message-ID: Date: Mon, 19 Sep 2022 21:12:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Provags-ID: V03:K1:Cj4c7h/B17rFacKbVdPkRfdMhKLXT9mkXLYu6pCzELjJ/MsLyFB 6s/5JApCGlvFFImHpJCmz0CIkyeJYmHXgi/aawm/ptXCIz3LynCMJXiE8tBRMBpRqdrYnL+ CyRAhAiObPKaT72AjWtrEal78E1BkCoxuY9xEkwrnoevvPNMJqmLMfRgZ9sdjZUDd3+lG2E Au7WMhqAZCG2UxXY1YF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KUSRovT6 g1JVe8fvGS1Ru3a056eaImZeorNoBc38l2FHMmEaNKXl5Um6hkDSYHydNf072ILRp1wi7zHpS UQ/PbMDB/lo+RCr9BOyt5Xyv6A0n1v2/XOX/yDNxO2W8rysmvOxddUhWBkQ9gRx0g0GjLlzFM vciUJoXhvm18ynEUAcaIfXmxRH X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,NICE_REPLY_A,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 Am 19.09.22 um 18:27 schrieb Rafael J. Wysocki: > 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. I would favor -ENODEV then, since it is already used by quiet a few drivers to indicate a unsupported battery. Armin Wolf >>> --- >>> 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 >>>