Skip to contentSkip to conversation

regulator: catch some registration errors

PATCH Applied Mark Brown 2 participants 2 messages Dec 31, 2008 – Jan 5, 2009 Voltage and current regulator framework

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 regulator: catch some registration errors

From: David Brownell <[email protected]>

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]

---
 drivers/regulator/core.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
drivers/regulator/core.c +14 -0
index 895f738..fcac9e5 100644
@@ -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;
Signature · 1 line
1.5.6.3