[PATCH v1 04/24] hw/misc/aspeed_pwm: 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 04/24] hw/misc/aspeed_pwm: 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 'aspeed_pwm_info' TypeInfo variable directly
into the 'aspeed_pwm_types[]' array, removing the need for a separate
declaration.

No functional change.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 hw/misc/aspeed_pwm.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/hw/misc/aspeed_pwm.c b/hw/misc/aspeed_pwm.c
index 673a0f1346..dfb93ae7fb 100644
--- a/hw/misc/aspeed_pwm.c
+++ b/hw/misc/aspeed_pwm.c
@@ -106,16 +106,13 @@ static void aspeed_pwm_class_init(ObjectClass *klass, const void *data)
     dc->vmsd = &vmstate_aspeed_pwm;
 }
 
-static const TypeInfo aspeed_pwm_info = {
-    .name = TYPE_ASPEED_PWM,
-    .parent = TYPE_SYS_BUS_DEVICE,
-    .instance_size = sizeof(AspeedPWMState),
-    .class_init = aspeed_pwm_class_init,
+static const TypeInfo aspeed_pwm_types[] = {
+    {
+        .name = TYPE_ASPEED_PWM,
+        .parent = TYPE_SYS_BUS_DEVICE,
+        .instance_size = sizeof(AspeedPWMState),
+        .class_init = aspeed_pwm_class_init,
+    }
 };
 
-static void aspeed_pwm_register_types(void)
-{
-    type_register_static(&aspeed_pwm_info);
-}
-
-type_init(aspeed_pwm_register_types);
+DEFINE_TYPES(aspeed_pwm_types)
-- 
2.43.0