From 583deafe1bcb453d20d4f3c81cfcdd7a364ab305 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 1 Oct 2018 11:55:19 -0600 Subject: [PATCH] UPSTREAM: dm: spi: Clean up detection of sandbox SPI emulator 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. Change-Id: I6dd9372cb74b8ee991e12314a02e928e3201ae3d Signed-off-by: Simon Glass Signed-off-by: Jon Lin (cherry picked from commit 66613f5dd25c4372b3f5ecb2f0c1d08b7f77b3a8) --- arch/sandbox/include/asm/state.h | 1 - drivers/mtd/spi/sandbox.c | 18 ++++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 617f95291a..3913d1c754 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -35,7 +35,6 @@ enum state_terminal_raw { }; struct sandbox_spi_info { - const char *spec; struct udevice *emul; }; diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c index cd21b4e9bb..a8ffde240d 100644 --- a/drivers/mtd/spi/sandbox.c +++ b/drivers/mtd/spi/sandbox.c @@ -117,24 +117,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) {