mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-18 04:35:11 +00:00
drivers/of: Specify parent node in of_fdt_unflatten_tree()
This adds one more argument to of_fdt_unflatten_tree() to specify the parent node of the FDT blob that is going to be unflattened. In the result, the function can be used to unflatten FDT blob that represents device sub-tree in PowerNV PCI hotplug driver. Cc: Jyri Sarha <jsarha@ti.com> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Acked-by: Rob Herring <robh@kernel.org> Acked-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Rob Herring <robh@kernel.org>
This commit is contained in:
parent
947c82cbf0
commit
c4263233f3
4 changed files with 13 additions and 6 deletions
|
|
@ -157,7 +157,7 @@ struct device_node * __init tilcdc_get_overlay(struct kfree_table *kft)
|
||||||
if (!overlay_data || kfree_table_add(kft, overlay_data))
|
if (!overlay_data || kfree_table_add(kft, overlay_data))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
of_fdt_unflatten_tree(overlay_data, &overlay);
|
of_fdt_unflatten_tree(overlay_data, NULL, &overlay);
|
||||||
if (!overlay) {
|
if (!overlay) {
|
||||||
pr_warn("%s: Unfattening overlay tree failed\n", __func__);
|
pr_warn("%s: Unfattening overlay tree failed\n", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -450,11 +450,13 @@ static int unflatten_dt_nodes(const void *blob,
|
||||||
* pointers of the nodes so the normal device-tree walking functions
|
* pointers of the nodes so the normal device-tree walking functions
|
||||||
* can be used.
|
* can be used.
|
||||||
* @blob: The blob to expand
|
* @blob: The blob to expand
|
||||||
|
* @dad: Parent device node
|
||||||
* @mynodes: The device_node tree created by the call
|
* @mynodes: The device_node tree created by the call
|
||||||
* @dt_alloc: An allocator that provides a virtual address to memory
|
* @dt_alloc: An allocator that provides a virtual address to memory
|
||||||
* for the resulting tree
|
* for the resulting tree
|
||||||
*/
|
*/
|
||||||
static void __unflatten_device_tree(const void *blob,
|
static void __unflatten_device_tree(const void *blob,
|
||||||
|
struct device_node *dad,
|
||||||
struct device_node **mynodes,
|
struct device_node **mynodes,
|
||||||
void * (*dt_alloc)(u64 size, u64 align))
|
void * (*dt_alloc)(u64 size, u64 align))
|
||||||
{
|
{
|
||||||
|
|
@ -479,7 +481,7 @@ static void __unflatten_device_tree(const void *blob,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* First pass, scan for size */
|
/* First pass, scan for size */
|
||||||
size = unflatten_dt_nodes(blob, NULL, NULL, NULL);
|
size = unflatten_dt_nodes(blob, NULL, dad, NULL);
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -495,7 +497,7 @@ static void __unflatten_device_tree(const void *blob,
|
||||||
pr_debug(" unflattening %p...\n", mem);
|
pr_debug(" unflattening %p...\n", mem);
|
||||||
|
|
||||||
/* Second pass, do actual unflattening */
|
/* Second pass, do actual unflattening */
|
||||||
unflatten_dt_nodes(blob, mem, NULL, mynodes);
|
unflatten_dt_nodes(blob, mem, dad, mynodes);
|
||||||
if (be32_to_cpup(mem + size) != 0xdeadbeef)
|
if (be32_to_cpup(mem + size) != 0xdeadbeef)
|
||||||
pr_warning("End of tree marker overwritten: %08x\n",
|
pr_warning("End of tree marker overwritten: %08x\n",
|
||||||
be32_to_cpup(mem + size));
|
be32_to_cpup(mem + size));
|
||||||
|
|
@ -512,6 +514,9 @@ static DEFINE_MUTEX(of_fdt_unflatten_mutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* of_fdt_unflatten_tree - create tree of device_nodes from flat blob
|
* of_fdt_unflatten_tree - create tree of device_nodes from flat blob
|
||||||
|
* @blob: Flat device tree blob
|
||||||
|
* @dad: Parent device node
|
||||||
|
* @mynodes: The device tree created by the call
|
||||||
*
|
*
|
||||||
* unflattens the device-tree passed by the firmware, creating the
|
* unflattens the device-tree passed by the firmware, creating the
|
||||||
* tree of struct device_node. It also fills the "name" and "type"
|
* tree of struct device_node. It also fills the "name" and "type"
|
||||||
|
|
@ -519,10 +524,11 @@ static DEFINE_MUTEX(of_fdt_unflatten_mutex);
|
||||||
* can be used.
|
* can be used.
|
||||||
*/
|
*/
|
||||||
void of_fdt_unflatten_tree(const unsigned long *blob,
|
void of_fdt_unflatten_tree(const unsigned long *blob,
|
||||||
|
struct device_node *dad,
|
||||||
struct device_node **mynodes)
|
struct device_node **mynodes)
|
||||||
{
|
{
|
||||||
mutex_lock(&of_fdt_unflatten_mutex);
|
mutex_lock(&of_fdt_unflatten_mutex);
|
||||||
__unflatten_device_tree(blob, mynodes, &kernel_tree_alloc);
|
__unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc);
|
||||||
mutex_unlock(&of_fdt_unflatten_mutex);
|
mutex_unlock(&of_fdt_unflatten_mutex);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree);
|
EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree);
|
||||||
|
|
@ -1195,7 +1201,7 @@ bool __init early_init_dt_scan(void *params)
|
||||||
*/
|
*/
|
||||||
void __init unflatten_device_tree(void)
|
void __init unflatten_device_tree(void)
|
||||||
{
|
{
|
||||||
__unflatten_device_tree(initial_boot_params, &of_root,
|
__unflatten_device_tree(initial_boot_params, NULL, &of_root,
|
||||||
early_init_dt_alloc_memory_arch);
|
early_init_dt_alloc_memory_arch);
|
||||||
|
|
||||||
/* Get pointer to "/chosen" and "/aliases" nodes for use everywhere */
|
/* Get pointer to "/chosen" and "/aliases" nodes for use everywhere */
|
||||||
|
|
|
||||||
|
|
@ -921,7 +921,7 @@ static int __init unittest_data_add(void)
|
||||||
"not running tests\n", __func__);
|
"not running tests\n", __func__);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
of_fdt_unflatten_tree(unittest_data, &unittest_data_node);
|
of_fdt_unflatten_tree(unittest_data, NULL, &unittest_data_node);
|
||||||
if (!unittest_data_node) {
|
if (!unittest_data_node) {
|
||||||
pr_warn("%s: No tree to attach; not running tests\n", __func__);
|
pr_warn("%s: No tree to attach; not running tests\n", __func__);
|
||||||
return -ENODATA;
|
return -ENODATA;
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ extern bool of_fdt_is_big_endian(const void *blob,
|
||||||
extern int of_fdt_match(const void *blob, unsigned long node,
|
extern int of_fdt_match(const void *blob, unsigned long node,
|
||||||
const char *const *compat);
|
const char *const *compat);
|
||||||
extern void of_fdt_unflatten_tree(const unsigned long *blob,
|
extern void of_fdt_unflatten_tree(const unsigned long *blob,
|
||||||
|
struct device_node *dad,
|
||||||
struct device_node **mynodes);
|
struct device_node **mynodes);
|
||||||
|
|
||||||
/* TBD: Temporary export of fdt globals - remove when code fully merged */
|
/* TBD: Temporary export of fdt globals - remove when code fully merged */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue