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: 10465879 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 E54C0600F4 for ; Fri, 15 Jun 2018 08:32:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1EA3283C7 for ; Fri, 15 Jun 2018 08:32:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3EC728D0A; Fri, 15 Jun 2018 08:32:28 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 764C1283C7 for ; Fri, 15 Jun 2018 08:32:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Cc:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2ARUCx1yUMSooX7+c/zUyhPE39NWxCYkR2CW4Ja+Bew=; b=kohQgb0daPryuRb670Te2m/w2 AbiZ8+hdwH2vzZN3GnIAqMJ2oplGC4giaJGVV1Fy6a72/ZOAKfz6lmVt92otlFfeMNL8PETHFIkrY v1tR6UoSj/mxwjVCZxJo/wn+a5FfzcvB+tFdttNrf6voVFe8OiyHIK0w6WiCe55iTMBi9B4Iec3t/ Nb+X7i+eyYqu4FlrVOPOrXbI3aeOb1A/AAWZ5NcQocUA4CybOOwx4nPCPmSjPSwgTC2a3q/EF49YS gnkCENXfH4EbZFrGSY0/nxYDuKApfkv54nKPlblwz0X1PTdKu2uWZvxzn3B2avOZ+w9kMoO7JI7l6 kjhsWmfGg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTk9h-0006aS-TF; Fri, 15 Jun 2018 08:32:25 +0000 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTk9R-0006JW-UF for linux-arm-kernel@lists.infradead.org; Fri, 15 Jun 2018 08:32:22 +0000 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 In-Reply-To: <20180615080014.GA29192@amd> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180615_013210_153116_0369C448 X-CRM114-Status: GOOD ( 14.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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;