@@ -580,3 +580,20 @@ bool fwnode_is_compatible(struct fwnode_handle *fwnode, const char *compatible)
return false;
}
EXPORT_SYMBOL_GPL(fwnode_is_compatible);
+
+int devm_acquire_fwnode(struct device *dev,
+ const struct devm_resource *resource)
+{
+ struct device_node *np;
+ struct fwnode_handle **nodep;
+
+ np = of_parse_phandle(dev->of_node, resource->name, 0);
+ if (IS_ERR(np))
+ return PTR_ERR(np);
+
+ nodep = dev_get_drvdata(dev) + resource->offset;
+ *nodep = &np->fwnode;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(devm_acquire_fwnode);
\ No newline at end of file
@@ -17,6 +17,7 @@
#include <linux/types.h>
struct device;
+struct devm_resource;
enum dev_prop_type {
DEV_PROP_U8,
@@ -172,4 +173,13 @@ void device_add_property_set(struct device *dev, struct property_set *pset);
bool device_dma_is_coherent(struct device *dev);
+int devm_acquire_fwnode(struct device *dev,
+ const struct devm_resource *resource);
+
+#define DEVM_FWNODE(_struct, _member, _name) { \
+ .initfunc = devm_acquire_fwnode, \
+ .offset = offsetof_t(struct _struct, _member, struct fwnode_handle *),\
+ .name = _name, \
+}
+
#endif /* _LINUX_PROPERTY_H_ */
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> --- drivers/base/property.c | 17 +++++++++++++++++ include/linux/property.h | 10 ++++++++++ 2 files changed, 27 insertions(+)