[PATCH v2] hw/pci-bridge: Convert pci-bridge to Resettable interface

Oscar Alejandro Sánchez Lucero posted 1 patch 1 week, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261112-pci-bridge-resettable-v2-1-a555b78a2262@gmail.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>
hw/pci-bridge/pci_bridge_dev.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
[PATCH v2] hw/pci-bridge: Convert pci-bridge to Resettable interface
Posted by Oscar Alejandro Sánchez Lucero 1 week, 3 days ago
Replace the deprecated device_class_set_legacy_reset() with the
ResettableClass hold phase.

Signed-off-by: Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>
---
To: qemu-devel@nongnu.org
To: Michael S. Tsirkin <mst@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
---
Changes in v2:
- Set rc->phases.hold directly without parent_phases chaining.
- Link to v1: https://lore.kernel.org/qemu-devel/20261112-pci-bridge-resettable-v1-1-ed36c7b26fbe@gmail.com
---
 hw/pci-bridge/pci_bridge_dev.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c
index bc53bcb..783a545 100644
--- a/hw/pci-bridge/pci_bridge_dev.c
+++ b/hw/pci-bridge/pci_bridge_dev.c
@@ -31,6 +31,7 @@
 #include "system/memory.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/core/hotplug.h"
+#include "hw/core/resettable.h"
 #include "qom/object.h"
 
 #define TYPE_PCI_BRIDGE_DEV      "pci-bridge"
@@ -158,11 +159,11 @@ static void pci_bridge_dev_write_config(PCIDevice *d,
     }
 }
 
-static void qdev_pci_bridge_dev_reset(DeviceState *qdev)
+static void pci_bridge_dev_reset_hold(Object *obj, ResetType type)
 {
-    PCIDevice *dev = PCI_DEVICE(qdev);
+    PCIDevice *dev = PCI_DEVICE(obj);
 
-    pci_bridge_reset(qdev);
+    pci_bridge_reset(DEVICE(obj));
     if (shpc_present(dev)) {
         shpc_reset(dev);
     }
@@ -245,6 +246,7 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     k->realize = pci_bridge_dev_realize;
     k->exit = pci_bridge_dev_exitfn;
@@ -253,7 +255,7 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, const void *data)
     k->device_id = PCI_DEVICE_ID_REDHAT_BRIDGE;
     k->class_id = PCI_CLASS_BRIDGE_PCI;
     dc->desc = "Standard PCI Bridge";
-    device_class_set_legacy_reset(dc, qdev_pci_bridge_dev_reset);
+    rc->phases.hold = pci_bridge_dev_reset_hold;
     device_class_set_props(dc, pci_bridge_dev_properties);
     dc->vmsd = &pci_bridge_dev_vmstate;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);

---
base-commit: 29760efaf96bbe5928f8111881eddbf5ac06439e
change-id: 20261112-pci-bridge-resettable-008877a75471

Best regards,
-- 
Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>