Skip to contentSkip to conversation

regulator: core: Prioritise consumer mappings over regulator name

PATCH Superseded Charles Keepax 2 participants 5 messages Jun 12, 2017 – Jun 13, 2017 Voltage and current regulator framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 drivers/regulator/core.c | 2 --
 1 file changed, 2 deletions(-)
drivers/regulator/core.c +0 -2
index 919b7f1..d257952 100644
@@ -1490,8 +1490,6 @@ static struct regulator_dev *regulator_dev_lookup(struct device *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) {
Signature · 1 line
2.1.4
maintainer
#1 lore raw

drivers/regulator/core.c static struct regulator_dev *regulator_dev_lookup(struct device *dev, · line 1494

Quoted 3 lines · Charles Keepax
drivers/regulator/core.c +0 -2
 	r = regulator_lookup_by_name(supply);
-	if (r)
-		return r;

Why have you left the lookup here?

#2 lore raw
Quoted 7 lines · Mark Brown

drivers/regulator/core.c static struct regulator_dev *regulator_dev_lookup(struct device *dev, · line 1494

Quoted 3 lines · Charles Keepax
drivers/regulator/core.c +0 -2
 	r = regulator_lookup_by_name(supply);
-	if (r)
-		return r;

Why have you left the lookup here?

Yeah was thinking that could maybe use a comment, if we don't find a match in the following loop over the supply map then we will exit with the regulator found here. So we can still use the regulator name for lookup just we default to the supply map.

Thanks,
Charles

maintainer
#3 lore raw
Quoted 9 lines · Charles Keepax
Quoted 7 lines · Mark Brown

drivers/regulator/core.c static struct regulator_dev *regulator_dev_lookup(struct device *dev, · line 1494

Quoted 3 lines · Charles Keepax
drivers/regulator/core.c +0 -2
 	r = regulator_lookup_by_name(supply);
-	if (r)
-		return r;

Why have you left the lookup here?

Quoted 4 lines

Yeah was thinking that could maybe use a comment, if we don't find a match in the following loop over the supply map then we will exit with the regulator found here. So we can still use the regulator name for lookup just we default to the supply map.

Why are we even doing the lookup here if we only use it if we fail to find a supply mapping?

#4 lore raw
Quoted 10 lines · Mark Brown
Quoted 8 lines · Charles Keepax
Quoted 7 lines · Mark Brown

drivers/regulator/core.c static struct regulator_dev *regulator_dev_lookup(struct device *dev, · line 1494

Quoted 3 lines · Charles Keepax
drivers/regulator/core.c +0 -2
 	r = regulator_lookup_by_name(supply);
-	if (r)
-		return r;

Why have you left the lookup here?

Quoted 7 lines
Quoted 4 lines

Yeah was thinking that could maybe use a comment, if we don't find a match in the following loop over the supply map then we will exit with the regulator found here. So we can still use the regulator name for lookup just we default to the supply map.

Why are we even doing the lookup here if we only use it if we fail to find a supply mapping?

Yeah I think that is probably a poor choice I will do a V2 that does the lookup conditionally after the search of the supply map.

Thanks,
Charles