aboutsummaryrefslogtreecommitdiff
path: root/tests/ds1338-test.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2019-03-18 15:09:51 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2019-06-03 14:03:01 +0200
commite8ecb706a8a3a75ea45387a3561b6debed9cacc3 (patch)
treee0074f37da7f4dce193e64c8d11192762429e366 /tests/ds1338-test.c
parent7d8ada6e4d20b47dcf42d22fc62599a9799eac7a (diff)
downloadqemu-e8ecb706a8a3a75ea45387a3561b6debed9cacc3.zip
qemu-e8ecb706a8a3a75ea45387a3561b6debed9cacc3.tar.gz
qemu-e8ecb706a8a3a75ea45387a3561b6debed9cacc3.tar.bz2
libqos: move common i2c code to libqos
The functions to read/write 8-bit or 16-bit registers are the same in tmp105 and pca9552 tests, and in fact they are a special case of "read block"/"write block" functionality; read block in turn is used in ds1338-test. Move everything inside libqos-test, removing the duplication. Account for the small differences by adding to tmp105-test.c the "read register after writing" behavior that is specific to it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/ds1338-test.c')
-rw-r--r--tests/ds1338-test.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/tests/ds1338-test.c b/tests/ds1338-test.c
index 742dad9..88f829f 100644
--- a/tests/ds1338-test.c
+++ b/tests/ds1338-test.c
@@ -35,17 +35,11 @@ static inline uint8_t bcd2bin(uint8_t x)
static void send_and_receive(void)
{
- uint8_t cmd[1];
uint8_t resp[7];
time_t now = time(NULL);
struct tm *tm_ptr = gmtime(&now);
- /* reset the index in the RTC memory */
- cmd[0] = 0;
- i2c_send(i2c, addr, cmd, 1);
-
- /* retrieve the date */
- i2c_recv(i2c, addr, resp, 7);
+ i2c_read_block(i2c, addr, 0, resp, sizeof(resp));
/* check retrieved time againt local time */
g_assert_cmpuint(bcd2bin(resp[4]), == , tm_ptr->tm_mday);