提交 9efdd276 编写于 作者: M Matthias Kaehlcke 提交者: Mark Brown

regulator: Add devm_regulator_get_exclusive()

Add a resource managed regulator_get_exclusive()
Signed-off-by: NMatthias Kaehlcke <matthias@kaehlcke.net>
Signed-off-by: NMark Brown <broonie@linaro.org>
上级 9e059bac
...@@ -1493,6 +1493,36 @@ static void _regulator_put(struct regulator *regulator) ...@@ -1493,6 +1493,36 @@ static void _regulator_put(struct regulator *regulator)
module_put(rdev->owner); module_put(rdev->owner);
} }
/**
* 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_put - "free" the regulator source
* @regulator: regulator source * @regulator: regulator source
......
...@@ -137,6 +137,8 @@ struct regulator *__must_check devm_regulator_get(struct device *dev, ...@@ -137,6 +137,8 @@ struct regulator *__must_check devm_regulator_get(struct device *dev,
const char *id); const char *id);
struct regulator *__must_check regulator_get_exclusive(struct device *dev, struct regulator *__must_check regulator_get_exclusive(struct device *dev,
const char *id); const char *id);
struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev,
const char *id);
struct regulator *__must_check regulator_get_optional(struct device *dev, struct regulator *__must_check regulator_get_optional(struct device *dev,
const char *id); const char *id);
struct regulator *__must_check devm_regulator_get_optional(struct device *dev, struct regulator *__must_check devm_regulator_get_optional(struct device *dev,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册