hw/timer/aspeed_timer: Convert to DEFINE_TYPES() with inlined TypeInfo
Replace the legacy type_register_static()/type_init() registration pattern with the modern DEFINE_TYPES() macro. Inline 6 standalone TypeInfo variables (aspeed_timer_info as abstract base, aspeed_2400_timer_info, aspeed_2500_timer_info, aspeed_2600_timer_info, aspeed_1030_timer_info, aspeed_2700_timer_info) directly into the 'aspeed_timer_types[]' array, removing the need for separate declarations. No functional change. Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Link: https://lore.kernel.org/qemu-devel/20260601024959.2347639-20-jamin_lin@aspeedtech.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
Jamin Lin committed
Jun 1, 2026 at 02:50 UTC
228ad5fac74e2a9e445670ad7670551f1a98d7d0
1 file changed
+35
-48
hw/timer/aspeed_timer.c
+35
-48
@@ -907,15 +907,6 @@ static void timer_class_init(ObjectClass *klass, const void *data)
907
device_class_set_props(dc, aspeed_timer_properties);
908
}
909
910
-static const TypeInfo aspeed_timer_info = {
911
- .name = TYPE_ASPEED_TIMER,
912
- .parent = TYPE_SYS_BUS_DEVICE,
913
- .instance_size = sizeof(AspeedTimerCtrlState),
914
- .class_init = timer_class_init,
915
- .class_size = sizeof(AspeedTimerClass),
916
- .abstract = true,
917
-};
918
-
910
static void aspeed_2400_timer_class_init(ObjectClass *klass, const void *data)
911
{
912
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -926,12 +917,6 @@ static void aspeed_2400_timer_class_init(ObjectClass *klass, const void *data)
917
awc->write = aspeed_2400_timer_write;
918
}
919
929
-static const TypeInfo aspeed_2400_timer_info = {
930
- .name = TYPE_ASPEED_2400_TIMER,
931
- .parent = TYPE_ASPEED_TIMER,
932
- .class_init = aspeed_2400_timer_class_init,
933
-};
934
-
920
static void aspeed_2500_timer_class_init(ObjectClass *klass, const void *data)
921
{
922
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -942,12 +927,6 @@ static void aspeed_2500_timer_class_init(ObjectClass *klass, const void *data)
927
awc->write = aspeed_2500_timer_write;
928
}
929
945
-static const TypeInfo aspeed_2500_timer_info = {
946
- .name = TYPE_ASPEED_2500_TIMER,
947
- .parent = TYPE_ASPEED_TIMER,
948
- .class_init = aspeed_2500_timer_class_init,
949
-};
950
-
930
static void aspeed_2600_timer_class_init(ObjectClass *klass, const void *data)
931
{
932
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -958,12 +937,6 @@ static void aspeed_2600_timer_class_init(ObjectClass *klass, const void *data)
937
awc->write = aspeed_2600_timer_write;
938
}
939
961
-static const TypeInfo aspeed_2600_timer_info = {
962
- .name = TYPE_ASPEED_2600_TIMER,
963
- .parent = TYPE_ASPEED_TIMER,
964
- .class_init = aspeed_2600_timer_class_init,
965
-};
966
-
940
static void aspeed_1030_timer_class_init(ObjectClass *klass, const void *data)
941
{
942
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -974,12 +947,6 @@ static void aspeed_1030_timer_class_init(ObjectClass *klass, const void *data)
947
awc->write = aspeed_2600_timer_write;
948
}
949
977
-static const TypeInfo aspeed_1030_timer_info = {
978
- .name = TYPE_ASPEED_1030_TIMER,
979
- .parent = TYPE_ASPEED_TIMER,
980
- .class_init = aspeed_1030_timer_class_init,
981
-};
982
-
950
static void aspeed_2700_timer_class_init(ObjectClass *klass, const void *data)
951
{
952
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -990,20 +957,40 @@ static void aspeed_2700_timer_class_init(ObjectClass *klass, const void *data)
957
awc->write = aspeed_2700_timer_write;
958
}
959
993
-static const TypeInfo aspeed_2700_timer_info = {
994
- .name = TYPE_ASPEED_2700_TIMER,
995
- .parent = TYPE_ASPEED_TIMER,
996
- .class_init = aspeed_2700_timer_class_init,
960
+static const TypeInfo aspeed_timer_types[] = {
961
+ {
962
+ .name = TYPE_ASPEED_TIMER,
963
+ .parent = TYPE_SYS_BUS_DEVICE,
964
+ .instance_size = sizeof(AspeedTimerCtrlState),
965
+ .class_init = timer_class_init,
966
+ .class_size = sizeof(AspeedTimerClass),
967
+ .abstract = true,
968
+ },
969
+ {
970
+ .name = TYPE_ASPEED_1030_TIMER,
971
+ .parent = TYPE_ASPEED_TIMER,
972
+ .class_init = aspeed_1030_timer_class_init,
973
+ },
974
+ {
975
+ .name = TYPE_ASPEED_2400_TIMER,
976
+ .parent = TYPE_ASPEED_TIMER,
977
+ .class_init = aspeed_2400_timer_class_init,
978
+ },
979
+ {
980
+ .name = TYPE_ASPEED_2500_TIMER,
981
+ .parent = TYPE_ASPEED_TIMER,
982
+ .class_init = aspeed_2500_timer_class_init,
983
+ },
984
+ {
985
+ .name = TYPE_ASPEED_2600_TIMER,
986
+ .parent = TYPE_ASPEED_TIMER,
987
+ .class_init = aspeed_2600_timer_class_init,
988
+ },
989
+ {
990
+ .name = TYPE_ASPEED_2700_TIMER,
991
+ .parent = TYPE_ASPEED_TIMER,
992
+ .class_init = aspeed_2700_timer_class_init,
993
+ }
994
};
995
999
-static void aspeed_timer_register_types(void)
1000
-{
1001
- type_register_static(&aspeed_timer_info);
1002
- type_register_static(&aspeed_2400_timer_info);
1003
- type_register_static(&aspeed_2500_timer_info);
1004
- type_register_static(&aspeed_2600_timer_info);
1005
- type_register_static(&aspeed_1030_timer_info);
1006
- type_register_static(&aspeed_2700_timer_info);
1007
-}
1008
-
1009
-type_init(aspeed_timer_register_types)
996
+DEFINE_TYPES(aspeed_timer_types)