diff options
author | Marek BehĂșn | 2021-05-26 14:08:18 +0200 |
---|---|---|
committer | Jagan Teki | 2021-06-24 11:53:00 +0530 |
commit | 0e116bea52af1b665a656d49c328468e976be913 (patch) | |
tree | a14f4bf602e2c3251e70671a8419fab0f8139441 /test | |
parent | 31a7b719d07ccb11950f423b5f1195375109b5fa (diff) |
dm: core: add ofnode_get_path()
Add function for retrieving full node path of a given ofnode.
This uses np->full_name if OF is live, otherwise a call to
fdt_get_path() is made.
Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/ofnode.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 9a69cf70c1e..94a4d2189e8 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -297,3 +297,24 @@ static int dm_test_ofnode_get_reg(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_ofnode_get_reg, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +static int dm_test_ofnode_get_path(struct unit_test_state *uts) +{ + const char *path = "/translation-test@8000/noxlatebus@3,300/dev@42"; + char buf[64]; + ofnode node; + int res; + + node = ofnode_path(path); + ut_assert(ofnode_valid(node)); + + res = ofnode_get_path(node, buf, 64); + ut_asserteq(0, res); + ut_asserteq_str(path, buf); + + res = ofnode_get_path(node, buf, 32); + ut_asserteq(-ENOSPC, res); + + return 0; +} +DM_TEST(dm_test_ofnode_get_path, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |