@samitouri / QOSamiQemu / commits / 39cb912af9

hw/gpio: pca9552: register types with DEFINE_TYPES()

Replace the separate TypeInfo definitions and pca955x_register_types() registration function with a single type array registered through the DEFINE_TYPES() macro, to prepare addition of new PCA955x-derived devices. No functional change. Signed-off-by: Emmanuel Blot <emmanuel.blot@free.fr> Reviewed-by: Glenn Miles <milesg@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260709-catalina-upgrade-v1-1-814575bc076b@free.fr Signed-off-by: Cédric Le Goater <clg@redhat.com>

Emmanuel Blot committed Jul 9, 2026 at 17:23 UTC 39cb912af93ebb64d4639ef4780ff0f08a0c1a60
1 file changed +21 -28
hw/gpio/pca9552.c
+21 -28
@@ -492,16 +492,6 @@ static void pca955x_class_init(ObjectClass *klass, const void *data)
492 device_class_set_props(dc, pca955x_properties);
493 }
494
495 -static const TypeInfo pca955x_info = {
496 - .name = TYPE_PCA955X,
497 - .parent = TYPE_I2C_SLAVE,
498 - .instance_init = pca955x_initfn,
499 - .instance_size = sizeof(PCA955xState),
500 - .class_init = pca955x_class_init,
501 - .class_size = sizeof(PCA955xClass),
502 - .abstract = true,
503 -};
504 -
495 static void pca9552_class_init(ObjectClass *oc, const void *data)
496 {
497 DeviceClass *dc = DEVICE_CLASS(oc);
@@ -526,23 +516,26 @@ static void pca9535_class_init(ObjectClass *oc, const void *data)
516 pc->has_led_support = false;
517 }
518
529 -static const TypeInfo pca9552_info = {
530 - .name = TYPE_PCA9552,
531 - .parent = TYPE_PCA955X,
532 - .class_init = pca9552_class_init,
533 -};
534 -
535 -static const TypeInfo pca9535_info = {
536 - .name = TYPE_PCA9535,
537 - .parent = TYPE_PCA955X,
538 - .class_init = pca9535_class_init,
519 +static const TypeInfo pca955x_types[] = {
520 + {
521 + .name = TYPE_PCA955X,
522 + .parent = TYPE_I2C_SLAVE,
523 + .instance_init = pca955x_initfn,
524 + .instance_size = sizeof(PCA955xState),
525 + .class_init = pca955x_class_init,
526 + .class_size = sizeof(PCA955xClass),
527 + .abstract = true,
528 + },
529 + {
530 + .name = TYPE_PCA9552,
531 + .parent = TYPE_PCA955X,
532 + .class_init = pca9552_class_init,
533 + },
534 + {
535 + .name = TYPE_PCA9535,
536 + .parent = TYPE_PCA955X,
537 + .class_init = pca9535_class_init,
538 + }
539 };
540
541 -static void pca955x_register_types(void)
542 -{
543 - type_register_static(&pca955x_info);
544 - type_register_static(&pca9552_info);
545 - type_register_static(&pca9535_info);
546 -}
547 -
548 -type_init(pca955x_register_types)
541 +DEFINE_TYPES(pca955x_types)