On Thu, Oct 05, 2017 at 06:24:50PM +0200, Igor Mammedov wrote: > Use a new DEFINE_TYPES() helper to simplify type registration > > Signed-off-by: Igor Mammedov <imamm...@redhat.com>
Acked-by: David Gibson <da...@gibson.dropbear.id.au> > --- > hw/ppc/pnv.c | 92 > ++++++++++++++++++++++-------------------------------------- > 1 file changed, 34 insertions(+), 58 deletions(-) > > diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c > index ab7083b..e23dc3c 100644 > --- a/hw/ppc/pnv.c > +++ b/hw/ppc/pnv.c > @@ -730,13 +730,6 @@ static void pnv_chip_power8e_class_init(ObjectClass > *klass, void *data) > dc->desc = "PowerNV Chip POWER8E"; > } > > -static const TypeInfo pnv_chip_power8e_info = { > - .name = TYPE_PNV_CHIP_POWER8E, > - .parent = TYPE_PNV_CHIP, > - .instance_size = sizeof(PnvChip), > - .class_init = pnv_chip_power8e_class_init, > -}; > - > static void pnv_chip_power8_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > @@ -751,13 +744,6 @@ static void pnv_chip_power8_class_init(ObjectClass > *klass, void *data) > dc->desc = "PowerNV Chip POWER8"; > } > > -static const TypeInfo pnv_chip_power8_info = { > - .name = TYPE_PNV_CHIP_POWER8, > - .parent = TYPE_PNV_CHIP, > - .instance_size = sizeof(PnvChip), > - .class_init = pnv_chip_power8_class_init, > -}; > - > static void pnv_chip_power8nvl_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > @@ -772,13 +758,6 @@ static void pnv_chip_power8nvl_class_init(ObjectClass > *klass, void *data) > dc->desc = "PowerNV Chip POWER8NVL"; > } > > -static const TypeInfo pnv_chip_power8nvl_info = { > - .name = TYPE_PNV_CHIP_POWER8NVL, > - .parent = TYPE_PNV_CHIP, > - .instance_size = sizeof(PnvChip), > - .class_init = pnv_chip_power8nvl_class_init, > -}; > - > static void pnv_chip_power9_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > @@ -793,13 +772,6 @@ static void pnv_chip_power9_class_init(ObjectClass > *klass, void *data) > dc->desc = "PowerNV Chip POWER9"; > } > > -static const TypeInfo pnv_chip_power9_info = { > - .name = TYPE_PNV_CHIP_POWER9, > - .parent = TYPE_PNV_CHIP, > - .instance_size = sizeof(PnvChip), > - .class_init = pnv_chip_power9_class_init, > -}; > - > static void pnv_chip_core_sanitize(PnvChip *chip, Error **errp) > { > PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip); > @@ -1001,15 +973,6 @@ static void pnv_chip_class_init(ObjectClass *klass, > void *data) > dc->desc = "PowerNV Chip"; > } > > -static const TypeInfo pnv_chip_info = { > - .name = TYPE_PNV_CHIP, > - .parent = TYPE_SYS_BUS_DEVICE, > - .class_init = pnv_chip_class_init, > - .instance_init = pnv_chip_init, > - .class_size = sizeof(PnvChipClass), > - .abstract = true, > -}; > - > static ICSState *pnv_ics_get(XICSFabric *xi, int irq) > { > PnvMachineState *pnv = POWERNV_MACHINE(xi); > @@ -1145,27 +1108,40 @@ static void powernv_machine_class_init(ObjectClass > *oc, void *data) > powernv_machine_class_props_init(oc); > } > > -static const TypeInfo powernv_machine_info = { > - .name = TYPE_POWERNV_MACHINE, > - .parent = TYPE_MACHINE, > - .instance_size = sizeof(PnvMachineState), > - .instance_init = powernv_machine_initfn, > - .class_init = powernv_machine_class_init, > - .interfaces = (InterfaceInfo[]) { > - { TYPE_XICS_FABRIC }, > - { TYPE_INTERRUPT_STATS_PROVIDER }, > - { }, > +#define DEFINE_PNV_CHIP_TYPE(type, class_initfn) \ > + { \ > + .name = type, \ > + .class_init = class_initfn, \ > + .parent = TYPE_PNV_CHIP, \ > + } > + > +static const TypeInfo types[] = { > + { > + .name = TYPE_POWERNV_MACHINE, > + .parent = TYPE_MACHINE, > + .instance_size = sizeof(PnvMachineState), > + .instance_init = powernv_machine_initfn, > + .class_init = powernv_machine_class_init, > + .interfaces = (InterfaceInfo[]) { > + { TYPE_XICS_FABRIC }, > + { TYPE_INTERRUPT_STATS_PROVIDER }, > + { }, > + }, > }, > + { > + .name = TYPE_PNV_CHIP, > + .parent = TYPE_SYS_BUS_DEVICE, > + .class_init = pnv_chip_class_init, > + .instance_init = pnv_chip_init, > + .instance_size = sizeof(PnvChip), > + .class_size = sizeof(PnvChipClass), > + .abstract = true, > + }, > + DEFINE_PNV_CHIP_TYPE(TYPE_PNV_CHIP_POWER9, pnv_chip_power9_class_init), > + DEFINE_PNV_CHIP_TYPE(TYPE_PNV_CHIP_POWER8, pnv_chip_power8_class_init), > + DEFINE_PNV_CHIP_TYPE(TYPE_PNV_CHIP_POWER8E, pnv_chip_power8e_class_init), > + DEFINE_PNV_CHIP_TYPE(TYPE_PNV_CHIP_POWER8NVL, > + pnv_chip_power8nvl_class_init), > }; > > -static void powernv_machine_register_types(void) > -{ > - type_register_static(&powernv_machine_info); > - type_register_static(&pnv_chip_info); > - type_register_static(&pnv_chip_power8e_info); > - type_register_static(&pnv_chip_power8_info); > - type_register_static(&pnv_chip_power8nvl_info); > - type_register_static(&pnv_chip_power9_info); > -} > - > -type_init(powernv_machine_register_types) > +DEFINE_TYPES(types) -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature