[PATCH v1 13/24] hw/gpio/aspeed_sgpio: 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 13/24] hw/gpio/aspeed_sgpio: 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 2 standalone TypeInfo variables (aspeed_sgpio_info and
aspeed_sgpio_ast2700_info) directly into the 'aspeed_sgpio_types[]'
array, removing the need for separate declarations.

No functional change.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 hw/gpio/aspeed_sgpio.c | 37 ++++++++++++++++---------------------
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/hw/gpio/aspeed_sgpio.c b/hw/gpio/aspeed_sgpio.c
index 0c53b03464..7d2f736995 100644
--- a/hw/gpio/aspeed_sgpio.c
+++ b/hw/gpio/aspeed_sgpio.c
@@ -321,26 +321,21 @@ static void aspeed_sgpio_2700_class_init(ObjectClass *klass, const void *data)
     agc->reg_ops = &aspeed_sgpio_2700_ops;
 }
 
-static const TypeInfo aspeed_sgpio_info = {
-    .name           = TYPE_ASPEED_SGPIO,
-    .parent         = TYPE_SYS_BUS_DEVICE,
-    .instance_size  = sizeof(AspeedSGPIOState),
-    .class_size     = sizeof(AspeedSGPIOClass),
-    .class_init     = aspeed_sgpio_class_init,
-    .abstract       = true,
-};
-
-static const TypeInfo aspeed_sgpio_ast2700_info = {
-    .name           = TYPE_ASPEED_SGPIO "-ast2700",
-    .parent         = TYPE_ASPEED_SGPIO,
-    .class_init     = aspeed_sgpio_2700_class_init,
-    .instance_init  = aspeed_sgpio_init,
+static const TypeInfo aspeed_sgpio_types[] = {
+    {
+        .name           = TYPE_ASPEED_SGPIO,
+        .parent         = TYPE_SYS_BUS_DEVICE,
+        .instance_size  = sizeof(AspeedSGPIOState),
+        .class_size     = sizeof(AspeedSGPIOClass),
+        .class_init     = aspeed_sgpio_class_init,
+        .abstract       = true,
+    },
+    {
+        .name           = TYPE_ASPEED_SGPIO "-ast2700",
+        .parent         = TYPE_ASPEED_SGPIO,
+        .class_init     = aspeed_sgpio_2700_class_init,
+        .instance_init  = aspeed_sgpio_init,
+    }
 };
 
-static void aspeed_sgpio_register_types(void)
-{
-    type_register_static(&aspeed_sgpio_info);
-    type_register_static(&aspeed_sgpio_ast2700_info);
-}
-
-type_init(aspeed_sgpio_register_types);
+DEFINE_TYPES(aspeed_sgpio_types)
-- 
2.43.0