All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] bq27x00: Do not cache current_now value for bq27000 batery
@ 2011-09-20 15:18 Pali Rohár
  2011-09-20 15:18 ` [PATCH 2/7] bq27x00: Add support for property POWER_SUPPLY_PROP_CAPACITY_LEVEL Pali Rohár
                   ` (7 more replies)
  0 siblings, 8 replies; 37+ messages in thread
From: Pali Rohár @ 2011-09-20 15:18 UTC (permalink / raw)
  To: linux-kernel, Anton Vorontsov, syed rafiuddin, Rodolfo Giometti
  Cc: Pali Rohár

* This prevent reporting old current_now value for bq27000
* Also ask for current flags, to make sure that current_now will be reported with correct signature
---
 drivers/power/bq27x00_battery.c |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index bb16f5b..d238144 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -80,8 +80,6 @@ struct bq27x00_reg_cache {
 	int cycle_count;
 	int capacity;
 	int flags;
-
-	int current_now;
 };
 
 struct bq27x00_device_info {
@@ -270,17 +268,12 @@ static void bq27x00_update(struct bq27x00_device_info *di)
 		cache.charge_full = bq27x00_battery_read_lmd(di);
 		cache.cycle_count = bq27x00_battery_read_cyct(di);
 
-		if (!is_bq27500)
-			cache.current_now = bq27x00_read(di, BQ27x00_REG_AI, false);
-
 		/* We only have to read charge design full once */
 		if (di->charge_design_full <= 0)
 			di->charge_design_full = bq27x00_battery_read_ilmd(di);
 	}
 
-	/* Ignore current_now which is a snapshot of the current battery state
-	 * and is likely to be different even between two consecutive reads */
-	if (memcmp(&di->cache, &cache, sizeof(cache) - sizeof(int)) != 0) {
+	if (memcmp(&di->cache, &cache, sizeof(cache)) != 0) {
 		di->cache = cache;
 		power_supply_changed(&di->bat);
 	}
@@ -330,12 +323,9 @@ static int bq27x00_battery_current(struct bq27x00_device_info *di,
 	union power_supply_propval *val)
 {
 	int curr;
+	int flags;
 
-	if (di->chip == BQ27500)
-	    curr = bq27x00_read(di, BQ27x00_REG_AI, false);
-	else
-	    curr = di->cache.current_now;
-
+	curr = bq27x00_read(di, BQ27x00_REG_AI, false);
 	if (curr < 0)
 		return curr;
 
@@ -343,7 +333,8 @@ static int bq27x00_battery_current(struct bq27x00_device_info *di,
 		/* bq27500 returns signed value */
 		val->intval = (int)((s16)curr) * 1000;
 	} else {
-		if (di->cache.flags & BQ27000_FLAG_CHGS) {
+		flags = bq27x00_read(di, BQ27x00_REG_FLAGS, false);
+		if (flags & BQ27000_FLAG_CHGS) {
 			dev_dbg(di->dev, "negative current!\n");
 			curr = -curr;
 		}
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2012-01-06  1:41 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-20 15:18 [PATCH 1/7] bq27x00: Do not cache current_now value for bq27000 batery Pali Rohár
2011-09-20 15:18 ` [PATCH 2/7] bq27x00: Add support for property POWER_SUPPLY_PROP_CAPACITY_LEVEL Pali Rohár
2011-09-20 15:18 ` [PATCH 3/7] bq27x00: Report -ENODATA if bq27000 battery was not calibrated Pali Rohár
2011-09-20 15:18 ` [PATCH 4/7] bq27x00: Cache energy property Pali Rohár
2011-09-20 15:18 ` [PATCH 5/7] bq27x00: Cache temperature value in converted unit Pali Rohár
2011-09-20 15:18 ` [PATCH 6/7] bq27x00: Fix reporting status value for bq27500 battery Pali Rohár
2011-09-20 15:18 ` [PATCH 7/7] bq27x00: Fix reporting error messages Pali Rohár
2011-11-01  0:43 ` [PATCH 1/9] bq27x00: Do not cache current_now value for bq27000 batery Pali Rohár
2011-11-01  0:43   ` [PATCH 2/9] bq27x00: Add support for property POWER_SUPPLY_PROP_CAPACITY_LEVEL Pali Rohár
2011-11-01  0:43   ` [PATCH 3/9] bq27x00: Report -ENODATA if bq27000 battery was not calibrated Pali Rohár
2011-11-01  0:43   ` [PATCH 4/9] bq27x00: Cache energy property Pali Rohár
2011-11-01  0:43   ` [PATCH 5/9] bq27x00: Cache temperature value in converted unit Pali Rohár
2011-11-01  0:43   ` [PATCH 6/9] bq27x00: Fix reporting status value for bq27500 battery Pali Rohár
2011-11-01  0:43   ` [PATCH 7/9] bq27x00: Fix reporting error messages Pali Rohár
2011-11-01  0:43   ` [PATCH 8/9] bq27x00: Add miscdevice for each battery with ioctl for reading registers Pali Rohár
2011-11-01 12:09     ` Lars-Peter Clausen
2011-11-01 12:23       ` Pali Rohár
2011-11-01 12:46         ` Lars-Peter Clausen
2011-11-01 12:53           ` Pali Rohár
2011-11-25 20:10             ` Anton Vorontsov
2011-11-25 20:30               ` Pali Rohár
2011-11-25 20:46                 ` Anton Vorontsov
2011-11-25 20:54                   ` Pali Rohár
2011-11-25 22:04                     ` Anton Vorontsov
2011-11-25 22:48                       ` Pali Rohár
2011-11-27 11:54                       ` Mark Brown
2011-12-05 19:37                         ` Pali Rohár
2011-12-05 19:40                           ` Mark Brown
2011-11-01  0:43   ` [PATCH 9/9] bq27x00: Fix OOPS caused by unregistring bq27x00 driver Pali Rohár
2011-11-13 20:54     ` Pali Rohár
2011-11-25 22:53 ` [PATCH] rx51: add bq27200 i2c board info Pali Rohár
2011-11-25 23:03   ` Anton Vorontsov
2011-12-05 19:24     ` Felipe Contreras
2011-12-06 15:49     ` Pali Rohár
2011-12-07 20:25     ` Tony Lindgren
2011-12-17  9:55       ` Pali Rohár
2012-01-06  1:41       ` Anton Vorontsov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.