Skip to contentSkip to conversation

hw/pci-host: Set DEVICE_CATEGORY_BRIDGE once in parent class_init()

PATCH In review Philippe Mathieu-Daudé 3 participants 4 messages Oct 27, 2025 – Oct 28, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/pci-host: Set DEVICE_CATEGORY_BRIDGE once in parent class_init()

No need to set DEVICE_CATEGORY_BRIDGE for each device implementing TYPE_PCI_HOST_BRIDGE: set it once in the parent.

---
 hw/pci-host/articia.c     | 1 -
 hw/pci-host/aspeed_pcie.c | 1 -
 hw/pci-host/designware.c  | 3 ---
 hw/pci-host/gpex.c        | 2 --
 hw/pci-host/grackle.c     | 1 -
 hw/pci-host/gt64120.c     | 1 -
 hw/pci-host/mv64361.c     | 1 -
 hw/pci-host/pnv_phb.c     | 1 -
 hw/pci-host/ppce500.c     | 1 -
 hw/pci-host/q35.c         | 1 -
 hw/pci-host/raven.c       | 1 -
 hw/pci-host/remote.c      | 1 -
 hw/pci-host/sabre.c       | 1 -
 hw/pci-host/uninorth.c    | 4 ----
 hw/pci-host/xilinx-pcie.c | 2 --
 hw/pci/pci_host.c         | 1 +
 16 files changed, 1 insertion(+), 22 deletions(-)
hw/pci-host/articia.c +0 -1
index cc65aac2a87..47f223879f0 100644
@@ -200,7 +200,6 @@ static void articia_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = articia_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 /* TYPE_ARTICIA_PCI_HOST */
hw/pci-host/aspeed_pcie.c +0 -1
index f7593444fc4..2499d3fe680 100644
@@ -312,7 +312,6 @@ static void aspeed_pcie_rc_class_init(ObjectClass *klass, const void *data)
     dc->desc = "ASPEED PCIe RC";
     dc->realize = aspeed_pcie_rc_realize;
     dc->fw_name = "pci";
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 
     hc->root_bus_path = aspeed_pcie_rc_root_bus_path;
     device_class_set_props(dc, aspeed_pcie_rc_props);
hw/pci-host/designware.c +0 -3
index f6e49ce9b8d..b0b51ad9517 100644
@@ -593,8 +593,6 @@ static void designware_pcie_root_class_init(ObjectClass *klass,
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
-
     k->vendor_id = PCI_VENDOR_ID_SYNOPSYS;
     k->device_id = 0xABCD;
     k->revision = 0;
@@ -736,7 +734,6 @@ static void designware_pcie_host_class_init(ObjectClass *klass,
 
     hc->root_bus_path = designware_pcie_host_root_bus_path;
     dc->realize = designware_pcie_host_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
     dc->vmsd = &vmstate_designware_pcie_host;
 }
hw/pci-host/gpex.c +0 -2
index b806a2286f7..5f809028be2 100644
@@ -200,7 +200,6 @@ static void gpex_host_class_init(ObjectClass *klass, const void *data)
     hc->root_bus_path = gpex_host_root_bus_path;
     dc->realize = gpex_host_realize;
     dc->unrealize = gpex_host_unrealize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
     device_class_set_props(dc, gpex_host_properties);
 }
@@ -242,7 +241,6 @@ static void gpex_root_class_init(ObjectClass *klass, const void *data)
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->desc = "QEMU generic PCIe host bridge";
     dc->vmsd = &vmstate_gpex_root;
     k->vendor_id = PCI_VENDOR_ID_REDHAT;
hw/pci-host/grackle.c +0 -1
index f9da5a908c1..fa872c17e3b 100644
@@ -140,7 +140,6 @@ static void grackle_class_init(ObjectClass *klass, const void *data)
 
     dc->realize = grackle_realize;
     device_class_set_props(dc, grackle_properties);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
     sbc->explicit_ofw_unit_address = grackle_ofw_unit_address;
 }
hw/pci-host/gt64120.c +0 -1
index b1d96f62fe9..bffa1165580 100644
@@ -1298,7 +1298,6 @@ static void gt64120_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     device_class_set_props(dc, gt64120_properties);
     dc->realize = gt64120_realize;
     device_class_set_legacy_reset(dc, gt64120_reset);
hw/pci-host/mv64361.c +0 -1
index e05b6770102..e5e6614b139 100644
@@ -108,7 +108,6 @@ static void mv64361_pcihost_class_init(ObjectClass *klass, const void *data)
 
     dc->realize = mv64361_pcihost_realize;
     device_class_set_props(dc, mv64361_pcihost_props);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo mv64361_pcihost_info = {
hw/pci-host/pnv_phb.c +0 -1
index 4b0ced79b08..e07cf8a0d0f 100644
@@ -202,7 +202,6 @@ static void pnv_phb_class_init(ObjectClass *klass, const void *data)
     hc->root_bus_path = pnv_phb_root_bus_path;
     dc->realize = pnv_phb_realize;
     device_class_set_props(dc, pnv_phb_properties);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->user_creatable = true;
 }
 
hw/pci-host/ppce500.c +0 -1
index 975d191ccb8..edadc35384c 100644
@@ -516,7 +516,6 @@ static void e500_pcihost_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = e500_pcihost_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     device_class_set_props(dc, pcihost_properties);
     dc->vmsd = &vmstate_ppce500_pci;
 }
hw/pci-host/q35.c +0 -1
index 1951ae440cc..c134679fa0c 100644
@@ -194,7 +194,6 @@ static void q35_host_class_init(ObjectClass *klass, const void *data)
     device_class_set_props(dc, q35_host_props);
     /* Reason: needs to be wired up by pc_q35_init */
     dc->user_creatable = false;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
 }
 
hw/pci-host/raven.c +0 -1
index eacffc86d84..661a4223d69 100644
@@ -365,7 +365,6 @@ static void raven_pcihost_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->realize = raven_pcihost_realizefn;
     dc->fw_name = "pci";
 }
hw/pci-host/remote.c +0 -1
index e6d2af4502a..959beb5c301 100644
@@ -55,7 +55,6 @@ static void remote_pcihost_class_init(ObjectClass *klass, const void *data)
     dc->realize = remote_pcihost_realize;
 
     dc->user_creatable = false;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
 }
 
hw/pci-host/sabre.c +0 -1
index 538624c5079..f95e5db583a 100644
@@ -505,7 +505,6 @@ static void sabre_class_init(ObjectClass *klass, const void *data)
     dc->realize = sabre_realize;
     device_class_set_legacy_reset(dc, sabre_reset);
     device_class_set_props(dc, sabre_properties);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
     sbc->explicit_ofw_unit_address = sabre_ofw_unit_address;
 }
hw/pci-host/uninorth.c +0 -4
index 194037d6e75..d337a2fd62c 100644
@@ -435,7 +435,6 @@ static void pci_unin_main_class_init(ObjectClass *klass, const void *data)
 
     dc->realize = pci_unin_main_realize;
     device_class_set_props(dc, pci_unin_main_pci_host_props);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
     sbc->explicit_ofw_unit_address = pci_unin_main_ofw_unit_address;
 }
@@ -453,7 +452,6 @@ static void pci_u3_agp_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = pci_u3_agp_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_u3_agp_info = {
@@ -469,7 +467,6 @@ static void pci_unin_agp_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = pci_unin_agp_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_unin_agp_info = {
@@ -485,7 +482,6 @@ static void pci_unin_internal_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = pci_unin_internal_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_unin_internal_info = {
hw/pci-host/xilinx-pcie.c +0 -2
index c71492de9e7..1540533223c 100644
@@ -172,7 +172,6 @@ static void xilinx_pcie_host_class_init(ObjectClass *klass, const void *data)
 
     hc->root_bus_path = xilinx_pcie_host_root_bus_path;
     dc->realize = xilinx_pcie_host_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
     device_class_set_props(dc, xilinx_pcie_host_props);
 }
@@ -291,7 +290,6 @@ static void xilinx_pcie_root_class_init(ObjectClass *klass, const void *data)
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->desc = "Xilinx AXI-PCIe Host Bridge";
     k->vendor_id = PCI_VENDOR_ID_XILINX;
     k->device_id = 0x7021;
hw/pci/pci_host.c +1 -0
index 7179d99178b..b5c624e12e8 100644
@@ -245,6 +245,7 @@ static void pci_host_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     device_class_set_props(dc, pci_host_properties_common);
     dc->vmsd = &vmstate_pcihost;
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_host_type_info = {
Signature · 1 line
2.51.0
#1 lore raw
Quoted 182 lines · Philippe Mathieu-Daudé

No need to set DEVICE_CATEGORY_BRIDGE for each device implementing TYPE_PCI_HOST_BRIDGE: set it once in the parent.

---

hw/pci-host/articia.c     | 1 -
hw/pci-host/aspeed_pcie.c | 1 -
hw/pci-host/designware.c  | 3 ---
hw/pci-host/gpex.c        | 2 --
hw/pci-host/grackle.c     | 1 -
hw/pci-host/gt64120.c     | 1 -
hw/pci-host/mv64361.c     | 1 -
hw/pci-host/pnv_phb.c     | 1 -
hw/pci-host/ppce500.c     | 1 -
hw/pci-host/q35.c         | 1 -
hw/pci-host/raven.c       | 1 -
hw/pci-host/remote.c      | 1 -
hw/pci-host/sabre.c       | 1 -
hw/pci-host/uninorth.c    | 4 ----
hw/pci-host/xilinx-pcie.c | 2 --
hw/pci/pci_host.c         | 1 +
16 files changed, 1 insertion(+), 22 deletions(-)
hw/pci-host/articia.c +0 -1
index cc65aac2a87..47f223879f0 100644
@@ -200,7 +200,6 @@ static void articia_class_init(ObjectClass *klass, const void *data)
    DeviceClass *dc = DEVICE_CLASS(klass);
 
    dc->realize = articia_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 /* TYPE_ARTICIA_PCI_HOST */
hw/pci-host/aspeed_pcie.c +0 -1
index f7593444fc4..2499d3fe680 100644
@@ -312,7 +312,6 @@ static void aspeed_pcie_rc_class_init(ObjectClass *klass, const void *data)
    dc->desc = "ASPEED PCIe RC";
    dc->realize = aspeed_pcie_rc_realize;
    dc->fw_name = "pci";
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 
    hc->root_bus_path = aspeed_pcie_rc_root_bus_path;
    device_class_set_props(dc, aspeed_pcie_rc_props);
hw/pci-host/designware.c +0 -3
index f6e49ce9b8d..b0b51ad9517 100644
@@ -593,8 +593,6 @@ static void designware_pcie_root_class_init(ObjectClass *klass,
    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
    DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
-
    k->vendor_id = PCI_VENDOR_ID_SYNOPSYS;
    k->device_id = 0xABCD;
    k->revision = 0;
@@ -736,7 +734,6 @@ static void designware_pcie_host_class_init(ObjectClass *klass,
 
    hc->root_bus_path = designware_pcie_host_root_bus_path;
    dc->realize = designware_pcie_host_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    dc->fw_name = "pci";
    dc->vmsd = &vmstate_designware_pcie_host;
 }
hw/pci-host/gpex.c +0 -2
index b806a2286f7..5f809028be2 100644
@@ -200,7 +200,6 @@ static void gpex_host_class_init(ObjectClass *klass, const void *data)
    hc->root_bus_path = gpex_host_root_bus_path;
    dc->realize = gpex_host_realize;
    dc->unrealize = gpex_host_unrealize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    dc->fw_name = "pci";
    device_class_set_props(dc, gpex_host_properties);
 }
@@ -242,7 +241,6 @@ static void gpex_root_class_init(ObjectClass *klass, const void *data)
    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
    DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    dc->desc = "QEMU generic PCIe host bridge";
    dc->vmsd = &vmstate_gpex_root;
    k->vendor_id = PCI_VENDOR_ID_REDHAT;
hw/pci-host/grackle.c +0 -1
index f9da5a908c1..fa872c17e3b 100644
@@ -140,7 +140,6 @@ static void grackle_class_init(ObjectClass *klass, const void *data)
 
    dc->realize = grackle_realize;
    device_class_set_props(dc, grackle_properties);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    dc->fw_name = "pci";
    sbc->explicit_ofw_unit_address = grackle_ofw_unit_address;
 }
hw/pci-host/gt64120.c +0 -1
index b1d96f62fe9..bffa1165580 100644
@@ -1298,7 +1298,6 @@ static void gt64120_class_init(ObjectClass *klass, const void *data)
 {
    DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    device_class_set_props(dc, gt64120_properties);
    dc->realize = gt64120_realize;
    device_class_set_legacy_reset(dc, gt64120_reset);
hw/pci-host/mv64361.c +0 -1
index e05b6770102..e5e6614b139 100644
@@ -108,7 +108,6 @@ static void mv64361_pcihost_class_init(ObjectClass *klass, const void *data)
 
    dc->realize = mv64361_pcihost_realize;
    device_class_set_props(dc, mv64361_pcihost_props);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo mv64361_pcihost_info = {
hw/pci-host/pnv_phb.c +0 -1
index 4b0ced79b08..e07cf8a0d0f 100644
@@ -202,7 +202,6 @@ static void pnv_phb_class_init(ObjectClass *klass, const void *data)
    hc->root_bus_path = pnv_phb_root_bus_path;
    dc->realize = pnv_phb_realize;
    device_class_set_props(dc, pnv_phb_properties);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    dc->user_creatable = true;
 }
 
hw/pci-host/ppce500.c +0 -1
index 975d191ccb8..edadc35384c 100644
@@ -516,7 +516,6 @@ static void e500_pcihost_class_init(ObjectClass *klass, const void *data)
    DeviceClass *dc = DEVICE_CLASS(klass);
 
    dc->realize = e500_pcihost_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    device_class_set_props(dc, pcihost_properties);
    dc->vmsd = &vmstate_ppce500_pci;
 }
hw/pci-host/q35.c +0 -1
index 1951ae440cc..c134679fa0c 100644
@@ -194,7 +194,6 @@ static void q35_host_class_init(ObjectClass *klass, const void *data)
    device_class_set_props(dc, q35_host_props);
    /* Reason: needs to be wired up by pc_q35_init */
    dc->user_creatable = false;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    dc->fw_name = "pci";
 }
 
hw/pci-host/raven.c +0 -1
index eacffc86d84..661a4223d69 100644
@@ -365,7 +365,6 @@ static void raven_pcihost_class_init(ObjectClass *klass, const void *data)
 {
    DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    dc->realize = raven_pcihost_realizefn;
    dc->fw_name = "pci";
 }
hw/pci-host/remote.c +0 -0
index e6d2af4502a..959beb5c301 100644

hw/pci-host/remote.c static void remote_pcihost_class_init(ObjectClass *klass, const void *data) · line 58

Quoted 4 lines
hw/pci-host/remote.c +0 -1
@@ -55,7 +55,6 @@ static void remote_pcihost_class_init(ObjectClass *klass, const void *data)
    dc->realize = remote_pcihost_realize;
 
    dc->user_creatable = false;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);

