Re: [PATCH] power: max17042: do not lose accuracy calculatingcurrent_now

From: MyungJoo Ham
Date: Tue Aug 16 2011 - 02:13:13 EST


Philip Rakity<prakity@xxxxxxxxxxx> Date : 2011-08-13 13:19 (GMT+09:00)
>
> 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

Acked-by: MyungJoo Ham <myungjoo.ham@xxxxxxxxxxx>

> ---
> drivers/power/max17042_battery.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
> index 4245806..7b7762a 100644
> --- a/drivers/power/max17042_battery.c
> +++ b/drivers/power/max17042_battery.c
> @@ -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;
> }
> --
> 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-8033N떑꿩ìr¸›y鉉싕b²XФ푤vØ^–)頻{.nÇ+돴¥Š{±묎çzX㎍썳變}©옽Æ zÚ&j:+v돣¾«묎çzZ+€Ê+zf"·hš닱~넮녬iÿ鎬z¹®wⅱ¸?솳鈺Ú&¢)刪f뷌^j푹y§m끷@A«a뛴ÿ 0띠h®å’i