From ce3d0af18308efbf99266cfcc2fd162c02b34c20 Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Tue, 11 Jul 2023 16:33:20 -0600 Subject: [PATCH] emul: Don't panic if matching emul can't be found When initializing emulators for devices registered on an emulated bus, Zephyr will assert if a matching emulator for the device cannot be found. This feels overly restrictive --there may be cases where we still want to build a driver for testing even without an emulator and drivers should be able to handle situations where there is no device emulator present (the I2C/SPI transactions will simply fail and the driver never becomes ready). This commit removes the assert and replaces it with an warning message if no matching emulator is found. Signed-off-by: Tristan Honscheid --- subsys/emul/emul.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/subsys/emul/emul.c b/subsys/emul/emul.c index 15299381a38..96adb888dd2 100644 --- a/subsys/emul/emul.c +++ b/subsys/emul/emul.c @@ -40,7 +40,10 @@ int emul_init_for_bus(const struct device *dev) for (elp = cfg->children; elp < end; elp++) { const struct emul *emul = emul_get_binding(elp->dev->name); - __ASSERT(emul, "Cannot find emulator for '%s'", elp->dev->name); + if (!emul) { + LOG_WRN("Cannot find emulator for '%s'", elp->dev->name); + continue; + } switch (emul->bus_type) { case EMUL_BUS_TYPE_I2C: