dm: core: add ofnode and dev function to iterate on node property
[oweals/u-boot.git] / test / dm / rtc.c
index 9397cf72a731536f8efc20024c7434a6853a6dc7..71887427647b1540ed6866ca32614a26c5a47ef1 100644 (file)
@@ -1,20 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2015 Google, Inc
- *
- * SPDX-License-Identifier:    GPL-2.0+
  * Written by Simon Glass <sjg@chromium.org>
  */
 
 #include <common.h>
 #include <dm.h>
+#include <i2c.h>
 #include <rtc.h>
 #include <asm/io.h>
-#include <dm/test.h>
-#include <dm/ut.h>
 #include <asm/test.h>
+#include <dm/test.h>
+#include <test/ut.h>
 
 /* Simple RTC sanity check */
-static int dm_test_rtc_base(struct dm_test_state *dms)
+static int dm_test_rtc_base(struct unit_test_state *uts)
 {
        struct udevice *dev;
 
@@ -52,7 +52,7 @@ static int cmp_times(struct rtc_time *expect, struct rtc_time *time, bool show)
 }
 
 /* Set and get the time */
-static int dm_test_rtc_set_get(struct dm_test_state *dms)
+static int dm_test_rtc_set_get(struct unit_test_state *uts)
 {
        struct rtc_time now, time, cmp;
        struct udevice *dev, *emul;
@@ -61,7 +61,7 @@ static int dm_test_rtc_set_get(struct dm_test_state *dms)
        ut_assertok(uclass_get_device(UCLASS_RTC, 0, &dev));
        ut_assertok(dm_rtc_get(dev, &now));
 
-       ut_assertok(device_find_first_child(dev, &emul));
+       ut_assertok(i2c_emul_find(dev, &emul));
        ut_assert(emul != NULL);
 
        /* Tell the RTC to go into manual mode */
@@ -117,7 +117,7 @@ static int dm_test_rtc_set_get(struct dm_test_state *dms)
 DM_TEST(dm_test_rtc_set_get, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
 
 /* Reset the time */
-static int dm_test_rtc_reset(struct dm_test_state *dms)
+static int dm_test_rtc_reset(struct unit_test_state *uts)
 {
        struct rtc_time now;
        struct udevice *dev, *emul;
@@ -126,7 +126,7 @@ static int dm_test_rtc_reset(struct dm_test_state *dms)
        ut_assertok(uclass_get_device(UCLASS_RTC, 0, &dev));
        ut_assertok(dm_rtc_get(dev, &now));
 
-       ut_assertok(device_find_first_child(dev, &emul));
+       ut_assertok(i2c_emul_find(dev, &emul));
        ut_assert(emul != NULL);
 
        old_base_time = sandbox_i2c_rtc_get_set_base_time(emul, 0);
@@ -143,7 +143,7 @@ static int dm_test_rtc_reset(struct dm_test_state *dms)
 DM_TEST(dm_test_rtc_reset, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
 
 /* Check that two RTC devices can be used independently */
-static int dm_test_rtc_dual(struct dm_test_state *dms)
+static int dm_test_rtc_dual(struct unit_test_state *uts)
 {
        struct rtc_time now1, now2, cmp;
        struct udevice *dev1, *dev2;
@@ -155,9 +155,9 @@ static int dm_test_rtc_dual(struct dm_test_state *dms)
        ut_assertok(uclass_get_device(UCLASS_RTC, 1, &dev2));
        ut_assertok(dm_rtc_get(dev2, &now2));
 
-       ut_assertok(device_find_first_child(dev1, &emul1));
+       ut_assertok(i2c_emul_find(dev1, &emul1));
        ut_assert(emul1 != NULL);
-       ut_assertok(device_find_first_child(dev2, &emul2));
+       ut_assertok(i2c_emul_find(dev2, &emul2));
        ut_assert(emul2 != NULL);
 
        offset = sandbox_i2c_rtc_set_offset(emul1, false, -1);