Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 165382
b: refs/heads/master
c: 9ed2099
h: refs/heads/master
v: v3
  • Loading branch information
Mark Brown authored and Liam Girdwood committed Sep 22, 2009
1 parent 2cda0b6 commit add304a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6bf87d17c9f5b855e9dde7b3d6f726385b966814
refs/heads/master: 9ed2099edca26d07947beb42c12bd1d6669e82bc
18 changes: 13 additions & 5 deletions trunk/drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
const char *supply)
{
struct regulator_map *node;
int has_dev;

if (consumer_dev && consumer_dev_name)
return -EINVAL;
Expand All @@ -882,6 +883,11 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
if (supply == NULL)
return -EINVAL;

if (consumer_dev_name != NULL)
has_dev = 1;
else
has_dev = 0;

list_for_each_entry(node, &regulator_map_list, list) {
if (consumer_dev_name != node->dev_name)
continue;
Expand All @@ -896,17 +902,19 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
return -EBUSY;
}

node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL);
node = kzalloc(sizeof(struct regulator_map), GFP_KERNEL);
if (node == NULL)
return -ENOMEM;

node->regulator = rdev;
node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL);
node->supply = supply;

if (node->dev_name == NULL) {
kfree(node);
return -ENOMEM;
if (has_dev) {
node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL);
if (node->dev_name == NULL) {
kfree(node);
return -ENOMEM;
}
}

list_add(&node->list, &regulator_map_list);
Expand Down

0 comments on commit add304a

Please sign in to comment.