mirror of
https://github.com/mii443/qemu.git
synced 2025-12-16 17:18:49 +00:00
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>
This commit is contained in:
committed by
Andreas Färber
parent
8185d21639
commit
0d936928ef
15
hw/i2c.c
15
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user