* [PATCH] regulator: Rail is said to be enable only if this and supply rails are enabled.
@ 2012-01-03 6:09 Laxman Dewangan
[not found] ` <1325570983-3700-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Laxman Dewangan @ 2012-01-03 6:09 UTC (permalink / raw)
To: broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
lrg-l0cyMroinI0
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-pm-u79uwXL29TY76Z2rM5mHXA,
linux-tegra-u79uwXL29TY76Z2rM5mHXA,
ldewangan-DDmLM1+adcrQT0dZR+AlfA
From: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
The given rail is said to be enabled only if this rail is eanbled
along with supply rail.
Adding check for the supply rail whether it is enabled or not when
query about rail enabled.
Signed-off-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
When consumer of any rails query about whether rail is enabled
or not, the function regulator_is_enabled() should return enabled
only if this rail and supply rail (both) are enabled.
if any one of rail, whether the given rail or supply rail, is enabled
then function should return as not enabled.
drivers/regulator/core.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index dbdebed..d914435 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1701,6 +1701,12 @@ int regulator_is_enabled(struct regulator *regulator)
{
int ret;
+ if (regulator->rdev->supply) {
+ ret = regulator_is_enabled(regulator->rdev->supply);
+ if (ret <= 0)
+ return ret;
+ }
+
mutex_lock(®ulator->rdev->mutex);
ret = _regulator_is_enabled(regulator->rdev);
mutex_unlock(®ulator->rdev->mutex);
--
1.7.1.1
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <1325570983-3700-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH] regulator: Rail is said to be enable only if this and supply rails are enabled. [not found] ` <1325570983-3700-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> @ 2012-01-03 20:16 ` Mark Brown [not found] ` <20120103201624.GC2843-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Mark Brown @ 2012-01-03 20:16 UTC (permalink / raw) To: Laxman Dewangan Cc: lrg-l0cyMroinI0, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-pm-u79uwXL29TY76Z2rM5mHXA, linux-tegra-u79uwXL29TY76Z2rM5mHXA, ldewangan-DDmLM1+adcrQT0dZR+AlfA On Tue, Jan 03, 2012 at 11:39:43AM +0530, Laxman Dewangan wrote: > From: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > > The given rail is said to be enabled only if this rail is eanbled > along with supply rail. > Adding check for the supply rail whether it is enabled or not when > query about rail enabled. This feels wrong - the code in general assumes that the parents will all be enabled for an enabled child (and does the required stuff on enable and disable). Doing the check isn't unreasonable but if it fails we really ought to be complaining loudly as we're probably confused and things might be going wrong elsewhere. We should also look at the bootstrapping code, we're not really making much effort to verify that the hardware configuration on boot is sane (though realistically it's unlikely that it won't be). > Signed-off-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > --- > When consumer of any rails query about whether rail is enabled > or not, the function regulator_is_enabled() should return enabled > only if this rail and supply rail (both) are enabled. > if any one of rail, whether the given rail or supply rail, is enabled > then function should return as not enabled. Please just put things in the changelog if they're useful. ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20120103201624.GC2843-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>]
* RE: [PATCH] regulator: Rail is said to be enable only if this and supply rails are enabled. [not found] ` <20120103201624.GC2843-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> @ 2012-01-04 6:19 ` Laxman Dewangan [not found] ` <96C9D994977DD0439FB6D3FE3B13DD907DBD3A9C2E-kdsAE/FnitNDw2glCA4ptUEOCMrvLtNR@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Laxman Dewangan @ 2012-01-04 6:19 UTC (permalink / raw) To: Mark Brown, Laxman Dewangan Cc: lrg-l0cyMroinI0@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > From: Mark Brown [mailto:broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org] > Sent: Wednesday, January 04, 2012 1:46 AM +0530 > > > > The given rail is said to be enabled only if this rail is eanbled > > along with supply rail. > > Adding check for the supply rail whether it is enabled or not when > > query about rail enabled. > > This feels wrong - the code in general assumes that the parents will all > be enabled for an enabled child (and does the required stuff on enable > and disable). Doing the check isn't unreasonable but if it fails we > really ought to be complaining loudly as we're probably confused and > things might be going wrong elsewhere. > Yes, in general checking of the parent rail is not really required but it is good to have on safer side because it directly checks at the interface of regulator level rather than the ref count and give the more correct results. I came to this issue when I set the supply regulator for a rail and set the rail is always on but the supply regulator was not always on. And so this function returns true but actually the rail is not enabled because supply rail was not enabled. Although it is fixed in other patch but such checks help more. > We should also look at the bootstrapping code, we're not really making > much effort to verify that the hardware configuration on boot is sane > (though realistically it's unlikely that it won't be). > > > Signed-off-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> > > --- > > When consumer of any rails query about whether rail is enabled > > or not, the function regulator_is_enabled() should return enabled > > only if this rail and supply rail (both) are enabled. > > if any one of rail, whether the given rail or supply rail, is enabled > > then function should return as not enabled. > > Please just put things in the changelog if they're useful. I already send the 2nd patch for putting this info on changelog. Thanks, Laxman ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <96C9D994977DD0439FB6D3FE3B13DD907DBD3A9C2E-kdsAE/FnitNDw2glCA4ptUEOCMrvLtNR@public.gmane.org>]
* Re: [PATCH] regulator: Rail is said to be enable only if this and supply rails are enabled. [not found] ` <96C9D994977DD0439FB6D3FE3B13DD907DBD3A9C2E-kdsAE/FnitNDw2glCA4ptUEOCMrvLtNR@public.gmane.org> @ 2012-01-05 6:06 ` Mark Brown [not found] ` <20120105060646.GG11867-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Mark Brown @ 2012-01-05 6:06 UTC (permalink / raw) To: Laxman Dewangan Cc: Laxman Dewangan, lrg-l0cyMroinI0@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Wed, Jan 04, 2012 at 11:49:14AM +0530, Laxman Dewangan wrote: > > This feels wrong - the code in general assumes that the parents will all > > be enabled for an enabled child (and does the required stuff on enable > > and disable). Doing the check isn't unreasonable but if it fails we > > really ought to be complaining loudly as we're probably confused and > > things might be going wrong elsewhere. > returns true but actually the rail is not enabled because supply rail was not enabled. > Although it is fixed in other patch but such checks help more. You're not quite getting my point here - we should be treating this as an error and complaining about it when we notice it, your patch will silently mask the condition which seems likely to just cause the bug to manifest elsewhere. ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20120105060646.GG11867-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>]
* RE: [PATCH] regulator: Rail is said to be enable only if this and supply rails are enabled. [not found] ` <20120105060646.GG11867-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> @ 2012-01-05 14:12 ` Laxman Dewangan 0 siblings, 0 replies; 5+ messages in thread From: Laxman Dewangan @ 2012-01-05 14:12 UTC (permalink / raw) To: Mark Brown Cc: Laxman Dewangan, lrg-l0cyMroinI0@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > From: linux-tegra-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org [mailto:linux-tegra- > owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org] On Behalf Of Mark Brown > Sent: Thursday, January 05, 2012 11:37 AM > > returns true but actually the rail is not enabled because supply rail was > not enabled. > > Although it is fixed in other patch but such checks help more. > > You're not quite getting my point here - we should be treating this as > an error and complaining about it when we notice it, your patch will > silently mask the condition which seems likely to just cause the bug to > manifest elsewhere. Agree with you. Thanks for such details. Thanks, Laxman ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-01-05 14:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-03 6:09 [PATCH] regulator: Rail is said to be enable only if this and supply rails are enabled Laxman Dewangan
[not found] ` <1325570983-3700-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-01-03 20:16 ` Mark Brown
[not found] ` <20120103201624.GC2843-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-01-04 6:19 ` Laxman Dewangan
[not found] ` <96C9D994977DD0439FB6D3FE3B13DD907DBD3A9C2E-kdsAE/FnitNDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2012-01-05 6:06 ` Mark Brown
[not found] ` <20120105060646.GG11867-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-01-05 14:12 ` Laxman Dewangan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox