From b3a219883ebe21f55a8ee5e7e5b38b9eb309e9c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juha=20Riihim=C3=A4ki?= Date: Mon, 8 Jun 2009 09:27:19 +0300 Subject: [PATCH] fix I2C slave addressing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit With the recent device handling changes the I2C slave addressing code was broken. With current code, if a slave with the correct address is not found on the bus the last scanned slave on the bus will be addressed. This is wrong. Please find attached a patch to fix it. Signed-off-by: Juha Riihimäki Acked-by: Riku Voipio Signed-off-by: Aurelien Jarno --- hw/i2c.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/i2c.c b/hw/i2c.c index 5c291ce0a9..bee8e88c6b 100644 --- a/hw/i2c.c +++ b/hw/i2c.c @@ -85,9 +85,11 @@ int i2c_start_transfer(i2c_bus *bus, uint8_t address, int recv) i2c_slave *slave = NULL; QLIST_FOREACH(qdev, &bus->qbus.children, sibling) { - slave = I2C_SLAVE_FROM_QDEV(qdev); - if (slave->address == address) + i2c_slave *candidate = I2C_SLAVE_FROM_QDEV(qdev); + if (candidate->address == address) { + slave = candidate; break; + } } if (!slave) -- 2.11.0