diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2019-03-18 13:48:23 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-06-03 14:03:02 +0200 |
commit | c0825c63cfae0d4af1f1f91867c42e609f3ed13c (patch) | |
tree | db8d1f421d002e0490db979aee276c320a0c3a64 /tests/libqos/i2c-imx.c | |
parent | 732c919cf04c0aaf1b092238e8b84cdb7adf657a (diff) |
libqos: convert I2C to qgraph
Create an i2c-bus interface, corresponding to the I2CAdapter struct.
Wrap IMXI2C and OMAPI2C with a QOSGraphObject, and add the get_driver
function to retrieve the I2CAdapter.
The conversion is still not complete; for simplicity, i2c_recv and
i2c_send (along with their wrappers) still take an adapter/address
pair. Fixing that would be complicated until the tests are converted
to qgraph, so it is left for after the conversion.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/libqos/i2c-imx.c')
-rw-r--r-- | tests/libqos/i2c-imx.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/libqos/i2c-imx.c b/tests/libqos/i2c-imx.c index 28289c521a..86d84a79e6 100644 --- a/tests/libqos/i2c-imx.c +++ b/tests/libqos/i2c-imx.c @@ -186,10 +186,22 @@ static void imx_i2c_recv(I2CAdapter *i2c, uint8_t addr, g_assert((status & I2SR_IBB) == 0); } +static void *imx_i2c_get_driver(void *obj, const char *interface) +{ + IMXI2C *s = obj; + if (!g_strcmp0(interface, "i2c-bus")) { + return &s->parent; + } + fprintf(stderr, "%s not present in imx-i2c\n", interface); + g_assert_not_reached(); +} + void imx_i2c_init(IMXI2C *s, QTestState *qts, uint64_t addr) { s->addr = addr; + s->obj.get_driver = imx_i2c_get_driver; + s->parent.send = imx_i2c_send; s->parent.recv = imx_i2c_recv; s->parent.qts = qts; @@ -213,3 +225,11 @@ void imx_i2c_free(I2CAdapter *i2c) s = container_of(i2c, IMXI2C, parent); g_free(s); } + +static void imx_i2c_register_nodes(void) +{ + qos_node_create_driver("imx.i2c", NULL); + qos_node_produces("imx.i2c", "i2c-bus"); +} + +libqos_init(imx_i2c_register_nodes); |