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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 10 Jun 2014 11:44:50 +0200
From:	Juergen Borleis <jbe@...gutronix.de>
To:	linux-kernel@...r.kernel.org
Cc:	Dmitry Eremin-Solenikov <dbaryshkov@...il.com>,
	David Woodhouse <dwmw2@...radead.org>, kernel@...gutronix.de
Subject: [PATCH 4/7] bq27425: the DesignCapacity register is at a different offset

For the BQ27425-g1 this register does not exists at all.
For the BQ27425-g2a this register is at offset 0x3C.

Signed-off-by: Juergen Borleis <jbe@...gutronix.de>
---
 drivers/power/bq27x00_battery.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 39b5194..a5a88f1 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -78,6 +78,9 @@
 #define BQ27425_REG_OFFSET		0x04
 #define BQ27425_REG_SOC			0x20 /* Register address plus offset */
 
+/* register offsets above 0x20 are DEVICE_TYPE 0x0425 specifc */
+#define BQ27425_REG_DCAP		0x40 /* Design capacity plus offset */
+
 #define BQ27000_RS			20 /* Resistor sense */
 #define BQ27x00_POWER_CONSTANT		(256 * 29200 / 1000)
 
@@ -265,9 +268,17 @@ static int bq27x00_battery_read_ilmd(struct bq27x00_device_info *di)
 {
 	int ilmd;
 
-	if (bq27xxx_is_chip_version_higher(di))
-		ilmd = bq27x00_read(di, BQ27500_REG_DCAP, false);
-	else
+	if (bq27xxx_is_chip_version_higher(di)) {
+		if (di->chip == BQ27425) {
+			if (di->chip_type == BQ27425_g2a)
+				ilmd = bq27x00_read(di, BQ27425_REG_DCAP,
+							false);
+			else
+				ilmd = -ENODATA;
+		} else {
+			ilmd = bq27x00_read(di, BQ27500_REG_DCAP, false);
+		}
+	} else
 		ilmd = bq27x00_read(di, BQ27000_REG_ILMD, true);
 
 	if (ilmd < 0) {
-- 
2.0.0.rc2

--
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