regulator: core: Pull non-DT supply mapping into regulator_dev_lookup()
Ensure we always apply the supply mapping when doing a lookup rather than only doing it in non-DT cases, ensuring that regulators with supplies specified in the regulator_desc can find their supplies on non-DT systems and generally making the code more obvious. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
6d191a5fc7
commit
576ca4367f
1 changed files with 16 additions and 13 deletions
|
@ -1174,6 +1174,8 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
|
||||||
{
|
{
|
||||||
struct regulator_dev *r;
|
struct regulator_dev *r;
|
||||||
struct device_node *node;
|
struct device_node *node;
|
||||||
|
struct regulator_map *map;
|
||||||
|
const char *devname = NULL;
|
||||||
|
|
||||||
/* first do a dt based lookup */
|
/* first do a dt based lookup */
|
||||||
if (dev && dev->of_node) {
|
if (dev && dev->of_node) {
|
||||||
|
@ -1195,10 +1197,24 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if not found, try doing it non-dt way */
|
/* if not found, try doing it non-dt way */
|
||||||
|
if (dev)
|
||||||
|
devname = dev_name(dev);
|
||||||
|
|
||||||
list_for_each_entry(r, ®ulator_list, list)
|
list_for_each_entry(r, ®ulator_list, list)
|
||||||
if (strcmp(rdev_get_name(r), supply) == 0)
|
if (strcmp(rdev_get_name(r), supply) == 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
list_for_each_entry(map, ®ulator_map_list, list) {
|
||||||
|
/* If the mapping has a device set up it must match */
|
||||||
|
if (map->dev_name &&
|
||||||
|
(!devname || strcmp(map->dev_name, devname)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcmp(map->supply, supply) == 0)
|
||||||
|
return map->regulator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1207,7 +1223,6 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
|
||||||
int exclusive)
|
int exclusive)
|
||||||
{
|
{
|
||||||
struct regulator_dev *rdev;
|
struct regulator_dev *rdev;
|
||||||
struct regulator_map *map;
|
|
||||||
struct regulator *regulator = ERR_PTR(-EPROBE_DEFER);
|
struct regulator *regulator = ERR_PTR(-EPROBE_DEFER);
|
||||||
const char *devname = NULL;
|
const char *devname = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -1226,18 +1241,6 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
|
||||||
if (rdev)
|
if (rdev)
|
||||||
goto found;
|
goto found;
|
||||||
|
|
||||||
list_for_each_entry(map, ®ulator_map_list, list) {
|
|
||||||
/* If the mapping has a device set up it must match */
|
|
||||||
if (map->dev_name &&
|
|
||||||
(!devname || strcmp(map->dev_name, devname)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (strcmp(map->supply, id) == 0) {
|
|
||||||
rdev = map->regulator;
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (board_wants_dummy_regulator) {
|
if (board_wants_dummy_regulator) {
|
||||||
rdev = dummy_regulator_rdev;
|
rdev = dummy_regulator_rdev;
|
||||||
goto found;
|
goto found;
|
||||||
|
|
Reference in a new issue