[rfc/patch 09/15] power: bq27200: fix up current reporting

From: Felipe Balbi
Date: Sun Jul 12 2009 - 14:31:36 EST


according to bq27200 datasheet, avarage current is calculated
with the following equation:

current = (256 * AI) * 3.57 / Rs

where Rs = 20mOhms

Signed-off-by: Felipe Balbi <me@xxxxxxxxxxxxxxx>
---
drivers/power/bq27200_battery.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/power/bq27200_battery.c b/drivers/power/bq27200_battery.c
index f36633c..869761e 100644
--- a/drivers/power/bq27200_battery.c
+++ b/drivers/power/bq27200_battery.c
@@ -52,6 +52,9 @@
#define BQ27200_REG_CYCT 0x2a /* cycle-count total */
#define BQ27200_REG_CSOC 0x2c /* compensated state-of-charge */

+#define BQ27200_SENSING_RESISTOR (20) /* 20 mOhms */
+#define BQ27200_CURRENT_CONSTANT (256 * 3570 / 1000) /* 256 * 3.57 uV */
+
struct bq27200 {
struct power_supply bat;
struct i2c_client *client;
@@ -143,7 +146,7 @@ static int bq27200_current(struct bq27200 *bq)
return 0;
}

- return ret;
+ return (ret * BQ27200_CURRENT_CONSTANT) / BQ27200_SENSING_RESISTOR;
}

/*
--
1.6.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/