diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-07-21 11:00:26 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2009-09-22 08:32:39 -0400 |
commit | 9ed2099edca26d07947beb42c12bd1d6669e82bc (patch) | |
tree | d44cdc4f737636e03354cde612cc854b1f469eb6 /drivers/regulator | |
parent | 6bf87d17c9f5b855e9dde7b3d6f726385b966814 (diff) |
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: Haojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 79a6910eb894..e38db55600e0 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -872,6 +872,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev, | |||
872 | const char *supply) | 872 | const char *supply) |
873 | { | 873 | { |
874 | struct regulator_map *node; | 874 | struct regulator_map *node; |
875 | int has_dev; | ||
875 | 876 | ||
876 | if (consumer_dev && consumer_dev_name) | 877 | if (consumer_dev && consumer_dev_name) |
877 | return -EINVAL; | 878 | return -EINVAL; |
@@ -882,6 +883,11 @@ static int set_consumer_device_supply(struct regulator_dev *rdev, | |||
882 | if (supply == NULL) | 883 | if (supply == NULL) |
883 | return -EINVAL; | 884 | return -EINVAL; |
884 | 885 | ||
886 | if (consumer_dev_name != NULL) | ||
887 | has_dev = 1; | ||
888 | else | ||
889 | has_dev = 0; | ||
890 | |||
885 | list_for_each_entry(node, ®ulator_map_list, list) { | 891 | list_for_each_entry(node, ®ulator_map_list, list) { |
886 | if (consumer_dev_name != node->dev_name) | 892 | if (consumer_dev_name != node->dev_name) |
887 | continue; | 893 | continue; |
@@ -896,17 +902,19 @@ static int set_consumer_device_supply(struct regulator_dev *rdev, | |||
896 | return -EBUSY; | 902 | return -EBUSY; |
897 | } | 903 | } |
898 | 904 | ||
899 | node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL); | 905 | node = kzalloc(sizeof(struct regulator_map), GFP_KERNEL); |
900 | if (node == NULL) | 906 | if (node == NULL) |
901 | return -ENOMEM; | 907 | return -ENOMEM; |
902 | 908 | ||
903 | node->regulator = rdev; | 909 | node->regulator = rdev; |
904 | node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL); | ||
905 | node->supply = supply; | 910 | node->supply = supply; |
906 | 911 | ||
907 | if (node->dev_name == NULL) { | 912 | if (has_dev) { |
908 | kfree(node); | 913 | node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL); |
909 | return -ENOMEM; | 914 | if (node->dev_name == NULL) { |
915 | kfree(node); | ||
916 | return -ENOMEM; | ||
917 | } | ||
910 | } | 918 | } |
911 | 919 | ||
912 | list_add(&node->list, ®ulator_map_list); | 920 | list_add(&node->list, ®ulator_map_list); |