mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] regulator: catch some registration errors
@ 2008-12-31 12:54 Mark Brown
  2009-01-05 12:04 ` Liam Girdwood
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2008-12-31 12:54 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: linux-kernel, David Brownell, Mark Brown

From: David Brownell <dbrownell@users.sourceforge.net>

Prevent registration of duplicate "struct regulator" names.
They'd be unavailable, and clearly indicate something wrong.

[Edited to remove check for NULL consumer device until we have a
solution for things like cpufreq -- broonie]

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/regulator/core.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 895f738..fcac9e5 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -775,6 +775,20 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
 	if (supply == NULL)
 		return -EINVAL;
 
+	list_for_each_entry(node, &regulator_map_list, list) {
+		if (consumer_dev != node->dev)
+			continue;
+		if (strcmp(node->supply, supply) != 0)
+			continue;
+
+		dev_dbg(consumer_dev, "%s/%s is '%s' supply; fail %s/%s\n",
+				dev_name(&node->regulator->dev),
+				node->regulator->desc->name,
+				supply,
+				dev_name(&rdev->dev), rdev->desc->name);
+		return -EBUSY;
+	}
+
 	node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL);
 	if (node == NULL)
 		return -ENOMEM;
-- 
1.5.6.3


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

* Re: [PATCH] regulator: catch some registration errors
  2008-12-31 12:54 [PATCH] regulator: catch some registration errors Mark Brown
@ 2009-01-05 12:04 ` Liam Girdwood
  0 siblings, 0 replies; 2+ messages in thread
From: Liam Girdwood @ 2009-01-05 12:04 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, David Brownell

On Wed, 2008-12-31 at 12:54 +0000, Mark Brown wrote:
> From: David Brownell <dbrownell@users.sourceforge.net>
> 
> Prevent registration of duplicate "struct regulator" names.
> They'd be unavailable, and clearly indicate something wrong.
> 
> [Edited to remove check for NULL consumer device until we have a
> solution for things like cpufreq -- broonie]
> 
> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Applied.

Thanks

Liam


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

end of thread, other threads:[~2009-01-05 12:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-31 12:54 [PATCH] regulator: catch some registration errors Mark Brown
2009-01-05 12:04 ` Liam Girdwood

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

all inboxes | Powered by JetHome®