Thanks for the patch, Philippe! The change to remote.c looks good. --
Jag

Quoted 86 lines
hw/pci-host/remote.c +0 -0
    dc->fw_name = "pci";
 }
 
hw/pci-host/sabre.c +0 -1
index 538624c5079..f95e5db583a 100644
@@ -505,7 +505,6 @@ static void sabre_class_init(ObjectClass *klass, const void *data)
    dc->realize = sabre_realize;
    device_class_set_legacy_reset(dc, sabre_reset);
    device_class_set_props(dc, sabre_properties);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    dc->fw_name = "pci";
    sbc->explicit_ofw_unit_address = sabre_ofw_unit_address;
 }
hw/pci-host/uninorth.c +0 -4
index 194037d6e75..d337a2fd62c 100644
@@ -435,7 +435,6 @@ static void pci_unin_main_class_init(ObjectClass *klass, const void *data)
 
    dc->realize = pci_unin_main_realize;
    device_class_set_props(dc, pci_unin_main_pci_host_props);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    dc->fw_name = "pci";
    sbc->explicit_ofw_unit_address = pci_unin_main_ofw_unit_address;
 }
@@ -453,7 +452,6 @@ static void pci_u3_agp_class_init(ObjectClass *klass, const void *data)
    DeviceClass *dc = DEVICE_CLASS(klass);
 
    dc->realize = pci_u3_agp_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_u3_agp_info = {
@@ -469,7 +467,6 @@ static void pci_unin_agp_class_init(ObjectClass *klass, const void *data)
    DeviceClass *dc = DEVICE_CLASS(klass);
 
    dc->realize = pci_unin_agp_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_unin_agp_info = {
@@ -485,7 +482,6 @@ static void pci_unin_internal_class_init(ObjectClass *klass, const void *data)
    DeviceClass *dc = DEVICE_CLASS(klass);
 
    dc->realize = pci_unin_internal_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_unin_internal_info = {
hw/pci-host/xilinx-pcie.c +0 -2
index c71492de9e7..1540533223c 100644
@@ -172,7 +172,6 @@ static void xilinx_pcie_host_class_init(ObjectClass *klass, const void *data)
 
    hc->root_bus_path = xilinx_pcie_host_root_bus_path;
    dc->realize = xilinx_pcie_host_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    dc->fw_name = "pci";
    device_class_set_props(dc, xilinx_pcie_host_props);
 }
@@ -291,7 +290,6 @@ static void xilinx_pcie_root_class_init(ObjectClass *klass, const void *data)
    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
    DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
    dc->desc = "Xilinx AXI-PCIe Host Bridge";
    k->vendor_id = PCI_VENDOR_ID_XILINX;
    k->device_id = 0x7021;
hw/pci/pci_host.c +1 -0
index 7179d99178b..b5c624e12e8 100644
@@ -245,6 +245,7 @@ static void pci_host_class_init(ObjectClass *klass, const void *data)
    DeviceClass *dc = DEVICE_CLASS(klass);
    device_class_set_props(dc, pci_host_properties_common);
    dc->vmsd = &vmstate_pcihost;
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_host_type_info = {
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

No need to set DEVICE_CATEGORY_BRIDGE for each device implementing TYPE_PCI_HOST_BRIDGE: set it once in the parent.

this will also categorize a bunch of devices

Quoted 264 lines
---
 hw/pci-host/articia.c     | 1 -
 hw/pci-host/aspeed_pcie.c | 1 -
 hw/pci-host/designware.c  | 3 ---
 hw/pci-host/gpex.c        | 2 --
 hw/pci-host/grackle.c     | 1 -
 hw/pci-host/gt64120.c     | 1 -
 hw/pci-host/mv64361.c     | 1 -
 hw/pci-host/pnv_phb.c     | 1 -
 hw/pci-host/ppce500.c     | 1 -
 hw/pci-host/q35.c         | 1 -
 hw/pci-host/raven.c       | 1 -
 hw/pci-host/remote.c      | 1 -
 hw/pci-host/sabre.c       | 1 -
 hw/pci-host/uninorth.c    | 4 ----
 hw/pci-host/xilinx-pcie.c | 2 --
 hw/pci/pci_host.c         | 1 +
 16 files changed, 1 insertion(+), 22 deletions(-)
hw/pci-host/articia.c +0 -1
index cc65aac2a87..47f223879f0 100644
@@ -200,7 +200,6 @@ static void articia_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = articia_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 /* TYPE_ARTICIA_PCI_HOST */
hw/pci-host/aspeed_pcie.c +0 -1
index f7593444fc4..2499d3fe680 100644
@@ -312,7 +312,6 @@ static void aspeed_pcie_rc_class_init(ObjectClass *klass, const void *data)
     dc->desc = "ASPEED PCIe RC";
     dc->realize = aspeed_pcie_rc_realize;
     dc->fw_name = "pci";
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 
     hc->root_bus_path = aspeed_pcie_rc_root_bus_path;
     device_class_set_props(dc, aspeed_pcie_rc_props);
hw/pci-host/designware.c +0 -3
index f6e49ce9b8d..b0b51ad9517 100644
@@ -593,8 +593,6 @@ static void designware_pcie_root_class_init(ObjectClass *klass,
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
-
     k->vendor_id = PCI_VENDOR_ID_SYNOPSYS;
     k->device_id = 0xABCD;
     k->revision = 0;
@@ -736,7 +734,6 @@ static void designware_pcie_host_class_init(ObjectClass *klass,
 
     hc->root_bus_path = designware_pcie_host_root_bus_path;
     dc->realize = designware_pcie_host_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
     dc->vmsd = &vmstate_designware_pcie_host;
 }
hw/pci-host/gpex.c +0 -2
index b806a2286f7..5f809028be2 100644
@@ -200,7 +200,6 @@ static void gpex_host_class_init(ObjectClass *klass, const void *data)
     hc->root_bus_path = gpex_host_root_bus_path;
     dc->realize = gpex_host_realize;
     dc->unrealize = gpex_host_unrealize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
     device_class_set_props(dc, gpex_host_properties);
 }
@@ -242,7 +241,6 @@ static void gpex_root_class_init(ObjectClass *klass, const void *data)
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->desc = "QEMU generic PCIe host bridge";
     dc->vmsd = &vmstate_gpex_root;
     k->vendor_id = PCI_VENDOR_ID_REDHAT;
hw/pci-host/grackle.c +0 -1
index f9da5a908c1..fa872c17e3b 100644
@@ -140,7 +140,6 @@ static void grackle_class_init(ObjectClass *klass, const void *data)
 
     dc->realize = grackle_realize;
     device_class_set_props(dc, grackle_properties);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
     sbc->explicit_ofw_unit_address = grackle_ofw_unit_address;
 }
hw/pci-host/gt64120.c +0 -1
index b1d96f62fe9..bffa1165580 100644
@@ -1298,7 +1298,6 @@ static void gt64120_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     device_class_set_props(dc, gt64120_properties);
     dc->realize = gt64120_realize;
     device_class_set_legacy_reset(dc, gt64120_reset);
hw/pci-host/mv64361.c +0 -1
index e05b6770102..e5e6614b139 100644
@@ -108,7 +108,6 @@ static void mv64361_pcihost_class_init(ObjectClass *klass, const void *data)
 
     dc->realize = mv64361_pcihost_realize;
     device_class_set_props(dc, mv64361_pcihost_props);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo mv64361_pcihost_info = {
hw/pci-host/pnv_phb.c +0 -1
index 4b0ced79b08..e07cf8a0d0f 100644
@@ -202,7 +202,6 @@ static void pnv_phb_class_init(ObjectClass *klass, const void *data)
     hc->root_bus_path = pnv_phb_root_bus_path;
     dc->realize = pnv_phb_realize;
     device_class_set_props(dc, pnv_phb_properties);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->user_creatable = true;
 }
 
hw/pci-host/ppce500.c +0 -1
index 975d191ccb8..edadc35384c 100644
@@ -516,7 +516,6 @@ static void e500_pcihost_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = e500_pcihost_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     device_class_set_props(dc, pcihost_properties);
     dc->vmsd = &vmstate_ppce500_pci;
 }
hw/pci-host/q35.c +0 -1
index 1951ae440cc..c134679fa0c 100644
@@ -194,7 +194,6 @@ static void q35_host_class_init(ObjectClass *klass, const void *data)
     device_class_set_props(dc, q35_host_props);
     /* Reason: needs to be wired up by pc_q35_init */
     dc->user_creatable = false;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
 }
 
