All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage
@ 2014-02-20 16:36 ` Markus Pargmann
  0 siblings, 0 replies; 16+ messages in thread
From: Markus Pargmann @ 2014-02-20 16:36 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: linux-kernel, linux-arm-kernel, kernel, Markus Pargmann

Hi,

These two patches replace all ops->enable/disable by
_regulator_do_disable/enable function calls. These wrappers also handle gpio
regulators.

v3 adds a comment about the moved _notifier_call_chain() function calls and
removes a unused variable from the core driver in patch 2
(Replace direct ops->disable usage).

Regards,

Markus


Markus Pargmann (2):
  regulator: core: Replace direct ops->enable usage
  regulator: core: Replace direct ops->disable usage

 drivers/regulator/core.c | 46 +++++++++++++++++++---------------------------
 1 file changed, 19 insertions(+), 27 deletions(-)

-- 
1.8.5.3


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

* [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage
@ 2014-02-20 16:36 ` Markus Pargmann
  0 siblings, 0 replies; 16+ messages in thread
From: Markus Pargmann @ 2014-02-20 16:36 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

These two patches replace all ops->enable/disable by
_regulator_do_disable/enable function calls. These wrappers also handle gpio
regulators.

v3 adds a comment about the moved _notifier_call_chain() function calls and
removes a unused variable from the core driver in patch 2
(Replace direct ops->disable usage).

Regards,

Markus


Markus Pargmann (2):
  regulator: core: Replace direct ops->enable usage
  regulator: core: Replace direct ops->disable usage

 drivers/regulator/core.c | 46 +++++++++++++++++++---------------------------
 1 file changed, 19 insertions(+), 27 deletions(-)

-- 
1.8.5.3

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

* [PATCH v3 1/2] regulator: core: Replace direct ops->enable usage
  2014-02-20 16:36 ` Markus Pargmann
@ 2014-02-20 16:36   ` Markus Pargmann
  -1 siblings, 0 replies; 16+ messages in thread
From: Markus Pargmann @ 2014-02-20 16:36 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: linux-kernel, linux-arm-kernel, kernel, Markus Pargmann, stable

There are some direct ops->enable in the regulator core driver. This is
a potential issue as the function _regulator_do_enable() handles gpio
regulators and the normal ops->enable calls. These gpio regulators are
simply ignored when ops->enable is called directly.

One possible bug is that boot-on and always-on gpio regulators are not
enabled on registration.

This patch replaces all ops->enable calls by _regulator_do_enable.

Cc: <stable@vger.kernel.org> # 3.10+
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/regulator/core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 16a309e..017f5cb 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -953,6 +953,8 @@ static int machine_constraints_current(struct regulator_dev *rdev,
 	return 0;
 }
 
+static int _regulator_do_enable(struct regulator_dev *rdev);
+
 /**
  * set_machine_constraints - sets regulator constraints
  * @rdev: regulator source
@@ -1013,9 +1015,8 @@ static int set_machine_constraints(struct regulator_dev *rdev,
 	/* If the constraints say the regulator should be on at this point
 	 * and we have control then make sure it is enabled.
 	 */
