aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Kaehlcke <matthias.list@kaehlcke.net>2013-08-25 11:54:13 -0400
committerMark Brown <broonie@linaro.org>2013-08-29 14:38:33 -0400
commit9efdd27678ef5e22c27c230a08a211b702768f3a (patch)
treec2a7d91b8786bdf1ac16635f02107fe99a6c4d7d
parent9e059bacecf1c46c1784cb6f6826f85629b4a1be (diff)
regulator: Add devm_regulator_get_exclusive()
Add a resource managed regulator_get_exclusive() Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/regulator/core.c30
-rw-r--r--include/linux/regulator/consumer.h2
2 files changed, 32 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a27a5b6267dd..4b9039b43b6c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1494,6 +1494,36 @@ static void _regulator_put(struct regulator *regulator)
1494} 1494}
1495 1495
1496/** 1496/**
1497 * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive()
1498 * @dev: device for regulator "consumer"
1499 * @id: Supply name or regulator ID.
1500 *
1501 * Managed regulator_get_exclusive(). Regulators returned from this function
1502 * are automatically regulator_put() on driver detach. See regulator_get() for
1503 * more information.
1504 */
1505struct regulator *devm_regulator_get_exclusive(struct device *dev,
1506 const char *id)
1507{
1508 struct regulator **ptr, *regulator;
1509
1510 ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL);
1511 if (!ptr)
1512 return ERR_PTR(-ENOMEM);
1513
1514 regulator = _regulator_get(dev, id, 1);
1515 if (!IS_ERR(regulator)) {
1516 *ptr = regulator;
1517 devres_add(dev, ptr);
1518 } else {
1519 devres_free(ptr);
1520 }
1521
1522 return regulator;
1523}
1524EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive);
1525
1526/**
1497 * regulator_put - "free" the regulator source 1527 * regulator_put - "free" the regulator source
1498 * @regulator: regulator source 1528 * @regulator: regulator source
1499 * 1529 *
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index e2bac6db4abc..91aca11198d8 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -137,6 +137,8 @@ struct regulator *__must_check devm_regulator_get(struct device *dev,
137 const char *id); 137 const char *id);
138struct regulator *__must_check regulator_get_exclusive(struct device *dev, 138struct regulator *__must_check regulator_get_exclusive(struct device *dev,
139 const char *id); 139 const char *id);
140struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev,
141 const char *id);
140struct regulator *__must_check regulator_get_optional(struct device *dev, 142struct regulator *__must_check regulator_get_optional(struct device *dev,
141 const char *id); 143 const char *id);
142struct regulator *__must_check devm_regulator_get_optional(struct device *dev, 144struct regulator *__must_check devm_regulator_get_optional(struct device *dev,