From patchwork Tue Jan 15 10:32:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10764271 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 50E2A13B4 for ; Tue, 15 Jan 2019 10:33:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 403C52B8FB for ; Tue, 15 Jan 2019 10:33:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 341EB2B96E; Tue, 15 Jan 2019 10:33:29 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 DDE8D2B8FB for ; Tue, 15 Jan 2019 10:33:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728894AbfAOKd1 (ORCPT ); Tue, 15 Jan 2019 05:33:27 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45337 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728879AbfAOKd1 (ORCPT ); Tue, 15 Jan 2019 05:33:27 -0500 Received: by mail-pg1-f195.google.com with SMTP id y4so1060189pgc.12 for ; Tue, 15 Jan 2019 02:33:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=dIyDlEhPk6JnUTXfldKLOjRO3WNV6b65BdAvK6H2ezc=; b=Idvhwjz2PCwfeCZlSfS8wWCImer2VupTl79ttniFdOy/ZB+YEuNAmrmVyyOmLkGq5D Dbv4rSDwlCtVk8Wt4wFSUwU1syU1szrBgfKGEKjXxsamyu1A3shEmeS0zJmYZ5W+RXBO OPZ7nV14PuHpDqoOPmRq9qwe8Gk6ATLWBL6CY= 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:in-reply-to :references:in-reply-to:references; bh=dIyDlEhPk6JnUTXfldKLOjRO3WNV6b65BdAvK6H2ezc=; b=mmH3ANQwElmk0OZELg5q7UyfkRYNE0Vk7wbZg6324prxykYHpf0KuRH0sIJmuWrlcK zVUBcwLiqnWmH4jA872BOKGf3Xy+ejl0+V0fghcZciiCnmZ7iVsJad7qLvJQj7cjxilg fUG69+J40nK/X+GC+jZOsJ1ZWr/wY24ixWVk1Hr8B/1nB48J7vmrpAJ7VeLUHjBpvYCv e3pYqwyjHMBUQY+lZg32ENvlBMPd4djwTKQQM1NKImQvtEwC3+RLXK+vqQSXgM11a74o qdYgwwIaFl+60IdQPDKw7KGRlQoyr9xRNcOYJrqgT4WxdsCG5e+C+Z1A8CVTS2A76Yxj yYTQ== X-Gm-Message-State: AJcUukfmSYKyqE+vuALWMnHCQhIN9mgV6VTPR8ic57+7vgWXAjp8AoKz C0ImYhjTBESpz7vgo8Z9JHqWWw== X-Google-Smtp-Source: ALg8bN5tPJ802wXKib0Xc/vXXsEVgz30eEx1kURE+RGxE654JSqnBiMyHcJwhhMu4sFSNmONVL88SQ== X-Received: by 2002:a62:cf02:: with SMTP id b2mr3364348pfg.183.1547548406698; Tue, 15 Jan 2019 02:33:26 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id d13sm5073957pfd.58.2019.01.15.02.33.22 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Jan 2019 02:33:25 -0800 (PST) From: Baolin Wang To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, broonie@kernel.org, zhang.lyra@gmail.com, orsonzhai@gmail.com Subject: [PATCH 3/4] power: supply: sc27xx: Fix the incorrect formula when converting capacity to coulomb counter Date: Tue, 15 Jan 2019 18:32:36 +0800 Message-Id: <7d23781552d6ff1fe6bbabfc56cbbb04d807fffa.1547544142.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <76a12fe5d0cc670266100b0587b047714c9a8a83.1547544142.git.baolin.wang@linaro.org> References: <76a12fe5d0cc670266100b0587b047714c9a8a83.1547544142.git.baolin.wang@linaro.org> In-Reply-To: <76a12fe5d0cc670266100b0587b047714c9a8a83.1547544142.git.baolin.wang@linaro.org> References: <76a12fe5d0cc670266100b0587b047714c9a8a83.1547544142.git.baolin.wang@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We should multiply the calibrated current data (cur_1000ma_adc) when converting current capacity (mAh) to coulomb counter, which can get an accurate coulomb counter from the fuel gauge controller. Signed-off-by: Baolin Wang --- drivers/power/supply/sc27xx_fuel_gauge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index 4926b8a..ea1349f 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -731,7 +731,7 @@ static int sc27xx_fgu_cap_to_clbcnt(struct sc27xx_fgu_data *data, int capacity) * Convert current capacity (mAh) to coulomb counter according to the * formula: 1 mAh =3.6 coulomb. */ - return DIV_ROUND_CLOSEST(cur_cap * 36, 10); + return DIV_ROUND_CLOSEST(cur_cap * 36 * data->cur_1000ma_adc, 10); } static int sc27xx_fgu_calibration(struct sc27xx_fgu_data *data)