Skip to content
Snippets Groups Projects
Commit 66613f5d authored by Simon Glass's avatar Simon Glass
Browse files

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.

Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
parent ef8a2500
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,6 @@ enum state_terminal_raw { ...@@ -36,7 +36,6 @@ enum state_terminal_raw {
}; };
struct sandbox_spi_info { struct sandbox_spi_info {
const char *spec;
struct udevice *emul; struct udevice *emul;
}; };
......
...@@ -115,24 +115,22 @@ static int sandbox_sf_probe(struct udevice *dev) ...@@ -115,24 +115,22 @@ static int sandbox_sf_probe(struct udevice *dev)
const struct spi_flash_info *data; const struct spi_flash_info *data;
struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev); struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev);
struct sandbox_state *state = state_get_current(); struct sandbox_state *state = state_get_current();
struct dm_spi_slave_platdata *slave_plat;
struct udevice *bus = dev->parent; struct udevice *bus = dev->parent;
const char *spec = NULL; const char *spec = NULL;
struct udevice *emul;
int ret = 0; int ret = 0;
int cs = -1; int cs = -1;
int i;
debug("%s: bus %d, looking for emul=%p: ", __func__, bus->seq, dev); debug("%s: bus %d, looking for emul=%p: ", __func__, bus->seq, dev);
if (bus->seq >= 0 && bus->seq < CONFIG_SANDBOX_SPI_MAX_BUS) { ret = sandbox_spi_get_emul(state, bus, dev, &emul);
for (i = 0; i < CONFIG_SANDBOX_SPI_MAX_CS; i++) { if (ret) {
if (state->spi[bus->seq][i].emul == dev)
cs = i;
}
}
if (cs == -1) {
printf("Error: Unknown chip select for device '%s'\n", printf("Error: Unknown chip select for device '%s'\n",
dev->name); dev->name);
return -EINVAL; return ret;
} }
slave_plat = dev_get_parent_platdata(dev);
cs = slave_plat->cs;
debug("found at cs %d\n", cs); debug("found at cs %d\n", cs);
if (!pdata->filename) { if (!pdata->filename) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment