diff options
author | Matthias Kaehlcke <matthias.list@kaehlcke.net> | 2013-08-25 17:54:13 +0200 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-08-29 19:38:33 +0100 |
commit | 9efdd27678ef5e22c27c230a08a211b702768f3a (patch) | |
tree | c2a7d91b8786bdf1ac16635f02107fe99a6c4d7d /drivers/regulator | |
parent | 9e059bacecf1c46c1784cb6f6826f85629b4a1be (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>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 30 |
1 files changed, 30 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) } /** + * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive() + * @dev: device for regulator "consumer" + * @id: Supply name or regulator ID. + * + * Managed regulator_get_exclusive(). Regulators returned from this function + * are automatically regulator_put() on driver detach. See regulator_get() for + * more information. + */ +struct regulator *devm_regulator_get_exclusive(struct device *dev, + const char *id) +{ + struct regulator **ptr, *regulator; + + ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + regulator = _regulator_get(dev, id, 1); + if (!IS_ERR(regulator)) { + *ptr = regulator; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return regulator; +} +EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); + +/** * regulator_put - "free" the regulator source * @regulator: regulator source * |