]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: spi: Clean up detection of sandbox SPI emulator
authorSimon Glass <sjg@chromium.org>
Mon, 1 Oct 2018 17:55:19 +0000 (11:55 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 9 Oct 2018 10:40:27 +0000 (04:40 -0600)
Now that we don't have to deal with the command-line flag we can simplify
the code for detecting the emulator. Remove the lookup based on the SPI
specification, relying just on the device tree to locate the emulator.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/include/asm/state.h
drivers/mtd/spi/sandbox.c

index a96bf44f4ac8f8ecd3492ee49678eadeaad352f5..dcb6d5f5683502458813cb85b521b543b9c065c4 100644 (file)
@@ -36,7 +36,6 @@ enum state_terminal_raw {
 };
 
 struct sandbox_spi_info {
-       const char *spec;
        struct udevice *emul;
 };
 
index 514484eba06639628687ee66fc9c9dfcbe75e57b..7fef754c6341c20a6d8919782a52887c79064048 100644 (file)
@@ -115,24 +115,22 @@ static int sandbox_sf_probe(struct udevice *dev)
        const struct spi_flash_info *data;
        struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev);
        struct sandbox_state *state = state_get_current();
+       struct dm_spi_slave_platdata *slave_plat;
        struct udevice *bus = dev->parent;
        const char *spec = NULL;
+       struct udevice *emul;
        int ret = 0;
        int cs = -1;
-       int i;
 
        debug("%s: bus %d, looking for emul=%p: ", __func__, bus->seq, dev);
-       if (bus->seq >= 0 && bus->seq < CONFIG_SANDBOX_SPI_MAX_BUS) {
-               for (i = 0; i < CONFIG_SANDBOX_SPI_MAX_CS; i++) {
-                       if (state->spi[bus->seq][i].emul == dev)
-                               cs = i;
-               }
-       }
-       if (cs == -1) {
+       ret = sandbox_spi_get_emul(state, bus, dev, &emul);
+       if (ret) {
                printf("Error: Unknown chip select for device '%s'\n",
-                      dev->name);
-               return -EINVAL;
+                       dev->name);
+               return ret;
        }
+       slave_plat = dev_get_parent_platdata(dev);
+       cs = slave_plat->cs;
        debug("found at cs %d\n", cs);
 
        if (!pdata->filename) {