@@ -15,7 +15,9 @@
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/regulator/driver.h>
+#include <linux/regulator/of_regulator.h>
#include <linux/module.h>
+#include <linux/of_platform.h>
#include "internal.h"
@@ -498,3 +500,19 @@ void devm_regulator_unregister_notifier(struct regulator *regulator,
WARN_ON(rc);
}
EXPORT_SYMBOL_GPL(devm_regulator_unregister_notifier);
+
+int devm_acquire_regulator(struct device *dev,
+ const struct devm_resource *resource)
+{
+ struct regulator *regulator, **regulatorp;
+
+ regulator = devm_regulator_get(dev, resource->name);
+ if (IS_ERR(regulator))
+ return PTR_ERR(regulator);
+
+ regulatorp = dev_get_drvdata(dev) + resource->offset;
+ *regulatorp = regulator;
+
+ return 0;
+}
+EXPORT_SYMBOL(devm_acquire_regulator);
@@ -38,6 +38,7 @@
#include <linux/err.h>
struct device;
+struct devm_resource;
struct notifier_block;
struct regmap;
@@ -173,6 +174,15 @@ struct regulator *__must_check devm_regulator_get_optional(struct device *dev,
void regulator_put(struct regulator *regulator);
void devm_regulator_put(struct regulator *regulator);
+int devm_acquire_regulator(struct device *dev,
+ const struct devm_resource *resource);
+
+#define DEVM_REGULATOR(_struct, _member, _name) { \
+ .initfunc = devm_acquire_regulator, \
+ .offset = offsetof_t(struct _struct, _member, struct regulator *),\
+ .name = _name, \
+}
+
int regulator_register_supply_alias(struct device *dev, const char *id,
struct device *alias_dev,
const char *alias_id);
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> --- drivers/regulator/devres.c | 18 ++++++++++++++++++ include/linux/regulator/consumer.h | 10 ++++++++++ 2 files changed, 28 insertions(+)