From patchwork Tue Mar 3 18:02:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristian Klausen X-Patchwork-Id: 229968 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FBB5C3F2C6 for ; Tue, 3 Mar 2020 18:02:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EDBF20866 for ; Tue, 3 Mar 2020 18:02:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=klausen.dk header.i=@klausen.dk header.b="UmSObYW4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388228AbgCCSCc (ORCPT ); Tue, 3 Mar 2020 13:02:32 -0500 Received: from mail.klausen.dk ([174.138.9.187]:34756 "EHLO mail.klausen.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388209AbgCCSCb (ORCPT ); Tue, 3 Mar 2020 13:02:31 -0500 From: Kristian Klausen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=klausen.dk; s=dkim; t=1583258548; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=z/KGfp2pJcneJByOd7eEODD0a+vDUElUqCBtaoU2vJU=; b=UmSObYW4lay58/CZqRQQyF016/siAveftwZyKM9BHdCt+gFa3BSnRyEBt1QkUod+dXVFyc jsqFVWmPUwVDhmFxCnBMs8yYtF8PJhds089SGDJiOdtL1xVyXrqzjll9SuL4uj1c+H2jW4 YAI+GqWrZ3jdOGXp41jore8AT78GIFc= To: platform-driver-x86@vger.kernel.org Cc: Kristian Klausen , stable@vger.kernel.org Subject: [PATCH v3] platform/x86: asus-wmi: Support laptops where the first battery is named BATT Date: Tue, 3 Mar 2020 19:02:15 +0100 Message-Id: <20200303180215.46791-1-kristian@klausen.dk> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The WMI method to set the charge threshold does not provide a way to specific a battery, so we assume it is the first/primary battery (by checking if the name is BAT0). On some newer ASUS laptops (Zenbook UM431DA) though, the primary/first battery isn't named BAT0 but BATT, so we need to support that case. Fixes: 7973353e92ee ("platform/x86: asus-wmi: Refactor charge threshold to use the battery hooking API") Cc: stable@vger.kernel.org Signed-off-by: Kristian Klausen --- I'm not sure if this is candidate for -stable, it fix a real bug (charge threshold doesn't work on newer ASUS laptops) which has been reported by a user[1], but is that enough? I had a quick look at[2], can this be considered a "something critical"? It "bothers people"[1]. My point: I'm not sure.. I'm unsure if there is a bettery way to fix this. Maybe a counter would be better (+1 for every new battery)? It would probably need to be atomic to prevent race condition (I'm not sure how this code is run), but this "fix" is way simpler. Please do not accept this patch just yet, I'm waiting for the tester to either confirm or deny credit[3]. [1] https://gist.github.com/klausenbusk/643f15320ae8997427155c38be13e445#gistcomment-3186025 [2] https://www.kernel.org/doc/html/v5.5/process/stable-kernel-rules.html [3] https://gist.github.com/klausenbusk/643f15320ae8997427155c38be13e445#gistcomment-3186429 v3: Add Fixes. v2: Add base commit Remove uneeded parenthesis and adjust styling drivers/platform/x86/asus-wmi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) base-commit: 11a48a5a18c63fd7621bb050228cebf13566e4d8 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 612ef5526226..01becbe2a9a8 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -426,8 +426,11 @@ static int asus_wmi_battery_add(struct power_supply *battery) { /* The WMI method does not provide a way to specific a battery, so we * just assume it is the first battery. + * Note: On some newer ASUS laptops (Zenbook UM431DA), the primary/first + * battery is named BATT. */ - if (strcmp(battery->desc->name, "BAT0") != 0) + if (strcmp(battery->desc->name, "BAT0") != 0 && + strcmp(battery->desc->name, "BATT") != 0) return -ENODEV; if (device_create_file(&battery->dev,