Commit ec95121a authored by Mark Brown's avatar Mark Brown Committed by Liam Girdwood

regulator: Fix support for deviceless supply mappings

The patch to add support for looking up consumers by device name
had the side effect of causing us to require a device which is
at best premature since at least cpufreq still operates outside
the device model. Remove that requirement.
Reported-by: default avatarHaojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent 747f9aa1
...@@ -872,6 +872,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev, ...@@ -872,6 +872,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
const char *supply) const char *supply)
{ {
struct regulator_map *node; struct regulator_map *node;
int has_dev;
if (consumer_dev && consumer_dev_name) if (consumer_dev && consumer_dev_name)
return -EINVAL; return -EINVAL;
...@@ -882,6 +883,11 @@ static int set_consumer_device_supply(struct regulator_dev *rdev, ...@@ -882,6 +883,11 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
if (supply == NULL) if (supply == NULL)
return -EINVAL; return -EINVAL;
if (consumer_dev_name != NULL)
has_dev = 1;
else
has_dev = 0;
list_for_each_entry(node, &regulator_map_list, list) { list_for_each_entry(node, &regulator_map_list, list) {
if (consumer_dev_name != node->dev_name) if (consumer_dev_name != node->dev_name)
continue; continue;
...@@ -896,18 +902,20 @@ static int set_consumer_device_supply(struct regulator_dev *rdev, ...@@ -896,18 +902,20 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
return -EBUSY; return -EBUSY;
} }
node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL); node = kzalloc(sizeof(struct regulator_map), GFP_KERNEL);
if (node == NULL) if (node == NULL)
return -ENOMEM; return -ENOMEM;
node->regulator = rdev; node->regulator = rdev;
node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL);
node->supply = supply; node->supply = supply;
if (has_dev) {
node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL);
if (node->dev_name == NULL) { if (node->dev_name == NULL) {
kfree(node); kfree(node);
return -ENOMEM; return -ENOMEM;
} }
}
list_add(&node->list, &regulator_map_list); list_add(&node->list, &regulator_map_list);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment