diff options
author | Rob Herring <robh@kernel.org> | 2023-03-28 15:15:57 -0500 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2023-04-13 17:46:35 -0500 |
commit | c75a79491835c50ca61938ae1ebd3ba5598f7410 (patch) | |
tree | a87517b093f73b412725b461af721e76d58946e8 /drivers/of/unittest.c | |
parent | 6d32dadb11a6480be62c6ada901bbdcbda1775c9 (diff) | |
download | linux-stable-c75a79491835c50ca61938ae1ebd3ba5598f7410.tar.gz linux-stable-c75a79491835c50ca61938ae1ebd3ba5598f7410.tar.bz2 linux-stable-c75a79491835c50ca61938ae1ebd3ba5598f7410.zip |
of/address: Add of_range_to_resource() helper
A few users need to convert a specific "ranges" entry into a struct
resource. Add a helper to similar to of_address_to_resource(). The
existing of_pci_range_to_resource() helper isn't really PCI specific,
so it can be used with the CONFIG_PCI check dropped.
Link: https://lore.kernel.org/r/20230328-dt-address-helpers-v1-2-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 | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 1a45df1f354a..945288d5672f 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -1013,7 +1013,8 @@ static void __init of_unittest_bus_ranges(void) struct device_node *np; struct of_range range; struct of_range_parser parser; - int i = 0; + struct resource res; + int ret, i = 0; np = of_find_node_by_path("/testcase-data/address-tests"); if (!np) { @@ -1026,6 +1027,19 @@ static void __init of_unittest_bus_ranges(void) return; } + ret = of_range_to_resource(np, 1, &res); + unittest(!ret, "of_range_to_resource returned error (%d) node %pOF\n", + ret, np); + unittest(resource_type(&res) == IORESOURCE_MEM, + "of_range_to_resource wrong resource type on node %pOF res=%pR\n", + np, &res); + unittest(res.start == 0xd0000000, + "of_range_to_resource wrong resource start address on node %pOF res=%pR\n", + np, &res); + unittest(resource_size(&res) == 0x20000000, + "of_range_to_resource wrong resource start address on node %pOF res=%pR\n", + np, &res); + /* * Get the "ranges" from the device tree */ |