[PATCH v1 20/24] hw/fsi/aspeed_apb2opb: Convert to DEFINE_TYPES() with inlined TypeInfo

Jamin Lin posted 24 patches 2 months, 1 week ago
Maintainers: "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Steven Lee <steven_lee@aspeedtech.com>, Troy Lee <leetroy@gmail.com>, Jamin Lin <jamin_lin@aspeedtech.com>, Kane Chen <kane_chen@aspeedtech.com>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>, Alistair Francis <alistair@alistair23.me>, Ninad Palsule <ninad@linux.ibm.com>, Jason Wang <jasowang@redhat.com>
[PATCH v1 20/24] hw/fsi/aspeed_apb2opb: Convert to DEFINE_TYPES() with inlined TypeInfo
Posted by Jamin Lin 2 months, 1 week ago
Replace the legacy type_register_static()/type_init() registration
pattern with the modern DEFINE_TYPES() macro.

This file contains two independent subsystems (aspeed_apb2opb and
fsi_opb), each with its own type_init() call. Both are converted to
separate DEFINE_TYPES() blocks to preserve the original registration
boundary.

Inline the standalone 'aspeed_apb2opb_info' and 'fsi_opb_info'
TypeInfo variables directly into their respective types arrays,
removing the need for separate declarations.

No functional change.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 hw/fsi/aspeed_apb2opb.c | 42 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 24 deletions(-)

diff --git a/hw/fsi/aspeed_apb2opb.c b/hw/fsi/aspeed_apb2opb.c
index f2d9a9669a..7a37770a43 100644
--- a/hw/fsi/aspeed_apb2opb.c
+++ b/hw/fsi/aspeed_apb2opb.c
@@ -319,20 +319,17 @@ static void fsi_aspeed_apb2opb_class_init(ObjectClass *klass, const void *data)
     rc->phases.hold = fsi_aspeed_apb2opb_reset_hold;
 }
 
-static const TypeInfo aspeed_apb2opb_info = {
-    .name = TYPE_ASPEED_APB2OPB,
-    .parent = TYPE_SYS_BUS_DEVICE,
-    .instance_init = fsi_aspeed_apb2opb_init,
-    .instance_size = sizeof(AspeedAPB2OPBState),
-    .class_init = fsi_aspeed_apb2opb_class_init,
+static const TypeInfo aspeed_apb2opb_types[] = {
+    {
+        .name = TYPE_ASPEED_APB2OPB,
+        .parent = TYPE_SYS_BUS_DEVICE,
+        .instance_init = fsi_aspeed_apb2opb_init,
+        .instance_size = sizeof(AspeedAPB2OPBState),
+        .class_init = fsi_aspeed_apb2opb_class_init,
+    }
 };
 
-static void aspeed_apb2opb_register_types(void)
-{
-    type_register_static(&aspeed_apb2opb_info);
-}
-
-type_init(aspeed_apb2opb_register_types);
+DEFINE_TYPES(aspeed_apb2opb_types)
 
 static void fsi_opb_init(Object *o)
 {
@@ -363,17 +360,14 @@ static void fsi_opb_class_init(ObjectClass *klass, const void *data)
     bc->unrealize = fsi_opb_unrealize;
 }
 
-static const TypeInfo opb_info = {
-    .name = TYPE_OP_BUS,
-    .parent = TYPE_BUS,
-    .instance_init = fsi_opb_init,
-    .instance_size = sizeof(OPBus),
-    .class_init = fsi_opb_class_init,
+static const TypeInfo fsi_opb_types[] = {
+    {
+        .name = TYPE_OP_BUS,
+        .parent = TYPE_BUS,
+        .instance_init = fsi_opb_init,
+        .instance_size = sizeof(OPBus),
+        .class_init = fsi_opb_class_init,
+    }
 };
 
-static void fsi_opb_register_types(void)
-{
-    type_register_static(&opb_info);
-}
-
-type_init(fsi_opb_register_types);
+DEFINE_TYPES(fsi_opb_types)
-- 
2.43.0