Skip to content

Commit

Permalink
emul: spi: SPI_EMUL_INIT(n) hard-coded to instance #0
Browse files Browse the repository at this point in the history
The `SPI_EMUL_INIT(n)` macro used to instantiate SPI bus emulators
builds an array of SPI devices attached to the bus, but always checks
instance #0 of the bus and not `n`. This makes multiple instances of an
emulated SPI bus unusable and popualtes them all with bus 0's devices.

Change the `0` to `n`, which matches how the I2C bus emulator does it.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
  • Loading branch information
tristan-google committed Jul 6, 2023
1 parent d17d28a commit 39cfc52
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/spi/spi_emul.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static struct spi_driver_api spi_emul_api = {

#define SPI_EMUL_INIT(n) \
static const struct emul_link_for_bus emuls_##n[] = { DT_FOREACH_CHILD( \
DT_DRV_INST(0), EMUL_LINK_AND_COMMA) }; \
DT_DRV_INST(n), EMUL_LINK_AND_COMMA) }; \
static struct emul_list_for_bus spi_emul_cfg_##n = { \
.children = emuls_##n, \
.num_children = ARRAY_SIZE(emuls_##n), \
Expand Down

0 comments on commit 39cfc52

Please sign in to comment.