public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: move set_machine_constraints after regulator device initialization
@ 2008-11-24 16:44 Mike Rapoport
  2008-11-25 11:39 ` Liam Girdwood
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Rapoport @ 2008-11-24 16:44 UTC (permalink / raw)
  To: lrg; +Cc: linux-kernel, Mike Rapoport

Calling set_machine_constraints before regulator device initialization
causes crash when constraints have apply_uV set.

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
---
 drivers/regulator/core.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 02a7744..c4636da 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1768,14 +1768,6 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
 		}
 	}
 
-	/* set regulator constraints */
-	ret = set_machine_constraints(rdev, &init_data->constraints);
-	if (ret < 0) {
-		kfree(rdev);
-		rdev = ERR_PTR(ret);
-		goto out;
-	}
-
 	/* register with sysfs */
 	rdev->dev.class = &regulator_class;
 	rdev->dev.parent = dev;
@@ -1790,6 +1782,15 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
 
 	dev_set_drvdata(&rdev->dev, rdev);
 
+	/* set regulator constraints */
+	ret = set_machine_constraints(rdev, &init_data->constraints);
+	if (ret < 0) {
+		device_unregister(&rdev->dev);
+		kfree(rdev);
+		rdev = ERR_PTR(ret);
+		goto out;
+	}
+
 	/* set supply regulator if it exists */
 	if (init_data->supply_regulator_dev) {
 		ret = set_supply(rdev,
-- 
1.5.6.4


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

* Re: [PATCH] regulator: move set_machine_constraints after regulator device initialization
  2008-11-24 16:44 [PATCH] regulator: move set_machine_constraints after regulator device initialization Mike Rapoport
@ 2008-11-25 11:39 ` Liam Girdwood
  2008-11-25 11:44   ` Mike Rapoport
  0 siblings, 1 reply; 3+ messages in thread
From: Liam Girdwood @ 2008-11-25 11:39 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: linux-kernel

On Mon, 2008-11-24 at 18:44 +0200, Mike Rapoport wrote:
> Calling set_machine_constraints before regulator device initialization
> causes crash when constraints have apply_uV set.
> 
> Signed-off-by: Mike Rapoport <mike@compulab.co.il>
> ---

There have been recent changes to regulator registration in the
regulator for-next branch. Does this crash still occur with for-next.

git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6.git #for-next

Liam


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

* Re: [PATCH] regulator: move set_machine_constraints after regulator device initialization
  2008-11-25 11:39 ` Liam Girdwood
@ 2008-11-25 11:44   ` Mike Rapoport
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Rapoport @ 2008-11-25 11:44 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: linux-kernel



Liam Girdwood wrote:
> On Mon, 2008-11-24 at 18:44 +0200, Mike Rapoport wrote:
>> Calling set_machine_constraints before regulator device initialization
>> causes crash when constraints have apply_uV set.
>>
>> Signed-off-by: Mike Rapoport <mike@compulab.co.il>
>> ---
> 
> There have been recent changes to regulator registration in the
> regulator for-next branch. Does this crash still occur with for-next.
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6.git #for-next

I haven't tested it yet, but looking at the code it seems the crash will occur
there as well.
regulator_register() calls set_machine_constraints() before setting rdev->dev
fields. The set_machine_constraints() in turn calls rdev->ops->set_voltage()
with NULL rdev->dev.

> Liam
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

-- 
Sincerely yours,
Mike.


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

end of thread, other threads:[~2008-11-25 11:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-24 16:44 [PATCH] regulator: move set_machine_constraints after regulator device initialization Mike Rapoport
2008-11-25 11:39 ` Liam Girdwood
2008-11-25 11:44   ` Mike Rapoport

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