Emulators are difficult to work with, they generally require maintaining
some state in a mutable data struct. Since the emulator struct doesn't
support a data field like devices do, the pattern seems to be to add it
to the configuration. This makes following the logic of where things are
difficult.
1. Add a `struct emul *parent` structure to the espi/i2c/spi emulator
structs to make it easier when casting up.
2. Add a `void *data` field to `struct emul` to hold the data for
emulators.
Signed-off-by: Yuval Peress <peress@chromium.org>
Issue #38271
Implement a getter for emulators similar to device_get_binding. This
function can be used to get the emulator instance during tests to call
emulator specific functions.
Example: The current BMI160 emulator pre-defines a finite set of data
samples that will be returned. If a test was to be written for logic
that uses that data, then the emulator would become completely useless
without the ability for the test to define what data should be returned.
This will also help in exercising error conditions in tests.
Signed-off-by: Yuval Peress <peress@chromium.org>
Move emul.h out of the top level include/ dir into
include/drivers/emul.h and deprecated the old location.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>