lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 12 Jul 2009 21:09:31 +0300
From:	Felipe Balbi <me@...ipebalbi.com>
To:	dwmw2@...radead.org
Cc:	linux-kernel@...r.kernel.org, Felipe Balbi <me@...ipebalbi.com>
Subject: [rfc/patch 09/15] power: bq27200: fix up current reporting

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@...ipebalbi.com>
---
 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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