-	if ((rdev->constraints->always_on || rdev->constraints->boot_on) &&
-	    ops->enable) {
-		ret = ops->enable(rdev);
+	if (rdev->constraints->always_on || rdev->constraints->boot_on) {
+		ret = _regulator_do_enable(rdev);
 		if (ret < 0) {
 			rdev_err(rdev, "failed to enable\n");
 			goto out;
@@ -3633,9 +3634,8 @@ int regulator_suspend_finish(void)
 		struct regulator_ops *ops = rdev->desc->ops;
 
 		mutex_lock(&rdev->mutex);
-		if ((rdev->use_count > 0  || rdev->constraints->always_on) &&
-				ops->enable) {
-			error = ops->enable(rdev);
+		if (rdev->use_count > 0  || rdev->constraints->always_on) {
+			error = _regulator_do_enable(rdev);
 			if (error)
 				ret = error;
 		} else {
-- 
1.8.5.3


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

* [PATCH v3 1/2] regulator: core: Replace direct ops->enable usage
@ 2014-02-20 16:36   ` Markus Pargmann
  0 siblings, 0 replies; 16+ messages in thread
From: Markus Pargmann @ 2014-02-20 16:36 UTC (permalink / raw)
  To: linux-arm-kernel

There are some direct ops->enable in the regulator core driver. This is
a potential issue as the function _regulator_do_enable() handles gpio
regulators and the normal ops->enable calls. These gpio regulators are
simply ignored when ops->enable is called directly.

One possible bug is that boot-on and always-on gpio regulators are not
enabled on registration.

This patch replaces all ops->enable calls by _regulator_do_enable.

Cc: <stable@vger.kernel.org> # 3.10+
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/regulator/core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 16a309e..017f5cb 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -953,6 +953,8 @@ static int machine_constraints_current(struct regulator_dev *rdev,
 	return 0;
 }
 
+static int _regulator_do_enable(struct regulator_dev *rdev);
+
 /**
  * set_machine_constraints - sets regulator constraints
  * @rdev: regulator source
@@ -1013,9 +1015,8 @@ static int set_machine_constraints(struct regulator_dev *rdev,
 	/* If the constraints say the regulator should be on at this point
 	 * and we have control then make sure it is enabled.
 	 */
-	if ((rdev->constraints->always_on || rdev->constraints->boot_on) &&
-	    ops->enable) {
-		ret = ops->enable(rdev);
+	if (rdev->constraints->always_on || rdev->constraints->boot_on) {
+		ret = _regulator_do_enable(rdev);
 		if (ret < 0) {
 			rdev_err(rdev, "failed to enable\n");
 			goto out;
@@ -3633,9 +3634,8 @@ int regulator_suspend_finish(void)
 		struct regulator_ops *ops = rdev->desc->ops;
 
 		mutex_lock(&rdev->mutex);
-		if ((rdev->use_count > 0  || rdev->constraints->always_on) &&
-				ops->enable) {
-			error = ops->enable(rdev);
+		if (rdev->use_count > 0  || rdev->constraints->always_on) {
+			error = _regulator_do_enable(rdev);
 			if (error)
 				ret = error;
 		} else {
-- 
1.8.5.3

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

* [PATCH v3 2/2] regulator: core: Replace direct ops->disable usage
  2014-02-20 16:36 ` Markus Pargmann
@ 2014-02-20 16:36   ` Markus Pargmann
  -1 siblings, 0 replies; 16+ messages in thread
From: Markus Pargmann @ 2014-02-20 16:36 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: linux-kernel, linux-arm-kernel, kernel, Markus Pargmann, stable

There are many places where ops->disable is called directly. Instead we
should use _regulator_do_disable() which also handles gpio regulators.

To be able to use the wrapper function from _regulator_force_disable(),
I moved the _notifier_call_chain() call from _regulator_do_disable() to
_regulator_disable(). This way, _regulator_force_disable() can use
different flags for _notifier_call_chain() without calling it twice.

Cc: <stable@vger.kernel.org> # 3.10+
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/regulator/core.c | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 017f5cb..e7a83e5 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1908,8 +1908,6 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
 
 	trace_regulator_disable_complete(rdev_get_name(rdev));
 
-	_notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
-			     NULL);
 	return 0;
 }
 
@@ -1933,6 +1931,8 @@ static int _regulator_disable(struct regulator_dev *rdev)
 				rdev_err(rdev, "failed to disable\n");
 				return ret;
 			}
+			_notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
+					NULL);
 		}
 
 		rdev->use_count = 0;
@@ -1985,20 +1985,16 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
 {
 	int ret = 0;
 
-	/* force disable */
-	if (rdev->desc->ops->disable) {
-		/* ah well, who wants to live forever... */
-		ret = rdev->desc->ops->disable(rdev);
-		if (ret < 0) {
-			rdev_err(rdev, "failed to force disable\n");
-			return ret;
-		}
-		/* notify other consumers that power has been forced off */
-		_notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
-			REGULATOR_EVENT_DISABLE, NULL);
+	ret = _regulator_do_disable(rdev);
+	if (ret < 0) {
+		rdev_err(rdev, "failed to force disable\n");
+		return ret;
 	}
 
-	return ret;
+	_notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
+			REGULATOR_EVENT_DISABLE, NULL);
+
+	return 0;
 }
 
 /**
@@ -3631,8 +3627,6 @@ int regulator_suspend_finish(void)
 
 	mutex_lock(&regulator_list_mutex);
 	list_for_each_entry(rdev, &regulator_list, list) {
-		struct regulator_ops *ops = rdev->desc->ops;
-
 		mutex_lock(&rdev->mutex);
 		if (rdev->use_count > 0  || rdev->constraints->always_on) {
 			error = _regulator_do_enable(rdev);
@@ -3641,12 +3635,10 @@ int regulator_suspend_finish(void)
 		} else {
 			if (!have_full_constraints())
 				goto unlock;
-			if (!ops->disable)
-				goto unlock;
 			if (!_regulator_is_enabled(rdev))
 				goto unlock;
 
-			error = ops->disable(rdev);
+			error = _regulator_do_disable(rdev);
 			if (error)
 				ret = error;
 		}
@@ -3820,7 +3812,7 @@ static int __init regulator_init_complete(void)
 		ops = rdev->desc->ops;
 		c = rdev->constraints;
 
-		if (!ops->disable || (c && c->always_on))
+		if (c && c->always_on)
 			continue;
 
 		mutex_lock(&rdev->mutex);
@@ -3841,7 +3833,7 @@ static int __init regulator_init_complete(void)
 			/* We log since this may kill the system if it
 			 * goes wrong. */
 			rdev_info(rdev, "disabling\n");
-			ret = ops->disable(rdev);
+			ret = _regulator_do_disable(rdev);
 			if (ret != 0)
 				rdev_err(rdev, "couldn't disable: %d\n", ret);
 		} else {
-- 
1.8.5.3


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

* [PATCH v3 2/2] regulator: core: Replace direct ops->disable usage
@ 2014-02-20 16:36   ` Markus Pargmann
  0 siblings, 0 replies; 16+ messages in thread
From: Markus Pargmann @ 2014-02-20 16:36 UTC (permalink / raw)
  To: linux-arm-kernel

There are many places where ops->disable is called directly. Instead we
should use _regulator_do_disable() which also handles gpio regulators.

To be able to use the wrapper function from _regulator_force_disable(),
I moved the _notifier_call_chain() call from _regulator_do_disable() to
_regulator_disable(). This way, _regulator_force_disable() can use
different flags for _notifier_call_chain() without calling it twice.

Cc: <stable@vger.kernel.org> # 3.10+
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 drivers/regulator/core.c | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 017f5cb..e7a83e5 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1908,8 +1908,6 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
 
 	trace_regulator_disable_complete(rdev_get_name(rdev));
 
-	_notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
-			     NULL);
 	return 0;
 }
 
@@ -1933,6 +1931,8 @@ static int _regulator_disable(struct regulator_dev *rdev)
 				rdev_err(rdev, "failed to disable\n");
 				return ret;
 			}
+			_notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
+					NULL);
 		}
 
 		rdev->use_count = 0;
