From: Juha Riihimäki Date: Mon, 8 Jun 2009 06:27:19 +0000 (+0300) Subject: fix I2C slave addressing X-Git-Tag: v0.11.1~1 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=beb52700347ae9f8ee5988e64801a09b7f3db24a;p=qemu.git fix I2C slave addressing 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 --- diff --git a/hw/i2c.c b/hw/i2c.c index 42a5d7a6b..16e511215 100644 --- a/hw/i2c.c +++ b/hw/i2c.c @@ -81,9 +81,11 @@ int i2c_start_transfer(i2c_bus *bus, int address, int recv) i2c_slave *slave = NULL; LIST_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)