mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-26 01:50:54 +07:00
of: reserved_mem: Accessor for acquiring reserved_mem
In some cases drivers referencing a reserved-memory region might want to remap the entire region, but when defining the reserved-memory by "size" the client driver has no means to know the associated base address of the reserved memory region. This patch adds an accessor for such drivers to acquire a handle to their associated reserved-memory for this purpose. A complicating factor for the implementation is that the reserved_mem objects are created from the flattened DeviceTree, as such we can't use the device_node address for comparison. Fortunately the name of the node will be used as "name" of the reserved_mem and will be used when building the full_name, so we can compare the "name" with the basename of the full_name to find the match. Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Andy Gross <andy.gross@linaro.org>
This commit is contained in:
parent
a50ff19d06
commit
eb297bc716
@ -397,3 +397,29 @@ void of_reserved_mem_device_release(struct device *dev)
|
||||
rmem->ops->device_release(rmem, dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_reserved_mem_device_release);
|
||||
|
||||
/**
|
||||
* of_reserved_mem_lookup() - acquire reserved_mem from a device node
|
||||
* @np: node pointer of the desired reserved-memory region
|
||||
*
|
||||
* This function allows drivers to acquire a reference to the reserved_mem
|
||||
* struct based on a device node handle.
|
||||
*
|
||||
* Returns a reserved_mem reference, or NULL on error.
|
||||
*/
|
||||
struct reserved_mem *of_reserved_mem_lookup(struct device_node *np)
|
||||
{
|
||||
const char *name;
|
||||
int i;
|
||||
|
||||
if (!np->full_name)
|
||||
return NULL;
|
||||
|
||||
name = kbasename(np->full_name);
|
||||
for (i = 0; i < reserved_mem_count; i++)
|
||||
if (!strcmp(reserved_mem[i].name, name))
|
||||
return &reserved_mem[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_reserved_mem_lookup);
|
||||
|
@ -44,6 +44,7 @@ int early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
|
||||
void fdt_init_reserved_mem(void);
|
||||
void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
|
||||
phys_addr_t base, phys_addr_t size);
|
||||
struct reserved_mem *of_reserved_mem_lookup(struct device_node *np);
|
||||
#else
|
||||
static inline int of_reserved_mem_device_init_by_idx(struct device *dev,
|
||||
struct device_node *np, int idx)
|
||||
@ -55,6 +56,10 @@ static inline void of_reserved_mem_device_release(struct device *pdev) { }
|
||||
static inline void fdt_init_reserved_mem(void) { }
|
||||
static inline void fdt_reserved_mem_save_node(unsigned long node,
|
||||
const char *uname, phys_addr_t base, phys_addr_t size) { }
|
||||
static inline struct reserved_mem *of_reserved_mem_lookup(struct device_node *np)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user