@@ -1985,20 +1985,16 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
 {
 	int ret = 0;
 
-	/* force disable */
-	if (rdev->desc->ops->disable) {
-		/* ah well, who wants to live forever... */
-		ret = rdev->desc->ops->disable(rdev);
-		if (ret < 0) {
-			rdev_err(rdev, "failed to force disable\n");
-			return ret;
-		}
-		/* notify other consumers that power has been forced off */
-		_notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
-			REGULATOR_EVENT_DISABLE, NULL);
+	ret = _regulator_do_disable(rdev);
+	if (ret < 0) {
+		rdev_err(rdev, "failed to force disable\n");
+		return ret;
 	}
 
-	return ret;
+	_notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
+			REGULATOR_EVENT_DISABLE, NULL);
+
+	return 0;
 }
 
 /**
@@ -3631,8 +3627,6 @@ int regulator_suspend_finish(void)
 
 	mutex_lock(&regulator_list_mutex);
 	list_for_each_entry(rdev, &regulator_list, list) {
-		struct regulator_ops *ops = rdev->desc->ops;
-
 		mutex_lock(&rdev->mutex);
 		if (rdev->use_count > 0  || rdev->constraints->always_on) {
 			error = _regulator_do_enable(rdev);
@@ -3641,12 +3635,10 @@ int regulator_suspend_finish(void)
 		} else {
 			if (!have_full_constraints())
 				goto unlock;
-			if (!ops->disable)
-				goto unlock;
 			if (!_regulator_is_enabled(rdev))
 				goto unlock;
 
-			error = ops->disable(rdev);
+			error = _regulator_do_disable(rdev);
 			if (error)
 				ret = error;
 		}
@@ -3820,7 +3812,7 @@ static int __init regulator_init_complete(void)
 		ops = rdev->desc->ops;
 		c = rdev->constraints;
 
-		if (!ops->disable || (c && c->always_on))
+		if (c && c->always_on)
 			continue;
 
 		mutex_lock(&rdev->mutex);
@@ -3841,7 +3833,7 @@ static int __init regulator_init_complete(void)
 			/* We log since this may kill the system if it
 			 * goes wrong. */
 			rdev_info(rdev, "disabling\n");
