public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: check for devicetree early.
@ 2013-11-01  2:48 NeilBrown
  2013-11-01  6:42 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: NeilBrown @ 2013-11-01  2:48 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: linux-kernel

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


The behaviour of regulator core with respect to device-tree and
CONFIG_REGULATOR_DUMMY is inconsistent.

If there is no device-tree, then a board file can call
regulator_has_full_constraints() and this will negate the effect of
CONFIG_REGULATOR_DUMMY.

If a device-tree is given, regulator_has_full_constraints() is called
automatically, but too late to effectively negate the effect of
CONFIG_REGULATOR_DUMMY.

So it makes sense for regulator/core to check for devicetree earlier and call
regulator_has_full_constraints() before any call to regulator_get() can trip
up on CONFIG_REGULATOR_DUMMY.

Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a01b8b3b70ca..8cd457ae66bc 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3748,13 +3748,8 @@ static int __init regulator_init(void)
 /* init early to allow our consumers to complete system booting */
 core_initcall(regulator_init);
 
-static int __init regulator_init_complete(void)
+static int __init regulator_init_early(void)
 {
-	struct regulator_dev *rdev;
-	struct regulator_ops *ops;
-	struct regulation_constraints *c;
-	int enabled, ret;
-
 	/*
 	 * Since DT doesn't provide an idiomatic mechanism for
 	 * enabling full constraints and since it's much more natural
@@ -3763,6 +3758,16 @@ static int __init regulator_init_complete(void)
 	 */
 	if (of_have_populated_dt())
 		has_full_constraints = true;
+	return 0;
+}
+early_initcall(regulator_init_early);
+
+static int __init regulator_init_complete(void)
+{
+	struct regulator_dev *rdev;
+	struct regulator_ops *ops;
+	struct regulation_constraints *c;
+	int enabled, ret;
 
 	mutex_lock(&regulator_list_mutex);
 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* Re: [PATCH] regulator: check for devicetree early.
  2013-11-01  2:48 [PATCH] regulator: check for devicetree early NeilBrown
@ 2013-11-01  6:42 ` Mark Brown
  2013-11-01  9:15   ` NeilBrown
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2013-11-01  6:42 UTC (permalink / raw)
  To: NeilBrown; +Cc: Liam Girdwood, linux-kernel

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

On Fri, Nov 01, 2013 at 01:48:33PM +1100, NeilBrown wrote:

> The behaviour of regulator core with respect to device-tree and
> CONFIG_REGULATOR_DUMMY is inconsistent.

Wei Ni reported this issue and is working on a patch which I'm expecting
to do this as part of device tree initialisation rather than by faffing
around with initcall ordering; this will be simpler and more robust
since there won't be any possibility of races being introduced.

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

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

* Re: [PATCH] regulator: check for devicetree early.
  2013-11-01  6:42 ` Mark Brown
@ 2013-11-01  9:15   ` NeilBrown
  0 siblings, 0 replies; 3+ messages in thread
From: NeilBrown @ 2013-11-01  9:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: Liam Girdwood, linux-kernel

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

On Thu, 31 Oct 2013 23:42:40 -0700 Mark Brown <broonie@kernel.org> wrote:

> On Fri, Nov 01, 2013 at 01:48:33PM +1100, NeilBrown wrote:
> 
> > The behaviour of regulator core with respect to device-tree and
> > CONFIG_REGULATOR_DUMMY is inconsistent.
> 
> Wei Ni reported this issue and is working on a patch which I'm expecting
> to do this as part of device tree initialisation rather than by faffing
> around with initcall ordering; this will be simpler and more robust
> since there won't be any possibility of races being introduced.

OK, thanks.  Sounds like a better approach.

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

end of thread, other threads:[~2013-11-01  9:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-01  2:48 [PATCH] regulator: check for devicetree early NeilBrown
2013-11-01  6:42 ` Mark Brown
2013-11-01  9:15   ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox