emul: Only add enabled DT nodes to bus emulators

The eSPI, I2C, and SPI emulators use devicetree macros to build an array
of devices on the virtual bus. Currently, they will add device nodes that
are not status-okay. This leads to linker errors because the respective
device drivers would not have instantiated device structs for these
nodes --assuming the driver was even compiled. This can be frustrating
if nodes need to be disabled for debugging or configuration purposes.

Update the bus emulators to only consider status-okay nodes by changing
the macros used to iterate over bus devices.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
This commit is contained in:
Tristan Honscheid 2023-07-10 22:40:42 -06:00 committed by Carles Cufí
parent 7fba7d3957
commit 8fd1ce7579
3 changed files with 6 additions and 6 deletions

View file

@ -232,8 +232,8 @@ static struct emul_espi_driver_api emul_espi_driver_api = {
},
#define ESPI_EMUL_INIT(n) \
static const struct emul_link_for_bus emuls_##n[] = { DT_FOREACH_CHILD( \
DT_DRV_INST(n), EMUL_LINK_AND_COMMA) }; \
static const struct emul_link_for_bus emuls_##n[] = { \
DT_FOREACH_CHILD_STATUS_OKAY(DT_DRV_INST(n), EMUL_LINK_AND_COMMA)}; \
static struct emul_list_for_bus espi_emul_cfg_##n = { \
.children = emuls_##n, \
.num_children = ARRAY_SIZE(emuls_##n), \

View file

@ -144,8 +144,8 @@ static struct i2c_driver_api i2c_emul_api = {
},
#define I2C_EMUL_INIT(n) \
static const struct emul_link_for_bus emuls_##n[] = { DT_FOREACH_CHILD( \
DT_DRV_INST(n), EMUL_LINK_AND_COMMA) }; \
static const struct emul_link_for_bus emuls_##n[] = { \
DT_FOREACH_CHILD_STATUS_OKAY(DT_DRV_INST(n), EMUL_LINK_AND_COMMA)}; \
static struct emul_list_for_bus i2c_emul_cfg_##n = { \
.children = emuls_##n, \
.num_children = ARRAY_SIZE(emuls_##n), \

View file

@ -119,8 +119,8 @@ 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(n), EMUL_LINK_AND_COMMA) }; \
static const struct emul_link_for_bus emuls_##n[] = { \
DT_FOREACH_CHILD_STATUS_OKAY(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), \