diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2019-03-18 15:06:50 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-06-03 14:03:02 +0200 |
commit | 06599472ec40efef3de7cb2bc98d61e8d4b18a63 (patch) | |
tree | 284d2baa0ab63e29a7c0e70adca2d80602a7e16e /tests/libqos/i2c.h | |
parent | 8130dbcbcda15b3fe5ae1da76bf48868c4ce90fb (diff) |
libqos: i2c: move address into QI2CDevice
This removes the hardcoded I2C address from the tests. The address
is passed via QOSGraphEdgeOptions to i2c_device_create and stored
in the QI2CDevice.
The i2c_send and i2c_recv functions, along with their wrappers,
therefore, can be changed to take a QI2CDevice rather than an
adapter/address pair.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/libqos/i2c.h')
-rw-r--r-- | tests/libqos/i2c.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/tests/libqos/i2c.h b/tests/libqos/i2c.h index 2c8cc3eab5..945b65b34c 100644 --- a/tests/libqos/i2c.h +++ b/tests/libqos/i2c.h @@ -22,6 +22,11 @@ struct I2CAdapter { QTestState *qts; }; +typedef struct QI2CAddress QI2CAddress; +struct QI2CAddress { + uint8_t addr; +}; + typedef struct QI2CDevice QI2CDevice; struct QI2CDevice { /* @@ -36,25 +41,23 @@ struct QI2CDevice { */ QOSGraphObject obj; I2CAdapter *bus; + uint8_t addr; }; void *i2c_device_create(void *i2c_bus, QGuestAllocator *alloc, void *addr); +void add_qi2c_address(QOSGraphEdgeOptions *opts, QI2CAddress *addr); -void i2c_send(I2CAdapter *i2c, uint8_t addr, - const uint8_t *buf, uint16_t len); -void i2c_recv(I2CAdapter *i2c, uint8_t addr, - uint8_t *buf, uint16_t len); +void i2c_send(QI2CDevice *dev, const uint8_t *buf, uint16_t len); +void i2c_recv(QI2CDevice *dev, uint8_t *buf, uint16_t len); -void i2c_read_block(I2CAdapter *i2c, uint8_t addr, uint8_t reg, +void i2c_read_block(QI2CDevice *dev, uint8_t reg, uint8_t *buf, uint16_t len); -void i2c_write_block(I2CAdapter *i2c, uint8_t addr, uint8_t reg, +void i2c_write_block(QI2CDevice *dev, uint8_t reg, const uint8_t *buf, uint16_t len); -uint8_t i2c_get8(I2CAdapter *i2c, uint8_t addr, uint8_t reg); -uint16_t i2c_get16(I2CAdapter *i2c, uint8_t addr, uint8_t reg); -void i2c_set8(I2CAdapter *i2c, uint8_t addr, uint8_t reg, - uint8_t value); -void i2c_set16(I2CAdapter *i2c, uint8_t addr, uint8_t reg, - uint16_t value); +uint8_t i2c_get8(QI2CDevice *dev, uint8_t reg); +uint16_t i2c_get16(QI2CDevice *dev, uint8_t reg); +void i2c_set8(QI2CDevice *dev, uint8_t reg, uint8_t value); +void i2c_set16(QI2CDevice *dev, uint8_t reg, uint16_t value); /* i2c-omap.c */ typedef struct OMAPI2C { |