forked from Minki/linux
of: Changes for v5.8-rc1
These changes add support for multiple reserved-memory regions per device. -----BEGIN PGP SIGNATURE----- iQJHBAABCAAxFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAl6+o6wTHHRyZWRpbmdA bnZpZGlhLmNvbQAKCRDdI6zXfz6zoRIqD/9Z4C5IW9brl79jJJdILAnyGb1Gg2QG I0i3IQDJxXBVZaAk4VY7Vizm/6CUAJ3yunAb2ycp51pmL6o3LzEDM3oOQrUhtEfB Nl94sBDU73c/KBjlUccajHC27BCAgY8ZLlRsl9rNxRs5MYF46jcuRtftmbbViGpJ hMVohHpNctCffsKljU0eifu8x/IMJlaiF8ErwJm6Md9d0/vSF1pcS9qbQzxSTopH Vgjnn0joZXfd/up6NClUQ0rOqc8jWaiBYconnf7UYrTFtSQM/OKJ+AJkfD166bVO 55fphI7L6o3wZsOuD/M9q9xmGcIbJ83z9gb8Iix+A9diTBWpZLtYfsQNuWUZJJxx ADD03KdEsP/VWZMZUflDNKD0zGTteECfTUVvqYSJ0QW5u6oOn6IHKN+92Hjhx1Ho cdOdPrERnyVKKEZoYTq2uwHTWFca++3Du3IM8qyYQw2a9b+3ZlwmQm7kspxh+Z6r JtTLDjNPJOnx0r22ZM9yAwFK7D8HUcHQFGKUQkZEwxOS8rvbW5P7I4T78uIHtVEG Yzmo2BvQXago267UD+Y8/K0HKMVQnz0bFRnxsKryqu+9NXRB+i41sHXJELiugC3K Ry6I23bqlY6qo6bzK1VDQPhV1at3HdgTFmaONO3z0Ra6/V/p/DLyPH+EPCjTJuWO Vwxd/K+t0HbpsQ== =yXZv -----END PGP SIGNATURE----- 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.com Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
commit
19207ea8e0
@ -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);
|
|||||||
*/
|
*/
|
||||||
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 @@
|
|||||||
#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);
|
|||||||
|
|
||||||
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,
|
|||||||
{
|
{
|
||||||
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) { }
|
||||||
|
Loading…
Reference in New Issue
Block a user