Patchwork spapr pci: getting rid of "busname" property

login
register
mail settings
Submitter Alexey Kardashevskiy
Date Feb. 20, 2013, 7:18 a.m.
Message ID <1361344715-25874-1-git-send-email-aik@ozlabs.ru>
Download mbox | patch
Permalink /patch/221973/
State New
Headers show

Comments

Alexey Kardashevskiy - Feb. 20, 2013, 7:18 a.m.
As sPAPRPHBState struct incapsulates DeviceState struct,
the "id" property can be set from the command line.
So there is no need in the "busname" property which is only used
to pass a PCI bus name from the spapr-pci-host-bridge device to
pci_register_bus().

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 hw/spapr_pci.c |   13 +++++++------
 hw/spapr_pci.h |    1 -
 2 files changed, 7 insertions(+), 7 deletions(-)

Patch

diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c
index a6885c4..45373ec 100644
--- a/hw/spapr_pci.c
+++ b/hw/spapr_pci.c
@@ -519,6 +519,7 @@  static int spapr_phb_init(SysBusDevice *s)
     sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(s);
     PCIHostState *phb = PCI_HOST_BRIDGE(s);
     char *namebuf;
+    const char *busname;
     int i;
     PCIBus *bus;
 
@@ -575,9 +576,6 @@  static int spapr_phb_init(SysBusDevice *s)
     }               
 
     sphb->dtbusname = g_strdup_printf("pci@%" PRIx64, sphb->buid);
-    if (!sphb->busname) {
-        sphb->busname = sphb->dtbusname;
-    }
 
     namebuf = alloca(strlen(sphb->dtbusname) + 32);
 
@@ -621,7 +619,11 @@  static int spapr_phb_init(SysBusDevice *s)
                                     &sphb->msiwindow);
     }
 
-    bus = pci_register_bus(DEVICE(s), sphb->busname,
+    busname = s->qdev.id;
+    if (!busname || !busname[0]) {
+        busname = sphb->dtbusname;
+    }
+    bus = pci_register_bus(DEVICE(s), busname,
                            pci_spapr_set_irq, pci_spapr_map_irq, sphb,
                            &sphb->memspace, &sphb->iospace,
                            PCI_DEVFN(0, 0), PCI_NUM_PINS);
@@ -663,7 +665,6 @@  static void spapr_phb_reset(DeviceState *qdev)
 }
 
 static Property spapr_phb_properties[] = {
-    DEFINE_PROP_STRING("busname", sPAPRPHBState, busname),
     DEFINE_PROP_INT32("index", sPAPRPHBState, index, -1),
     DEFINE_PROP_HEX64("buid", sPAPRPHBState, buid, -1),
     DEFINE_PROP_HEX32("liobn", sPAPRPHBState, dma_liobn, -1),
@@ -750,7 +751,7 @@  PCIHostState *spapr_create_phb(sPAPREnvironment *spapr, int index,
 
     dev = qdev_create(NULL, TYPE_SPAPR_PCI_HOST_BRIDGE);
     qdev_prop_set_uint32(dev, "index", index);
-    qdev_prop_set_string(dev, "busname", busname);
+    dev->id = g_strdup(busname);
     qdev_init_nofail(dev);
 
     return PCI_HOST_BRIDGE(dev);
diff --git a/hw/spapr_pci.h b/hw/spapr_pci.h
index b05241d..35960d7 100644
--- a/hw/spapr_pci.h
+++ b/hw/spapr_pci.h
@@ -39,7 +39,6 @@  typedef struct sPAPRPHBState {
 
     int32_t index;
     uint64_t buid;
-    char *busname;
     char *dtbusname;
 
     MemoryRegion memspace, iospace;