From 81310769a95f6cc782cac98605b43ac799af4591 Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Thu, 6 Jul 2023 16:00:28 -0600 Subject: [PATCH] emul: spi: SPI_EMUL_INIT(n) hard-coded to instance #0 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 --- drivers/spi/spi_emul.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi_emul.c b/drivers/spi/spi_emul.c index 183941ee750..98445319b99 100644 --- a/drivers/spi/spi_emul.c +++ b/drivers/spi/spi_emul.c @@ -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), \