public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V1] fix adc to voltage calculation in da9052 power driver
@ 2013-12-18 15:21 Anthony Olech
  2013-12-18 15:32 ` [lm-sensors] " Jean Delvare
  0 siblings, 1 reply; 10+ messages in thread
From: Anthony Olech @ 2013-12-18 15:21 UTC (permalink / raw)
  To: Anton Vorontsov, David Woodhouse
  Cc: open list:HARDWARE MONITORING, open list, David Dajun Chen

The ADC resolution of the PMIC is 10-bits, this means that the maximum
possible value is 1023 and not the 1024 as in the code.

Signed-off-by: Anthony Olech <anthony.olech.opensource@diasemi.com>
---
This patch is relative to linux-next repository tag next-20131218

 drivers/power/da9052-battery.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/da9052-battery.c b/drivers/power/da9052-battery.c
index f8f4c0f..8f0f259 100644
--- a/drivers/power/da9052-battery.c
+++ b/drivers/power/da9052-battery.c
@@ -178,7 +178,7 @@ struct da9052_battery {
 
 static inline int volt_reg_to_mV(int value)
 {
-	return ((value * 1000) / 512) + 2500;
+	return DIV_ROUND_CLOSEST(value * 2000, 1023) + 2500;
 }
 
 static inline int ichg_reg_to_mA(int value)
-- 
end-of-patch for fix adc to voltage calculation in da9052 power driver V1


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

end of thread, other threads:[~2013-12-21 17:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-18 15:21 [PATCH V1] fix adc to voltage calculation in da9052 power driver Anthony Olech
2013-12-18 15:32 ` [lm-sensors] " Jean Delvare
2013-12-18 15:45   ` Opensource [Anthony Olech]
2013-12-18 17:24     ` Guenter Roeck
2013-12-19 14:13       ` Opensource [Anthony Olech]
2013-12-19 14:54         ` Jean Delvare
2013-12-19 18:10           ` Guenter Roeck
2013-12-19 18:15             ` Opensource [Anthony Olech]
2013-12-21 17:30             ` Jean Delvare
2013-12-21 17:53               ` Guenter Roeck

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