[Gta04-owner] New "3.7-gta04" branch in my kernel tree.

NeilBrown neilb at suse.de
Sat Feb 16 21:49:19 CET 2013


On Fri, 15 Feb 2013 09:52:17 +0100 Sven Dyroff <S.Dyroff at phytec.de> wrote:

> Hello Neil,
> 
> > I've just created a new "3.7-gta04" branch in 
> git://neil.brown.name/gta04
> >
> > It contains the 3.7-based kernel that was in my 'mainline' branch 
> recently,
> > but with a little bit of tidying up and some minor enhancements:
> >
> > - If no bq27000 battery charge monitor can be found, it is now correctly
> >   reported as "not present" rather than "not calibrated".
> 
> please also make the driver stop ignoring values when battery is not 
> calibrated. Discussions within this list should have revealed that most 
> people prefer to have inaccurate values instead of having none - including 
> me.

I'd like to still make it possible to tell if the battery thinks those values
are reliable or not.  Maybe I can just set health to "unknown" if the battery
is present but not calibrated.

Maybe something like this.

NeilBrown



diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 96d64c66e..f3bde0e 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -426,33 +426,26 @@ static void bq27x00_update(struct bq27x00_device_info *di)
 		/* read error */
 		cache.flags = -1;
 	if (cache.flags >= 0) {
-		if (!is_bq27500 && !is_bq27425
-				&& (cache.flags & BQ27000_FLAG_CI)) {
-			dev_dbg(di->dev, "battery is not calibrated! ignoring capacity values\n");
-			cache.capacity = -ENODATA;
-			cache.energy = -ENODATA;
-			cache.time_to_empty = -ENODATA;
-			cache.time_to_empty_avg = -ENODATA;
-			cache.time_to_full = -ENODATA;
-			cache.charge_full = -ENODATA;
-			cache.health = -ENODATA;
-		} else {
-			cache.capacity = bq27x00_battery_read_rsoc(di);
-			if (!is_bq27425) {
-				cache.energy = bq27x00_battery_read_energy(di);
-				cache.time_to_empty =
-					bq27x00_battery_read_time(di,
-							BQ27x00_REG_TTE);
-				cache.time_to_empty_avg =
-					bq27x00_battery_read_time(di,
-							BQ27x00_REG_TTECP);
-				cache.time_to_full =
-					bq27x00_battery_read_time(di,
-							BQ27x00_REG_TTF);
-			}
-			cache.charge_full = bq27x00_battery_read_lmd(di);
-			cache.health = bq27x00_battery_read_health(di);
+		cache.capacity = bq27x00_battery_read_rsoc(di);
+		if (!is_bq27425) {
+			cache.energy = bq27x00_battery_read_energy(di);
+			cache.time_to_empty =
+				bq27x00_battery_read_time(di,
+							  BQ27x00_REG_TTE);
+			cache.time_to_empty_avg =
+				bq27x00_battery_read_time(di,
+							  BQ27x00_REG_TTECP);
+			cache.time_to_full =
+				bq27x00_battery_read_time(di,
+							  BQ27x00_REG_TTF);
 		}
+		cache.charge_full = bq27x00_battery_read_lmd(di);
+		cache.health = bq27x00_battery_read_health(di);
+		if (!is_bq27500 && !is_bq27425
+		    && cache.heath == POWER_SUPPLY_HEALTH_GOOD
+		    && (cache.flags & BQ27000_FLAG_CI))
+			cache.health = POWER_SUPPLY_HEALTH_UNKNOWN;
+
 		cache.temperature = bq27x00_battery_read_temperature(di);
 		if (!is_bq27425)
 			cache.cycle_count = bq27x00_battery_read_cyct(di);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 828 bytes
Desc: not available
URL: <http://lists.goldelico.com/pipermail/gta04-owner/attachments/20130217/4a2b5712/attachment.bin>


More information about the Gta04-owner mailing list