Skip to contentSkip to conversation

regulator: core: Prioritise consumer mappings over regulator name

PATCH In review Charles Keepax 2 participants 2 messages Jun 13, 2017 Voltage and current regulator framework

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 regulator: core: Prioritise consumer mappings over regulator name

Currently, when looking up a regulator supply, the regulator name takes priority over the consumer mappings. As there are a lot of regulator names that are in fairly common use (VDD, MICVDD, etc.) this can easily lead to obtaining the wrong supply, when a system contains two regulators that share a name.

The explicit consumer mappings contain much less ambiguity as they specify both a name and a consumer device. As such prioritise those if one exists and only fall back to the regulator name if there are no matching explicit mappings.

---

Changes since v1:
- Move regulator_lookup_by_name till after the search of the map list

Thanks,
Charles

 drivers/regulator/core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/regulator/core.c +5 -5
index 919b7f1..91f87fa 100644
@@ -1462,7 +1462,7 @@ static struct regulator_dev *regulator_lookup_by_name(const char *name)
 static struct regulator_dev *regulator_dev_lookup(struct device *dev,
 						  const char *supply)
 {
-	struct regulator_dev *r;
+	struct regulator_dev *r = NULL;
 	struct device_node *node;
 	struct regulator_map *map;
 	const char *devname = NULL;
@@ -1489,10 +1489,6 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
 	if (dev)
 		devname = dev_name(dev);
 
-	r = regulator_lookup_by_name(supply);
-	if (r)
-		return r;
-
 	mutex_lock(&regulator_list_mutex);
 	list_for_each_entry(map, &regulator_map_list, list) {
 		/* If the mapping has a device set up it must match */
@@ -1511,6 +1507,10 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
 	if (r)
 		return r;
 
+	r = regulator_lookup_by_name(supply);
+	if (r)
+		return r;
+
 	return ERR_PTR(-ENODEV);
 }
 
Signature · 1 line
2.1.4
maintainer
#1 lore raw

Applied "regulator: core: Prioritise consumer mappings over regulator name" to the regulator tree

The patch

regulator: core: Prioritise consumer mappings over regulator name

has been applied to the regulator tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 062171973e05440673cb997e64395e84a8e66350 Mon Sep 17 00:00:00 2001

From: Charles Keepax <[email protected]>
Date: Tue, 13 Jun 2017 16:12:47 +0100
Subject: [PATCH] regulator: core: Prioritise consumer mappings over regulator
name

Currently, when looking up a regulator supply, the regulator name takes priority over the consumer mappings. As there are a lot of regulator names that are in fairly common use (VDD, MICVDD, etc.) this can easily lead to obtaining the wrong supply, when a system contains two regulators that share a name.

The explicit consumer mappings contain much less ambiguity as they specify both a name and a consumer device. As such prioritise those if one exists and only fall back to the regulator name if there are no matching explicit mappings.

---
 drivers/regulator/core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/regulator/core.c +5 -5
index c0d9ae8d0860..a0362a63902e 100644
@@ -1462,7 +1462,7 @@ static struct regulator_dev *regulator_lookup_by_name(const char *name)
 static struct regulator_dev *regulator_dev_lookup(struct device *dev,
 						  const char *supply)
 {
-	struct regulator_dev *r;
+	struct regulator_dev *r = NULL;
 	struct device_node *node;
 	struct regulator_map *map;
 	const char *devname = NULL;
@@ -1489,10 +1489,6 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
 	if (dev)
 		devname = dev_name(dev);
 
-	r = regulator_lookup_by_name(supply);
-	if (r)
-		return r;
-
 	mutex_lock(&regulator_list_mutex);
 	list_for_each_entry(map, &regulator_map_list, list) {
 		/* If the mapping has a device set up it must match */
@@ -1511,6 +1507,10 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
 	if (r)
 		return r;
 
+	r = regulator_lookup_by_name(supply);
+	if (r)
+		return r;
+
 	return ERR_PTR(-ENODEV);
 }
 
Signature · 1 line
2.11.0