Skip to content

Commit 8fd1ce7

Browse files
tristan-googlecarlescufi
authored andcommitted
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>
1 parent 7fba7d3 commit 8fd1ce7

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

drivers/espi/espi_emul.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ static struct emul_espi_driver_api emul_espi_driver_api = {
232232
},
233233

234234
#define ESPI_EMUL_INIT(n) \
235-
static const struct emul_link_for_bus emuls_##n[] = { DT_FOREACH_CHILD( \
236-
DT_DRV_INST(n), EMUL_LINK_AND_COMMA) }; \
235+
static const struct emul_link_for_bus emuls_##n[] = { \
236+
DT_FOREACH_CHILD_STATUS_OKAY(DT_DRV_INST(n), EMUL_LINK_AND_COMMA)}; \
237237
static struct emul_list_for_bus espi_emul_cfg_##n = { \
238238
.children = emuls_##n, \
239239
.num_children = ARRAY_SIZE(emuls_##n), \

drivers/i2c/i2c_emul.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ static struct i2c_driver_api i2c_emul_api = {
144144
},
145145

146146
#define I2C_EMUL_INIT(n) \
147-
static const struct emul_link_for_bus emuls_##n[] = { DT_FOREACH_CHILD( \
148-
DT_DRV_INST(n), EMUL_LINK_AND_COMMA) }; \
147+
static const struct emul_link_for_bus emuls_##n[] = { \
148+
DT_FOREACH_CHILD_STATUS_OKAY(DT_DRV_INST(n), EMUL_LINK_AND_COMMA)}; \
149149
static struct emul_list_for_bus i2c_emul_cfg_##n = { \
150150
.children = emuls_##n, \
151151
.num_children = ARRAY_SIZE(emuls_##n), \

drivers/spi/spi_emul.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ static struct spi_driver_api spi_emul_api = {
119119
},
120120

121121
#define SPI_EMUL_INIT(n) \
122-
static const struct emul_link_for_bus emuls_##n[] = { DT_FOREACH_CHILD( \
123-
DT_DRV_INST(n), EMUL_LINK_AND_COMMA) }; \
122+
static const struct emul_link_for_bus emuls_##n[] = { \
123+
DT_FOREACH_CHILD_STATUS_OKAY(DT_DRV_INST(n), EMUL_LINK_AND_COMMA)}; \
124124
static struct emul_list_for_bus spi_emul_cfg_##n = { \
125125
.children = emuls_##n, \
126126
.num_children = ARRAY_SIZE(emuls_##n), \

0 commit comments

Comments
 (0)