From patchwork Fri Jun 15 08:31:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 10465875 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7F943603B4 for ; Fri, 15 Jun 2018 08:32:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EBE4283C7 for ; Fri, 15 Jun 2018 08:32:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 636C428D0A; Fri, 15 Jun 2018 08:32:01 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,T_TVD_MIME_EPI 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 08A1A283C7 for ; Fri, 15 Jun 2018 08:32:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755968AbeFOIb7 (ORCPT ); Fri, 15 Jun 2018 04:31:59 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:58356 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755964AbeFOIb7 (ORCPT ); Fri, 15 Jun 2018 04:31:59 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 197868050E; Fri, 15 Jun 2018 10:31:58 +0200 (CEST) Date: Fri, 15 Jun 2018 10:31:56 +0200 From: Pavel Machek To: kernel list , linux-arm-kernel , linux-omap@vger.kernel.org, tony@atomide.com, sre@kernel.org, nekit1000@gmail.com, mpartap@gmx.net, merlijn@wizzup.org Subject: Re: Charge counter on droid 4 Message-ID: <20180615083156.GA32102@amd> References: <20180615080014.GA29192@amd> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180615080014.GA29192@amd> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri 2018-06-15 10:00:14, Pavel Machek wrote: > Hi! > > Droid 4 has non-removable battery, yet the charge counter is reset to > near zero on each boot of linux. > > Unfortunately, that makes charge counter pretty much useless on d4, as > the "battery full" and "battery empty" limits will be different during > each boot. Hmm, and could we refrain from providing "power" values? I was thinking great, we have hardware that does proper power measuerement for us. No.... it is driver providing synthetic values. As userland has enough information to do that itself, I believe we should not do this in kernel. Pavel diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c index 839e365..1610026 100644 --- a/drivers/power/supply/cpcap-battery.c +++ b/drivers/power/supply/cpcap-battery.c @@ -490,24 +490,6 @@ static int cpcap_battery_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_CHARGE_COUNTER: val->intval = latest->counter_uah; break; - case POWER_SUPPLY_PROP_POWER_NOW: - tmp = (latest->voltage / 10000) * latest->current_ua; - val->intval = div64_s64(tmp, 100); - break; - case POWER_SUPPLY_PROP_POWER_AVG: - if (cached) { - tmp = cpcap_battery_cc_get_avg_current(ddata); - tmp *= (latest->voltage / 10000); - val->intval = div64_s64(tmp, 100); - break; - } - sample = latest->cc.sample - previous->cc.sample; - accumulator = latest->cc.accumulator - previous->cc.accumulator; - tmp = cpcap_battery_cc_to_ua(ddata, sample, accumulator, - latest->cc.offset); - tmp *= ((latest->voltage + previous->voltage) / 20000); - val->intval = div64_s64(tmp, 100); - break; case POWER_SUPPLY_PROP_CAPACITY_LEVEL: if (cpcap_battery_full(ddata)) val->intval = POWER_SUPPLY_CAPACITY_LEVEL_FULL;