aboutsummaryrefslogtreecommitdiff
path: root/hw/i2c.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-05-02 09:00:20 +0200
committerAndreas Färber <afaerber@suse.de>2012-06-18 15:14:38 +0200
commit0d936928ef87ca1bb7b41b5b89c400c699a7691c (patch)
tree134a900379f06e1e84f31728a866d8afc7e9869a /hw/i2c.c
parent8185d21639ab749979445734ec671122aa96e805 (diff)
qdev: Convert busses to QEMU Object Model
This is far less interesting than it sounds. We simply add an Object to each BusState and then register the types appropriately. Most of the interesting refactoring will follow in the next patches. Since we're changing fundamental type names (BusInfo -> BusClass), it all needs to convert at once. Fortunately, not a lot of code is affected. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> [AF: Made all new bus TypeInfos static const.] [AF: Made qbus_free() call object_delete(), required {qom,glib}_allocated] Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/i2c.c')
-rw-r--r--hw/i2c.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/hw/i2c.c b/hw/i2c.c
index af5979e65d..319b249da3 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -22,9 +22,13 @@ static Property i2c_props[] = {
DEFINE_PROP_END_OF_LIST(),
};
-static struct BusInfo i2c_bus_info = {
- .name = "I2C",
- .size = sizeof(i2c_bus),
+#define TYPE_I2C_BUS "i2c-bus"
+#define I2C_BUS(obj) OBJECT_CHECK(i2c_bus, (obj), TYPE_I2C_BUS)
+
+static const TypeInfo i2c_bus_info = {
+ .name = TYPE_I2C_BUS,
+ .parent = TYPE_BUS,
+ .instance_size = sizeof(i2c_bus),
};
static void i2c_bus_pre_save(void *opaque)
@@ -62,7 +66,7 @@ i2c_bus *i2c_init_bus(DeviceState *parent, const char *name)
{
i2c_bus *bus;
- bus = FROM_QBUS(i2c_bus, qbus_create(&i2c_bus_info, parent, name));
+ bus = FROM_QBUS(i2c_bus, qbus_create(TYPE_I2C_BUS, parent, name));
vmstate_register(NULL, -1, &vmstate_i2c_bus, bus);
return bus;
}
@@ -219,7 +223,7 @@ static void i2c_slave_class_init(ObjectClass *klass, void *data)
{
DeviceClass *k = DEVICE_CLASS(klass);
k->init = i2c_slave_qdev_init;
- k->bus_info = &i2c_bus_info;
+ k->bus_type = TYPE_I2C_BUS;
k->props = i2c_props;
}
@@ -234,6 +238,7 @@ static TypeInfo i2c_slave_type_info = {
static void i2c_slave_register_types(void)
{
+ type_register_static(&i2c_bus_info);
type_register_static(&i2c_slave_type_info);
}