From fda31ca5feeb0d5582375b366cfbe413c5f3153b Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 20 Jan 2012 20:09:18 +0000 Subject: [PATCH] --- yaml --- r: 292079 b: refs/heads/master c: d5ad34f7cb8b23ab165cabef69577a2a20d53195 h: refs/heads/master i: 292077: 134102e6901998d4f30bff9d5355f1305783fce9 292075: 7330a3b839caa3f2878ecac45feb09be41067952 292071: ec7e7f5947557b218f84a9df57f35a9c9b6e6895 292063: 3a7d18e3ab7a14a8131cf349abc0ea471cf77043 v: v3 --- [refs] | 2 +- trunk/drivers/regulator/core.c | 28 ++++++++++++++++++++++++ trunk/include/linux/regulator/consumer.h | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 4670bb14b01b..17414619c6cb 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 070b9079226d4f3e3e7c9f4eb81f2e02e7d99572 +refs/heads/master: d5ad34f7cb8b23ab165cabef69577a2a20d53195 diff --git a/trunk/drivers/regulator/core.c b/trunk/drivers/regulator/core.c index 214640db084b..88bcb111ca68 100644 --- a/trunk/drivers/regulator/core.c +++ b/trunk/drivers/regulator/core.c @@ -1421,6 +1421,34 @@ void regulator_put(struct regulator *regulator) } EXPORT_SYMBOL_GPL(regulator_put); +static int devm_regulator_match(struct device *dev, void *res, void *data) +{ + struct regulator **r = res; + if (!r || !*r) { + WARN_ON(!r || !*r); + return 0; + } + return *r == data; +} + +/** + * devm_regulator_put - Resource managed regulator_put() + * @regulator: regulator to free + * + * Deallocate a regulator allocated with devm_regulator_get(). Normally + * this function will not need to be called and the resource management + * code will ensure that the resource is freed. + */ +void devm_regulator_put(struct regulator *regulator) +{ + int rc; + + rc = devres_destroy(regulator->dev, devm_regulator_release, + devm_regulator_match, regulator); + WARN_ON(rc); +} +EXPORT_SYMBOL_GPL(devm_regulator_put); + static int _regulator_can_change_status(struct regulator_dev *rdev) { if (!rdev->constraints) diff --git a/trunk/include/linux/regulator/consumer.h b/trunk/include/linux/regulator/consumer.h index bcfe10658763..60c2f996d895 100644 --- a/trunk/include/linux/regulator/consumer.h +++ b/trunk/include/linux/regulator/consumer.h @@ -137,6 +137,7 @@ struct regulator *__must_check devm_regulator_get(struct device *dev, struct regulator *__must_check regulator_get_exclusive(struct device *dev, const char *id); void regulator_put(struct regulator *regulator); +void devm_regulator_free(struct regulator *regulator); /* regulator output control and status */ int regulator_enable(struct regulator *regulator);