hw/pci-host/raven.c +0 -1
index eacffc86d84..661a4223d69 100644
@@ -365,7 +365,6 @@ static void raven_pcihost_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->realize = raven_pcihost_realizefn;
     dc->fw_name = "pci";
 }
hw/pci-host/remote.c +0 -1
index e6d2af4502a..959beb5c301 100644
@@ -55,7 +55,6 @@ static void remote_pcihost_class_init(ObjectClass *klass, const void *data)
     dc->realize = remote_pcihost_realize;
 
     dc->user_creatable = false;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
 }
 
hw/pci-host/sabre.c +0 -1
index 538624c5079..f95e5db583a 100644
@@ -505,7 +505,6 @@ static void sabre_class_init(ObjectClass *klass, const void *data)
     dc->realize = sabre_realize;
     device_class_set_legacy_reset(dc, sabre_reset);
     device_class_set_props(dc, sabre_properties);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
     sbc->explicit_ofw_unit_address = sabre_ofw_unit_address;
 }
hw/pci-host/uninorth.c +0 -4
index 194037d6e75..d337a2fd62c 100644
@@ -435,7 +435,6 @@ static void pci_unin_main_class_init(ObjectClass *klass, const void *data)
 
     dc->realize = pci_unin_main_realize;
     device_class_set_props(dc, pci_unin_main_pci_host_props);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
     sbc->explicit_ofw_unit_address = pci_unin_main_ofw_unit_address;
 }
