Skip to contentSkip to conversation

max17042: Fix value scaling for VCELL and avgVCELL

PATCH MyungJoo Ham 1 participant 1 message Dec 12, 2011

lore
Share & tools
lore

MyungJoo Ham

author Acked-by
#0 lore raw
Quoted 7 lines

From: Bruce Robertson <[email protected]>

The bottom three bits of the register are don't care bits. The LSB value is 625 uV. Adjust the returned values appropriately

Quoted 29 lines
---
 drivers/power/max17042_battery.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/power/max17042_battery.c +6 -2
index 001eca1..80a6ee7 100644
@@ -148,11 +148,15 @@ static int max17042_get_property(struct power_supply *psy,
 		break;
 	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
 		val->intval = max17042_read_reg(chip->client,
-				MAX17042_VCELL) * 83; /* 1000 / 12 = 83 */
+				MAX17042_VCELL);
+		val->intval >>= 3;
+		val->intval *= 625; /* Units of LSB = 625 uV */
 		break;
 	case POWER_SUPPLY_PROP_VOLTAGE_AVG:
 		val->intval = max17042_read_reg(chip->client,
-				MAX17042_AvgVCELL) * 83;
+				MAX17042_AvgVCELL);
+		val->intval >>= 3;
+		val->intval *= 625; /* Units of LSB = 625 uV */
 		break;
 	case POWER_SUPPLY_PROP_CAPACITY:
 		val->intval = max17042_read_reg(chip->client,
Signature · 1 line
1.7.7.3

�淸�{.n�+돴윯돪�+%듚�깁負쪐w��{.n�+돴쪐{깸G쳺��{ay����,j�f"톒쉹��묎�z_溫(�쉸듶줷"얎�m����G쳺�◀?솳鈺�&x�~뤳턨O뺞촾퇉v�^�m��� �띠�◀?뻀