Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp109914pxu; Tue, 24 Nov 2020 20:49:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+ZQVlo/gvjt0Sjloiv/OkIr7kMMaxyYUpSI/uARE0NI6che5UgAb9Rfu2mHFNZTuUnY6G X-Received: by 2002:a17:906:4551:: with SMTP id s17mr1498707ejq.545.1606279756285; Tue, 24 Nov 2020 20:49:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606279756; cv=none; d=google.com; s=arc-20160816; b=cGM5rcQe8dbXIgVerxXV6bbrAjMe8empfn2oj2lVSg1uV+JX4/1sMsmVHFXxADSGEA ynHNKKZLjFigAvJAw4fmRqFi7u3oZRmqhNvUBy9U6gcXjmWphVzZ+xSFVdYubOdkpVw9 pupRxiIJ/AOt1HqB6HQTCSfkJJcWTKzS9iYOK8qGPhWCmN2tDXETjGPVYDM7TTg+hT7j 836RnNYYs1UlAOmocMC9ZX9N42no9e5bdWPNKJfBGlsY52rMS98ZYK2Ywe7Blh3WycM3 T/+Wq8SoZpz20WYg6ztJBQv35vfVO9NjnaoNNZml1bh3dbUNTs3TYP/Dba2RxlTI9SFS p+kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:references:in-reply-to :message-id:date:subject:cc:to:from; bh=31E+xhELycjFr0YFRWpv3tXwc8K4W/DYxrqeNi9i9bU=; b=qZfDmoVcryyL09wQOnXi4a4CmbkqrE02Fo8X/x31JhwROScxF7KPi6cGotmqslXN1F fskaYAHlMjLYMsdDK9BfWFtzzbZ0Qjm4VECze7wWABf8/BIaU788CgtJsVBT0hQ6n/uB NV4vj46Gax4Tt/qSScIF2/uYZzJ1pTdk84qRiwZWcGs6o8EomslS61xHYWMNefAQaVPW ZHBcksKFA3g+8M/XeIL+xnfOhrjBQG6qW+QlPCXPTe/sGFZLOGO1FklzPsj5+1dw5Muj Ai8gzQ6kPCJh5wUt6VCwlkicUS3QOKeRqgRGy+owzAY+aMcq0k6b6FyiTtB0pUEOoc5S ba4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df6si521796edb.508.2020.11.24.20.48.52; Tue, 24 Nov 2020 20:49:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728036AbgKYErJ (ORCPT + 99 others); Tue, 24 Nov 2020 23:47:09 -0500 Received: from comms.puri.sm ([159.203.221.185]:48106 "EHLO comms.puri.sm" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726330AbgKYErJ (ORCPT ); Tue, 24 Nov 2020 23:47:09 -0500 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id 3FDC3E0399; Tue, 24 Nov 2020 20:47:09 -0800 (PST) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oYTaweB7_C_3; Tue, 24 Nov 2020 20:47:08 -0800 (PST) From: Sebastian Krzyszkowiak To: Sebastian Reichel Cc: Geordan Neukum , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@puri.sm Subject: [PATCH 3/4] power: max17042_battery: Take r_sns value into account in charge_counter Date: Wed, 25 Nov 2020 05:47:04 +0100 Message-ID: <146027451.poJRWWCWiI@pliszka> In-Reply-To: <2264396.HPVdm0XNkV@pliszka> References: <2264396.HPVdm0XNkV@pliszka> Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The default r_sns value was hardcoded there, so let's change it to the actually configured one. Signed-off-by: Sebastian Krzyszkowiak --- drivers/power/supply/max17042_battery.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 86adccb0f32d..26f6f89eb648 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -354,7 +354,8 @@ static int max17042_get_property(struct power_supply *psy, if (ret < 0) return ret; - val->intval = data * 1000 / 2; + data64 = sign_extend64(data, 15) * 5000000ll; + val->intval = div_s64(data64, chip->pdata->r_sns); break; case POWER_SUPPLY_PROP_TEMP: ret = max17042_get_temperature(chip, &val->intval); -- 2.29.2