Commit 19207ea8 authored by Arnd Bergmann's avatar Arnd Bergmann

Merge tag 'tegra-for-5.8-of' of...

Merge tag 'tegra-for-5.8-of' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux into arm/drivers

of: Changes for v5.8-rc1

These changes add support for multiple reserved-memory regions per
device.

* tag 'tegra-for-5.8-of' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux:
  of: Make <linux/of_reserved_mem.h> self-contained
  of: reserved-memory: Support multiple regions per device
  of: reserved-memory: Support lookup of regions by name

Link: https://lore.kernel.org/r/20200515145311.1580134-5-thierry.reding@gmail.comSigned-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parents 2e60fac7 4a470f00
...@@ -357,6 +357,25 @@ int of_reserved_mem_device_init_by_idx(struct device *dev, ...@@ -357,6 +357,25 @@ int of_reserved_mem_device_init_by_idx(struct device *dev,
} }
EXPORT_SYMBOL_GPL(of_reserved_mem_device_init_by_idx); EXPORT_SYMBOL_GPL(of_reserved_mem_device_init_by_idx);
/**
* of_reserved_mem_device_init_by_name() - assign named reserved memory region
* to given device
* @dev: pointer to the device to configure
* @np: pointer to the device node with 'memory-region' property
* @name: name of the selected memory region
*
* Returns: 0 on success or a negative error-code on failure.
*/
int 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 of_reserved_mem_device_init_by_idx(dev, np, idx);
}
EXPORT_SYMBOL_GPL(of_reserved_mem_device_init_by_name);
/** /**
* of_reserved_mem_device_release() - release reserved memory device structures * of_reserved_mem_device_release() - release reserved memory device structures
* @dev: Pointer to the device to deconfigure * @dev: Pointer to the device to deconfigure
...@@ -366,24 +385,22 @@ EXPORT_SYMBOL_GPL(of_reserved_mem_device_init_by_idx); ...@@ -366,24 +385,22 @@ EXPORT_SYMBOL_GPL(of_reserved_mem_device_init_by_idx);
*/ */
void of_reserved_mem_device_release(struct device *dev) void of_reserved_mem_device_release(struct device *dev)
{ {
struct rmem_assigned_device *rd; struct rmem_assigned_device *rd, *tmp;
struct reserved_mem *rmem = NULL; LIST_HEAD(release_list);
mutex_lock(&of_rmem_assigned_device_mutex); mutex_lock(&of_rmem_assigned_device_mutex);
list_for_each_entry(rd, &of_rmem_assigned_device_list, list) { list_for_each_entry_safe(rd, tmp, &of_rmem_assigned_device_list, list) {
if (rd->dev == dev) { if (rd->dev == dev)
rmem = rd->rmem; list_move_tail(&rd->list, &release_list);
list_del(&rd->list);
kfree(rd);
break;
}
} }
mutex_unlock(&of_rmem_assigned_device_mutex); mutex_unlock(&of_rmem_assigned_device_mutex);
if (!rmem || !rmem->ops || !rmem->ops->device_release) list_for_each_entry_safe(rd, tmp, &release_list, list) {
return; if (rd->rmem && rd->rmem->ops && rd->rmem->ops->device_release)
rd->rmem->ops->device_release(rd->rmem, dev);
rmem->ops->device_release(rmem, dev); kfree(rd);
}
} }
EXPORT_SYMBOL_GPL(of_reserved_mem_device_release); EXPORT_SYMBOL_GPL(of_reserved_mem_device_release);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#define __OF_RESERVED_MEM_H #define __OF_RESERVED_MEM_H
#include <linux/device.h> #include <linux/device.h>
#include <linux/of.h>
struct of_phandle_args; struct of_phandle_args;
struct reserved_mem_ops; struct reserved_mem_ops;
...@@ -33,6 +34,9 @@ typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem); ...@@ -33,6 +34,9 @@ typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem);
int of_reserved_mem_device_init_by_idx(struct device *dev, int of_reserved_mem_device_init_by_idx(struct device *dev,
struct device_node *np, int idx); struct device_node *np, int idx);
int of_reserved_mem_device_init_by_name(struct device *dev,
struct device_node *np,
const char *name);
void of_reserved_mem_device_release(struct device *dev); void of_reserved_mem_device_release(struct device *dev);
void fdt_init_reserved_mem(void); void fdt_init_reserved_mem(void);
...@@ -45,6 +49,14 @@ static inline int of_reserved_mem_device_init_by_idx(struct device *dev, ...@@ -45,6 +49,14 @@ static inline int of_reserved_mem_device_init_by_idx(struct device *dev,
{ {
return -ENOSYS; return -ENOSYS;
} }
static inline int of_reserved_mem_device_init_by_name(struct device *dev,
struct device_node *np,
const char *name)
{
return -ENOSYS;
}
static inline void of_reserved_mem_device_release(struct device *pdev) { } static inline void of_reserved_mem_device_release(struct device *pdev) { }
static inline void fdt_init_reserved_mem(void) { } static inline void fdt_init_reserved_mem(void) { }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment