public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Andrew F. Davis" <afd@ti.com>
To: "H. Nikolaus Schaller" <hns@goldelico.com>,
	"Ivaylo Dimitrov" <ivo.g.dimitrov.75@gmail.com>,
	"Andrzej Hajda" <a.hajda@samsung.com>,
	"Pali Rohár" <pali.rohar@gmail.com>,
	"Sebastian Reichel" <sre@kernel.org>,
	"Dmitry Eremin-Solenikov" <dbaryshkov@gmail.com>,
	"David Woodhouse" <dwmw2@infradead.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	letux-kernel@openphoenux.org
Subject: Re: [PATCH] power:bq27xxx: 27000/10 read FLAGS register as single
Date: Tue, 26 Jul 2016 08:04:04 -0500	[thread overview]
Message-ID: <86b85127-3f2b-8b1f-a884-6431066636e6@ti.com> (raw)
In-Reply-To: <6ff28e18f78d1b9581cba5fd214fcc00e4a6d23a.1468858328.git.hns@goldelico.com>

On 07/18/2016 11:12 AM, H. Nikolaus Schaller wrote:
> The bq27000 and bq27010 have a single byte FLAGS register.
> Other gauges have 16 bit FLAGS registers.
> 
> For reading the FLAGS register it is sufficient to read the single
> register instead of reading RSOC at the next higher address as
> well and then ignore the high byte.
> 
> This does not change functionality but optimizes i2c and hdq
> traffic.
> 
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> ---

Matches the datasheet,

Acked-by: Andrew F. Davis <afd@ti.com>

>  drivers/power/bq27xxx_battery.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/bq27xxx_battery.c b/drivers/power/bq27xxx_battery.c
> index 45f6ebf..56712b2 100644
> --- a/drivers/power/bq27xxx_battery.c
> +++ b/drivers/power/bq27xxx_battery.c
> @@ -656,8 +656,9 @@ static bool bq27xxx_battery_dead(struct bq27xxx_device_info *di, u16 flags)
>  static int bq27xxx_battery_read_health(struct bq27xxx_device_info *di)
>  {
>  	int flags;
> +	bool has_singe_flag = di->chip == BQ27000 || di->chip == BQ27010;
>  
> -	flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, false);
> +	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;
> @@ -760,7 +761,7 @@ static int bq27xxx_battery_current(struct bq27xxx_device_info *di,
>  	}
>  
>  	if (di->chip == BQ27000 || di->chip == BQ27010) {
> -		flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, false);
> +		flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, true);
>  		if (flags & BQ27000_FLAG_CHGS) {
>  			dev_dbg(di->dev, "negative current!\n");
>  			curr = -curr;
> 

  parent reply	other threads:[~2016-07-26 13:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18 16:12 [PATCH] power:bq27xxx: 27000/10 read FLAGS register as single H. Nikolaus Schaller
2016-07-26  6:08 ` H. Nikolaus Schaller
2016-07-26  7:27 ` Pali Rohár
2016-07-26 13:04 ` Andrew F. Davis [this message]
2016-08-15 19:27 ` Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86b85127-3f2b-8b1f-a884-6431066636e6@ti.com \
    --to=afd@ti.com \
    --cc=a.hajda@samsung.com \
    --cc=dbaryshkov@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=hns@goldelico.com \
    --cc=ivo.g.dimitrov.75@gmail.com \
    --cc=letux-kernel@openphoenux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pali.rohar@gmail.com \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox