From patchwork Wed Aug 1 22:19:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 10553107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C59B15E9 for ; Wed, 1 Aug 2018 22:30:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BD762A8CB for ; Wed, 1 Aug 2018 22:30:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FE912A974; Wed, 1 Aug 2018 22:30:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81E4C2A905 for ; Wed, 1 Aug 2018 22:30:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726906AbeHBASB (ORCPT ); Wed, 1 Aug 2018 20:18:01 -0400 Received: from ned.t-8ch.de ([212.47.237.191]:48106 "EHLO ned.t-8ch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728708AbeHBASB (ORCPT ); Wed, 1 Aug 2018 20:18:01 -0400 From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1533161986; bh=HXyrnEyQgMTntDPqB9BHhXAy/uCNBJVdDie9QL0ObsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XTslZrhhFBRsCI2Ooj4fqb0whYloo4+roq7Ka2sao7Q5qUitCxdCogmHDDyk/YOcW zl6Ya0fkiLEOAgYzBAR8o/UeNRQH9w5sMTbsx/xGzbTBgfUBB9yntT6rLHKiSTsGlc lUQkLM76OkYpiSg2lXxY3lC+HcWRG7EhcUyRgL98= To: platform-driver-x86@vger.kernel.org, ibm-acpi-devel@lists.sourceforge.net Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Ognjen Galic Subject: [PATCH] platform/x86: thinkpad_acpi: Fix multi-battery bug Date: Thu, 2 Aug 2018 00:19:19 +0200 Message-Id: <20180801221919.19187-1-linux@weissschuh.net> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801114747.qrjclik665ya7oh5@khazad-dum.debian.net> References: <20180801114747.qrjclik665ya7oh5@khazad-dum.debian.net> Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The struct containing the supported operations for all batteries is being zeroed on each battery probe. This prevents all other batteries except the lastly probed one from being configured. --- drivers/platform/x86/thinkpad_acpi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 3dbff2dda9be..60de1c577ce0 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -9374,7 +9374,9 @@ static int tpacpi_battery_probe(int battery) { int ret = 0; - memset(&battery_info, 0, sizeof(struct tpacpi_battery_driver_data)); + memset(&battery_info.batteries[battery], 0, + sizeof(battery_info.batteries[battery])); + /* * 1) Get the current start threshold * 2) Check for support @@ -9616,6 +9618,8 @@ static const struct tpacpi_quirk battery_quirk_table[] __initconst = { static int __init tpacpi_battery_init(struct ibm_init_struct *ibm) { + memset(&battery_info, 0, sizeof(battery_info)); + tp_features.battery_force_primary = tpacpi_check_quirks( battery_quirk_table, ARRAY_SIZE(battery_quirk_table));