lkml.org 
[lkml]   [2009]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[rfc/patch 15/15] power: bq27200: add energy average
Date
report energy average to userland.

Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/power/bq27200_battery.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/drivers/power/bq27200_battery.c b/drivers/power/bq27200_battery.c
index 26ef2be..2fbe7a4 100644
--- a/drivers/power/bq27200_battery.c
+++ b/drivers/power/bq27200_battery.c
@@ -77,6 +77,7 @@ static enum power_supply_property bq27200_props[] = {
POWER_SUPPLY_PROP_POWER_AVG,
POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
+ POWER_SUPPLY_PROP_ENERGY_AVG,
};

/*
@@ -183,6 +184,19 @@ static int bq27200_power(struct bq27200 *bq)
return (ret * BQ27200_POWER_CONSTANT) / BQ27200_SENSING_RESISTOR;
}

+static int bq27200_energy(struct bq27200 *bq)
+{
+ int ret;
+
+ ret = bq27200_readw(bq, BQ27200_REG_SAE);
+ if (ret < 0) {
+ dev_err(&bq->client->dev, "error reading average energy\n");
+ return ret;
+ }
+
+ return (ret * BQ27200_POWER_CONSTANT) / BQ27200_SENSING_RESISTOR;
+}
+
static int bq27200_time_to_empty(struct bq27200 *bq)
{
int ret;
@@ -242,6 +256,9 @@ static int bq27200_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
val->intval = bq27200_time_to_full(bq);
break;
+ case POWER_SUPPLY_PROP_ENERGY_AVG:
+ val->intval = bq27200_energy(bq);
+ break;
default:
return -EINVAL;
}
--
1.6.1.3


\
 
 \ /
  Last update: 2009-07-12 20:33    [from the cache]
©2003-2011 Jasper Spaans