Message ID | 20230520054510.68822-3-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | hw/riscv/opentitan: Correct QOM type/size of OpenTitanState | expand |
On 5/20/23 02:45, Philippe Mathieu-Daudé wrote: > When multiple QOM types are registered in the same file, > it is simpler to use the the DEFINE_TYPES() macro. Replace > the type_init() / type_register_static() combination. This > is in preparation of adding the OpenTitan machine type to > this array in a pair of commits. I wonder whether we should forbid type_init()/type_register_static() and force everyone to use DEFINE_TYPES(). We need less options when dealing with QOM. Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > hw/riscv/opentitan.c | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > > diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c > index 2d21ee39c5..294955eeea 100644 > --- a/hw/riscv/opentitan.c > +++ b/hw/riscv/opentitan.c > @@ -320,17 +320,14 @@ static void lowrisc_ibex_soc_class_init(ObjectClass *oc, void *data) > dc->user_creatable = false; > } > > -static const TypeInfo lowrisc_ibex_soc_type_info = { > - .name = TYPE_RISCV_IBEX_SOC, > - .parent = TYPE_DEVICE, > - .instance_size = sizeof(LowRISCIbexSoCState), > - .instance_init = lowrisc_ibex_soc_init, > - .class_init = lowrisc_ibex_soc_class_init, > +static const TypeInfo open_titan_types[] = { > + { > + .name = TYPE_RISCV_IBEX_SOC, > + .parent = TYPE_DEVICE, > + .instance_size = sizeof(LowRISCIbexSoCState), > + .instance_init = lowrisc_ibex_soc_init, > + .class_init = lowrisc_ibex_soc_class_init, > + } > }; > > -static void lowrisc_ibex_soc_register_types(void) > -{ > - type_register_static(&lowrisc_ibex_soc_type_info); > -} > - > -type_init(lowrisc_ibex_soc_register_types) > +DEFINE_TYPES(open_titan_types)
On Sat, May 20, 2023 at 3:46 PM Philippe Mathieu-Daudé <philmd@linaro.org> wrote: > > When multiple QOM types are registered in the same file, > it is simpler to use the the DEFINE_TYPES() macro. Replace > the type_init() / type_register_static() combination. This > is in preparation of adding the OpenTitan machine type to > this array in a pair of commits. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Alistair > --- > hw/riscv/opentitan.c | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > > diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c > index 2d21ee39c5..294955eeea 100644 > --- a/hw/riscv/opentitan.c > +++ b/hw/riscv/opentitan.c > @@ -320,17 +320,14 @@ static void lowrisc_ibex_soc_class_init(ObjectClass *oc, void *data) > dc->user_creatable = false; > } > > -static const TypeInfo lowrisc_ibex_soc_type_info = { > - .name = TYPE_RISCV_IBEX_SOC, > - .parent = TYPE_DEVICE, > - .instance_size = sizeof(LowRISCIbexSoCState), > - .instance_init = lowrisc_ibex_soc_init, > - .class_init = lowrisc_ibex_soc_class_init, > +static const TypeInfo open_titan_types[] = { > + { > + .name = TYPE_RISCV_IBEX_SOC, > + .parent = TYPE_DEVICE, > + .instance_size = sizeof(LowRISCIbexSoCState), > + .instance_init = lowrisc_ibex_soc_init, > + .class_init = lowrisc_ibex_soc_class_init, > + } > }; > > -static void lowrisc_ibex_soc_register_types(void) > -{ > - type_register_static(&lowrisc_ibex_soc_type_info); > -} > - > -type_init(lowrisc_ibex_soc_register_types) > +DEFINE_TYPES(open_titan_types) > -- > 2.38.1 > >
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 2d21ee39c5..294955eeea 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -320,17 +320,14 @@ static void lowrisc_ibex_soc_class_init(ObjectClass *oc, void *data) dc->user_creatable = false; } -static const TypeInfo lowrisc_ibex_soc_type_info = { - .name = TYPE_RISCV_IBEX_SOC, - .parent = TYPE_DEVICE, - .instance_size = sizeof(LowRISCIbexSoCState), - .instance_init = lowrisc_ibex_soc_init, - .class_init = lowrisc_ibex_soc_class_init, +static const TypeInfo open_titan_types[] = { + { + .name = TYPE_RISCV_IBEX_SOC, + .parent = TYPE_DEVICE, + .instance_size = sizeof(LowRISCIbexSoCState), + .instance_init = lowrisc_ibex_soc_init, + .class_init = lowrisc_ibex_soc_class_init, + } }; -static void lowrisc_ibex_soc_register_types(void) -{ - type_register_static(&lowrisc_ibex_soc_type_info); -} - -type_init(lowrisc_ibex_soc_register_types) +DEFINE_TYPES(open_titan_types)
When multiple QOM types are registered in the same file, it is simpler to use the the DEFINE_TYPES() macro. Replace the type_init() / type_register_static() combination. This is in preparation of adding the OpenTitan machine type to this array in a pair of commits. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/riscv/opentitan.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)