-			ret = ops->disable(rdev);
+			ret = _regulator_do_disable(rdev);
 			if (ret != 0)
 				rdev_err(rdev, "couldn't disable: %d\n", ret);
 		} else {
-- 
1.8.5.3

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

* Re: [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage
  2014-02-20 16:36 ` Markus Pargmann
@ 2014-02-23  5:12   ` Mark Brown
  -1 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-02-23  5:12 UTC (permalink / raw)
  To: Markus Pargmann; +Cc: Liam Girdwood, linux-kernel, linux-arm-kernel, kernel

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

On Thu, Feb 20, 2014 at 05:36:02PM +0100, Markus Pargmann wrote:
> Hi,
> 
> These two patches replace all ops->enable/disable by
> _regulator_do_disable/enable function calls. These wrappers also handle gpio
> regulators.

Applied both, thanks.

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

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

* [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage
@ 2014-02-23  5:12   ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-02-23  5:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Feb 20, 2014 at 05:36:02PM +0100, Markus Pargmann wrote:
> Hi,
> 
> These two patches replace all ops->enable/disable by
> _regulator_do_disable/enable function calls. These wrappers also handle gpio
> regulators.

Applied both, thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140223/89983088/attachment.sig>

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

* Re: [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage
  2014-02-23  5:12   ` Mark Brown
@ 2014-02-24 17:23     ` Fabio Estevam
  -1 siblings, 0 replies; 16+ messages in thread
From: Fabio Estevam @ 2014-02-24 17:23 UTC (permalink / raw)
  To: Mark Brown
  Cc: Markus Pargmann, Sascha Hauer, Liam Girdwood, linux-arm-kernel,
	linux-kernel

On Sun, Feb 23, 2014 at 2:12 AM, Mark Brown <broonie@kernel.org> wrote:
> On Thu, Feb 20, 2014 at 05:36:02PM +0100, Markus Pargmann wrote:
>> Hi,
>>
>> These two patches replace all ops->enable/disable by
>> _regulator_do_disable/enable function calls. These wrappers also handle gpio
>> regulators.
>
> Applied both, thanks.

With these two patches applied I get the following error on
mx6qsabresd running today's linux-next:

vdd1p1: failed to enable
anatop_regulator regulator-1p1.2: failed to register vdd1p1
anatop_regulator: probe of regulator-1p1.2 failed with error -22
vdd3p0: failed to enable
anatop_regulator regulator-3p0.3: failed to register vdd3p0
anatop_regulator: probe of regulator-3p0.3 failed with error -22
vdd2p5: failed to enable
anatop_regulator regulator-2p5.4: failed to register vdd2p5
anatop_regulator: probe of regulator-2p5.4 failed with error -22
vddarm: 725 <--> 1450 mV at 1100 mV
vddpu: 725 <--> 1450 mV at 1100 mV
vddsoc: 725 <--> 1450 mV at 1175 mV
....

pfuze100-regulator 1-0008: Full layer: 1, Metal layer: 0
pfuze100-regulator 1-0008: FAB: 0, FIN: 0
SW1AB: failed to enable
pfuze100-regulator 1-0008: register regulatorSW1AB failed
pfuze100-regulator: probe of 1-0008 failed with error -22


Reverting these two patches the regulators probe successfully.

Any ideas?

Regards,

Fabio Estevam

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

* [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage
@ 2014-02-24 17:23     ` Fabio Estevam
  0 siblings, 0 replies; 16+ messages in thread
From: Fabio Estevam @ 2014-02-24 17:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Feb 23, 2014 at 2:12 AM, Mark Brown <broonie@kernel.org> wrote:
> On Thu, Feb 20, 2014 at 05:36:02PM +0100, Markus Pargmann wrote:
>> Hi,
>>
>> These two patches replace all ops->enable/disable by
>> _regulator_do_disable/enable function calls. These wrappers also handle gpio
>> regulators.
>
> Applied both, thanks.

With these two patches applied I get the following error on
mx6qsabresd running today's linux-next:

vdd1p1: failed to enable
anatop_regulator regulator-1p1.2: failed to register vdd1p1
anatop_regulator: probe of regulator-1p1.2 failed with error -22
vdd3p0: failed to enable
anatop_regulator regulator-3p0.3: failed to register vdd3p0
anatop_regulator: probe of regulator-3p0.3 failed with error -22
vdd2p5: failed to enable
anatop_regulator regulator-2p5.4: failed to register vdd2p5
anatop_regulator: probe of regulator-2p5.4 failed with error -22
vddarm: 725 <--> 1450 mV at 1100 mV
vddpu: 725 <--> 1450 mV at 1100 mV
vddsoc: 725 <--> 1450 mV at 1175 mV
....

pfuze100-regulator 1-0008: Full layer: 1, Metal layer: 0
pfuze100-regulator 1-0008: FAB: 0, FIN: 0
SW1AB: failed to enable
pfuze100-regulator 1-0008: register regulatorSW1AB failed
pfuze100-regulator: probe of 1-0008 failed with error -22


Reverting these two patches the regulators probe successfully.

Any ideas?

Regards,

Fabio Estevam

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

* Re: [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage
  2014-02-24 17:23     ` Fabio Estevam
@ 2014-02-24 20:50       ` Markus Pargmann
  -1 siblings, 0 replies; 16+ messages in thread
From: Markus Pargmann @ 2014-02-24 20:50 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Mark Brown, Sascha Hauer, Liam Girdwood, linux-arm-kernel, linux-kernel

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

Hi Fabio,

On Mon, Feb 24, 2014 at 02:23:50PM -0300, Fabio Estevam wrote:
> On Sun, Feb 23, 2014 at 2:12 AM, Mark Brown <broonie@kernel.org> wrote:
> > On Thu, Feb 20, 2014 at 05:36:02PM +0100, Markus Pargmann wrote:
> >> Hi,
> >>
> >> These two patches replace all ops->enable/disable by
> >> _regulator_do_disable/enable function calls. These wrappers also handle gpio
> >> regulators.
> >
> > Applied both, thanks.
> 
> With these two patches applied I get the following error on
> mx6qsabresd running today's linux-next:
> 
> vdd1p1: failed to enable
> anatop_regulator regulator-1p1.2: failed to register vdd1p1
> anatop_regulator: probe of regulator-1p1.2 failed with error -22
> vdd3p0: failed to enable
> anatop_regulator regulator-3p0.3: failed to register vdd3p0
> anatop_regulator: probe of regulator-3p0.3 failed with error -22
> vdd2p5: failed to enable
> anatop_regulator regulator-2p5.4: failed to register vdd2p5
> anatop_regulator: probe of regulator-2p5.4 failed with error -22
> vddarm: 725 <--> 1450 mV at 1100 mV
> vddpu: 725 <--> 1450 mV at 1100 mV
> vddsoc: 725 <--> 1450 mV at 1175 mV
> ....
> 
> pfuze100-regulator 1-0008: Full layer: 1, Metal layer: 0
> pfuze100-regulator 1-0008: FAB: 0, FIN: 0
> SW1AB: failed to enable
> pfuze100-regulator 1-0008: register regulatorSW1AB failed
> pfuze100-regulator: probe of 1-0008 failed with error -22
> 
> 
> Reverting these two patches the regulators probe successfully.
> 
> Any ideas?

Thanks, I just searched for the reason and found it. My patches do not
handle dummy regulators correctly:

_regulator_do_enable() line 1764:
        if (rdev->ena_pin) {
                ret = regulator_ena_gpio_ctrl(rdev, true);
                if (ret < 0)
                        return ret;
                rdev->ena_gpio_state = 1;
        } else if (rdev->desc->ops->enable) {
                ret = rdev->desc->ops->enable(rdev);
                if (ret < 0)
                        return ret;
        } else {
                return -EINVAL;
        }

The only situation where this returns -EINVAL is a dummy regulator that
is not always_on. As it doesn't make sense to have a dummy regulator
that is not always_on, I will add a check for exactly this situation to
the regulator_register function and drop the "return -EINVAL" above.

Regards,

Markus

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage
@ 2014-02-24 20:50       ` Markus Pargmann
  0 siblings, 0 replies; 16+ messages in thread
From: Markus Pargmann @ 2014-02-24 20:50 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Fabio,

On Mon, Feb 24, 2014 at 02:23:50PM -0300, Fabio Estevam wrote:
> On Sun, Feb 23, 2014 at 2:12 AM, Mark Brown <broonie@kernel.org> wrote:
> > On Thu, Feb 20, 2014 at 05:36:02PM +0100, Markus Pargmann wrote:
> >> Hi,
> >>
> >> These two patches replace all ops->enable/disable by
> >> _regulator_do_disable/enable function calls. These wrappers also handle gpio
> >> regulators.
> >
> > Applied both, thanks.
> 
> With these two patches applied I get the following error on
> mx6qsabresd running today's linux-next:
> 
> vdd1p1: failed to enable
> anatop_regulator regulator-1p1.2: failed to register vdd1p1
> anatop_regulator: probe of regulator-1p1.2 failed with error -22
> vdd3p0: failed to enable
> anatop_regulator regulator-3p0.3: failed to register vdd3p0
> anatop_regulator: probe of regulator-3p0.3 failed with error -22
> vdd2p5: failed to enable
> anatop_regulator regulator-2p5.4: failed to register vdd2p5
> anatop_regulator: probe of regulator-2p5.4 failed with error -22
> vddarm: 725 <--> 1450 mV at 1100 mV
> vddpu: 725 <--> 1450 mV at 1100 mV
> vddsoc: 725 <--> 1450 mV at 1175 mV
> ....
> 
> pfuze100-regulator 1-0008: Full layer: 1, Metal layer: 0
> pfuze100-regulator 1-0008: FAB: 0, FIN: 0
> SW1AB: failed to enable
> pfuze100-regulator 1-0008: register regulatorSW1AB failed
> pfuze100-regulator: probe of 1-0008 failed with error -22
> 
> 
> Reverting these two patches the regulators probe successfully.
> 
> Any ideas?

Thanks, I just searched for the reason and found it. My patches do not
handle dummy regulators correctly:

_regulator_do_enable() line 1764:
        if (rdev->ena_pin) {
                ret = regulator_ena_gpio_ctrl(rdev, true);
                if (ret < 0)
                        return ret;
                rdev->ena_gpio_state = 1;
        } else if (rdev->desc->ops->enable) {
                ret = rdev->desc->ops->enable(rdev);
                if (ret < 0)
                        return ret;
        } else {
                return -EINVAL;
        }

The only situation where this returns -EINVAL is a dummy regulator that
is not always_on. As it doesn't make sense to have a dummy regulator
that is not always_on, I will add a check for exactly this situation to
the regulator_register function and drop the "return -EINVAL" above.

Regards,

Markus

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140224/22a14332/attachment.sig>

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

* Re: [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage
  2014-02-24 20:50       ` Markus Pargmann
@ 2014-02-25  1:34         ` Mark Brown
  -1 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-02-25  1:34 UTC (permalink / raw)
  To: Markus Pargmann
  Cc: Fabio Estevam, Sascha Hauer, Liam Girdwood, linux-arm-kernel,
	linux-kernel

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

On Mon, Feb 24, 2014 at 09:50:58PM +0100, Markus Pargmann wrote:

> The only situation where this returns -EINVAL is a dummy regulator that
> is not always_on. As it doesn't make sense to have a dummy regulator
> that is not always_on, I will add a check for exactly this situation to
> the regulator_register function and drop the "return -EINVAL" above.

I've squashed the following fix in today:

From 937635aa9c667b90b76505de91c5693da6a5c120 Mon Sep 17 00:00:00 2001
From: Mark Brown <broonie@linaro.org>
Date: Tue, 25 Feb 2014 10:24:55 +0900
Subject: [PATCH] regulator: Handle invalid enable operation for always/boot on
 regulators

Signed-off-by: Mark Brown <broonie@linaro.org>
---
 drivers/regulator/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 8cbc7d7..9a09f3c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1017,7 +1017,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
 	 */
 	if (rdev->constraints->always_on || rdev->constraints->boot_on) {
 		ret = _regulator_do_enable(rdev);
-		if (ret < 0) {
+		if (ret < 0 && ret != -EINVAL) {
 			rdev_err(rdev, "failed to enable\n");
 			goto out;
 		}
-- 
1.9.0.rc3


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

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

* [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage
@ 2014-02-25  1:34         ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-02-25  1:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Feb 24, 2014 at 09:50:58PM +0100, Markus Pargmann wrote:

> The only situation where this returns -EINVAL is a dummy regulator that
> is not always_on. As it doesn't make sense to have a dummy regulator
> that is not always_on, I will add a check for exactly this situation to
> the regulator_register function and drop the "return -EINVAL" above.

I've squashed the following fix in today:

>From 937635aa9c667b90b76505de91c5693da6a5c120 Mon Sep 17 00:00:00 2001
From: Mark Brown <broonie@linaro.org>
Date: Tue, 25 Feb 2014 10:24:55 +0900
Subject: [PATCH] regulator: Handle invalid enable operation for always/boot on
 regulators

Signed-off-by: Mark Brown <broonie@linaro.org>
---
 drivers/regulator/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 8cbc7d7..9a09f3c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1017,7 +1017,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
 	 */
 	if (rdev->constraints->always_on || rdev->constraints->boot_on) {
 		ret = _regulator_do_enable(rdev);
-		if (ret < 0) {
+		if (ret < 0 && ret != -EINVAL) {
 			rdev_err(rdev, "failed to enable\n");
 			goto out;
 		}
-- 
1.9.0.rc3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140225/08164a1a/attachment.sig>

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

* Re: [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage
  2014-02-25  1:34         ` Mark Brown
@ 2014-02-25  2:18           ` Fabio Estevam
  -1 siblings, 0 replies; 16+ messages in thread
From: Fabio Estevam @ 2014-02-25  2:18 UTC (permalink / raw)
  To: Mark Brown
  Cc: Markus Pargmann, Sascha Hauer, Liam Girdwood, linux-arm-kernel,
	linux-kernel

On Mon, Feb 24, 2014 at 10:34 PM, Mark Brown <broonie@kernel.org> wrote:
> On Mon, Feb 24, 2014 at 09:50:58PM +0100, Markus Pargmann wrote:
>
>> The only situation where this returns -EINVAL is a dummy regulator that
>> is not always_on. As it doesn't make sense to have a dummy regulator
>> that is not always_on, I will add a check for exactly this situation to
>> the regulator_register function and drop the "return -EINVAL" above.
>
> I've squashed the following fix in today:

Thanks. This fixes the issue.

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

* [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage
@ 2014-02-25  2:18           ` Fabio Estevam
  0 siblings, 0 replies; 16+ messages in thread
From: Fabio Estevam @ 2014-02-25  2:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Feb 24, 2014 at 10:34 PM, Mark Brown <broonie@kernel.org> wrote:
> On Mon, Feb 24, 2014 at 09:50:58PM +0100, Markus Pargmann wrote:
>
>> The only situation where this returns -EINVAL is a dummy regulator that
>> is not always_on. As it doesn't make sense to have a dummy regulator
>> that is not always_on, I will add a check for exactly this situation to
>> the regulator_register function and drop the "return -EINVAL" above.
>
> I've squashed the following fix in today:

Thanks. This fixes the issue.

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

end of thread, other threads:[~2014-02-25  2:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-20 16:36 [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage Markus Pargmann
2014-02-20 16:36 ` Markus Pargmann
2014-02-20 16:36 ` [PATCH v3 1/2] regulator: core: Replace direct ops->enable usage Markus Pargmann
2014-02-20 16:36   ` Markus Pargmann
2014-02-20 16:36 ` [PATCH v3 2/2] regulator: core: Replace direct ops->disable usage Markus Pargmann
2014-02-20 16:36   ` Markus Pargmann
2014-02-23  5:12 ` [PATCH v3 0/2] regulator: core: Fix ops->enable/disable usage Mark Brown
2014-02-23  5:12   ` Mark Brown
2014-02-24 17:23   ` Fabio Estevam
2014-02-24 17:23     ` Fabio Estevam
2014-02-24 20:50     ` Markus Pargmann
2014-02-24 20:50       ` Markus Pargmann
2014-02-25  1:34       ` Mark Brown
2014-02-25  1:34         ` Mark Brown
2014-02-25  2:18         ` Fabio Estevam
2014-02-25  2:18           ` Fabio Estevam

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.