* Copyright (c) 2007 CodeSourcery.
* Written by Paul Brook
*
- * This code is licenced under the LGPL.
+ * This code is licensed under the LGPL.
*/
#include "i2c.h"
i2c_bus *bus;
bus = FROM_QBUS(i2c_bus, qbus_create(&i2c_bus_info, parent, name));
- vmstate_register(-1, &vmstate_i2c_bus, bus);
+ vmstate_register(NULL, -1, &vmstate_i2c_bus, bus);
return bus;
}
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)
return 0;
}
-static const VMStateDescription vmstate_i2c_slave = {
+const VMStateDescription vmstate_i2c_slave = {
.name = "i2c_slave",
.version_id = 1,
.minimum_version_id = 1,
}
};
-void i2c_slave_save(QEMUFile *f, i2c_slave *dev)
-{
- vmstate_save_state(f, &vmstate_i2c_slave, dev);
-}
-
-void i2c_slave_load(QEMUFile *f, i2c_slave *dev)
-{
- vmstate_load_state(f, &vmstate_i2c_slave, dev,
- vmstate_i2c_slave.version_id);
-}
-
static int i2c_slave_qdev_init(DeviceState *dev, DeviceInfo *base)
{
I2CSlaveInfo *info = container_of(base, I2CSlaveInfo, qdev);
dev = qdev_create(&bus->qbus, name);
qdev_prop_set_uint8(dev, "address", addr);
- qdev_init(dev);
+ qdev_init_nofail(dev);
return dev;
}