Message ID | 1392894472-11956-3-git-send-email-mpa@pengutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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
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?
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
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.
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 {
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(-)