diff mbox series

[v3,17/19] hw/virtio/virtio-pci: Reduce generic_type_info scope

Message ID 20250212213249.45574-18-philmd@linaro.org
State New
Headers show
Series qom: Constify class_data | expand

Commit Message

Philippe Mathieu-Daudé Feb. 12, 2025, 9:32 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/virtio/virtio-pci.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 6f0e1772669..99724deb3d9 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -2488,18 +2488,6 @@  void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t)
         .abstract      = true,
         .interfaces    = t->interfaces,
     };
-    const TypeInfo generic_type_info = {
-        .name = t->generic_name,
-        .parent = t->base_name ?: base_name,
-        .class_init = t->base_name ? virtio_pci_generic_class_init
-                                   : virtio_pci_base_class_init,
-        .class_data = t->base_name ? NULL : t,
-        .interfaces = (const InterfaceInfo[]) {
-            { INTERFACE_PCIE_DEVICE },
-            { INTERFACE_CONVENTIONAL_PCI_DEVICE },
-            { }
-        },
-    };
 
     assert(t->base_name || !t->non_transitional_name);
     assert(t->base_name || !t->transitional_name);
@@ -2507,6 +2495,19 @@  void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t)
     type_register_static(&base_type_info);
 
     if (t->generic_name) {
+        const TypeInfo generic_type_info = {
+            .name = t->generic_name,
+            .parent = t->base_name ?: base_name,
+            .class_init = t->base_name ? virtio_pci_generic_class_init
+                                       : virtio_pci_base_class_init,
+            .class_data = t->base_name ? NULL : t,
+            .interfaces = (const InterfaceInfo[]) {
+                { INTERFACE_PCIE_DEVICE },
+                { INTERFACE_CONVENTIONAL_PCI_DEVICE },
+                { }
+            },
+        };
+
         type_register_static(&generic_type_info);
     }