From: Graeme Gregory <gg@slimlogic.co.uk>
To: Axel Lin <axel.lin@gmail.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>,
linux-kernel@vger.kernel.org, Liam Girdwood <lrg@ti.com>
Subject: Re: [PATCH] regulator: palmas: Fix calculating selector in palmas_map_voltage_ldo
Date: Wed, 18 Jul 2012 08:55:30 +0100 [thread overview]
Message-ID: <50066BF2.7050507@slimlogic.co.uk> (raw)
In-Reply-To: <1342582211.12515.2.camel@phoenix>
On 18/07/12 04:30, Axel Lin wrote:
> This patch fixes below issues when choosing selector:
>
> 1. Current code returns negative selector if min_uV < 900000 which is wrong.
> For example, it is possible to satisfy the request with selector = 1 if
> the requested min_uV is 850000.
Isnt this defending against bugs in the regulator core? I am normally
against repeating the same checks at multiple levels in a stack.
> 2. Current code may select a voltage lower than requested min_uV.
> For example, if the requested min_uV is 945000, current code chooses
> selector = 1 which is lower than requested min_uV.
> DIV_ROUND_UP to avoid this case.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> drivers/regulator/palmas-regulator.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
> index 17d19fb..0fcf355 100644
> --- a/drivers/regulator/palmas-regulator.c
> +++ b/drivers/regulator/palmas-regulator.c
> @@ -486,9 +486,12 @@ static int palmas_map_voltage_ldo(struct regulator_dev *rdev,
> {
> int ret, voltage;
>
> - ret = ((min_uV - 900000) / 50000) + 1;
> - if (ret < 0)
> - return ret;
> + if (min_uV == 0)
> + return 0;
> +
> + if (min_uV < 900000)
> + min_uV = 900000;
> + ret = DIV_ROUND_UP(min_uV - 900000, 50000) + 1;
>
> /* Map back into a voltage to verify we're still in bounds */
> voltage = palmas_list_voltage_ldo(rdev, ret);
next prev parent reply other threads:[~2012-07-18 7:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-18 3:30 Axel Lin
2012-07-18 7:55 ` Graeme Gregory [this message]
2012-07-18 10:06 ` Mark Brown
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=50066BF2.7050507@slimlogic.co.uk \
--to=gg@slimlogic.co.uk \
--cc=axel.lin@gmail.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@ti.com \
/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
Powered by JetHome