diff mbox series

[v6,02/14] test: dm: add test item for ofnode_get_child_count()

Message ID 1587352883-8641-3-git-send-email-chunfeng.yun@mediatek.com
State Superseded
Headers show
Series Add support for MediaTek xHCI host controller | expand

Commit Message

Chunfeng Yun (云春峰) April 20, 2020, 3:21 a.m. UTC
Add a test item for ofnode_get_child_count()

Signed-off-by: Chunfeng Yun <chunfeng.yun at mediatek.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Weijie Gao <weijie.gao at mediatek.com>
---
v6: add Reviewed-by Weijie

v4~v5: no changes

v3:
    1. squash dts patch into this one suggested by Simon
    2. add reviewed-by Simon

v2:
    a new patch to test ofnode_get_child_count() suggested by Simon
---
 arch/sandbox/dts/test.dts | 18 ++++++++++++++++++
 test/dm/ofnode.c          | 21 +++++++++++++++++++++
 2 files changed, 39 insertions(+)

Comments

Simon Glass April 20, 2020, 1:10 p.m. UTC | #1
On Sun, 19 Apr 2020 at 21:22, Chunfeng Yun <chunfeng.yun at mediatek.com> wrote:
>
> Add a test item for ofnode_get_child_count()
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun at mediatek.com>
> Reviewed-by: Simon Glass <sjg at chromium.org>
> Reviewed-by: Weijie Gao <weijie.gao at mediatek.com>
> ---
> v6: add Reviewed-by Weijie
>
> v4~v5: no changes
>
> v3:
>     1. squash dts patch into this one suggested by Simon
>     2. add reviewed-by Simon
>
> v2:
>     a new patch to test ofnode_get_child_count() suggested by Simon
> ---
>  arch/sandbox/dts/test.dts | 18 ++++++++++++++++++
>  test/dm/ofnode.c          | 21 +++++++++++++++++++++
>  2 files changed, 39 insertions(+)

Reviewed-by: Simon Glass <sjg at chromium.org>
Fabio Estevam April 20, 2020, 2:07 p.m. UTC | #2
On Mon, Apr 20, 2020 at 12:22 AM Chunfeng Yun <chunfeng.yun at mediatek.com> wrote:

> +       i-test {
> +               compatible = "mediatek,u-boot-fdt-test";
> +               #address-cells = <1>;
> +               #size-cells = <0>;
> +
> +               subnode0 {
> +                       reg = <0>;
> +               };

This has a reg property without its corresponding @.

Shouldn't this be subnode at 0 instead?
Chunfeng Yun (云春峰) April 21, 2020, 1:39 a.m. UTC | #3
On Mon, 2020-04-20 at 11:07 -0300, Fabio Estevam wrote:
> On Mon, Apr 20, 2020 at 12:22 AM Chunfeng Yun <chunfeng.yun at mediatek.com> wrote:
> 
> > +       i-test {
> > +               compatible = "mediatek,u-boot-fdt-test";
> > +               #address-cells = <1>;
> > +               #size-cells = <0>;
> > +
> > +               subnode0 {
> > +                       reg = <0>;
> > +               };
> 
> This has a reg property without its corresponding @.
> 
> Shouldn't this be subnode at 0 instead?
Yes, will add it, thanks
diff mbox series

Patch

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index df9f1835c9..6be0a5887c 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -218,6 +218,24 @@ 
 		compatible = "denx,u-boot-fdt-test1";
 	};
 
+	i-test {
+		compatible = "mediatek,u-boot-fdt-test";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		subnode0 {
+			reg = <0>;
+		};
+
+		subnode1 {
+			reg = <1>;
+		};
+
+		subnode2 {
+			reg = <2>;
+		};
+	};
+
 	devres-test {
 		compatible = "denx,u-boot-devres-test";
 	};
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 1c49eaf38b..07d5c7d7a6 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -113,3 +113,24 @@  static int dm_test_ofnode_read_chosen(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_ofnode_read_chosen, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int dm_test_ofnode_get_child_count(struct unit_test_state *uts)
+{
+	ofnode node, child_node;
+	u32 val;
+
+	node = ofnode_path("/i-test");
+	ut_assert(ofnode_valid(node));
+
+	val = ofnode_get_child_count(node);
+	ut_asserteq(3, val);
+
+	child_node = ofnode_first_subnode(node);
+	ut_assert(ofnode_valid(child_node));
+	val = ofnode_get_child_count(child_node);
+	ut_asserteq(0, val);
+
+	return 0;
+}
+DM_TEST(dm_test_ofnode_get_child_count,
+	DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);