linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: core: Update regulator_is_supported_voltage for fixed voltages
@ 2012-11-09 10:51 Tushar Behera
  2012-11-09 17:09 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Tushar Behera @ 2012-11-09 10:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: broonie, philipspatches, patches

Commit c5f3939b8fe0 ("regulator: core: Support fixed voltages in
regulator_is_supported_voltage()") adds support for fixed regulators
in regulator_is_supported_voltage.

In case of fixed regulators for which voltage cannot be changed,
regulator_is_supported_voltage should return success only if the
min_uV and max_uV parameters are same and it is equal to the current
voltage of the regulator.

Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
---

Currently this patch breaks MMC support for boards on which vmmc is a
fixed regulator and the voltage is not equal to either of 3.3v, 3.0v
or 1.8v. Earlier it used to work if the voltage was less than 3.3v.

 drivers/regulator/core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 1a35251..4a377a7 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1974,7 +1974,7 @@ int regulator_is_supported_voltage(struct regulator *regulator,
 	if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
 		ret = regulator_get_voltage(regulator);
 		if (ret >= 0)
-			return (min_uV >= ret && ret <= max_uV);
+			return (ret == min_uV && ret == max_uV);
 		else
 			return ret;
 	}
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] regulator: core: Update regulator_is_supported_voltage for fixed voltages
  2012-11-09 10:51 [PATCH] regulator: core: Update regulator_is_supported_voltage for fixed voltages Tushar Behera
@ 2012-11-09 17:09 ` Mark Brown
  2012-11-12  4:43   ` Tushar Behera
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2012-11-09 17:09 UTC (permalink / raw)
  To: Tushar Behera; +Cc: linux-kernel, philipspatches, patches

[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]

On Fri, Nov 09, 2012 at 04:21:49PM +0530, Tushar Behera wrote:

> In case of fixed regulators for which voltage cannot be changed,
> regulator_is_supported_voltage should return success only if the
> min_uV and max_uV parameters are same and it is equal to the current
> voltage of the regulator.

This makes no sense to me at all.  The caller is asking if it's possible
to set the voltage between the minimum and maximum values, any voltage
in that range should be OK.  Your patch makes the function massively
less useful.

> Currently this patch breaks MMC support for boards on which vmmc is a
> fixed regulator and the voltage is not equal to either of 3.3v, 3.0v
> or 1.8v. Earlier it used to work if the voltage was less than 3.3v.

This sounds like a problem in the MMC framework.  If it's happy with
non-standard voltages it should be happy with non-standard voltages,
or perhaps it should be ignoring voltages if it can't find any sane
voltages at all.  The regulator framework is accurately answering the
question it was asked.

It also seems like the MMC framework will be broken by a regulator which
can change voltage but not over the full range the MMC framework is
interested in, this is essentially just a special case of that situation.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] regulator: core: Update regulator_is_supported_voltage for fixed voltages
  2012-11-09 17:09 ` Mark Brown
@ 2012-11-12  4:43   ` Tushar Behera
  2012-11-13  6:48     ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Tushar Behera @ 2012-11-12  4:43 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, philipspatches, patches

On 11/09/2012 10:39 PM, Mark Brown wrote:
> On Fri, Nov 09, 2012 at 04:21:49PM +0530, Tushar Behera wrote:
> 
>> In case of fixed regulators for which voltage cannot be changed,
>> regulator_is_supported_voltage should return success only if the
>> min_uV and max_uV parameters are same and it is equal to the current
>> voltage of the regulator.
> 
> This makes no sense to me at all.  The caller is asking if it's possible
> to set the voltage between the minimum and maximum values, any voltage
> in that range should be OK.  Your patch makes the function massively
> less useful.
> 

Ok.

In that case, we should modify the test condition as following.
Currently it passes success when the regulator voltage is less than both
min_uV and max_uV. If ok, I will send another patch for this.

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 1a35251..e90e5c3 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1974,7 +1974,7 @@ int regulator_is_supported_voltage(struct
regulator *regulator,
        if (!(rdev->constraints->valid_ops_mask &
REGULATOR_CHANGE_VOLTAGE)) {
                ret = regulator_get_voltage(regulator);
                if (ret >= 0)
-                       return (min_uV >= ret && ret <= max_uV);
+                       return (ret >= min_uV && ret <= max_uV);
                else
                        return ret;
        }


-- 
Tushar Behera

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] regulator: core: Update regulator_is_supported_voltage for fixed voltages
  2012-11-12  4:43   ` Tushar Behera
@ 2012-11-13  6:48     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-11-13  6:48 UTC (permalink / raw)
  To: Tushar Behera; +Cc: linux-kernel, philipspatches, patches

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

On Mon, Nov 12, 2012 at 10:13:55AM +0530, Tushar Behera wrote:

> In that case, we should modify the test condition as following.
> Currently it passes success when the regulator voltage is less than both
> min_uV and max_uV. If ok, I will send another patch for this.

Documentation/SubmittingPatches...

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-11-13  6:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-09 10:51 [PATCH] regulator: core: Update regulator_is_supported_voltage for fixed voltages Tushar Behera
2012-11-09 17:09 ` Mark Brown
2012-11-12  4:43   ` Tushar Behera
2012-11-13  6:48     ` 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).