From: Laxman Dewangan <ldewangan@nvidia.com>
To: <broonie@kernel.org>, <robh+dt@kernel.org>, <pawel.moll@arm.com>
Cc: <lgirdwood@gmail.com>, <lee.jones@linaro.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH 1/5] regulator: pwm: Fix calculation of voltage-to-duty cycle
Date: Tue, 8 Mar 2016 16:23:21 +0530 [thread overview]
Message-ID: <1457434405-30372-2-git-send-email-ldewangan@nvidia.com> (raw)
In-Reply-To: <1457434405-30372-1-git-send-email-ldewangan@nvidia.com>
With following equation for calculating
voltage_to_duty_cycle_percentage
100 - (((req_uV * 100) - (min_uV * 100)) / diff);
we get 0% for max_uV and 100% for min_uV.
Correcting this to
((req_uV * 100) - (min_uV * 100)) / diff;
to get proper duty cycle.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Cc: Lee Jones <lee.jones@linaro.org>
---
drivers/regulator/pwm-regulator.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c
index 3aca067..4d8eb35 100644
--- a/drivers/regulator/pwm-regulator.c
+++ b/drivers/regulator/pwm-regulator.c
@@ -115,7 +115,7 @@ static int pwm_voltage_to_duty_cycle_percentage(struct regulator_dev *rdev, int
int max_uV = rdev->constraints->max_uV;
int diff = max_uV - min_uV;
- return 100 - (((req_uV * 100) - (min_uV * 100)) / diff);
+ return ((req_uV * 100) - (min_uV * 100)) / diff;
}
static int pwm_regulator_get_voltage(struct regulator_dev *rdev)
--
2.1.4
next prev parent reply other threads:[~2016-03-08 11:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-08 10:53 [PATCH 0/5] regulator: pwm: Add supports for multiple instance and voltage linear steps Laxman Dewangan
2016-03-08 10:53 ` Laxman Dewangan [this message]
2016-03-08 10:53 ` [PATCH 2/5] regulator: pwm: Add support to have multiple instance of pwm regulator Laxman Dewangan
2016-03-08 10:53 ` [PATCH 3/5] regulator: pwm: Prints error number when it fails Laxman Dewangan
2016-03-12 6:05 ` Mark Brown
2016-03-13 13:07 ` Laxman Dewangan
2016-03-08 10:53 ` [PATCH 4/5] regulator: pwm: Add support for voltage linear equal steps Laxman Dewangan
2016-03-12 6:09 ` Mark Brown
2016-03-13 13:06 ` Laxman Dewangan
2016-03-14 16:28 ` Mark Brown
2016-03-15 6:44 ` Laxman Dewangan
2016-03-08 10:53 ` [PATCH 5/5] regulator: pwm: Add DT binding details for Linear Equal Step Mode Laxman Dewangan
2016-03-17 15:27 ` Rob Herring
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=1457434405-30372-2-git-send-email-ldewangan@nvidia.com \
--to=ldewangan@nvidia.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.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
Powered by JetHome