Skip to content

Commit

Permalink
bq27x00_battery: Fix flag register read
Browse files Browse the repository at this point in the history
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: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
  • Loading branch information
Grazvydas Ignotas authored and Anton Vorontsov committed Feb 1, 2012
1 parent b7aaacf commit 4d40365
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/power/bq27x00_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,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");
Expand Down

0 comments on commit 4d40365

Please sign in to comment.