diff mbox series

[02/10] hw/arm/realview: Declare QOM types using DEFINE_TYPES() macro

Message ID 20230524145906.33156-3-philmd@linaro.org
State New
Headers show
Series hw/arm/realview: Introduce abstract RealviewMachineClass | expand

Commit Message

Philippe Mathieu-Daudé May 24, 2023, 2:58 p.m. UTC
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.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/realview.c | 50 ++++++++++++++++++-----------------------------
 1 file changed, 19 insertions(+), 31 deletions(-)

Comments

Richard Henderson May 24, 2023, 7:01 p.m. UTC | #1
On 5/24/23 07:58, 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.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   hw/arm/realview.c | 50 ++++++++++++++++++-----------------------------
>   1 file changed, 19 insertions(+), 31 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index a52ff35084..07a80d0de3 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -412,12 +412,6 @@  static void realview_eb_class_init(ObjectClass *oc, void *data)
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm926");
 }
 
-static const TypeInfo realview_eb_type = {
-    .name = MACHINE_TYPE_NAME("realview-eb"),
-    .parent = TYPE_MACHINE,
-    .class_init = realview_eb_class_init,
-};
-
 static void realview_eb_mpcore_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -430,12 +424,6 @@  static void realview_eb_mpcore_class_init(ObjectClass *oc, void *data)
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm11mpcore");
 }
 
-static const TypeInfo realview_eb_mpcore_type = {
-    .name = MACHINE_TYPE_NAME("realview-eb-mpcore"),
-    .parent = TYPE_MACHINE,
-    .class_init = realview_eb_mpcore_class_init,
-};
-
 static void realview_pb_a8_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -446,12 +434,6 @@  static void realview_pb_a8_class_init(ObjectClass *oc, void *data)
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a8");
 }
 
-static const TypeInfo realview_pb_a8_type = {
-    .name = MACHINE_TYPE_NAME("realview-pb-a8"),
-    .parent = TYPE_MACHINE,
-    .class_init = realview_pb_a8_class_init,
-};
-
 static void realview_pbx_a9_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -463,18 +445,24 @@  static void realview_pbx_a9_class_init(ObjectClass *oc, void *data)
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a9");
 }
 
-static const TypeInfo realview_pbx_a9_type = {
-    .name = MACHINE_TYPE_NAME("realview-pbx-a9"),
-    .parent = TYPE_MACHINE,
-    .class_init = realview_pbx_a9_class_init,
+static const TypeInfo realview_machine_types[] = {
+    {
+        .name           = MACHINE_TYPE_NAME("realview-eb"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = realview_eb_class_init,
+    }, {
+        .name           = MACHINE_TYPE_NAME("realview-eb-mpcore"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = realview_eb_mpcore_class_init,
+    }, {
+        .name           = MACHINE_TYPE_NAME("realview-pb-a8"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = realview_pb_a8_class_init,
+    }, {
+        .name           = MACHINE_TYPE_NAME("realview-pbx-a9"),
+        .parent         = TYPE_MACHINE,
+        .class_init     = realview_pbx_a9_class_init,
+    }
 };
 
-static void realview_machine_init(void)
-{
-    type_register_static(&realview_eb_type);
-    type_register_static(&realview_eb_mpcore_type);
-    type_register_static(&realview_pb_a8_type);
-    type_register_static(&realview_pbx_a9_type);
-}
-
-type_init(realview_machine_init)
+DEFINE_TYPES(realview_machine_types)