libqos: split I2CAdapter initialization and allocation

Provide *_init functions that populate an I2CAdapter struct without
allocating one, and make the existing *_create functions wrap them.

Because in the new setup *_create might return a pointer inside the
IMXI2C or OMAPI2C struct, create companion *_free functions to go
back to the outer pointer.

All this is temporary until allocation will be handled entirely by
qgraph.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2019-03-18 17:12:25 +01:00
parent c4f00daa5b
commit 732c919cf0
5 changed files with 67 additions and 34 deletions

View file

@ -39,10 +39,26 @@ void i2c_set8(I2CAdapter *i2c, uint8_t addr, uint8_t reg,
void i2c_set16(I2CAdapter *i2c, uint8_t addr, uint8_t reg,
uint16_t value);
/* libi2c-omap.c */
I2CAdapter *omap_i2c_create(QTestState *qts, uint64_t addr);
/* i2c-omap.c */
typedef struct OMAPI2C {
I2CAdapter parent;
/* libi2c-imx.c */
uint64_t addr;
} OMAPI2C;
void omap_i2c_init(OMAPI2C *s, QTestState *qts, uint64_t addr);
I2CAdapter *omap_i2c_create(QTestState *qts, uint64_t addr);
void omap_i2c_free(I2CAdapter *i2c);
/* i2c-imx.c */
typedef struct IMXI2C {
I2CAdapter parent;
uint64_t addr;
} IMXI2C;
void imx_i2c_init(IMXI2C *s, QTestState *qts, uint64_t addr);
I2CAdapter *imx_i2c_create(QTestState *qts, uint64_t addr);
void imx_i2c_free(I2CAdapter *i2c);
#endif