diff options
author | Rob Herring <robh@kernel.org> | 2023-03-28 22:15:59 +0200 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2023-04-14 00:46:35 +0200 |
commit | b50c788a56964a900ebcc817c8a5ad35ddad87b6 (patch) | |
tree | 979111f2e492fe935904e94bc84f7a54176544d5 /drivers/of/unittest.c | |
parent | of/address: Add support for 3 address cell bus (diff) | |
download | linux-b50c788a56964a900ebcc817c8a5ad35ddad87b6.tar.xz linux-b50c788a56964a900ebcc817c8a5ad35ddad87b6.zip |
of/address: Add of_range_count() helper
Some users need a count of the number of ranges entries before
iterating over the entries. Typically this is for allocating some data
structure based on the size. Add a helper, of_range_count(), to get the
count. The helper must be called with an struct of_range_parser
initialized by of_range_parser_init().
Link: https://lore.kernel.org/r/20230328-dt-address-helpers-v1-4-e2456c3e77ab@kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of/unittest.c')
-rw-r--r-- | drivers/of/unittest.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 29066ecbed47..eaeb58065acc 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -1014,7 +1014,7 @@ static void __init of_unittest_bus_ranges(void) struct of_range range; struct of_range_parser parser; struct resource res; - int ret, i = 0; + int ret, count, i = 0; np = of_find_node_by_path("/testcase-data/address-tests"); if (!np) { @@ -1040,6 +1040,11 @@ static void __init of_unittest_bus_ranges(void) "of_range_to_resource wrong resource start address on node %pOF res=%pR\n", np, &res); + count = of_range_count(&parser); + unittest(count == 2, + "of_range_count wrong size on node %pOF count=%d\n", + np, count); + /* * Get the "ranges" from the device tree */ |