diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-03-30 07:24:37 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-03 09:00:49 -0400 |
commit | 576ca4367f291a9b240d027670fa2e344edf8c8a (patch) | |
tree | e4ef799e1f300e4bfd1b1e654737619a453eaf66 /drivers/regulator/core.c | |
parent | 6d191a5fc7a969d972f1681e1c23781aecb06a61 (diff) |
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>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r-- | drivers/regulator/core.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 7b11979d79d1..f032823caa98 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1174,6 +1174,8 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, | |||
1174 | { | 1174 | { |
1175 | struct regulator_dev *r; | 1175 | struct regulator_dev *r; |
1176 | struct device_node *node; | 1176 | struct device_node *node; |
1177 | struct regulator_map *map; | ||
1178 | const char *devname = NULL; | ||
1177 | 1179 | ||
1178 | /* first do a dt based lookup */ | 1180 | /* first do a dt based lookup */ |
1179 | if (dev && dev->of_node) { | 1181 | if (dev && dev->of_node) { |
@@ -1195,10 +1197,24 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, | |||
1195 | } | 1197 | } |
1196 | 1198 | ||
1197 | /* if not found, try doing it non-dt way */ | 1199 | /* if not found, try doing it non-dt way */ |
1200 | if (dev) | ||
1201 | devname = dev_name(dev); | ||
1202 | |||
1198 | list_for_each_entry(r, ®ulator_list, list) | 1203 | list_for_each_entry(r, ®ulator_list, list) |
1199 | if (strcmp(rdev_get_name(r), supply) == 0) | 1204 | if (strcmp(rdev_get_name(r), supply) == 0) |
1200 | return r; | 1205 | return r; |
1201 | 1206 | ||
1207 | list_for_each_entry(map, ®ulator_map_list, list) { | ||
1208 | /* If the mapping has a device set up it must match */ | ||
1209 | if (map->dev_name && | ||
1210 | (!devname || strcmp(map->dev_name, devname))) | ||
1211 | continue; | ||
1212 | |||
1213 | if (strcmp(map->supply, supply) == 0) | ||
1214 | return map->regulator; | ||
1215 | } | ||
1216 | |||
1217 | |||
1202 | return NULL; | 1218 | return NULL; |
1203 | } | 1219 | } |
1204 | 1220 | ||
@@ -1207,7 +1223,6 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, | |||
1207 | int exclusive) | 1223 | int exclusive) |
1208 | { | 1224 | { |
1209 | struct regulator_dev *rdev; | 1225 | struct regulator_dev *rdev; |
1210 | struct regulator_map *map; | ||
1211 | struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); | 1226 | struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); |
1212 | const char *devname = NULL; | 1227 | const char *devname = NULL; |
1213 | int ret; | 1228 | int ret; |
@@ -1226,18 +1241,6 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, | |||
1226 | if (rdev) | 1241 | if (rdev) |
1227 | goto found; | 1242 | goto found; |
1228 | 1243 | ||
1229 | list_for_each_entry(map, ®ulator_map_list, list) { | ||
1230 | /* If the mapping has a device set up it must match */ | ||
1231 | if (map->dev_name && | ||
1232 | (!devname || strcmp(map->dev_name, devname))) | ||
1233 | continue; | ||
1234 | |||
1235 | if (strcmp(map->supply, id) == 0) { | ||
1236 | rdev = map->regulator; | ||
1237 | goto found; | ||
1238 | } | ||
1239 | } | ||
1240 | |||
1241 | if (board_wants_dummy_regulator) { | 1244 | if (board_wants_dummy_regulator) { |
1242 | rdev = dummy_regulator_rdev; | 1245 | rdev = dummy_regulator_rdev; |
1243 | goto found; | 1246 | goto found; |