Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3758062imj; Tue, 19 Feb 2019 08:57:28 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib0ICSXEmH/nTuRXuZmwZqbU8vK6z3K5t+5n5QhA4M+rI0xXcJ0VFGSIX5Eg+JXS88yYW07 X-Received: by 2002:a63:d112:: with SMTP id k18mr9653801pgg.426.1550595448603; Tue, 19 Feb 2019 08:57:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550595448; cv=none; d=google.com; s=arc-20160816; b=lwjioUweoH5DExMvR8oDbux6U6Cb8eWZqdyqkQQwJtaEV9Luw8Lp531wqI8CBKWfS8 Lyej2wGe/4Az6Kjf5ZmnjDd+GG8b+cEQTpjUJCJW8iH1+cmmTJHh8VcMgkuzdbmPPwPT pvuCrAMdmbeHRxDMUwP1xR/5BBaiacYQWI6nB0o5pG7kqnm58F/SUFAarjR1Yc8mEnb2 ULNtaPLXMmbZSHSFJrvl0kBWMgaviuXh0dLc1pcZkMmgLIU/+aHtl03WgPswQWHORjn2 gionUf/IBK+sM+Bn42hOnveIoPkUKRzwM+PHkAq7Oj+HaKEZ01W5W69p8+z929ldlSo8 ScXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=M44LB+PRNgBsgOFKtCI0Ekh3VGZmiezY7ckDfddy4bc=; b=ubFBm8nTD4OWpcACX1ORIKf9zVPa+uRkiKUUEbwCl2YJ1Ki1LHF2mDRy2unuz2B43Z mfgh43Rj4tVaDdLMj8NPkwCZuMzVR/qMtei5E2RBoZbdmi5BpN7VCmS5hGh6NEDgGABw NaCW+bTiLncvTIPAWQlBUx4bEqkGbX+cDCNObP0bk76MqDDLMF7VXIJRWErA0VxR3erP p85qCDlpAWQbtMbNo0PQvpNCygksKViaJS2vfAwbwr5W6Ok5XJMrwKg1gQSVKznfBPxs +j+7cmV8jSPqP7wb66DIsl3hYpb9WtDRpOEtltxlSeayiTKgDYoVKvqy5vEkMP9CX17A EXDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=tVFnDAex; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t2si14317766pfh.52.2019.02.19.08.57.13; Tue, 19 Feb 2019 08:57:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@ti.com header.s=ti-com-17Q1 header.b=tVFnDAex; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729397AbfBSQzm (ORCPT + 99 others); Tue, 19 Feb 2019 11:55:42 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:53434 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726244AbfBSQzm (ORCPT ); Tue, 19 Feb 2019 11:55:42 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x1JGtdUj128305; Tue, 19 Feb 2019 10:55:39 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1550595339; bh=M44LB+PRNgBsgOFKtCI0Ekh3VGZmiezY7ckDfddy4bc=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=tVFnDAexACYNn4qjvpdoGdvwT2Q2KhEcTz82uskd5yGFbMfbV89WKPKBk42pStqnJ R0imCGXR4qIOr0AxYBSLgXyjRYY9Cu4MQNeCquKcT6J6GEb27vR4P7kzvVcdrTeY/y 6xGxGqKNBFH3QsT4Xh41xrHSANOiS2zRh4rIdVDE= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x1JGtddb032783 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 19 Feb 2019 10:55:39 -0600 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Tue, 19 Feb 2019 10:55:38 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Tue, 19 Feb 2019 10:55:38 -0600 Received: from [172.22.103.104] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id x1JGtbUE013939; Tue, 19 Feb 2019 10:55:38 -0600 Subject: Re: [PATCH] bq27x00: use cached flags To: Arthur Demchenkov CC: =?UTF-8?Q?Pali_Roh=c3=a1r?= , Sebastian Reichel , , References: <20190218065920.16205-1-spinal.by@gmail.com> From: "Andrew F. Davis" Message-ID: Date: Tue, 19 Feb 2019 10:55:37 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190218065920.16205-1-spinal.by@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/18/19 12:59 AM, Arthur Demchenkov wrote: > The flags were just read by bq27xxx_battery_update(), > no need to read them again. > > Signed-off-by: Arthur Demchenkov > --- Nothing obviously wrong with this patch so: Reviewed-by: Andrew F. Davis At this point we have W1 regmap and so we now have everything we should need to convert this driver over to regmap. Then the caching comes for free and a lot of checks and such can be dropped. Thanks, Andrew > drivers/power/supply/bq27xxx_battery.c | 20 ++++---------------- > 1 file changed, 4 insertions(+), 16 deletions(-) > > diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c > index 6dbbe95844a3..29b3a4056865 100644 > --- a/drivers/power/supply/bq27xxx_battery.c > +++ b/drivers/power/supply/bq27xxx_battery.c > @@ -1555,27 +1555,14 @@ static bool bq27xxx_battery_dead(struct bq27xxx_device_info *di, u16 flags) > return flags & (BQ27XXX_FLAG_SOC1 | BQ27XXX_FLAG_SOCF); > } > > -/* > - * Read flag register. > - * Return < 0 if something fails. > - */ > static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di) > { > - int flags; > - bool has_singe_flag = di->opts & BQ27XXX_O_ZERO; > - > - flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, has_singe_flag); > - if (flags < 0) { > - dev_err(di->dev, "error reading flag register:%d\n", flags); > - return flags; > - } > - > /* Unlikely but important to return first */ > - if (unlikely(bq27xxx_battery_overtemp(di, flags))) > + if (unlikely(bq27xxx_battery_overtemp(di, di->cache.flags))) > return POWER_SUPPLY_HEALTH_OVERHEAT; > - if (unlikely(bq27xxx_battery_undertemp(di, flags))) > + if (unlikely(bq27xxx_battery_undertemp(di, di->cache.flags))) > return POWER_SUPPLY_HEALTH_COLD; > - if (unlikely(bq27xxx_battery_dead(di, flags))) > + if (unlikely(bq27xxx_battery_dead(di, di->cache.flags))) > return POWER_SUPPLY_HEALTH_DEAD; > > return POWER_SUPPLY_HEALTH_GOOD; > @@ -1612,6 +1599,7 @@ void bq27xxx_battery_update(struct bq27xxx_device_info *di) > cache.capacity = bq27xxx_battery_read_soc(di); > if (di->regs[BQ27XXX_REG_AE] != INVALID_REG_ADDR) > cache.energy = bq27xxx_battery_read_energy(di); > + di->cache.flags = cache.flags; > cache.health = bq27xxx_battery_read_health(di); > } > if (di->regs[BQ27XXX_REG_CYCT] != INVALID_REG_ADDR) >