* [PATCH] regulator: rc5t583: Simplify rc5t583_set_voltage_time_sel implementation
@ 2012-06-07 8:38 Axel Lin
2012-06-07 10:37 ` Laxman Dewangan
2012-06-07 23:28 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-06-07 8:38 UTC (permalink / raw)
To: linux-kernel; +Cc: Laxman Dewangan, Liam Girdwood, Mark Brown
For linear mappings, we can use below equation to get the voltage difference
between new_selector and old_selector:
abs(new_selector - old_selector) * rdev->desc->uV_step
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/rc5t583-regulator.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c
index 1d34e64..332eae8 100644
--- a/drivers/regulator/rc5t583-regulator.c
+++ b/drivers/regulator/rc5t583-regulator.c
@@ -70,18 +70,10 @@ static int rc5t583_set_voltage_time_sel(struct regulator_dev *rdev,
unsigned int old_selector, unsigned int new_selector)
{
struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
- int old_uV, new_uV;
- old_uV = regulator_list_voltage_linear(rdev, old_selector);
- if (old_uV < 0)
- return old_uV;
-
- new_uV = regulator_list_voltage_linear(rdev, new_selector);
- if (new_uV < 0)
- return new_uV;
-
- return DIV_ROUND_UP(abs(old_uV - new_uV),
- reg->reg_info->change_uv_per_us);
+ return DIV_ROUND_UP(abs(new_selector - old_selector) *
+ rdev->desc->uV_step,
+ reg->reg_info->change_uv_per_us);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] regulator: rc5t583: Simplify rc5t583_set_voltage_time_sel implementation
2012-06-07 8:38 [PATCH] regulator: rc5t583: Simplify rc5t583_set_voltage_time_sel implementation Axel Lin
@ 2012-06-07 10:37 ` Laxman Dewangan
2012-06-07 23:28 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Laxman Dewangan @ 2012-06-07 10:37 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel@vger.kernel.org, Liam Girdwood, Mark Brown
On Thursday 07 June 2012 02:08 PM, Axel Lin wrote:
> For linear mappings, we can use below equation to get the voltage difference
> between new_selector and old_selector:
>
> abs(new_selector - old_selector) * rdev->desc->uV_step
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
Looks good to me.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: rc5t583: Simplify rc5t583_set_voltage_time_sel implementation
2012-06-07 8:38 [PATCH] regulator: rc5t583: Simplify rc5t583_set_voltage_time_sel implementation Axel Lin
2012-06-07 10:37 ` Laxman Dewangan
@ 2012-06-07 23:28 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-06-07 23:28 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Laxman Dewangan, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 196 bytes --]
On Thu, Jun 07, 2012 at 04:38:09PM +0800, Axel Lin wrote:
> For linear mappings, we can use below equation to get the voltage difference
> between new_selector and old_selector:
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-06-08 0:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-07 8:38 [PATCH] regulator: rc5t583: Simplify rc5t583_set_voltage_time_sel implementation Axel Lin
2012-06-07 10:37 ` Laxman Dewangan
2012-06-07 23:28 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox