* [PATCH] power:bq27xxx: 27000/10 read FLAGS register as single
@ 2016-07-18 16:12 H. Nikolaus Schaller
2016-07-26 6:08 ` H. Nikolaus Schaller
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: H. Nikolaus Schaller @ 2016-07-18 16:12 UTC (permalink / raw)
To: Andrew F . Davis, Ivaylo Dimitrov, Andrzej Hajda, Pali Rohár,
Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse
Cc: linux-pm, linux-kernel, letux-kernel, H. Nikolaus Schaller
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>
---
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;
--
2.7.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] power:bq27xxx: 27000/10 read FLAGS register as single
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
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: H. Nikolaus Schaller @ 2016-07-26 6:08 UTC (permalink / raw)
To: Andrew F . Davis, Ivaylo Dimitrov, Andrzej Hajda, Pali Rohár,
Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse
Cc: linux-pm, linux-kernel, letux-kernel
ping
> Am 18.07.2016 um 18:12 schrieb H. Nikolaus Schaller <hns@goldelico.com>:
>
> 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>
> ---
> 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;
> --
> 2.7.3
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] power:bq27xxx: 27000/10 read FLAGS register as single
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
2016-08-15 19:27 ` Sebastian Reichel
3 siblings, 0 replies; 5+ messages in thread
From: Pali Rohár @ 2016-07-26 7:27 UTC (permalink / raw)
To: H. Nikolaus Schaller
Cc: Andrew F . Davis, Ivaylo Dimitrov, Andrzej Hajda,
Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse,
linux-pm, linux-kernel, letux-kernel
On Monday 18 July 2016 18:12:09 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>
Looks good, add my Acked-by.
--
Pali Rohár
pali.rohar@gmail.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] power:bq27xxx: 27000/10 read FLAGS register as single
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
2016-08-15 19:27 ` Sebastian Reichel
3 siblings, 0 replies; 5+ messages in thread
From: Andrew F. Davis @ 2016-07-26 13:04 UTC (permalink / raw)
To: H. Nikolaus Schaller, Ivaylo Dimitrov, Andrzej Hajda,
Pali Rohár, Sebastian Reichel, Dmitry Eremin-Solenikov,
David Woodhouse
Cc: linux-pm, linux-kernel, letux-kernel
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;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] power:bq27xxx: 27000/10 read FLAGS register as single
2016-07-18 16:12 [PATCH] power:bq27xxx: 27000/10 read FLAGS register as single H. Nikolaus Schaller
` (2 preceding siblings ...)
2016-07-26 13:04 ` Andrew F. Davis
@ 2016-08-15 19:27 ` Sebastian Reichel
3 siblings, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2016-08-15 19:27 UTC (permalink / raw)
To: H. Nikolaus Schaller
Cc: Andrew F . Davis, Ivaylo Dimitrov, Andrzej Hajda, Pali Rohár,
Dmitry Eremin-Solenikov, David Woodhouse, linux-pm, linux-kernel,
letux-kernel
[-- Attachment #1: Type: text/plain, Size: 512 bytes --]
Hi,
On Mon, Jul 18, 2016 at 06:12:09PM +0200, 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.
Thanks, queued into power-supply's -next branch.
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-08-15 19:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2016-08-15 19:27 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox