diff options
author | Nicholas Piggin <npiggin@gmail.com> | 2017-04-18 21:12:18 +0200 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2017-05-09 14:55:58 +0200 |
commit | ea47dd191d543f81e0912b5dc0471b48346b016e (patch) | |
tree | 2b3c5bcee2b645be83f5be38a025041817194b06 /drivers/of | |
parent | Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/scottwoo... (diff) | |
download | linux-ea47dd191d543f81e0912b5dc0471b48346b016e.tar.xz linux-ea47dd191d543f81e0912b5dc0471b48346b016e.zip |
of/fdt: introduce of_scan_flat_dt_subnodes and of_get_flat_dt_phandle
Introduce primitives for FDT parsing. These will be used for powerpc
cpufeatures node scanning, which has quite complex structure but should
be processed early.
Cc: devicetree@vger.kernel.org
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/fdt.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index e5ce4b59e162..961ca97072a9 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -754,6 +754,36 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, } /** + * of_scan_flat_dt_subnodes - scan sub-nodes of a node call callback on each. + * @it: callback function + * @data: context data pointer + * + * This function is used to scan sub-nodes of a node. + */ +int __init of_scan_flat_dt_subnodes(unsigned long parent, + int (*it)(unsigned long node, + const char *uname, + void *data), + void *data) +{ + const void *blob = initial_boot_params; + int node; + + fdt_for_each_subnode(node, blob, parent) { + const char *pathp; + int rc; + + pathp = fdt_get_name(blob, node, NULL); + if (*pathp == '/') + pathp = kbasename(pathp); + rc = it(node, pathp, data); + if (rc) + return rc; + } + return 0; +} + +/** * of_get_flat_dt_subnode_by_name - get the subnode by given name * * @node: the parent node @@ -812,6 +842,14 @@ int __init of_flat_dt_match(unsigned long node, const char *const *compat) return of_fdt_match(initial_boot_params, node, compat); } +/** + * of_get_flat_dt_prop - Given a node in the flat blob, return the phandle + */ +uint32_t __init of_get_flat_dt_phandle(unsigned long node) +{ + return fdt_get_phandle(initial_boot_params, node); +} + struct fdt_scan_status { const char *name; int namelen; |