Skip to contentSkip to conversation

bq27x00_battery: fix flag register read

PATCH Applied Grazvydas Ignotas 3 participants 3 messages Jan 14, 2012 – Feb 1, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bq27x00_battery: fix flag register read

When reading flags, bq27x00_read() argument is inverted and causes reads 2 of bytes for bq27200 and 1 byte for bq27500, while their register sizes are 1 and 2 bytes respectively. This causes bq27500 upper flag bits always to be returned as 0, causing full charge state to never be reported correctly, so fix it.

Cc Pali Rohár <[email protected]>
Cc Lars-Peter Clausen <[email protected]>
---
 drivers/power/bq27x00_battery.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/power/bq27x00_battery.c +1 -1
index 98bf567..86decb4 100644
@@ -312,7 +312,7 @@ static void bq27x00_update(struct bq27x00_device_info *di)
 	struct bq27x00_reg_cache cache = {0, };
 	bool is_bq27500 = di->chip == BQ27500;
 
-	cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, is_bq27500);
+	cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, !is_bq27500);
 	if (cache.flags >= 0) {
 		if (!is_bq27500 && (cache.flags & BQ27000_FLAG_CI)) {
 			dev_info(di->dev, "battery is not calibrated! ignoring capacity values\n");
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 26 lines · On Saturday 14 January 2012 22:50:49 Grazvydas Ignotas wrote:

When reading flags, bq27x00_read() argument is inverted and causes reads 2 of bytes for bq27200 and 1 byte for bq27500, while their register sizes are 1 and 2 bytes respectively. This causes bq27500 upper flag bits always to be returned as 0, causing full charge state to never be reported correctly, so fix it.

Cc Pali Rohár <[email protected]>
Cc Lars-Peter Clausen <[email protected]>
---
 drivers/power/bq27x00_battery.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/drivers/power/bq27x00_battery.c index 98bf567..86decb4 100644

drivers/power/bq27x00_battery.c +1 -1
@@ -312,7 +312,7 @@ static void bq27x00_update(struct bq27x00_device_info
 *di) struct bq27x00_reg_cache cache = {0, };
 	bool is_bq27500 = di->chip == BQ27500;
 
-	cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, is_bq27500);
+	cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, !is_bq27500);
 	if (cache.flags >= 0) {
 		if (!is_bq27500 && (cache.flags & BQ27000_FLAG_CI)) {
 			dev_info(di->dev, "battery is not calibrated! ignoring capacity
Quoted 1 line

values\n");

Yes, you are right, this patch fixing flags register reading. Anton Vorontsov, can you send this patch to linux 3.3?

Signature · 2 lines
Pali Rohár
[email protected]
#2 lore raw
Quoted 22 lines · Pali Rohár
Quoted 21 lines · On Saturday 14 January 2012 22:50:49 Grazvydas Ignotas wrote:

When reading flags, bq27x00_read() argument is inverted and causes reads 2 of bytes for bq27200 and 1 byte for bq27500, while their register sizes are 1 and 2 bytes respectively. This causes bq27500 upper flag bits always to be returned as 0, causing full charge state to never be reported correctly, so fix it.

Cc Pali Rohár <[email protected]>
Cc Lars-Peter Clausen <[email protected]>
---
 drivers/power/bq27x00_battery.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/drivers/power/bq27x00_battery.c index 98bf567..86decb4 100644

drivers/power/bq27x00_battery.c +0 -0
@@ -312,7 +312,7 @@ static void bq27x00_update(struct bq27x00_device_info
 *di) struct bq27x00_reg_cache cache = {0, };
 	bool is_bq27500 = di->chip == BQ27500;
 
Quoted 9 lines
Quoted 6 lines
drivers/power/bq27x00_battery.c +1 -1
-	cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, is_bq27500);
+	cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, !is_bq27500);
 	if (cache.flags >= 0) {
 		if (!is_bq27500 && (cache.flags & BQ27000_FLAG_CI)) {
 			dev_info(di->dev, "battery is not calibrated! ignoring capacity

values\n");

Yes, you are right, this patch fixing flags register reading. Anton Vorontsov, can you send this patch to linux 3.3?

Applied to battery-urgent.git, thanks guys!

Signature · 2 lines
Anton Vorontsov
Email: [email protected]