Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Charles Keepax and committed by
Mark Brown
06217197 2ea659a9

+5 -5
+5 -5
drivers/regulator/core.c
··· 1462 1462 static struct regulator_dev *regulator_dev_lookup(struct device *dev, 1463 1463 const char *supply) 1464 1464 { 1465 - struct regulator_dev *r; 1465 + struct regulator_dev *r = NULL; 1466 1466 struct device_node *node; 1467 1467 struct regulator_map *map; 1468 1468 const char *devname = NULL; ··· 1489 1489 if (dev) 1490 1490 devname = dev_name(dev); 1491 1491 1492 - r = regulator_lookup_by_name(supply); 1493 - if (r) 1494 - return r; 1495 - 1496 1492 mutex_lock(&regulator_list_mutex); 1497 1493 list_for_each_entry(map, &regulator_map_list, list) { 1498 1494 /* If the mapping has a device set up it must match */ ··· 1504 1508 } 1505 1509 mutex_unlock(&regulator_list_mutex); 1506 1510 1511 + if (r) 1512 + return r; 1513 + 1514 + r = regulator_lookup_by_name(supply); 1507 1515 if (r) 1508 1516 return r; 1509 1517