All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC/RFT] regulator: core: Fix continuous_voltage_range case in regulator_can_change_voltage
@ 2012-12-12  1:22 Axel Lin
  2012-12-13  8:56 ` Marek Szyprowski
  2012-12-24 16:31 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2012-12-12  1:22 UTC (permalink / raw)
  To: Mark Brown; +Cc: Pawel Moll, Marek Szyprowski, Liam Girdwood, linux-kernel

Regulator drivers with continuous_voltage_range flag set allows not setting
n_voltages. Thus if continuous_voltage_range is set, check the constraint range
instead.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/core.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 0f65b24..d7448ad 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1885,9 +1885,15 @@ int regulator_can_change_voltage(struct regulator *regulator)
 	struct regulator_dev	*rdev = regulator->rdev;
 
 	if (rdev->constraints &&
-	    rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE &&
-	    (rdev->desc->n_voltages - rdev->desc->linear_min_sel) > 1)
-		return 1;
+	    (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
+		if (rdev->desc->n_voltages - rdev->desc->linear_min_sel > 1)
+			return 1;
+
+		if (rdev->desc->continuous_voltage_range &&
+		    rdev->constraints->min_uV && rdev->constraints->max_uV &&
+		    rdev->constraints->min_uV != rdev->constraints->max_uV)
+			return 1;
+	}
 
 	return 0;
 }
-- 
1.7.9.5




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

* Re: [PATCH RFC/RFT] regulator: core: Fix continuous_voltage_range case in regulator_can_change_voltage
  2012-12-12  1:22 [PATCH RFC/RFT] regulator: core: Fix continuous_voltage_range case in regulator_can_change_voltage Axel Lin
@ 2012-12-13  8:56 ` Marek Szyprowski
  2012-12-13  8:59   ` Mark Brown
  2012-12-24 16:31 ` Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Marek Szyprowski @ 2012-12-13  8:56 UTC (permalink / raw)
  To: Axel Lin
  Cc: Mark Brown, Pawel Moll, Liam Girdwood, linux-kernel, Chris Ball,
	Kevin Liu

Hello,

On 12/12/2012 2:22 AM, Axel Lin wrote:
> Regulator drivers with continuous_voltage_range flag set allows not setting
> n_voltages. Thus if continuous_voltage_range is set, check the constraint range
> instead.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>   drivers/regulator/core.c |   12 +++++++++---
>   1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 0f65b24..d7448ad 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -1885,9 +1885,15 @@ int regulator_can_change_voltage(struct regulator *regulator)
>   	struct regulator_dev	*rdev = regulator->rdev;
>
>   	if (rdev->constraints &&
> -	    rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE &&
> -	    (rdev->desc->n_voltages - rdev->desc->linear_min_sel) > 1)
> -		return 1;
> +	    (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
> +		if (rdev->desc->n_voltages - rdev->desc->linear_min_sel > 1)
> +			return 1;
> +
> +		if (rdev->desc->continuous_voltage_range &&
> +		    rdev->constraints->min_uV && rdev->constraints->max_uV &&
> +		    rdev->constraints->min_uV != rdev->constraints->max_uV)
> +			return 1;
> +	}
>
>   	return 0;
>   }
>

This change looks reasonable, I've missed the fact that there is a
support for regulators with continuous voltage range. This change also
shows that the n_voltages based workaround used earlier by mmc core was
indeed only a hack and regulator_can_change_voltage() approach is much
cleaner solution.

Best regards
-- 
Marek Szyprowski
Samsung Poland R&D Center


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

* Re: [PATCH RFC/RFT] regulator: core: Fix continuous_voltage_range case in regulator_can_change_voltage
  2012-12-13  8:56 ` Marek Szyprowski
@ 2012-12-13  8:59   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-12-13  8:59 UTC (permalink / raw)
  To: Marek Szyprowski
  Cc: Axel Lin, Pawel Moll, Liam Girdwood, linux-kernel, Chris Ball, Kevin Liu

On Thu, Dec 13, 2012 at 09:56:25AM +0100, Marek Szyprowski wrote:

> This change looks reasonable, I've missed the fact that there is a
> support for regulators with continuous voltage range. This change also
> shows that the n_voltages based workaround used earlier by mmc core was
> indeed only a hack and regulator_can_change_voltage() approach is much
> cleaner 

Both changes are new for v3.8 so it's not surprising that you missed the
continuous regulators.

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

* Re: [PATCH RFC/RFT] regulator: core: Fix continuous_voltage_range case in regulator_can_change_voltage
  2012-12-12  1:22 [PATCH RFC/RFT] regulator: core: Fix continuous_voltage_range case in regulator_can_change_voltage Axel Lin
  2012-12-13  8:56 ` Marek Szyprowski
@ 2012-12-24 16:31 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-12-24 16:31 UTC (permalink / raw)
  To: Axel Lin; +Cc: Pawel Moll, Marek Szyprowski, Liam Girdwood, linux-kernel

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

On Wed, Dec 12, 2012 at 09:22:46AM +0800, Axel Lin wrote:
> Regulator drivers with continuous_voltage_range flag set allows not setting
> n_voltages. Thus if continuous_voltage_range is set, check the constraint range
> instead.

Applied, thanks.

[-- 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-12-24 16:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-12  1:22 [PATCH RFC/RFT] regulator: core: Fix continuous_voltage_range case in regulator_can_change_voltage Axel Lin
2012-12-13  8:56 ` Marek Szyprowski
2012-12-13  8:59   ` Mark Brown
2012-12-24 16:31 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.