Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp288109imd; Fri, 2 Nov 2018 23:58:23 -0700 (PDT) X-Google-Smtp-Source: AJdET5dvQbNttcv4ZJdHUcgsd+alAumiFJF1qGwgWnM5G44zxgQKGE5FYF5aLSLqQeL/EIqoLxHh X-Received: by 2002:a17:902:28a2:: with SMTP id f31-v6mr14534477plb.312.1541228303636; Fri, 02 Nov 2018 23:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541228303; cv=none; d=google.com; s=arc-20160816; b=RD+VeAPbTlFcvNkrG23wlLNDX8CGnzoJJMF0qzvbU3Qu72j2UIsHNnn13W6PrR2gvH gqdLWi2RhkOH2e56BnqB+1KiMWyB2gQvTJSPEhhqKJ7AOpvLnFVL5m5r7vqNdm1Fnhub f0Ff35psv7QUWb4haIrr8+MH4tc2R4ABNtLgTKSkOUXl2WygORdJGFOOncPXc+5PFN5f 6wUxspInn/DZXU9gr+APszkP01bMceOJ7vr4lXcJH+LjokzXuf/wI1eMcmKx/KPiWeOs DpBirgUX6l7rO/a/WOxtSO69m2zmeUip/LzPfqM1cvY53pJMj6o75JoKBRL/goO+HkVL ebnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=6JHhrYkl8glioL91dogikLtzyd+0Fx0iTIucTVxzCO8=; b=T3R5Bsz/o9jGB5uAebWFBwE75TkULM/1JKVrV3DaTFwscyk1x3Bn6YLo7JE85HyKyh e+4xW4Lyk2HafW5hIBzQN8He1O4u9BvRTrzdWguCHGlF9OktwafI9X5Q4XbxYvDpjYFf dobyiNtb4iEi5apRdzyFdmta3I1vnavlXjLhMy4BKpoIhvovLfYve9Ioh5bFR+pTLHRg jHlA0CbqXz2nI2NySTI1rrtTTHK/ezGGEfa5aj1PGYQYuxyOmnqnGsp7CnSJSk2k3Csl YkSULEYQpJNVfzNxBj227GBNOpyb9kWID2VFIB8jNAlzE56xa3pJtY0Nuqg4+RBSgIhs Hv5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FrCmDJlg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u23-v6si35423378plk.47.2018.11.02.23.58.09; Fri, 02 Nov 2018 23:58:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FrCmDJlg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728149AbeKCQH5 (ORCPT + 99 others); Sat, 3 Nov 2018 12:07:57 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38981 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbeKCQH5 (ORCPT ); Sat, 3 Nov 2018 12:07:57 -0400 Received: by mail-pf1-f196.google.com with SMTP id n11-v6so2014460pfb.6; Fri, 02 Nov 2018 23:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6JHhrYkl8glioL91dogikLtzyd+0Fx0iTIucTVxzCO8=; b=FrCmDJlgjU6llk+hF1CExnJH0filDVHkKgJeE6AoCLRdHynuaxnz4amoqTMyRvu5Wm XH0b0GhY4uX6hJgCSbdk5kbmgcE46Ggoe7JQjGDSjGuJedJ4Vz5Ln+ONdxZukDe59yMu f+K6khesPwLpgzqpk9vuUc2iB04vN9uMVsXEk8TZTzfmEEW70QVFWTuOuDCMd1pXzf6+ 6ECo0Ygv1k9l7mWpF4PuXC7w2mJKRnHiNy0bbR5i9nfXDvESH9/JDTdn0FVk28wY/zo0 FA1o/KJ3iVZt/sa5uke9mnGsPnuPu0WwYXZRGv1gWIYGYMaoXSLoh+VPs/aai9QUuxF/ /czg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6JHhrYkl8glioL91dogikLtzyd+0Fx0iTIucTVxzCO8=; b=kiaP1U8SFAZHywjiQAlMfDafBB9WNgfoeLqSMzXAU3j0Z2Ckctxs89hJeWczzZmhGT wOXkBh8MbeImulE48WIcTTvYIbfNnn3vpmko11pN3+n+sOidf+7kk/N3dvga3z+wVqDt TbJ6FjpXmP2Fd/dVhTaJqt+014H8u54CWc1uiCwXDvrwMkxx1xW8cxpQPS43U8gxAfWo EMjkSYUve2l/2P1h0PEREO6teQjyXwqoqzcq4T7UZ6tLAtHnSJmQPDyR7tPW2wVGqF5w bSz+VGDqHxyQOZ39yUl4biQ3O/y0KBzKoASA/LWH9gLvkz5MpxTYM8MX4+PoG1bg91hI 2sFg== X-Gm-Message-State: AGRZ1gIlf8vaTiv+eQdgU1N0GpEojLfZoFB7M0YTax2+YxwgDcJpadXY lJNMm+2zvpe4ENLyPiv+kCoGd9+3 X-Received: by 2002:a63:e20a:: with SMTP id q10mr10560984pgh.206.1541228258374; Fri, 02 Nov 2018 23:57:38 -0700 (PDT) Received: from kiddo.endlessm-sf.com ([2601:602:9400:bc9f::3b0]) by smtp.gmail.com with ESMTPSA id k70-v6sm42030223pfc.76.2018.11.02.23.57.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Nov 2018 23:57:37 -0700 (PDT) From: "=?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?=" X-Google-Original-From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= To: "Rafael J . Wysocki" , Len Brown , Hans de Goede , linux-acpi@vger.kernel.org Cc: Daniel Drake , Sebastian Reichel , linux-kernel@vger.kernel.org, linux@endlessm.com, =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Subject: [PATCH] ACPI / battery: Fix reporting "Not charging" when capacity is 100% Date: Fri, 2 Nov 2018 23:57:32 -0700 Message-Id: <20181103065732.12134-1-jprvita@endlessm.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 19fffc8450d4378580a8f019b195c4617083176f fixed reporting "Discharging" on some machines when AC was connected but the battery was not charging. But now on these machines the battery status is reported as "Not charging" even when the battery is fully charged. This commit takes the battery capacity into consideration when checking if "Not charging" should be returned and "Full" is returned when the capacity is 100%. Signed-off-by: João Paulo Rechi Vita --- drivers/acpi/battery.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index cb97b6105f52..82e194290f01 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -217,8 +217,12 @@ static int acpi_battery_handle_discharging(struct acpi_battery *battery) * was plugged in and the device thus did not start a new charge cycle. */ if ((battery_ac_is_broken || power_supply_is_system_supplied()) && - battery->rate_now == 0) + battery->rate_now == 0) { + if (battery->capacity_now && battery->full_charge_capacity && + battery->capacity_now / battery->full_charge_capacity == 1) + return POWER_SUPPLY_STATUS_FULL; return POWER_SUPPLY_STATUS_NOT_CHARGING; + } return POWER_SUPPLY_STATUS_DISCHARGING; } -- 2.19.1