[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v3 38/44] pci: Reuse pci-bridge hotplug handler handl
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v3 38/44] pci: Reuse pci-bridge hotplug handler handlers for pcie-pci-bridge |
Date: |
Thu, 20 Dec 2018 13:40:05 -0500 |
From: David Hildenbrand <address@hidden>
These functions are essentially the same, we only have to use
object_get_typename() for reporting errors. So let's share the
implementation of hotplug handler callbacks.
Suggested-by: Igor Mammedov <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>
Signed-off-by: David Hildenbrand <address@hidden>
Reviewed-by: David Gibson <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
include/hw/pci/pci_bridge.h | 4 ++++
hw/pci-bridge/pci_bridge_dev.c | 12 ++++++------
hw/pci-bridge/pcie_pci_bridge.c | 30 ++----------------------------
3 files changed, 12 insertions(+), 34 deletions(-)
diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h
index cdff7edfd1..6e37c7551a 100644
--- a/include/hw/pci/pci_bridge.h
+++ b/include/hw/pci/pci_bridge.h
@@ -99,6 +99,10 @@ void pci_bridge_reset(DeviceState *qdev);
void pci_bridge_initfn(PCIDevice *pci_dev, const char *typename);
void pci_bridge_exitfn(PCIDevice *pci_dev);
+void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
+ Error **errp);
+void pci_bridge_dev_unplug_request_cb(HotplugHandler *hotplug_dev,
+ DeviceState *dev, Error **errp);
/*
* before qdev initialization(qdev_init()), this function sets bus_name and
diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c
index e1df9a52ac..fa0be13ac4 100644
--- a/hw/pci-bridge/pci_bridge_dev.c
+++ b/hw/pci-bridge/pci_bridge_dev.c
@@ -206,27 +206,27 @@ static const VMStateDescription pci_bridge_dev_vmstate = {
}
};
-static void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev,
- DeviceState *dev, Error **errp)
+void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
+ Error **errp)
{
PCIDevice *pci_hotplug_dev = PCI_DEVICE(hotplug_dev);
if (!shpc_present(pci_hotplug_dev)) {
error_setg(errp, "standard hotplug controller has been disabled for "
- "this %s", TYPE_PCI_BRIDGE_DEV);
+ "this %s", object_get_typename(OBJECT(hotplug_dev)));
return;
}
shpc_device_plug_cb(hotplug_dev, dev, errp);
}
-static void pci_bridge_dev_unplug_request_cb(HotplugHandler *hotplug_dev,
- DeviceState *dev, Error **errp)
+void pci_bridge_dev_unplug_request_cb(HotplugHandler *hotplug_dev,
+ DeviceState *dev, Error **errp)
{
PCIDevice *pci_hotplug_dev = PCI_DEVICE(hotplug_dev);
if (!shpc_present(pci_hotplug_dev)) {
error_setg(errp, "standard hotplug controller has been disabled for "
- "this %s", TYPE_PCI_BRIDGE_DEV);
+ "this %s", object_get_typename(OBJECT(hotplug_dev)));
return;
}
shpc_device_unplug_request_cb(hotplug_dev, dev, errp);
diff --git a/hw/pci-bridge/pcie_pci_bridge.c b/hw/pci-bridge/pcie_pci_bridge.c
index c634353b06..0ffea680d5 100644
--- a/hw/pci-bridge/pcie_pci_bridge.c
+++ b/hw/pci-bridge/pcie_pci_bridge.c
@@ -137,32 +137,6 @@ static const VMStateDescription
pcie_pci_bridge_dev_vmstate = {
}
};
-static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev,
- DeviceState *dev, Error **errp)
-{
- PCIDevice *pci_hotplug_dev = PCI_DEVICE(hotplug_dev);
-
- if (!shpc_present(pci_hotplug_dev)) {
- error_setg(errp, "standard hotplug controller has been disabled for "
- "this %s", TYPE_PCIE_PCI_BRIDGE_DEV);
- return;
- }
- shpc_device_plug_cb(hotplug_dev, dev, errp);
-}
-
-static void pcie_pci_bridge_unplug_request_cb(HotplugHandler *hotplug_dev,
- DeviceState *dev, Error **errp)
-{
- PCIDevice *pci_hotplug_dev = PCI_DEVICE(hotplug_dev);
-
- if (!shpc_present(pci_hotplug_dev)) {
- error_setg(errp, "standard hotplug controller has been disabled for "
- "this %s", TYPE_PCIE_PCI_BRIDGE_DEV);
- return;
- }
- shpc_device_unplug_request_cb(hotplug_dev, dev, errp);
-}
-
static void pcie_pci_bridge_class_init(ObjectClass *klass, void *data)
{
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
@@ -179,8 +153,8 @@ static void pcie_pci_bridge_class_init(ObjectClass *klass,
void *data)
dc->props = pcie_pci_bridge_dev_properties;
dc->reset = &pcie_pci_bridge_reset;
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
- hc->plug = pcie_pci_bridge_plug_cb;
- hc->unplug_request = pcie_pci_bridge_unplug_request_cb;
+ hc->plug = pci_bridge_dev_plug_cb;
+ hc->unplug_request = pci_bridge_dev_unplug_request_cb;
}
static const TypeInfo pcie_pci_bridge_info = {
--
MST
- [Qemu-devel] [PULL v3 25/44] hw: arm: Carry RSDP specific data through AcpiRsdpData, (continued)
- [Qemu-devel] [PULL v3 25/44] hw: arm: Carry RSDP specific data through AcpiRsdpData, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 33/44] s390x/pci: rename hotplug handler callbacks, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 26/44] hw: arm: Convert the RSDP build to the buid_append_foo() API, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 37/44] pci/pcie: perform unplug via the hotplug handler, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 36/44] pci/pcihp: perform unplug via the hotplug handler, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 30/44] hw/i386: Remove deprecated machines pc-0.10 and pc-0.11, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 35/44] pci/pcihp: overwrite hotplug handler recursively from the start, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 34/44] pci/pcihp: perform check for bus capability in pre_plug handler, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 39/44] pci/shpc: perform unplug via the hotplug handler, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 40/44] spapr_pci: perform unplug via the hotplug handler, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 38/44] pci: Reuse pci-bridge hotplug handler handlers for pcie-pci-bridge,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v3 41/44] pci: Adjust PCI config limit based on bus topology, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 44/44] x86-iommu: turn on IR by default if proper, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 43/44] x86-iommu: switch intr_supported to OnOffAuto type, Michael S. Tsirkin, 2018/12/20
- [Qemu-devel] [PULL v3 42/44] q35: set split kernel irqchip as default, Michael S. Tsirkin, 2018/12/20
- Re: [Qemu-devel] [PULL v3 00/44] pci, pc, virtio: fixes, features, Peter Maydell, 2018/12/21
- Re: [Qemu-devel] [PULL v3 00/44] pci, pc, virtio: fixes, features, no-reply, 2018/12/26