This returns the allocate memory chunk, storing the unflattened device
tree, from of_fdt_unflatten_tree() so that memory chunk can be released
on demand in PowerNV PCI hotplug driver.
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
* @mynodes: The device_node tree created by the call
* @dt_alloc: An allocator that provides a virtual address to memory
* for the resulting tree
* @mynodes: The device_node tree created by the call
* @dt_alloc: An allocator that provides a virtual address to memory
* for the resulting tree
+ *
+ * Returns NULL on failure or the memory chunk containing the unflattened
+ * device tree on success.
-static void __unflatten_device_tree(const void *blob,
- struct device_node *dad,
- struct device_node **mynodes,
- void * (*dt_alloc)(u64 size, u64 align))
+static void *__unflatten_device_tree(const void *blob,
+ struct device_node *dad,
+ struct device_node **mynodes,
+ void *(*dt_alloc)(u64 size, u64 align))
if (!blob) {
pr_debug("No device tree pointer\n");
if (!blob) {
pr_debug("No device tree pointer\n");
}
pr_debug("Unflattening device tree:\n");
}
pr_debug("Unflattening device tree:\n");
if (fdt_check_header(blob)) {
pr_err("Invalid device tree blob header\n");
if (fdt_check_header(blob)) {
pr_err("Invalid device tree blob header\n");
}
/* First pass, scan for size */
size = unflatten_dt_nodes(blob, NULL, dad, NULL);
if (size < 0)
}
/* First pass, scan for size */
size = unflatten_dt_nodes(blob, NULL, dad, NULL);
if (size < 0)
size = ALIGN(size, 4);
pr_debug(" size is %d, allocating...\n", size);
size = ALIGN(size, 4);
pr_debug(" size is %d, allocating...\n", size);
be32_to_cpup(mem + size));
pr_debug(" <- unflatten_device_tree()\n");
be32_to_cpup(mem + size));
pr_debug(" <- unflatten_device_tree()\n");
}
static void *kernel_tree_alloc(u64 size, u64 align)
}
static void *kernel_tree_alloc(u64 size, u64 align)
* tree of struct device_node. It also fills the "name" and "type"
* pointers of the nodes so the normal device-tree walking functions
* can be used.
* tree of struct device_node. It also fills the "name" and "type"
* pointers of the nodes so the normal device-tree walking functions
* can be used.
+ *
+ * Returns NULL on failure or the memory chunk containing the unflattened
+ * device tree on success.
-void of_fdt_unflatten_tree(const unsigned long *blob,
- struct device_node *dad,
- struct device_node **mynodes)
+void *of_fdt_unflatten_tree(const unsigned long *blob,
+ struct device_node *dad,
+ struct device_node **mynodes)
mutex_lock(&of_fdt_unflatten_mutex);
mutex_lock(&of_fdt_unflatten_mutex);
- __unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc);
+ mem = __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);
unsigned long node);
extern int of_fdt_match(const void *blob, unsigned long node,
const char *const *compat);
unsigned long node);
extern int of_fdt_match(const void *blob, unsigned long node,
const char *const *compat);
-extern void of_fdt_unflatten_tree(const unsigned long *blob,
- struct device_node *dad,
- struct device_node **mynodes);
+extern void *of_fdt_unflatten_tree(const unsigned long *blob,
+ struct device_node *dad,
+ struct device_node **mynodes);
/* TBD: Temporary export of fdt globals - remove when code fully merged */
extern int __initdata dt_root_addr_cells;
/* TBD: Temporary export of fdt globals - remove when code fully merged */
extern int __initdata dt_root_addr_cells;