regulator: Add devm_regulator_get()

Add a resource managed regulator_get() to simplify regulator
usage in drivers. This allows driver authors to "get and forget"
about their regulators by automatically calling regulator_put()
when the driver is detached.

[Fixed up a couple of coding style issues -- broonie]

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
Stephen Boyd
2012-01-16 19:39:58 -08:00
committed by Mark Brown
parent dcd6c92267
commit 070b907922
3 changed files with 46 additions and 0 deletions

View File

@@ -132,6 +132,8 @@ struct regulator_bulk_data {
/* regulator get and put */
struct regulator *__must_check regulator_get(struct device *dev,
const char *id);
struct regulator *__must_check devm_regulator_get(struct device *dev,
const char *id);
struct regulator *__must_check regulator_get_exclusive(struct device *dev,
const char *id);
void regulator_put(struct regulator *regulator);
@@ -200,6 +202,13 @@ static inline struct regulator *__must_check regulator_get(struct device *dev,
*/
return NULL;
}
static inline struct regulator *__must_check
devm_regulator_get(struct device *dev, const char *id)
{
return NULL;
}
static inline void regulator_put(struct regulator *regulator)
{
}