Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73712fe3 authored by Rob Herring's avatar Rob Herring Committed by Joonwoo Park
Browse files

of: create unflatten_and_copy_device_tree



Several architectures using DT support built-in dtb's in the init
section. These platforms need to copy the dtb from init since the
strings are referenced after unflattening. Every arch has their own
copying routine which do the same thing. Create a common function,
unflatten_and_copy_device_tree, to copy the dtb when unflattening the
dtb.

Signed-off-by: default avatarRob Herring <rob.herring@calxeda.com>
Acked-by: default avatarGrant Likely <grant.likely@linaro.org>
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


Git-commit: a8bf7527a2e17ccf1366e67f6ac728327ca34c40
[joonwoop@codeaurora.org: fixed trivial merge conflict.]
Signed-off-by: default avatarJoonwoo Park <joonwoop@codeaurora.org>
parent ed018de4
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -902,4 +902,28 @@ void __init unflatten_device_tree(void)
	of_alias_scan(early_init_dt_alloc_memory_arch);
}

/**
 * unflatten_and_copy_device_tree - copy and create tree of device_nodes from flat blob
 *
 * Copies and unflattens the device-tree passed by the firmware, creating the
 * 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. This should only be used when the FDT memory has not been
 * reserved such is the case when the FDT is built-in to the kernel init
 * section. If the FDT memory is reserved already then unflatten_device_tree
 * should be used instead.
 */
void __init unflatten_and_copy_device_tree(void)
{
	int size = __be32_to_cpu(initial_boot_params->totalsize);
	void *dt = early_init_dt_alloc_memory_arch(size,
		__alignof__(struct boot_param_header));

	if (dt) {
		memcpy(dt, initial_boot_params, size);
		initial_boot_params = dt;
	}
	unflatten_device_tree();
}

#endif /* CONFIG_OF_EARLY_FLATTREE */
+2 −0
Original line number Diff line number Diff line
@@ -144,11 +144,13 @@ extern const void *of_flat_dt_match_machine(const void *default_match,

/* Other Prototypes */
extern void unflatten_device_tree(void);
extern void unflatten_and_copy_device_tree(void);
extern void early_init_devtree(void *);
#else /* CONFIG_OF_FLATTREE */
static inline void early_init_fdt_scan_reserved_mem(void) {}
static inline const char *of_flat_dt_get_machine_name(void) { return NULL; }
static inline void unflatten_device_tree(void) {}
static inline void unflatten_and_copy_device_tree(void) {}
static inline void *of_get_flat_dt_prop(unsigned long node, const char *name,
				 unsigned long *size) { return NULL; }