spapr_pci: drop redundant args in spapr_[populate, create]_pci_child_dt
* 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 <aik@ozlabs.ru> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
16b0ea1d85
commit
e634b89c6e
|
@ -937,14 +937,17 @@ static void populate_resource_props(PCIDevice *d, ResourceProps *rp)
|
||||||
rp->assigned_len = assigned_idx * sizeof(ResourceFields);
|
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,
|
static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,
|
||||||
int phb_index, int drc_index,
|
|
||||||
sPAPRPHBState *sphb)
|
sPAPRPHBState *sphb)
|
||||||
{
|
{
|
||||||
ResourceProps rp;
|
ResourceProps rp;
|
||||||
bool is_bridge = false;
|
bool is_bridge = false;
|
||||||
int pci_status, err;
|
int pci_status, err;
|
||||||
char *buf = NULL;
|
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) ==
|
if (pci_default_read_config(dev, PCI_HEADER_TYPE, 1) ==
|
||||||
PCI_HEADER_TYPE_BRIDGE) {
|
PCI_HEADER_TYPE_BRIDGE) {
|
||||||
|
@ -1017,7 +1020,9 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,
|
||||||
return err;
|
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",
|
_FDT(fdt_setprop_cell(fdt, offset, "#address-cells",
|
||||||
RESOURCE_CELLS_ADDRESS));
|
RESOURCE_CELLS_ADDRESS));
|
||||||
|
@ -1034,12 +1039,8 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,
|
||||||
return 0;
|
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 */
|
/* create OF node for pci device and required OF DT properties */
|
||||||
static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,
|
static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,
|
||||||
int drc_index, const char *drc_name,
|
|
||||||
void *fdt, int node_offset)
|
void *fdt, int node_offset)
|
||||||
{
|
{
|
||||||
int offset, ret;
|
int offset, ret;
|
||||||
|
@ -1053,8 +1054,8 @@ static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,
|
||||||
snprintf(nodename, FDT_NAME_MAX, "pci@%x", slot);
|
snprintf(nodename, FDT_NAME_MAX, "pci@%x", slot);
|
||||||
}
|
}
|
||||||
offset = fdt_add_subnode(fdt, node_offset, nodename);
|
offset = fdt_add_subnode(fdt, node_offset, nodename);
|
||||||
ret = spapr_populate_pci_child_dt(dev, fdt, offset, phb->index, drc_index,
|
ret = spapr_populate_pci_child_dt(dev, fdt, offset, phb);
|
||||||
phb);
|
|
||||||
g_assert(!ret);
|
g_assert(!ret);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1069,15 +1070,12 @@ static void spapr_phb_add_pci_device(sPAPRDRConnector *drc,
|
||||||
{
|
{
|
||||||
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
|
||||||
DeviceState *dev = DEVICE(pdev);
|
DeviceState *dev = DEVICE(pdev);
|
||||||
int drc_index = drck->get_index(drc);
|
|
||||||
void *fdt = NULL;
|
void *fdt = NULL;
|
||||||
int fdt_start_offset = 0, fdt_size;
|
int fdt_start_offset = 0, fdt_size;
|
||||||
|
|
||||||
if (dev->hotplugged) {
|
if (dev->hotplugged) {
|
||||||
fdt = create_device_tree(&fdt_size);
|
fdt = create_device_tree(&fdt_size);
|
||||||
fdt_start_offset = spapr_create_pci_child_dt(phb, pdev,
|
fdt_start_offset = spapr_create_pci_child_dt(phb, pdev, fdt, 0);
|
||||||
drc_index, NULL,
|
|
||||||
fdt, 0);
|
|
||||||
if (!fdt_start_offset) {
|
if (!fdt_start_offset) {
|
||||||
error_setg(errp, "Failed to create pci child device tree node");
|
error_setg(errp, "Failed to create pci child device tree node");
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -1579,11 +1577,8 @@ static void spapr_populate_pci_devices_dt(PCIBus *bus, PCIDevice *pdev,
|
||||||
sPAPRFDT *p = opaque;
|
sPAPRFDT *p = opaque;
|
||||||
int offset;
|
int offset;
|
||||||
sPAPRFDT s_fdt;
|
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,
|
offset = spapr_create_pci_child_dt(p->sphb, pdev, p->fdt, p->node_off);
|
||||||
drc_index, NULL,
|
|
||||||
p->fdt, p->node_off);
|
|
||||||
if (!offset) {
|
if (!offset) {
|
||||||
error_report("Failed to create pci child device tree node");
|
error_report("Failed to create pci child device tree node");
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue