[PATCH 02/42] of: reserved_mem: Add devm_of_reserved_mem_device_init_by_name()
Mukesh Ojha
mukesh.ojha at oss.qualcomm.com
Fri Jul 3 12:38:15 PDT 2026
Add a resource managed inline wrapper for
of_reserved_mem_device_init_by_name() to complement the existing
devm_of_reserved_mem_device_init_by_idx() and
devm_of_reserved_mem_device_init() helpers.
Signed-off-by: Mukesh Ojha <mukesh.ojha at oss.qualcomm.com>
---
include/linux/of_reserved_mem.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index b9fd78123d77..52aacdbf432c 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -133,4 +133,25 @@ static inline int devm_of_reserved_mem_device_init(struct device *dev)
return devm_of_reserved_mem_device_init_by_idx(dev, dev->of_node, 0);
}
+/**
+ * devm_of_reserved_mem_device_init_by_name() - Resource managed of_reserved_mem_device_init_by_name
+ * @dev: Pointer to the device to configure
+ * @np: Pointer to the device node with 'memory-region' property
+ * @name: Name of the selected memory region
+ *
+ * This is a resource managed version of of_reserved_mem_device_init_by_name().
+ * The reserved memory region will be released automatically when the device
+ * is unbound.
+ *
+ * Returns error code or zero on success.
+ */
+static inline int devm_of_reserved_mem_device_init_by_name(struct device *dev,
+ struct device_node *np,
+ const char *name)
+{
+ int idx = of_property_match_string(np, "memory-region-names", name);
+
+ return devm_of_reserved_mem_device_init_by_idx(dev, np, idx);
+}
+
#endif /* __OF_RESERVED_MEM_H */
--
2.53.0
More information about the Linux-mediatek
mailing list