diff options
| author | Jani Nikula <ext-jani.1.nikula@nokia.com> | 2010-04-29 03:55:11 -0400 |
|---|---|---|
| committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-05-25 05:16:01 -0400 |
| commit | d4033b54fc91221b13e2850bf298683c0f2ff37d (patch) | |
| tree | 079d249721fb97e96bd06253ab7505c99ec1ef09 | |
| parent | 47bd53f0e8008294ff58c5b37d713f25a8dc56aa (diff) | |
regulator: simplify regulator_register() error handling
Simply remove all consumer supplies for the regulator on errors. Remove
unset_consumer_device_supply() which is no longer used.
Signed-off-by: Jani Nikula <ext-jani.1.nikula@nokia.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
| -rw-r--r-- | drivers/regulator/core.c | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a50672f33afa..98e5d14f94f3 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -981,29 +981,6 @@ static int set_consumer_device_supply(struct regulator_dev *rdev, | |||
| 981 | return 0; | 981 | return 0; |
| 982 | } | 982 | } |
| 983 | 983 | ||
| 984 | static void unset_consumer_device_supply(struct regulator_dev *rdev, | ||
| 985 | const char *consumer_dev_name, struct device *consumer_dev) | ||
| 986 | { | ||
| 987 | struct regulator_map *node, *n; | ||
| 988 | |||
| 989 | if (consumer_dev && !consumer_dev_name) | ||
| 990 | consumer_dev_name = dev_name(consumer_dev); | ||
| 991 | |||
| 992 | list_for_each_entry_safe(node, n, ®ulator_map_list, list) { | ||
| 993 | if (rdev != node->regulator) | ||
| 994 | continue; | ||
| 995 | |||
| 996 | if (consumer_dev_name && node->dev_name && | ||
| 997 | strcmp(consumer_dev_name, node->dev_name)) | ||
| 998 | continue; | ||
| 999 | |||
| 1000 | list_del(&node->list); | ||
| 1001 | kfree(node->dev_name); | ||
| 1002 | kfree(node); | ||
| 1003 | return; | ||
| 1004 | } | ||
| 1005 | } | ||
| 1006 | |||
| 1007 | static void unset_regulator_supplies(struct regulator_dev *rdev) | 984 | static void unset_regulator_supplies(struct regulator_dev *rdev) |
| 1008 | { | 985 | { |
| 1009 | struct regulator_map *node, *n; | 986 | struct regulator_map *node, *n; |
| @@ -2375,13 +2352,8 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | |||
| 2375 | init_data->consumer_supplies[i].dev, | 2352 | init_data->consumer_supplies[i].dev, |
| 2376 | init_data->consumer_supplies[i].dev_name, | 2353 | init_data->consumer_supplies[i].dev_name, |
| 2377 | init_data->consumer_supplies[i].supply); | 2354 | init_data->consumer_supplies[i].supply); |
| 2378 | if (ret < 0) { | 2355 | if (ret < 0) |
| 2379 | for (--i; i >= 0; i--) | 2356 | goto unset_supplies; |
| 2380 | unset_consumer_device_supply(rdev, | ||
| 2381 | init_data->consumer_supplies[i].dev_name, | ||
| 2382 | init_data->consumer_supplies[i].dev); | ||
| 2383 | goto scrub; | ||
| 2384 | } | ||
| 2385 | } | 2357 | } |
| 2386 | 2358 | ||
| 2387 | list_add(&rdev->list, ®ulator_list); | 2359 | list_add(&rdev->list, ®ulator_list); |
| @@ -2389,6 +2361,9 @@ out: | |||
| 2389 | mutex_unlock(®ulator_list_mutex); | 2361 | mutex_unlock(®ulator_list_mutex); |
| 2390 | return rdev; | 2362 | return rdev; |
| 2391 | 2363 | ||
| 2364 | unset_supplies: | ||
| 2365 | unset_regulator_supplies(rdev); | ||
| 2366 | |||
| 2392 | scrub: | 2367 | scrub: |
| 2393 | device_unregister(&rdev->dev); | 2368 | device_unregister(&rdev->dev); |
| 2394 | /* device core frees rdev */ | 2369 | /* device core frees rdev */ |
