* [PATCH v2 0/2] regulator: core: Fix ops->enable/disable usage
@ 2014-02-20 11:07 Markus Pargmann
2014-02-20 11:07 ` [PATCH v2 1/2] regulator: core: Replace direct ops->enable usage Markus Pargmann
2014-02-20 11:07 ` [PATCH v2 2/2] regulator: core: Replace direct ops->disable usage Markus Pargmann
0 siblings, 2 replies; 7+ messages in thread
From: Markus Pargmann @ 2014-02-20 11:07 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.
v2 enables all regulators with delays and I added a patch to fix all direct
disable calls.
Regards,
Markus
Markus Pargmann (2):
regulator: core: Replace direct ops->enable usage
regulator: core: Replace direct ops->disable usage
drivers/regulator/core.c | 44 +++++++++++++++++++-------------------------
1 file changed, 19 insertions(+), 25 deletions(-)
--
1.8.5.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] regulator: core: Replace direct ops->enable usage
2014-02-20 11:07 [PATCH v2 0/2] regulator: core: Fix ops->enable/disable usage Markus Pargmann
@ 2014-02-20 11:07 ` Markus Pargmann
2014-02-20 11:07 ` [PATCH v2 2/2] regulator: core: Replace direct ops->disable usage Markus Pargmann
1 sibling, 0 replies; 7+ messages in thread
From: Markus Pargmann @ 2014-02-20 11:07 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] 7+ messages in thread
* [PATCH v2 2/2] regulator: core: Replace direct ops->disable usage
2014-02-20 11:07 [PATCH v2 0/2] regulator: core: Fix ops->enable/disable usage Markus Pargmann
2014-02-20 11:07 ` [PATCH v2 1/2] regulator: core: Replace direct ops->enable usage Markus Pargmann
@ 2014-02-20 11:07 ` Markus Pargmann
2014-02-20 12:03 ` Markus Pargmann
2014-02-20 12:51 ` Mark Brown
1 sibling, 2 replies; 7+ messages in thread
From: Markus Pargmann @ 2014-02-20 11:07 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.
Cc: <stable@vger.kernel.org> # 3.10+
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
drivers/regulator/core.c | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 017f5cb..a0c916f 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;
}
/**
@@ -3641,12 +3637,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 +3814,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 +3835,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] 7+ messages in thread
* [PATCH v2 2/2] regulator: core: Replace direct ops->disable usage
2014-02-20 11:07 ` [PATCH v2 2/2] regulator: core: Replace direct ops->disable usage Markus Pargmann
@ 2014-02-20 12:03 ` Markus Pargmann
2014-02-20 12:51 ` Mark Brown
1 sibling, 0 replies; 7+ messages in thread
From: Markus Pargmann @ 2014-02-20 12:03 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Feb 20, 2014 at 12:07:52PM +0100, Markus Pargmann wrote:
> There are many places where ops->disable is called directly. Instead we
> should use _regulator_do_disable() which also handles gpio regulators.
>
> Cc: <stable@vger.kernel.org> # 3.10+
> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> ---
> drivers/regulator/core.c | 32 +++++++++++++-------------------
> 1 file changed, 13 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 017f5cb..a0c916f 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
...
> @@ -3641,12 +3637,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);
ops is unused and creates a compile warning. I will resend later with
the 'ops' variable removed from the function.
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/20140220/5e70776e/attachment.sig>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] regulator: core: Replace direct ops->disable usage
2014-02-20 11:07 ` [PATCH v2 2/2] regulator: core: Replace direct ops->disable usage Markus Pargmann
2014-02-20 12:03 ` Markus Pargmann
@ 2014-02-20 12:51 ` Mark Brown
2014-02-20 13:01 ` Markus Pargmann
1 sibling, 1 reply; 7+ messages in thread
From: Mark Brown @ 2014-02-20 12:51 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Feb 20, 2014 at 12:07:52PM +0100, Markus Pargmann wrote:
> --- 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;
This change doesn't seem obviously related?
-------------- 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/20140220/8f0705dc/attachment-0001.sig>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] regulator: core: Replace direct ops->disable usage
2014-02-20 12:51 ` Mark Brown
@ 2014-02-20 13:01 ` Markus Pargmann
2014-02-20 13:17 ` Mark Brown
0 siblings, 1 reply; 7+ messages in thread
From: Markus Pargmann @ 2014-02-20 13:01 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Feb 20, 2014 at 09:51:30PM +0900, Mark Brown wrote:
> On Thu, Feb 20, 2014 at 12:07:52PM +0100, Markus Pargmann wrote:
>
> > --- 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;
>
> This change doesn't seem obviously related?
I am using this function from _regulator_force_disable(), which calls
_notifier_call_chain() with one additional flag
"REGULATOR_EVENT_FORCE_DISABLE". To prevent calling
_notifier_call_chain() twice for the force_disable case, I moved that
function call out of _regulator_do_disable().
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/20140220/e35c4719/attachment.sig>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] regulator: core: Replace direct ops->disable usage
2014-02-20 13:01 ` Markus Pargmann
@ 2014-02-20 13:17 ` Mark Brown
0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2014-02-20 13:17 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Feb 20, 2014 at 02:01:08PM +0100, Markus Pargmann wrote:
> I am using this function from _regulator_force_disable(), which calls
> _notifier_call_chain() with one additional flag
> "REGULATOR_EVENT_FORCE_DISABLE". To prevent calling
> _notifier_call_chain() twice for the force_disable case, I moved that
> function call out of _regulator_do_disable().
OK, put that in the changelog please.
-------------- 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/20140220/c13b83e8/attachment.sig>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-02-20 13:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-20 11:07 [PATCH v2 0/2] regulator: core: Fix ops->enable/disable usage Markus Pargmann
2014-02-20 11:07 ` [PATCH v2 1/2] regulator: core: Replace direct ops->enable usage Markus Pargmann
2014-02-20 11:07 ` [PATCH v2 2/2] regulator: core: Replace direct ops->disable usage Markus Pargmann
2014-02-20 12:03 ` Markus Pargmann
2014-02-20 12:51 ` Mark Brown
2014-02-20 13:01 ` Markus Pargmann
2014-02-20 13:17 ` 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).