From 8b74e2114c9c4b3a2382cda1d82e099b14b0d5e6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juha=20Riihim=C3=A4ki?= Date: Mon, 8 Jun 2009 18:32:39 +0300 Subject: [PATCH] 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. --- hw/i2c.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/i2c.c b/hw/i2c.c index 8a0c4d7..e1dacef 100644 --- a/hw/i2c.c +++ b/hw/i2c.c @@ -69,9 +69,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) -- 1.7.9.5