* [PATCH 1/2] regulator: core: Only delay if we successfully set the voltage
@ 2012-06-26 10:26 Mark Brown
2012-06-26 10:26 ` [PATCH 2/2] regulator: core: Check that the selector from map_voltage() is valid Mark Brown
2012-06-26 10:30 ` [PATCH 1/2] regulator: core: Only delay if we successfully set the voltage Axel Lin
0 siblings, 2 replies; 6+ messages in thread
From: Mark Brown @ 2012-06-26 10:26 UTC (permalink / raw)
To: Liam Girdwood; +Cc: linux-kernel, Axel Lin, Mark Brown
There is no need to wait for the voltage to ramp if we didn't manage to
set it.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/regulator/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 30ecb49..9f28f2f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2131,7 +2131,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
best_val = _regulator_get_voltage(rdev);
/* Call set_voltage_time_sel if successfully obtained old_selector */
- if (_regulator_is_enabled(rdev) && ret == 0 && old_selector >= 0 &&
+ if (ret == 0 &&
+ _regulator_is_enabled(rdev) && ret == 0 && old_selector >= 0 &&
rdev->desc->ops->set_voltage_time_sel) {
delay = rdev->desc->ops->set_voltage_time_sel(rdev,
--
1.7.10
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] regulator: core: Check that the selector from map_voltage() is valid
2012-06-26 10:26 [PATCH 1/2] regulator: core: Only delay if we successfully set the voltage Mark Brown
@ 2012-06-26 10:26 ` Mark Brown
2012-06-26 12:40 ` Axel Lin
2012-06-26 10:30 ` [PATCH 1/2] regulator: core: Only delay if we successfully set the voltage Axel Lin
1 sibling, 1 reply; 6+ messages in thread
From: Mark Brown @ 2012-06-26 10:26 UTC (permalink / raw)
To: Liam Girdwood; +Cc: linux-kernel, Axel Lin, Mark Brown
Lots of regulator drivers have checks in their map_voltage() functions
to verify that the result of the mapping is in the range originally
specified. Factor these out in the core and provide a bit of extra
defensiveness for other drivers by doing the check in the core.
Since we're now doing a list_voltage() earlier move the current mapping
back to a voltage out into the set_voltage() call to save redoing it.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/regulator/core.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 9f28f2f..0ba27c2 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2071,7 +2071,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
{
int ret;
int delay = 0;
- int best_val;
+ int best_val = 0;
unsigned int selector;
int old_selector = -1;
@@ -2095,6 +2095,15 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
if (rdev->desc->ops->set_voltage) {
ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV,
&selector);
+
+ if (ret >= 0) {
+ if (rdev->desc->ops->list_voltage)
+ best_val = rdev->desc->ops->list_voltage(rdev,
+ selector);
+ else
+ best_val = _regulator_get_voltage(rdev);
+ }
+
} else if (rdev->desc->ops->set_voltage_sel) {
if (rdev->desc->ops->map_voltage) {
ret = rdev->desc->ops->map_voltage(rdev, min_uV,
@@ -2110,10 +2119,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
}
if (ret >= 0) {
- if (min_uV < rdev->desc->ops->list_voltage(rdev,
- ret) &&
- max_uV > rdev->desc->ops->list_voltage(rdev,
- ret)) {
+ best_val = rdev->desc->ops->list_voltage(rdev, ret);
+ if (min_uV <= best_val && max_uV >= best_val) {
selector = ret;
ret = rdev->desc->ops->set_voltage_sel(rdev,
ret);
@@ -2125,11 +2132,6 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
ret = -EINVAL;
}
- if (rdev->desc->ops->list_voltage)
- best_val = rdev->desc->ops->list_voltage(rdev, selector);
- else
- best_val = _regulator_get_voltage(rdev);
-
/* Call set_voltage_time_sel if successfully obtained old_selector */
if (ret == 0 &&
_regulator_is_enabled(rdev) && ret == 0 && old_selector >= 0 &&
--
1.7.10
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] regulator: core: Only delay if we successfully set the voltage
2012-06-26 10:26 [PATCH 1/2] regulator: core: Only delay if we successfully set the voltage Mark Brown
2012-06-26 10:26 ` [PATCH 2/2] regulator: core: Check that the selector from map_voltage() is valid Mark Brown
@ 2012-06-26 10:30 ` Axel Lin
2012-06-26 10:40 ` Mark Brown
1 sibling, 1 reply; 6+ messages in thread
From: Axel Lin @ 2012-06-26 10:30 UTC (permalink / raw)
To: Mark Brown; +Cc: Liam Girdwood, linux-kernel
2012/6/26 Mark Brown <broonie@opensource.wolfsonmicro.com>:
> There is no need to wait for the voltage to ramp if we didn't manage to
> set it.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> drivers/regulator/core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 30ecb49..9f28f2f 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -2131,7 +2131,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
> best_val = _regulator_get_voltage(rdev);
>
> /* Call set_voltage_time_sel if successfully obtained old_selector */
> - if (_regulator_is_enabled(rdev) && ret == 0 && old_selector >= 0 &&
^^^^^^^^
We
already check ret ==0 here.
> + if (ret == 0 &&
> + _regulator_is_enabled(rdev) && ret == 0 && old_selector >= 0 &&
> rdev->desc->ops->set_voltage_time_sel) {
>
> delay = rdev->desc->ops->set_voltage_time_sel(rdev,
> --
> 1.7.10
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] regulator: core: Only delay if we successfully set the voltage
2012-06-26 10:30 ` [PATCH 1/2] regulator: core: Only delay if we successfully set the voltage Axel Lin
@ 2012-06-26 10:40 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2012-06-26 10:40 UTC (permalink / raw)
To: Axel Lin; +Cc: Liam Girdwood, linux-kernel
On Tue, Jun 26, 2012 at 06:30:16PM +0800, Axel Lin wrote:
> > /* Call set_voltage_time_sel if successfully obtained old_selector */
> > - if (_regulator_is_enabled(rdev) && ret == 0 && old_selector >= 0 &&
> ^^^^^^^^
> We
> already check ret ==0 here.
Your mailer is seriously messing up your formatting - the indentation is
nothing to do with what you're trying to point at...
The checks do need to be reordered here, though - we should check the
return value first.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] regulator: core: Check that the selector from map_voltage() is valid
2012-06-26 10:26 ` [PATCH 2/2] regulator: core: Check that the selector from map_voltage() is valid Mark Brown
@ 2012-06-26 12:40 ` Axel Lin
2012-06-26 13:13 ` Mark Brown
0 siblings, 1 reply; 6+ messages in thread
From: Axel Lin @ 2012-06-26 12:40 UTC (permalink / raw)
To: Mark Brown; +Cc: Liam Girdwood, linux-kernel
2012/6/26 Mark Brown <broonie@opensource.wolfsonmicro.com>:
> Lots of regulator drivers have checks in their map_voltage() functions
> to verify that the result of the mapping is in the range originally
> specified. Factor these out in the core and provide a bit of extra
> defensiveness for other drivers by doing the check in the core.
>
> Since we're now doing a list_voltage() earlier move the current mapping
> back to a voltage out into the set_voltage() call to save redoing it.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Hi Mark,
This patch does not apply to both linux-next tree and regulator tree
(for-next branch).
I got below diff in drivers/regulator/core.c.rej.
--- drivers/regulator/core.c
+++ drivers/regulator/core.c
@@ -2119,10 +2128,8 @@
}
if (ret >= 0) {
- if (min_uV < rdev->desc->ops->list_voltage(rdev,
- ret) &&
- max_uV > rdev->desc->ops->list_voltage(rdev,
- ret)) {
+ best_val = rdev->desc->ops->list_voltage(rdev, ret);
+ if (min_uV <= best_val && max_uV >= best_val) {
selector = ret;
ret = rdev->desc->ops->set_voltage_sel(rdev,
ret);
Regards,
Axel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] regulator: core: Check that the selector from map_voltage() is valid
2012-06-26 12:40 ` Axel Lin
@ 2012-06-26 13:13 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2012-06-26 13:13 UTC (permalink / raw)
To: Axel Lin; +Cc: Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 275 bytes --]
On Tue, Jun 26, 2012 at 08:40:42PM +0800, Axel Lin wrote:
> This patch does not apply to both linux-next tree and regulator tree
> (for-next branch).
I know, I had an earlier version of the change I'd forgotten I
committed. The final version shown in the diff is correct.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-06-26 13:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-26 10:26 [PATCH 1/2] regulator: core: Only delay if we successfully set the voltage Mark Brown
2012-06-26 10:26 ` [PATCH 2/2] regulator: core: Check that the selector from map_voltage() is valid Mark Brown
2012-06-26 12:40 ` Axel Lin
2012-06-26 13:13 ` Mark Brown
2012-06-26 10:30 ` [PATCH 1/2] regulator: core: Only delay if we successfully set the voltage Axel Lin
2012-06-26 10:40 ` 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).