History

of: reserved-memory: Support lookup of regions by name

Add support for looking up memory regions by name. This looks up the given name in the newly introduced memory-region-names property and returns the memory region at the corresponding index in the memory- region(s) property.

Thierry Reding committed 6 years ago

Commit 0da0e311 parent 8f3d9f32 files · +30 −0Browse files

Unified · Split

2 files
  1. drivers/of/of_reserved_mem.c +19 −0
  2. include/linux/of_reserved_mem.h +11 −0
drivers/of/of_reserved_mem.c+19−0
@@ -357,6 +357,25 @@ int of_reserved_mem_device_init_by_idx(struct device *dev, · 356 unmodified lines
357357 }
358358 EXPORT_SYMBOL_GPL(of_reserved_mem_device_init_by_idx);
359359
360+/**
361+ * of_reserved_mem_device_init_by_name() - assign named reserved memory region
362+ * to given device
363+ * @dev: pointer to the device to configure
364+ * @np: pointer to the device node with 'memory-region' property
365+ * @name: name of the selected memory region
366+ *
367+ * Returns: 0 on success or a negative error-code on failure.
368+ */
369+int of_reserved_mem_device_init_by_name(struct device *dev,
370+ struct device_node *np,
371+ const char *name)
372+{
373+ int idx = of_property_match_string(np, "memory-region-names", name);
374+
375+ return of_reserved_mem_device_init_by_idx(dev, np, idx);
376+}
377+EXPORT_SYMBOL_GPL(of_reserved_mem_device_init_by_name);
378+
360379 /**
361380 * of_reserved_mem_device_release() - release reserved memory device structures
362381 * @dev: Pointer to the device to deconfigure
include/linux/of_reserved_mem.h+11−0
@@ -33,6 +33,9 @@ typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem); · 32 unmodified lines
3333
3434 int of_reserved_mem_device_init_by_idx(struct device *dev,
3535 struct device_node *np, int idx);
36+int of_reserved_mem_device_init_by_name(struct device *dev,
37+ struct device_node *np,
38+ const char *name);
3639 void of_reserved_mem_device_release(struct device *dev);
3740
3841 void fdt_init_reserved_mem(void);
@@ -45,6 +48,14 @@ static inline int of_reserved_mem_device_init_by_idx(struct device *dev, · 6 unmodified lines
4548 {
4649 return -ENOSYS;
4750 }
51+
52+static inline int of_reserved_mem_device_init_by_name(struct device *dev,
53+ struct device_node *np,
54+ const char *name)
55+{
56+ return -ENOSYS;
57+}
58+
4859 static inline void of_reserved_mem_device_release(struct device *pdev) { }
4960
5061 static inline void fdt_init_reserved_mem(void) { }