@@ -453,7 +452,6 @@ static void pci_u3_agp_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = pci_u3_agp_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_u3_agp_info = {
@@ -469,7 +467,6 @@ static void pci_unin_agp_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = pci_unin_agp_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_unin_agp_info = {
@@ -485,7 +482,6 @@ static void pci_unin_internal_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = pci_unin_internal_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_unin_internal_info = {
hw/pci-host/xilinx-pcie.c +0 -2
index c71492de9e7..1540533223c 100644
@@ -172,7 +172,6 @@ static void xilinx_pcie_host_class_init(ObjectClass *klass, const void *data)
 
     hc->root_bus_path = xilinx_pcie_host_root_bus_path;
     dc->realize = xilinx_pcie_host_realize;
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
     device_class_set_props(dc, xilinx_pcie_host_props);
 }
@@ -291,7 +290,6 @@ static void xilinx_pcie_root_class_init(ObjectClass *klass, const void *data)
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->desc = "Xilinx AXI-PCIe Host Bridge";
     k->vendor_id = PCI_VENDOR_ID_XILINX;
     k->device_id = 0x7021;
hw/pci/pci_host.c +1 -1
index 7179d99178b..b5c624e12e8 100644
@@ -245,6 +245,7 @@ static void pci_host_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     device_class_set_props(dc, pci_host_properties_common);
     dc->vmsd = &vmstate_pcihost;
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_host_type_info = {
--

2.51.0

Signature · 1 line
Marc-André Lureau
#3 lore raw
Quoted 10 lines · Marc-André Lureau
Quoted 6 lines · Philippe Mathieu-Daudé

No need to set DEVICE_CATEGORY_BRIDGE for each device implementing TYPE_PCI_HOST_BRIDGE: set it once in the parent.

this will also categorize a bunch of devices

Indeed:

$ git grep -l parent.*TYPE_PCI_HOST_BRIDGE
hw/alpha/typhoon.c
hw/pci-bridge/pci_expander_bridge.c
hw/pci-host/articia.c
hw/pci-host/astro.c
hw/pci-host/bonito.c
hw/pci-host/designware.c
hw/pci-host/dino.c
hw/pci-host/grackle.c
hw/pci-host/gt64120.c
hw/pci-host/i440fx.c
hw/pci-host/mv64361.c
hw/pci-host/ppc440_pcix.c
hw/pci-host/ppc4xx_pci.c
hw/pci-host/ppce500.c
hw/pci-host/raven.c
hw/pci-host/sabre.c
hw/pci-host/sh_pci.c
hw/pci-host/uninorth.c
hw/pci-host/versatile.c
hw/pci/pcie_host.c
hw/ppc/spapr_pci.c
hw/s390x/s390-pci-bus.c

So the following ones are categorized:

hw/alpha/typhoon.c
hw/pci-bridge/pci_expander_bridge.c
hw/pci-host/astro.c
hw/pci-host/bonito.c
hw/pci-host/dino.c
hw/pci-host/i440fx.c
hw/pci-host/ppc440_pcix.c
hw/pci-host/ppc4xx_pci.c
hw/pci-host/sh_pci.c
hw/pci-host/versatile.c
hw/pci/pcie_host.c
hw/ppc/spapr_pci.c
hw/s390x/s390-pci-bus.c

I'll update the description.

Quoted 1 line

Thanks!

Quoted 19 lines
Quoted 19 lines
---
  hw/pci-host/articia.c     | 1 -
  hw/pci-host/aspeed_pcie.c | 1 -
  hw/pci-host/designware.c  | 3 ---
  hw/pci-host/gpex.c        | 2 --
  hw/pci-host/grackle.c     | 1 -
  hw/pci-host/gt64120.c     | 1 -
  hw/pci-host/mv64361.c     | 1 -
  hw/pci-host/pnv_phb.c     | 1 -
  hw/pci-host/ppce500.c     | 1 -
  hw/pci-host/q35.c         | 1 -
  hw/pci-host/raven.c       | 1 -
  hw/pci-host/remote.c      | 1 -
  hw/pci-host/sabre.c       | 1 -
  hw/pci-host/uninorth.c    | 4 ----
  hw/pci-host/xilinx-pcie.c | 2 --
  hw/pci/pci_host.c         | 1 +
  16 files changed, 1 insertion(+), 22 deletions(-)