@samitouri / QOSamiQemu / commits / a3f6263c7e

hw/adc/aspeed_adc: Convert to DEFINE_TYPES() with inlined TypeInfo

Replace the legacy type_register_static()/type_init() registration pattern with the modern DEFINE_TYPES() macro. Inline 7 standalone TypeInfo variables (aspeed_adc_engine_info, aspeed_adc_info as abstract base, aspeed_2400_adc_info, aspeed_2500_adc_info, aspeed_2600_adc_info, aspeed_1030_adc_info, aspeed_2700_adc_info) directly into the 'aspeed_adc_types[]' array, removing the need for separate declarations. Note that aspeed_2400 and aspeed_2500 variants carry only .name and .parent with no class_init. 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-11-jamin_lin@aspeedtech.com Signed-off-by: Cédric Le Goater <clg@redhat.com>

Jamin Lin committed Jun 1, 2026 at 02:50 UTC a3f6263c7ebbfd3a375b53828d909a98314b48e4
1 file changed +40 -55
hw/adc/aspeed_adc.c
+40 -55
@@ -304,13 +304,6 @@ static void aspeed_adc_engine_class_init(ObjectClass *klass, const void *data)
304 dc->vmsd = &vmstate_aspeed_adc_engine;
305 }
306
307 -static const TypeInfo aspeed_adc_engine_info = {
308 - .name = TYPE_ASPEED_ADC_ENGINE,
309 - .parent = TYPE_SYS_BUS_DEVICE,
310 - .instance_size = sizeof(AspeedADCEngineState),
311 - .class_init = aspeed_adc_engine_class_init,
312 -};
313 -
307 static void aspeed_adc_instance_init(Object *obj)
308 {
309 AspeedADCState *s = ASPEED_ADC(obj);
@@ -408,53 +401,45 @@ static void aspeed_2700_adc_class_init(ObjectClass *klass, const void *data)
401 aac->nr_engines = 2;
402 }
403
411 -static const TypeInfo aspeed_adc_info = {
412 - .name = TYPE_ASPEED_ADC,
413 - .parent = TYPE_SYS_BUS_DEVICE,
414 - .instance_init = aspeed_adc_instance_init,
415 - .instance_size = sizeof(AspeedADCState),
416 - .class_init = aspeed_adc_class_init,
417 - .class_size = sizeof(AspeedADCClass),
418 - .abstract = true,
419 -};
420 -
421 -static const TypeInfo aspeed_2400_adc_info = {
422 - .name = TYPE_ASPEED_2400_ADC,
423 - .parent = TYPE_ASPEED_ADC,
424 -};
425 -
426 -static const TypeInfo aspeed_2500_adc_info = {
427 - .name = TYPE_ASPEED_2500_ADC,
428 - .parent = TYPE_ASPEED_ADC,
429 -};
430 -
431 -static const TypeInfo aspeed_2600_adc_info = {
432 - .name = TYPE_ASPEED_2600_ADC,
433 - .parent = TYPE_ASPEED_ADC,
434 - .class_init = aspeed_2600_adc_class_init,
435 -};
436 -
437 -static const TypeInfo aspeed_1030_adc_info = {
438 - .name = TYPE_ASPEED_1030_ADC,
439 - .parent = TYPE_ASPEED_ADC,
440 - .class_init = aspeed_1030_adc_class_init, /* No change since AST2600 */
441 -};
442 -
443 -static const TypeInfo aspeed_2700_adc_info = {
444 - .name = TYPE_ASPEED_2700_ADC,
445 - .parent = TYPE_ASPEED_ADC,
446 - .class_init = aspeed_2700_adc_class_init,
404 +static const TypeInfo aspeed_adc_types[] = {
405 + {
406 + .name = TYPE_ASPEED_ADC_ENGINE,
407 + .parent = TYPE_SYS_BUS_DEVICE,
408 + .instance_size = sizeof(AspeedADCEngineState),
409 + .class_init = aspeed_adc_engine_class_init,
410 + },
411 + {
412 + .name = TYPE_ASPEED_ADC,
413 + .parent = TYPE_SYS_BUS_DEVICE,
414 + .instance_init = aspeed_adc_instance_init,
415 + .instance_size = sizeof(AspeedADCState),
416 + .class_init = aspeed_adc_class_init,
417 + .class_size = sizeof(AspeedADCClass),
418 + .abstract = true,
419 + },
420 + {
421 + .name = TYPE_ASPEED_1030_ADC,
422 + .parent = TYPE_ASPEED_ADC,
423 + .class_init = aspeed_1030_adc_class_init, /* No change since AST2600 */
424 + },
425 + {
426 + .name = TYPE_ASPEED_2400_ADC,
427 + .parent = TYPE_ASPEED_ADC,
428 + },
429 + {
430 + .name = TYPE_ASPEED_2500_ADC,
431 + .parent = TYPE_ASPEED_ADC,
432 + },
433 + {
434 + .name = TYPE_ASPEED_2600_ADC,
435 + .parent = TYPE_ASPEED_ADC,
436 + .class_init = aspeed_2600_adc_class_init,
437 + },
438 + {
439 + .name = TYPE_ASPEED_2700_ADC,
440 + .parent = TYPE_ASPEED_ADC,
441 + .class_init = aspeed_2700_adc_class_init,
442 + }
443 };
444
449 -static void aspeed_adc_register_types(void)
450 -{
451 - type_register_static(&aspeed_adc_engine_info);
452 - type_register_static(&aspeed_adc_info);
453 - type_register_static(&aspeed_2400_adc_info);
454 - type_register_static(&aspeed_2500_adc_info);
455 - type_register_static(&aspeed_2600_adc_info);
456 - type_register_static(&aspeed_1030_adc_info);
457 - type_register_static(&aspeed_2700_adc_info);
458 -}
459 -
460 -type_init(aspeed_adc_register_types);
445 +DEFINE_TYPES(aspeed_adc_types)