From: Jean Delvare <khali@linux-fr.org>
To: Anthony Olech <anthony.olech.opensource@diasemi.com>
Cc: Anton Vorontsov <anton@enomsg.org>,
David Woodhouse <dwmw2@infradead.org>,
David Dajun Chen <david.chen@diasemi.com>,
open list <linux-kernel@vger.kernel.org>,
"open list:HARDWARE MONITORING" <lm-sensors@lm-sensors.org>
Subject: Re: [lm-sensors] [PATCH V1] fix adc to voltage calculation in da9052 power driver
Date: Wed, 18 Dec 2013 16:32:34 +0100 [thread overview]
Message-ID: <20131218163234.714a166c@endymion.delvare> (raw)
In-Reply-To: <201312181524.rBIFOv96017094@swsrvapps-02.lan>
On Wed, 18 Dec 2013 15:21:13 +0000, Anthony Olech wrote:
> 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.
The conversion from register value to mV depends on the ADC's LSB, not
its range. So the maximum value which can be represented is irrelevant.
>
> 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)
--
Jean Delvare
next prev parent reply other threads:[~2013-12-18 15:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-18 15:21 [PATCH V1] fix adc to voltage calculation in da9052 power driver Anthony Olech
2013-12-18 15:32 ` Jean Delvare [this message]
2013-12-18 15:45 ` [lm-sensors] " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131218163234.714a166c@endymion.delvare \
--to=khali@linux-fr.org \
--cc=anthony.olech.opensource@diasemi.com \
--cc=anton@enomsg.org \
--cc=david.chen@diasemi.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox