From: Christian Marangi <ansuelsmth@gmail.com>
To: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>,
Christian Marangi <ansuelsmth@gmail.com>,
Sughosh Ganu <sughosh.ganu@linaro.org>,
Sean Anderson <seanga2@gmail.com>,
Julien Masson <jmasson@baylibre.com>,
Patrick Rudolph <patrick.rudolph@9elements.com>,
Yang Xiwen <forbidden405@outlook.com>,
Mattijs Korpershoek <mkorpershoek@baylibre.com>,
Caleb Connolly <caleb.connolly@linaro.org>,
Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>,
Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
Marek Vasut <marex@denx.de>,
Michael Polyntsov <michael.polyntsov@iopsys.eu>,
u-boot@lists.denx.de
Subject: [PATCH 4/8] test: dm: Expand dm_test_ofnode_phandle(_ot) with new ofnode/tree_parse_phandle
Date: Sat, 9 Nov 2024 19:00:29 +0100 [thread overview]
Message-ID: <20241109180038.10344-5-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20241109180038.10344-1-ansuelsmth@gmail.com>
Expand dm_test_ofnode_phandle(_ot) with new ofnode/tree_parse_phandle() op.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
arch/sandbox/dts/other.dts | 7 ++++++
arch/sandbox/dts/test.dts | 7 ++++++
test/dm/ofnode.c | 44 ++++++++++++++++++++++++++++++++++----
3 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/arch/sandbox/dts/other.dts b/arch/sandbox/dts/other.dts
index 110063fa1c6..226226e3020 100644
--- a/arch/sandbox/dts/other.dts
+++ b/arch/sandbox/dts/other.dts
@@ -30,6 +30,7 @@
<&other_gpio_b 5 GPIO_ACTIVE_HIGH 3 2 1>,
<0>, <&other_gpio_a 12>;
other-phandle-value = <&other_gpio_c 10>, <0xFFFFFFFF 20>, <&other_gpio_a 30>;
+ other-phandle-nodes = <&other_phandle_node_1>, <&other_phandle_node_2>;
};
other_gpio_a: other-gpio-a {
@@ -44,6 +45,12 @@
#gpio-cells = <2>;
};
+ other_phandle_node_1: other-phandle-node-1 {
+ };
+
+ other_phandle_node_2: other-phandle-node-2 {
+ };
+
target: target {
compatible = "sandbox-other2";
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 3017b33d67b..b8a46463158 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -296,6 +296,12 @@
compatible = "sandbox,dsi-host";
};
+ phandle_node_1: phandle-node-1 {
+ };
+
+ phandle_node_2: phandle-node-2 {
+ };
+
a-test {
reg = <0 1>;
compatible = "denx,u-boot-fdt-test";
@@ -334,6 +340,7 @@
interrupts-extended = <&irq 3 0>;
acpi,name = "GHIJ";
phandle-value = <&gpio_c 10>, <0xFFFFFFFF 20>, <&gpio_a 30>;
+ phandle-nodes = <&phandle_node_1>, <&phandle_node_2>;
mux-controls = <&muxcontroller0 0>, <&muxcontroller0 1>,
<&muxcontroller0 2>, <&muxcontroller0 3>,
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 5e36a228395..c05de1c54ca 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -273,15 +273,16 @@ static int dm_test_ofnode_read_ot(struct unit_test_state *uts)
}
DM_TEST(dm_test_ofnode_read_ot, UTF_SCAN_FDT | UTF_OTHER_FDT);
-/* test ofnode_count_/parse_phandle_with_args() */
+/* test ofnode_count_/parse/_phandle_with_args() */
static int dm_test_ofnode_phandle(struct unit_test_state *uts)
{
struct ofnode_phandle_args args;
- ofnode node;
+ ofnode node, phandle, target;
int ret;
const char prop[] = "test-gpios";
const char cell[] = "#gpio-cells";
const char prop2[] = "phandle-value";
+ const char prop3[] = "phandle-nodes";
node = ofnode_path("/a-test");
ut_assert(ofnode_valid(node));
@@ -345,20 +346,38 @@ static int dm_test_ofnode_phandle(struct unit_test_state *uts)
ret = ofnode_parse_phandle_with_args(node, prop2, NULL, 1, 3, &args);
ut_asserteq(-ENOENT, ret);
+ /* Test ofnode_parse_phandle */
+ phandle = ofnode_parse_phandle(node, "missing", 0);
+ ut_assert(ofnode_equal(ofnode_null(), phandle));
+
+ target = ofnode_path("/phandle-node-1");
+ ut_assert(ofnode_valid(target));
+ phandle = ofnode_parse_phandle(node, prop3, 0);
+ ut_assert(ofnode_equal(target, phandle));
+
+ target = ofnode_path("/phandle-node-2");
+ ut_assert(ofnode_valid(target));
+ phandle = ofnode_parse_phandle(node, prop3, 1);
+ ut_assert(ofnode_equal(target, phandle));
+
+ phandle = ofnode_parse_phandle(node, prop3, 3);
+ ut_assert(ofnode_equal(ofnode_null(), phandle));
+
return 0;
}
DM_TEST(dm_test_ofnode_phandle, UTF_SCAN_PDATA | UTF_SCAN_FDT);
-/* test oftree_count_/parse_phandle_with_args() with 'other' tree */
+/* test oftree_count_/parse/_phandle_with_args() with 'other' tree */
static int dm_test_ofnode_phandle_ot(struct unit_test_state *uts)
{
oftree otree = get_other_oftree(uts);
struct ofnode_phandle_args args;
- ofnode node;
+ ofnode node, phandle, target;
int ret;
const char prop[] = "other-test-gpios";
const char cell[] = "#gpio-cells";
const char prop2[] = "other-phandle-value";
+ const char prop3[] = "other-phandle-nodes";
node = oftree_path(otree, "/other-a-test");
ut_assert(ofnode_valid(node));
@@ -422,6 +441,23 @@ static int dm_test_ofnode_phandle_ot(struct unit_test_state *uts)
ret = oftree_parse_phandle_with_args(otree, node, prop2, NULL, 1, 3, &args);
ut_asserteq(-ENOENT, ret);
+ /* Test oftree_parse_phandle */
+ phandle = oftree_parse_phandle(otree, node, "missing", 0);
+ ut_assert(ofnode_equal(ofnode_null(), phandle));
+
+ target = oftree_path(otree, "/other-phandle-node-1");
+ ut_assert(ofnode_valid(target));
+ phandle = oftree_parse_phandle(otree, node, prop3, 0);
+ ut_assert(ofnode_equal(target, phandle));
+
+ target = oftree_path(otree, "/other-phandle-node-2");
+ ut_assert(ofnode_valid(target));
+ phandle = oftree_parse_phandle(otree, node, prop3, 1);
+ ut_assert(ofnode_equal(target, phandle));
+
+ phandle = oftree_parse_phandle(otree, node, prop3, 3);
+ ut_assert(ofnode_equal(ofnode_null(), phandle));
+
return 0;
}
DM_TEST(dm_test_ofnode_phandle_ot, UTF_OTHER_FDT);
--
2.45.2
next prev parent reply other threads:[~2024-11-09 18:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-09 18:00 [PATCH 0/8] led: update LED boot/activity to new property implementation Christian Marangi
2024-11-09 18:00 ` [PATCH 1/8] dm: core: implement oftree variant of parse_phandle OPs Christian Marangi
2024-11-09 18:00 ` [PATCH 2/8] test: dm: fix broken dm_test_ofnode_phandle_ot Christian Marangi
2024-11-09 18:00 ` [PATCH 3/8] dm: core: implement ofnode/tree_parse_phandle() helper Christian Marangi
2024-11-09 18:00 ` Christian Marangi [this message]
2024-11-09 18:00 ` [PATCH 5/8] dm: core: implement phandle ofnode_options helper Christian Marangi
2024-11-09 18:00 ` [PATCH 6/8] test: dm: Add test for ofnode options phandle helper Christian Marangi
2024-11-09 18:00 ` [PATCH 7/8] led: update LED boot/activity to new property implementation Christian Marangi
2024-11-09 18:00 ` [PATCH 8/8] test: dm: Update test for LED activity and boot Christian Marangi
2024-11-09 20:29 ` [PATCH 0/8] led: update LED boot/activity to new property implementation Christian Marangi
2024-11-20 13:46 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241109180038.10344-5-ansuelsmth@gmail.com \
--to=ansuelsmth@gmail.com \
--cc=caleb.connolly@linaro.org \
--cc=forbidden405@outlook.com \
--cc=jmasson@baylibre.com \
--cc=marex@denx.de \
--cc=michael.polyntsov@iopsys.eu \
--cc=mikhail.kshevetskiy@iopsys.eu \
--cc=mkorpershoek@baylibre.com \
--cc=patrick.rudolph@9elements.com \
--cc=rasmus.villemoes@prevas.dk \
--cc=seanga2@gmail.com \
--cc=sjg@chromium.org \
--cc=sughosh.ganu@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox