* [PATCH RFC] regulator: Use list_voltage() to get voltage in regulator_set_voltage_time_sel
@ 2012-06-19 1:38 Axel Lin
2012-06-19 22:29 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-06-19 1:38 UTC (permalink / raw)
To: linux-kernel; +Cc: Yadwinder Singh Brar, Liam Girdwood, Mark Brown
With this change, regulator_set_voltage_time_sel() can be more generic and not
limited to linear and table based mapping now.
One side-effect of this change is that list_voltage() must be implemented.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/core.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 8008c865..e207b21 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2303,8 +2303,7 @@ EXPORT_SYMBOL_GPL(regulator_set_voltage_time);
* Provided with the starting and target voltage selectors, this function
* returns time in microseconds required to rise or fall to this new voltage
*
- * Drivers providing uV_step or volt_table in their regulator_desc and
- * ramp_delay in regulation_constraints can use this as their
+ * Drivers providing ramp_delay in regulation_constraints can use this as their
* set_voltage_time_sel() operation.
*/
int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
@@ -2312,6 +2311,7 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
unsigned int new_selector)
{
unsigned int ramp_delay = 0;
+ int old_volt, new_volt;
if (rdev->constraints->ramp_delay)
ramp_delay = rdev->constraints->ramp_delay;
@@ -2323,19 +2323,14 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
return 0;
}
- if (rdev->desc->uV_step) {
- return DIV_ROUND_UP(rdev->desc->uV_step *
- abs(new_selector - old_selector),
- ramp_delay);
- } else if (rdev->desc->volt_table) {
- return DIV_ROUND_UP(abs(rdev->desc->volt_table[new_selector] -
- rdev->desc->volt_table[old_selector]),
- ramp_delay);
- } else {
- rdev_warn(rdev, "Unsupported voltage mapping settings\n");
- }
+ /* sanity check */
+ if (!rdev->desc->ops->list_voltage)
+ return -EINVAL;
- return 0;
+ old_volt = rdev->desc->ops->list_voltage(rdev, old_selector);
+ new_volt = rdev->desc->ops->list_voltage(rdev, new_selector);
+
+ return DIV_ROUND_UP(abs(new_volt - old_volt), ramp_delay);
}
/**
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH RFC] regulator: Use list_voltage() to get voltage in regulator_set_voltage_time_sel
2012-06-19 1:38 [PATCH RFC] regulator: Use list_voltage() to get voltage in regulator_set_voltage_time_sel Axel Lin
@ 2012-06-19 22:29 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-06-19 22:29 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Yadwinder Singh Brar, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 283 bytes --]
On Tue, Jun 19, 2012 at 09:38:45AM +0800, Axel Lin wrote:
> With this change, regulator_set_voltage_time_sel() can be more generic and not
> limited to linear and table based mapping now.
> One side-effect of this change is that list_voltage() must be implemented.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-19 22:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-19 1:38 [PATCH RFC] regulator: Use list_voltage() to get voltage in regulator_set_voltage_time_sel Axel Lin
2012-06-19 22:29 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).