[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 22/22] spapr_pci: drop redundant args in spapr_[popu
From: |
David Gibson |
Subject: |
[Qemu-devel] [PATCH 22/22] spapr_pci: drop redundant args in spapr_[populate, create]_pci_child_dt |
Date: |
Wed, 24 Jun 2015 16:30:36 +1000 |
From: Nikunj A Dadhania <address@hidden>
* phb_index is not being used and if required can be obtained from sphb
* use helper to get drc_index in spapr_populate_pci_child_dt()
* Check if drc_index is zero
Suggested-by: Alexey Kardashevskiy <address@hidden>
Signed-off-by: Nikunj A Dadhania <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr_pci.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 7585983..a139aea 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -937,14 +937,17 @@ static void populate_resource_props(PCIDevice *d,
ResourceProps *rp)
rp->assigned_len = assigned_idx * sizeof(ResourceFields);
}
+static uint32_t spapr_phb_get_pci_drc_index(sPAPRPHBState *phb,
+ PCIDevice *pdev);
+
static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,
- int phb_index, int drc_index,
sPAPRPHBState *sphb)
{
ResourceProps rp;
bool is_bridge = false;
int pci_status, err;
char *buf = NULL;
+ uint32_t drc_index = spapr_phb_get_pci_drc_index(sphb, dev);
if (pci_default_read_config(dev, PCI_HEADER_TYPE, 1) ==
PCI_HEADER_TYPE_BRIDGE) {
@@ -1017,7 +1020,9 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev,
void *fdt, int offset,
return err;
}
- _FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index));
+ if (drc_index) {
+ _FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index));
+ }
_FDT(fdt_setprop_cell(fdt, offset, "#address-cells",
RESOURCE_CELLS_ADDRESS));
@@ -1034,12 +1039,8 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev,
void *fdt, int offset,
return 0;
}
-static uint32_t spapr_phb_get_pci_drc_index(sPAPRPHBState *phb,
- PCIDevice *pdev);
-
/* create OF node for pci device and required OF DT properties */
static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,
- int drc_index, const char *drc_name,
void *fdt, int node_offset)
{
int offset, ret;
@@ -1053,8 +1054,8 @@ static int spapr_create_pci_child_dt(sPAPRPHBState *phb,
PCIDevice *dev,
snprintf(nodename, FDT_NAME_MAX, "address@hidden", slot);
}
offset = fdt_add_subnode(fdt, node_offset, nodename);
- ret = spapr_populate_pci_child_dt(dev, fdt, offset, phb->index, drc_index,
- phb);
+ ret = spapr_populate_pci_child_dt(dev, fdt, offset, phb);
+
g_assert(!ret);
if (ret) {
return 0;
@@ -1069,15 +1070,12 @@ static void spapr_phb_add_pci_device(sPAPRDRConnector
*drc,
{
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
DeviceState *dev = DEVICE(pdev);
- int drc_index = drck->get_index(drc);
void *fdt = NULL;
int fdt_start_offset = 0, fdt_size;
if (dev->hotplugged) {
fdt = create_device_tree(&fdt_size);
- fdt_start_offset = spapr_create_pci_child_dt(phb, pdev,
- drc_index, NULL,
- fdt, 0);
+ fdt_start_offset = spapr_create_pci_child_dt(phb, pdev, fdt, 0);
if (!fdt_start_offset) {
error_setg(errp, "Failed to create pci child device tree node");
goto out;
@@ -1579,11 +1577,8 @@ static void spapr_populate_pci_devices_dt(PCIBus *bus,
PCIDevice *pdev,
sPAPRFDT *p = opaque;
int offset;
sPAPRFDT s_fdt;
- uint32_t drc_index = spapr_phb_get_pci_drc_index(p->sphb, pdev);
- offset = spapr_create_pci_child_dt(p->sphb, pdev,
- drc_index, NULL,
- p->fdt, p->node_off);
+ offset = spapr_create_pci_child_dt(p->sphb, pdev, p->fdt, p->node_off);
if (!offset) {
error_report("Failed to create pci child device tree node");
return;
--
2.4.3
- [Qemu-devel] [PATCH 13/22] spapr: Consider max_cpus during xics initialization, (continued)
- [Qemu-devel] [PATCH 13/22] spapr: Consider max_cpus during xics initialization, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 05/22] spapr: Remove obsolete entry_point field from sPAPRMachineState, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 04/22] spapr: Remove obsolete ram_limit field from sPAPRMachineState, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 08/22] spapr_pci: encode class code including Prog IF register, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 03/22] spapr: Merge sPAPREnvironment into sPAPRMachineState, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 02/22] pseries: Update SLOF firmware image to qemu-slof-20150429, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 01/22] spapr: ensure we have at least one XICS server, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 15/22] cpus: Add a macro to walk CPUs in reverse, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 17/22] spapr: Consolidate cpu init code into a routine, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 18/22] ppc: Update cpu_model in MachineState, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 22/22] spapr_pci: drop redundant args in spapr_[populate, create]_pci_child_dt,
David Gibson <=
- [Qemu-devel] [PATCH 19/22] xics_kvm: Don't enable KVM_CAP_IRQ_XICS if already enabled, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 21/22] spapr_pci: populate ibm,loc-code, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 20/22] spapr_pci: enumerate and add PCI device tree, David Gibson, 2015/06/24
- [Qemu-devel] [PATCH 16/22] spapr: Reorganize CPU dt generation code, David Gibson, 2015/06/24
- Re: [Qemu-devel] [PATCH 00/22] sPAPR updates 2015-06-24, David Gibson, 2015/06/24