@@ -303,3 +303,16 @@ int device_reset(struct device *dev)
return ret;
}
EXPORT_SYMBOL_GPL(device_reset);
+
+int devm_acquire_reset(struct device *dev,
+ const struct devm_resource *resource)
+{
+ struct reset_control **rstp = dev_get_drvdata(dev) + resource->offset;
+
+ *rstp = devm_reset_control_get(dev, resource->name);
+ if (IS_ERR(*rstp))
+ return PTR_ERR(*rstp);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(devm_acquire_reset);
@@ -3,6 +3,7 @@
struct device;
struct device_node;
+struct devm_resource;
struct reset_control;
#ifdef CONFIG_RESET_CONTROLLER
@@ -38,6 +39,15 @@ static inline struct reset_control *devm_reset_control_get_optional(
struct reset_control *of_reset_control_get(struct device_node *node,
const char *id);
+int devm_acquire_reset(struct device *dev,
+ const struct devm_resource *resource);
+
+#define DEVM_RESET(_struct, _member, _name) { \
+ .initfunc = devm_acquire_reset, \
+ .offset = offsetof_t(struct _struct, _member, struct reset_control *),\
+ .name = _name, \
+}
+
#else
static inline int reset_control_reset(struct reset_control *rstc)
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> --- drivers/reset/core.c | 13 +++++++++++++ include/linux/reset.h | 10 ++++++++++ 2 files changed, 23 insertions(+)