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: 155654 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4717798jaa; Tue, 15 Jan 2019 02:33:29 -0800 (PST) X-Google-Smtp-Source: ALg8bN48lTnw0ZXAeECVzyKnTF/pYoQF6zBEUF1ac4SSJqLvHTJO6Mxd1dLmNNM3dDgQgS1OaHhb X-Received: by 2002:a63:4101:: with SMTP id o1mr3157951pga.447.1547548409113; Tue, 15 Jan 2019 02:33:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547548409; cv=none; d=google.com; s=arc-20160816; b=yPtf6prSnM330WYFRGu1bdrePmCGoV1RD7foKzm7Mo8GFycc/PZFZdubfTue2L2PFC 1ZRjoKQxlb8eAXn6xUk8RZqptZM3rpA+LnadF3kzwEKjpstWjzlIJhZcfn/5rBMsUqH8 5f2XefIkDMp407jxBA9WITpvwOg6GatAJXt/g2yR2tTfcyTA/BDDmSvbN1QRxmqFj/BI rhQOKMESqh82wPswAmALiv1lPRoH6MJL3LAAP+p5FQLSP+ENLfIuqLew50JPuxo0X2cL Ukh5QEXMwBI125uuz5d+XOAn+M/vvEAzpiAKGE+7w+nmOc94gNdZs3KbXOrHHbBfn//e nIqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=dIyDlEhPk6JnUTXfldKLOjRO3WNV6b65BdAvK6H2ezc=; b=wYnJTXafJ2T9ijqDWk8Gh6qxmWTbaQ+jMnYg4KzMDgaYrmO1wv+8B2Ig5GZRDLCVZ7 xyoGgWocMKbgZUmM/uUZJdnpaysMC6Azc7i37NMXjiVLjB01Nv2oLJr4Kj3WaKLixNW/ Lbd1k/UUokPpuDeZyaHiAhs0MHi5aGBDrowt/F22KQgGSDieBK1Npib8tNY/QqhtXdd2 x/PKMaMrweMj5nemRzSws9JxlAHnYx+WbVIZDpMTTsGiUjfG3TqTg1YIrJNJi36SONPr n7H6H7ZZ4FVRS0qDpyU1jq1EGqoihY8q+ZIKpEyRcovZAnPzIpV22rcoZjhLcP9wVm1H 77WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Idvhwjz2; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si3157930pgk.183.2019.01.15.02.33.28; Tue, 15 Jan 2019 02:33:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=@linaro.org header.s=google header.b=Idvhwjz2; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728894AbfAOKd1 (ORCPT + 11 others); 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-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 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(-) -- 1.7.9.5 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)