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.
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)