Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4101664imj; Tue, 19 Feb 2019 15:32:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IZm/PTY672S5qZJPpb3wDrcqytQtv8fk2JtIjVsjd0nnM9wwnZvuQgYj4zu4JK1eoZDI6TF X-Received: by 2002:a62:6e07:: with SMTP id j7mr32638568pfc.135.1550619145533; Tue, 19 Feb 2019 15:32:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550619145; cv=none; d=google.com; s=arc-20160816; b=MubJC2tmReM5BNT345XxREWc6Ms39KLX6r1SUZwl1dCgY5/iXFCgfwbHC/7jnMxsB7 kLPTFQSxUi2Wv6i1pK0jbkszoQrkCGclIPoxDa8Q1xyRZ9RPblRGYge6qnWmYUgehoMJ w+KYXhwJhOLuypuj/ymxlchVqlHrNcFktyXS3Ddcm4vAyvcDamdBrqqg340+SAWpWNyM t1YvzrOnqz5tszGci9U7EhPFLuMKmsiX/LtI15dv0DHauZOGIvNSxCQ1X8No96wCtjAZ esAX/xuxkxpGUbC3FkM5XF8zHSXeH7Y8pziMoSk5UV1aqmExEUydL5yq5vwkbrPYeUMs Lh6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GEajHaBviVI+N0coqZfOplFXr/gFefKdHSV5QVQsMhw=; b=jxs9ekAszIF9vrQNXux8NbNOLuByPDv3VJBSICu9NU0i5fKxkdZuvvCXnfughmd3Vg /9qUsoJSX21luF9igjWsbr33gRxRc4NcUc5uxKXKpRCASIRaHAZ2rh1S5yqsFZBL/GtJ N3KkSVWyu3tQk5jarow2RjKF4LjN8oILWqt2Irwf5RgLBRshd3EpW3KSDXMuIxLmzdPR 9ZG128med1nBFyFYqfEWH+43O9VxjlBPBlYHSzuRL2tqyG4ZCJTd45IbUdhkk1PmCCBO KFkpfjAQT54Z9IYYse0gHvsdThV6ka0Xx4HgKU/z4vDqS8Nv+tBgI2FwznXEvNI6G9tj OHkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bEMcXfVl; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k21si16740406pgb.514.2019.02.19.15.32.10; Tue, 19 Feb 2019 15:32:25 -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=@kernel.org header.s=default header.b=bEMcXfVl; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730052AbfBSXaf (ORCPT + 99 others); Tue, 19 Feb 2019 18:30:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:38642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729700AbfBSXad (ORCPT ); Tue, 19 Feb 2019 18:30:33 -0500 Received: from earth.universe (unknown [185.216.33.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 592462147A; Tue, 19 Feb 2019 23:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550619032; bh=fWo1xkeeNjGWZo2YZUVhWLgi8eFQh0BY6waxHe8D1gc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bEMcXfVlwT5xhHDk2YszufV15IA2hVPjBa7CV6jf0PW+SY1eNjM1J/qy7vFVA07UZ +Ej6w2sGvTODqYXi3N+X2UAvDc72U5A8mcLf6SSucDSPwRF8sLV19JTXanC7/pv0aL zv9EzSA5uyJKNkzyJrXJXIRoTEaBPTE3nTKeb9x4= Received: by earth.universe (Postfix, from userid 1000) id 58B793C08DD; Wed, 20 Feb 2019 00:30:30 +0100 (CET) Date: Wed, 20 Feb 2019 00:30:30 +0100 From: Sebastian Reichel To: "Andrew F. Davis" Cc: Arthur Demchenkov , Pali =?utf-8?B?Um9ow6Fy?= , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] bq27x00: use cached flags Message-ID: <20190219233030.uo3akxvvf47ymxsg@earth.universe> References: <20190218065920.16205-1-spinal.by@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gt374reos3wdetyp" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --gt374reos3wdetyp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue, Feb 19, 2019 at 10:55:37AM -0600, Andrew F. Davis wrote: > 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. > >=20 > > Signed-off-by: Arthur Demchenkov > > --- >=20 > Nothing obviously wrong with this patch so: >=20 > Reviewed-by: Andrew F. Davis >=20 > 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. Yes, bq27xxx could be simplified a lot by converting to regmap and a patch would be appreciated. This register cannot be cached by regmap, though. Regmap caching is only for registers, that are not modified by the hardware (except during reset). Thanks for the patch and the review, I just merged this to power-supply-nex= t. -- Sebastian >=20 > Thanks, > Andrew >=20 > > drivers/power/supply/bq27xxx_battery.c | 20 ++++---------------- > > 1 file changed, 4 insertions(+), 16 deletions(-) > >=20 > > diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/sup= ply/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); > > } > > =20 > > -/* > > - * 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 =3D di->opts & BQ27XXX_O_ZERO; > > - > > - flags =3D 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; > > =20 > > return POWER_SUPPLY_HEALTH_GOOD; > > @@ -1612,6 +1599,7 @@ void bq27xxx_battery_update(struct bq27xxx_device= _info *di) > > cache.capacity =3D bq27xxx_battery_read_soc(di); > > if (di->regs[BQ27XXX_REG_AE] !=3D INVALID_REG_ADDR) > > cache.energy =3D bq27xxx_battery_read_energy(di); > > + di->cache.flags =3D cache.flags; > > cache.health =3D bq27xxx_battery_read_health(di); > > } > > if (di->regs[BQ27XXX_REG_CYCT] !=3D INVALID_REG_ADDR) > >=20 --gt374reos3wdetyp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlxskZMACgkQ2O7X88g7 +ppFag/8Cm5PzVT+V0CTAJcdVmSmW2D3uTcE4OkT+zftbiyiqPnI31P+7rJ8MDoE zl+ruccb6ZUp7ngncYfSXcJpGlIo6x5yVfFe+ZNFzn3oWCbSHHfZFW7guVyeVua5 mP4hHR8Q0EWfJld0mAHmqFWKUbq+Fkc2mQTRZRlomlzKyJYRXkKO0zrLTZscDTlZ eC08urUkv8AZOIcNS23dG4kdaEqXtokQ2z1f1JznRo/DrGTJWoNRmX33O+D5vJpe u0DW6S6lcWWadMGB5uIRODzjyds7dikF+v3nq4ojw+66VZmyvALD62zrdIuB2oYI lPA050JNjJ6ELoWhTUYJr70GEtRoJ40ygQLi7+Tj6XlbSwc8yZ+HX0N1Z2Hl7j9e eZ9UxRkXOrkpo+bjFOCUCdK0Z2v/t7vhaMQrRTvobIm9BpOAO5GCx8Eh7UO1KXnG k+PObGKxQqwkYISApUOvkF/7asCxRsuLo1zc6qFN28lqDm+GJAHdu/h3cs4DP0hg ZbuKhjw5W5ItsI48ZADxLY2yrsiF2ngsZmyaLnKMlL8Jqcw5dXDv5q++yC0M79QU jagWz8AcJK5XAh+H1cNe/ccCGfBGgd1AY21e83ydE/aBd9KedMLt9YR/nZe6FuTt GZkOaUlVCYoHLTo8nCz7O8VVG4rV3Z8VsHZ3Usclqc4KhbKU4iw= =3O4w -----END PGP SIGNATURE----- --gt374reos3wdetyp--