public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power: max17042: do not lose accuracy calculating current_now
@ 2011-08-13  4:19 Philip Rakity
  0 siblings, 0 replies; 3+ messages in thread
From: Philip Rakity @ 2011-08-13  4:19 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org
  Cc: Anton Vorontsov, Kyungmin Park, myungjoo.ham@samsung.com

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 <prakity@marvell.com>
---
 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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] power: max17042: do not lose accuracy calculating current_now
@ 2011-08-16  6:12 MyungJoo Ham
  2011-08-19 16:50 ` Anton Vorontsov
  0 siblings, 1 reply; 3+ messages in thread
From: MyungJoo Ham @ 2011-08-16  6:12 UTC (permalink / raw)
  To: Philip Rakity, linux-kernel@vger.kernel.org
  Cc: Anton Vorontsov, 박경민

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=euc-kr, Size: 1260 bytes --]

Philip Rakity<prakity@marvell.com> 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@samsung.com>

> ---
> 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-8033ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] power: max17042: do not lose accuracy calculating current_now
  2011-08-16  6:12 [PATCH] power: max17042: do not lose accuracy calculating current_now MyungJoo Ham
@ 2011-08-19 16:50 ` Anton Vorontsov
  0 siblings, 0 replies; 3+ messages in thread
From: Anton Vorontsov @ 2011-08-19 16:50 UTC (permalink / raw)
  To: MyungJoo Ham
  Cc: Philip Rakity, linux-kernel@vger.kernel.org,
	박경민

On Tue, Aug 16, 2011 at 06:12:58AM +0000, MyungJoo Ham wrote:
> Philip Rakity<prakity@marvell.com> 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@samsung.com>

Applied, thanks!

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-19 16:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-16  6:12 [PATCH] power: max17042: do not lose accuracy calculating current_now MyungJoo Ham
2011-08-19 16:50 ` Anton Vorontsov
  -- strict thread matches above, loose matches on Subject: below --
2011-08-13  4:19 Philip Rakity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox