From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA72BC433F5 for ; Tue, 16 Nov 2021 01:00:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3436617E4 for ; Tue, 16 Nov 2021 01:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243473AbhKPBDM (ORCPT ); Mon, 15 Nov 2021 20:03:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:44648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245720AbhKOTVF (ORCPT ); Mon, 15 Nov 2021 14:21:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0237163287; Mon, 15 Nov 2021 18:40:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637001608; bh=U6fQnsNKbPTE11NFNlm0+xZgCeG7JwAaZO672gNR+qs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VEUiCdYzBz2Ivn9mldFtBKKss5UAwxHj8KIc6q2J5pa+gWEC2DcD+KHs4oaCSoosm vln6Daf/9lYFE5CnfGP76HLCKduPeRXJAWs+uMkW++W0YuFI5n+i4PmGLbzL6KzeeB rSlXEZmNQnaUGAk6aTgzIB01qNFY/ceO8i28/744= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Andr=C3=A9=20Almeida?= , Hans de Goede , Sebastian Reichel , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.15 254/917] ACPI: battery: Accept charges over the design capacity as full Date: Mon, 15 Nov 2021 17:55:49 +0100 Message-Id: <20211115165437.397894404@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211115165428.722074685@linuxfoundation.org> References: <20211115165428.722074685@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: André Almeida [ Upstream commit 2835f327bd1240508db2c89fe94a056faa53c49a ] Some buggy firmware and/or brand new batteries can support a charge that's slightly over the reported design capacity. In such cases, the kernel will report to userspace that the charging state of the battery is "Unknown", when in reality the battery charge is "Full", at least from the design capacity point of view. Make the fallback condition accepts capacities over the designed capacity so userspace knows that is full. Signed-off-by: André Almeida Reviewed-by: Hans de Goede Reviewed-by: Sebastian Reichel Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index dae91f906cea9..8afa85d6eb6a7 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -169,7 +169,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery) return 1; /* fallback to using design values for broken batteries */ - if (battery->design_capacity == battery->capacity_now) + if (battery->design_capacity <= battery->capacity_now) return 1; /* we don't do any sort of metric based on percentages */ -- 2.33.0