mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-25 06:19:56 +00:00
feat(fdt-wrappers): add function to find or add a sudnode
This change adds a new utility function - `fdtw_find_or_add_subnode` to find a subnode. If the subnode is not present, the function adds it in the flattened device tree. Signed-off-by: Ruchika Gupta <ruchika.gupta@linaro.org> Change-Id: Idf3ceddc57761ac015763d4a8b004877bcad766a
This commit is contained in:
parent
19a9cc3a1b
commit
dea8ee0d3f
2 changed files with 25 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2021, ARM Limited and Contributors. All rights reserved.
|
* Copyright (c) 2018-2022, ARM Limited and Contributors. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -618,3 +618,24 @@ int fdtw_for_each_cpu(const void *dtb,
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find a given node in device tree. If not present, add it.
|
||||||
|
* Returns offset of node found/added on success, and < 0 on error.
|
||||||
|
*/
|
||||||
|
int fdtw_find_or_add_subnode(void *fdt, int parentoffset, const char *name)
|
||||||
|
{
|
||||||
|
int offset;
|
||||||
|
|
||||||
|
offset = fdt_subnode_offset(fdt, parentoffset, name);
|
||||||
|
|
||||||
|
if (offset == -FDT_ERR_NOTFOUND) {
|
||||||
|
offset = fdt_add_subnode(fdt, parentoffset, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset < 0) {
|
||||||
|
ERROR("%s: %s: %s\n", __func__, name, fdt_strerror(offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2021, ARM Limited and Contributors. All rights reserved.
|
* Copyright (c) 2018-2022, ARM Limited and Contributors. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -44,6 +44,8 @@ uint64_t fdtw_translate_address(const void *dtb, int bus_node,
|
||||||
int fdtw_for_each_cpu(const void *fdt,
|
int fdtw_for_each_cpu(const void *fdt,
|
||||||
int (*callback)(const void *dtb, int node, uintptr_t mpidr));
|
int (*callback)(const void *dtb, int node, uintptr_t mpidr));
|
||||||
|
|
||||||
|
int fdtw_find_or_add_subnode(void *fdt, int parentoffset, const char *name);
|
||||||
|
|
||||||
static inline uint32_t fdt_blob_size(const void *dtb)
|
static inline uint32_t fdt_blob_size(const void *dtb)
|
||||||
{
|
{
|
||||||
const uint32_t *dtb_header = dtb;
|
const uint32_t *dtb_header = dtb;
|
||||||
|
|
Loading…
Add table
Reference in a new issue