[PATCH v1 11/24] hw/arm/aspeed_ast1700: 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 11/24] hw/arm/aspeed_ast1700: 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.

Inline the standalone TypeInfo variable directly into the
'aspeed_ast1700_types[]' array, removing the need for a separate
declaration.

No functional change.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 hw/arm/aspeed_ast1700.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/hw/arm/aspeed_ast1700.c b/hw/arm/aspeed_ast1700.c
index e90302c11b..5af5da5b8a 100644
--- a/hw/arm/aspeed_ast1700.c
+++ b/hw/arm/aspeed_ast1700.c
@@ -260,17 +260,14 @@ static void aspeed_ast1700_class_init(ObjectClass *klass, const void *data)
     device_class_set_props(dc, aspeed_ast1700_props);
 }
 
-static const TypeInfo aspeed_ast1700_info = {
-    .name          = TYPE_ASPEED_AST1700,
-    .parent        = TYPE_SYS_BUS_DEVICE,
-    .instance_size = sizeof(AspeedAST1700SoCState),
-    .class_init    = aspeed_ast1700_class_init,
-    .instance_init = aspeed_ast1700_instance_init,
+static const TypeInfo aspeed_ast1700_types[] = {
+    {
+        .name          = TYPE_ASPEED_AST1700,
+        .parent        = TYPE_SYS_BUS_DEVICE,
+        .instance_size = sizeof(AspeedAST1700SoCState),
+        .class_init    = aspeed_ast1700_class_init,
+        .instance_init = aspeed_ast1700_instance_init,
+    }
 };
 
-static void aspeed_ast1700_register_types(void)
-{
-    type_register_static(&aspeed_ast1700_info);
-}
-
-type_init(aspeed_ast1700_register_types);
+DEFINE_TYPES(aspeed_ast1700_types)
-- 
2.43.0