diff options
author | Markus Armbruster <armbru@redhat.com> | 2020-05-05 17:29:25 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2020-05-15 07:08:14 +0200 |
commit | 7ef1553dac8ef8dbe547b58d7420461a16be0eeb (patch) | |
tree | de122c337a188aac8eb152c1095a47fcd97c6ced /hw/ppc | |
parent | b69c3c21a5d11075d42100d5cfe0a736593fae6b (diff) |
spapr_pci: Drop some dead error handling
chassis_from_bus() uses object_property_get_uint() to get property
"chassis_nr" of the bridge device. Failure would be a programming
error. Pass &error_abort, and simplify its callers.
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: qemu-ppc@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-18-armbru@redhat.com>
Diffstat (limited to 'hw/ppc')
-rw-r--r-- | hw/ppc/spapr_pci.c | 86 |
1 files changed, 18 insertions, 68 deletions
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 616034222d..83f1453096 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1203,46 +1203,36 @@ static SpaprDrc *drc_from_devfn(SpaprPhbState *phb, drc_id_from_devfn(phb, chassis, devfn)); } -static uint8_t chassis_from_bus(PCIBus *bus, Error **errp) +static uint8_t chassis_from_bus(PCIBus *bus) { if (pci_bus_is_root(bus)) { return 0; } else { PCIDevice *bridge = pci_bridge_get_device(bus); - return object_property_get_uint(OBJECT(bridge), "chassis_nr", errp); + return object_property_get_uint(OBJECT(bridge), "chassis_nr", + &error_abort); } } static SpaprDrc *drc_from_dev(SpaprPhbState *phb, PCIDevice *dev) { - Error *local_err = NULL; - uint8_t chassis = chassis_from_bus(pci_get_bus(dev), &local_err); - - if (local_err) { - error_report_err(local_err); - return NULL; - } + uint8_t chassis = chassis_from_bus(pci_get_bus(dev)); return drc_from_devfn(phb, chassis, dev->devfn); } -static void add_drcs(SpaprPhbState *phb, PCIBus *bus, Error **errp) +static void add_drcs(SpaprPhbState *phb, PCIBus *bus) { Object *owner; int i; uint8_t chassis; - Error *local_err = NULL; if (!phb->dr_enabled) { return; } - chassis = chassis_from_bus(bus, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } + chassis = chassis_from_bus(bus); if (pci_bus_is_root(bus)) { owner = OBJECT(phb); @@ -1256,21 +1246,16 @@ static void add_drcs(SpaprPhbState *phb, PCIBus *bus, Error **errp) } } -static void remove_drcs(SpaprPhbState *phb, PCIBus *bus, Error **errp) +static void remove_drcs(SpaprPhbState *phb, PCIBus *bus) { int i; uint8_t chassis; - Error *local_err = NULL; if (!phb->dr_enabled) { return; } - chassis = chassis_from_bus(bus, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } + chassis = chassis_from_bus(bus); for (i = PCI_SLOT_MAX * PCI_FUNC_MAX - 1; i >= 0; i--) { SpaprDrc *drc = drc_from_devfn(phb, chassis, i); @@ -1488,17 +1473,11 @@ int spapr_pci_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr, } static void spapr_pci_bridge_plug(SpaprPhbState *phb, - PCIBridge *bridge, - Error **errp) + PCIBridge *bridge) { - Error *local_err = NULL; PCIBus *bus = pci_bridge_get_sec_bus(bridge); - add_drcs(phb, bus, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } + add_drcs(phb, bus); } static void spapr_pci_plug(HotplugHandler *plug_handler, @@ -1529,11 +1508,7 @@ static void spapr_pci_plug(HotplugHandler *plug_handler, g_assert(drc); if (pc->is_bridge) { - spapr_pci_bridge_plug(phb, PCI_BRIDGE(plugged_dev), &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } + spapr_pci_bridge_plug(phb, PCI_BRIDGE(plugged_dev)); } /* Following the QEMU convention used for PCIe multifunction @@ -1560,12 +1535,7 @@ static void spapr_pci_plug(HotplugHandler *plug_handler, spapr_drc_reset(drc); } else if (PCI_FUNC(pdev->devfn) == 0) { int i; - uint8_t chassis = chassis_from_bus(pci_get_bus(pdev), &local_err); - - if (local_err) { - error_propagate(errp, local_err); - return; - } + uint8_t chassis = chassis_from_bus(pci_get_bus(pdev)); for (i = 0; i < 8; i++) { SpaprDrc *func_drc; @@ -1587,17 +1557,11 @@ out: } static void spapr_pci_bridge_unplug(SpaprPhbState *phb, - PCIBridge *bridge, - Error **errp) + PCIBridge *bridge) { - Error *local_err = NULL; PCIBus *bus = pci_bridge_get_sec_bus(bridge); - remove_drcs(phb, bus, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } + remove_drcs(phb, bus); } static void spapr_pci_unplug(HotplugHandler *plug_handler, @@ -1619,11 +1583,7 @@ static void spapr_pci_unplug(HotplugHandler *plug_handler, pci_device_reset(PCI_DEVICE(plugged_dev)); if (pc->is_bridge) { - Error *local_err = NULL; - spapr_pci_bridge_unplug(phb, PCI_BRIDGE(plugged_dev), &local_err); - if (local_err) { - error_propagate(errp, local_err); - } + spapr_pci_bridge_unplug(phb, PCI_BRIDGE(plugged_dev)); return; } @@ -1654,13 +1614,7 @@ static void spapr_pci_unplug_request(HotplugHandler *plug_handler, SpaprDrcClass *func_drck; SpaprDREntitySense state; int i; - Error *local_err = NULL; - uint8_t chassis = chassis_from_bus(pci_get_bus(pdev), &local_err); - - if (local_err) { - error_propagate(errp, local_err); - return; - } + uint8_t chassis = chassis_from_bus(pci_get_bus(pdev)); if (pc->is_bridge) { error_setg(errp, "PCI: Hot unplug of PCI bridges not supported"); @@ -1745,7 +1699,7 @@ static void spapr_phb_unrealize(DeviceState *dev) } } - remove_drcs(sphb, phb->bus, &error_abort); + remove_drcs(sphb, phb->bus); for (i = PCI_NUM_PINS - 1; i >= 0; i--) { if (sphb->lsi_table[i].irq) { @@ -1984,11 +1938,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp) } /* allocate connectors for child PCI devices */ - add_drcs(sphb, phb->bus, &local_err); - if (local_err) { - error_propagate(errp, local_err); - goto unrealize; - } + add_drcs(sphb, phb->bus); /* DMA setup */ for (i = 0; i < windows_supported; ++i) { |