Skip to contentSkip to conversation

power: max17042: do not lose accuracy calculating current_now

PATCH Applied MyungJoo Ham 2 participants 2 messages Aug 16, 2011 – Aug 19, 2011

lore
Share & tools
lore

MyungJoo Ham

author Acked-by
#0 lore raw

Philip Rakity<[email protected]> Date : 2011-08-13 13:19 (GMT+09:00)

Quoted 6 lines

PROP_CURRENT_NOW value is first divided then multiplied up causing a lose of accuracy. Use the same method as PROP_CURRENT_AVG to do the calculation.

Signed-off-by Philip Rakity
Quoted 23 lines

---
drivers/power/max17042_battery.c | 3 +--

1 files changed, 1 insertions(+), 2 deletions(-)
drivers/power/max17042_battery.c +1 -2
index 4245806..7b7762a 100644
@@ -153,8 +153,7 @@ static int max17042_get_property(struct power_supply *psy,
 val->intval++;
 val->intval *= -1;
 }
- val->intval >>= 4;
- val->intval *= 1000000 * 25 / chip->pdata->r_sns;
+ val->intval *= 1562500 / chip->pdata->r_sns;
 } else {
 return -EINVAL;
 }
Signature · 1 line
1.7.0.4

MyungJoo Ham (함명주)
Mobile Software Platform Lab,
Digital Media and Communications (DMC) Business
Samsung Electronics
cell: +82-10-6714-2858 / office: +82-31-279-8033�淸�{.n�+돴윯돪�+%듚�깁負쪐w��{.n�+돴쪐{깸G쳺��{ay����,j�f"톒쉹��묎�z_溫(�쉸듶줷"얎�m����G쳺�◀?솳鈺�&x�~뤳턨O뺞촾퇉v�^�m��� �띠�◀?뻀�

#1 lore raw
Quoted 9 lines · MyungJoo Ham

Philip Rakity<[email protected]> Date : 2011-08-13 13:19 (GMT+09:00)

Quoted 6 lines

PROP_CURRENT_NOW value is first divided then multiplied up causing a lose of accuracy. Use the same method as PROP_CURRENT_AVG to do the calculation.

Signed-off-by Philip Rakity

Applied, thanks!

Signature · 2 lines
Anton Vorontsov
Email: [email protected]