Update the parameters sandbox_sf_bind_emul to support livetree.

Signed-off-by: Simon Glass <[email protected]>
---

 drivers/mtd/spi/sandbox.c | 9 +++++----
 include/spi_flash.h       | 2 +-
 test/dm/spi.c             | 8 ++++----
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c
index 7893efee12..6dc2030281 100644
--- a/drivers/mtd/spi/sandbox.c
+++ b/drivers/mtd/spi/sandbox.c
@@ -556,7 +556,7 @@ static int sandbox_cmdline_cb_spi_sf(struct sandbox_state 
*state,
 SANDBOX_CMDLINE_OPT(spi_sf, 1, "connect a SPI flash: <bus>:<cs>:<id>:<file>");
 
 int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs,
-                        struct udevice *bus, int of_offset, const char *spec)
+                        struct udevice *bus, ofnode node, const char *spec)
 {
        struct udevice *emul;
        char name[20], *str;
@@ -575,7 +575,7 @@ int sandbox_sf_bind_emul(struct sandbox_state *state, int 
busnum, int cs,
                puts("Cannot find sandbox_sf_emul driver\n");
                return -ENOENT;
        }
-       ret = device_bind(bus, drv, str, NULL, of_offset, &emul);
+       ret = device_bind_ofnode(bus, drv, str, NULL, node, &emul);
        if (ret) {
                printf("Cannot create emul device for spec '%s' (err=%d)\n",
                       spec, ret);
@@ -619,7 +619,8 @@ static int sandbox_sf_bind_bus_cs(struct sandbox_state 
*state, int busnum,
        if (ret)
                return ret;
 
-       return sandbox_sf_bind_emul(state, busnum, cs, bus, -1, spec);
+       return sandbox_sf_bind_emul(state, busnum, cs, bus, ofnode_null(),
+                                   spec);
 }
 
 int sandbox_spi_get_emul(struct sandbox_state *state,
@@ -637,7 +638,7 @@ int sandbox_spi_get_emul(struct sandbox_state *state,
                debug("%s: busnum=%u, cs=%u: binding SPI flash emulation: ",
                      __func__, busnum, cs);
                ret = sandbox_sf_bind_emul(state, busnum, cs, bus,
-                                          dev_of_offset(slave), slave->name);
+                                          dev_ofnode(slave), slave->name);
                if (ret) {
                        debug("failed (err=%d)\n", ret);
                        return ret;
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 22533311c5..0ec98fb55d 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -185,7 +185,7 @@ static inline int spi_flash_erase(struct spi_flash *flash, 
u32 offset,
 struct sandbox_state;
 
 int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs,
-                        struct udevice *bus, int of_offset, const char *spec);
+                        struct udevice *bus, ofnode node, const char *spec);
 
 void sandbox_sf_unbind_emul(struct sandbox_state *state, int busnum, int cs);
 
diff --git a/test/dm/spi.c b/test/dm/spi.c
index 252b87431f..ffd789cd7f 100644
--- a/test/dm/spi.c
+++ b/test/dm/spi.c
@@ -23,7 +23,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
        struct udevice *bus, *dev;
        const int busnum = 0, cs = 0, mode = 0, speed = 1000000, cs_b = 1;
        struct spi_cs_info info;
-       int of_offset;
+       ofnode node;
 
        ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_SPI, busnum,
                                                       false, &bus));
@@ -34,7 +34,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
         */
        ut_asserteq(0, uclass_get_device_by_seq(UCLASS_SPI, busnum, &bus));
        ut_assertok(spi_cs_info(bus, cs, &info));
-       of_offset = dev_of_offset(info.dev);
+       node = dev_ofnode(info.dev);
        device_remove(info.dev, DM_REMOVE_NORMAL);
        device_unbind(info.dev);
 
@@ -65,7 +65,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
        ut_asserteq_ptr(NULL, info.dev);
 
        /* Add the emulation and try again */
-       ut_assertok(sandbox_sf_bind_emul(state, busnum, cs, bus, of_offset,
+       ut_assertok(sandbox_sf_bind_emul(state, busnum, cs, bus, node,
                                         "name"));
        ut_assertok(spi_find_bus_and_cs(busnum, cs, &bus, &dev));
        ut_assertok(spi_get_bus_and_cs(busnum, cs, speed, mode,
@@ -75,7 +75,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
        ut_asserteq_ptr(info.dev, slave->dev);
 
        /* We should be able to add something to another chip select */
-       ut_assertok(sandbox_sf_bind_emul(state, busnum, cs_b, bus, of_offset,
+       ut_assertok(sandbox_sf_bind_emul(state, busnum, cs_b, bus, node,
                                         "name"));
        ut_assertok(spi_get_bus_and_cs(busnum, cs_b, speed, mode,
                                       "spi_flash_std", "name", &bus, &slave));
-- 
2.18.0.rc1.242.g61856ae69a-goog

_______________________________________________
U-Boot mailing list
[email protected]
https://lists.denx.de/listinfo/u-boot

Reply via email to