Patchwork [08/14] sysbus: make create_varargs take an id

login
register
mail settings
Submitter Anthony Liguori
Date Sept. 16, 2011, 4 p.m.
Message ID <1316188834-13675-9-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/114972/
State New
Headers show

Comments

Anthony Liguori - Sept. 16, 2011, 4 p.m.
This is mostly mechanical but also changes sysbus_create_simple() in order to
call into the new create_varargs.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 hw/axis_dev88.c        |    4 +-
 hw/integratorcp.c      |    5 ++-
 hw/musicpal.c          |    3 +-
 hw/pc.c                |    2 +-
 hw/ppce500_mpc8544ds.c |    2 +-
 hw/pxa2xx.c            |    4 +-
 hw/r2d.c               |    4 +-
 hw/realview.c          |    4 +-
 hw/stellaris.c         |    2 +-
 hw/strongarm.c         |   10 ++++---
 hw/sysbus.c            |   67 +++++++++++++++++++++++++++++++++++++++++++----
 hw/sysbus.h            |   33 ++++++++++++-----------
 hw/versatilepb.c       |    8 +++---
 hw/vexpress.c          |    2 +-
 14 files changed, 105 insertions(+), 45 deletions(-)

Patch

diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c
index 6987387..e0982d9 100644
--- a/hw/axis_dev88.c
+++ b/hw/axis_dev88.c
@@ -330,8 +330,8 @@  void axisdev88_init (ram_addr_t ram_size,
     }
 
     /* 2 timers.  */
-    sysbus_create_varargs("etraxfs,timer", 0x3001e000, irq[0x1b], nmi[1], NULL);
-    sysbus_create_varargs("etraxfs,timer", 0x3005e000, irq[0x1b], nmi[1], NULL);
+    sysbus_create_varargs("etraxfs,timer", 0x3001e000, NULL, irq[0x1b], nmi[1], NULL);
+    sysbus_create_varargs("etraxfs,timer", 0x3005e000, NULL, irq[0x1b], nmi[1], NULL);
 
     for (i = 0; i < 4; i++) {
         sysbus_create_simple("etraxfs,serial", 0x30026000 + i * 0x2000,
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index a163cf1..37ad898 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -502,13 +502,14 @@  static void integratorcp_init(ram_addr_t ram_size,
 
     cpu_pic = arm_pic_init_cpu(env);
     dev = sysbus_create_varargs("integrator_pic", 0x14000000,
+                                NULL,
                                 cpu_pic[ARM_PIC_CPU_IRQ],
                                 cpu_pic[ARM_PIC_CPU_FIQ], NULL);
     for (i = 0; i < 32; i++) {
         pic[i] = qdev_get_gpio_in(dev, i);
     }
     sysbus_create_simple("integrator_pic", 0xca000000, pic[26], NULL);
-    sysbus_create_varargs("integrator_pit", 0x13000000,
+    sysbus_create_varargs("integrator_pit", 0x13000000, NULL,
                           pic[5], pic[6], pic[7], NULL);
     sysbus_create_simple("pl031", 0x15000000, pic[8], NULL);
     sysbus_create_simple("pl011", 0x16000000, pic[1], NULL);
@@ -516,7 +517,7 @@  static void integratorcp_init(ram_addr_t ram_size,
     icp_control_init(0xcb000000);
     sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3], NULL);
     sysbus_create_simple("pl050_mouse", 0x19000000, pic[4], NULL);
-    sysbus_create_varargs("pl181", 0x1c000000, pic[23], pic[24], NULL);
+    sysbus_create_varargs("pl181", 0x1c000000, NULL, pic[23], pic[24], NULL);
     if (nd_table[0].vlan)
         smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
 
diff --git a/hw/musicpal.c b/hw/musicpal.c
index 1a4f865..edca3dc 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -1526,7 +1526,8 @@  static void musicpal_init(ram_addr_t ram_size,
     for (i = 0; i < 32; i++) {
         pic[i] = qdev_get_gpio_in(dev, i);
     }
-    sysbus_create_varargs("mv88w8618_pit", MP_PIT_BASE, pic[MP_TIMER1_IRQ],
+    sysbus_create_varargs("mv88w8618_pit", MP_PIT_BASE, NULL,
+                          pic[MP_TIMER1_IRQ],
                           pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],
                           pic[MP_TIMER4_IRQ], NULL);
 
diff --git a/hw/pc.c b/hw/pc.c
index a6d0f47..db5d5f3 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1132,7 +1132,7 @@  void pc_basic_device_init(qemu_irq *isa_irq,
     register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
 
     if (!no_hpet) {
-        DeviceState *hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL);
+        DeviceState *hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL, NULL);
 
         if (hpet) {
             for (i = 0; i < 24; i++) {
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index f2989a8..50c9e24 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -289,7 +289,7 @@  static void mpc8544ds_init(ram_addr_t ram_size,
     sysbus_create_simple("mpc8544-guts", MPC8544_UTIL_BASE, NULL, NULL);
 
     /* PCI */
-    dev = sysbus_create_varargs("e500-pcihost", MPC8544_PCI_REGS_BASE,
+    dev = sysbus_create_varargs("e500-pcihost", MPC8544_PCI_REGS_BASE, NULL,
                                 mpic[pci_irq_nrs[0]], mpic[pci_irq_nrs[1]],
                                 mpic[pci_irq_nrs[2]], mpic[pci_irq_nrs[3]],
                                 NULL);
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index 089d54d..c3eddba 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -2093,7 +2093,7 @@  PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision)
     s->dma = pxa27x_dma_init(0x40000000,
                     qdev_get_gpio_in(s->pic, PXA2XX_PIC_DMA));
 
-    sysbus_create_varargs("pxa27x-timer", 0x40a00000,
+    sysbus_create_varargs("pxa27x-timer", 0x40a00000, NULL,
                     qdev_get_gpio_in(s->pic, PXA2XX_PIC_OST_0 + 0),
                     qdev_get_gpio_in(s->pic, PXA2XX_PIC_OST_0 + 1),
                     qdev_get_gpio_in(s->pic, PXA2XX_PIC_OST_0 + 2),
@@ -2232,7 +2232,7 @@  PXA2xxState *pxa255_init(unsigned int sdram_size)
     s->dma = pxa255_dma_init(0x40000000,
                     qdev_get_gpio_in(s->pic, PXA2XX_PIC_DMA));
 
-    sysbus_create_varargs("pxa25x-timer", 0x40a00000,
+    sysbus_create_varargs("pxa25x-timer", 0x40a00000, NULL,
                     qdev_get_gpio_in(s->pic, PXA2XX_PIC_OST_0 + 0),
                     qdev_get_gpio_in(s->pic, PXA2XX_PIC_OST_0 + 1),
                     qdev_get_gpio_in(s->pic, PXA2XX_PIC_OST_0 + 2),
diff --git a/hw/r2d.c b/hw/r2d.c
index b8b0df3..624e465 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -255,8 +255,8 @@  static void r2d_init(ram_addr_t ram_size,
     /* Register peripherals */
     s = sh7750_init(env);
     irq = r2d_fpga_init(0x04000000, sh7750_irl(s));
-    sysbus_create_varargs("sh_pci", 0x1e200000, irq[PCI_INTA], irq[PCI_INTB],
-                          irq[PCI_INTC], irq[PCI_INTD], NULL);
+    sysbus_create_varargs("sh_pci", 0x1e200000, NULL, irq[PCI_INTA],
+                          irq[PCI_INTB], irq[PCI_INTC], irq[PCI_INTD], NULL);
 
     sm501_init(0x10000000, SM501_VRAM_SIZE, irq[SM501], serial_hds[2]);
 
diff --git a/hw/realview.c b/hw/realview.c
index 0f532d9..4b33534 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -253,7 +253,7 @@  static void realview_init(ram_addr_t ram_size,
 
     sysbus_create_simple("pl111", 0x10020000, pic[23], NULL);
 
-    dev = sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL);
+    dev = sysbus_create_varargs("pl181", 0x10005000, NULL, pic[17], pic[18], NULL);
     /* Wire up MMC card detect and read-only signals. These have
      * to go to both the PL061 GPIO and the sysctl register.
      * Note that the PL181 orders these lines (readonly,inserted)
@@ -272,7 +272,7 @@  static void realview_init(ram_addr_t ram_size,
     sysbus_create_simple("pl031", 0x10017000, pic[10], NULL);
 
     if (!is_pb) {
-        dev = sysbus_create_varargs("realview_pci", 0x60000000,
+        dev = sysbus_create_varargs("realview_pci", 0x60000000, NULL,
                                     pic[48], pic[49], pic[50], pic[51], NULL);
         pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
         if (usb_enabled) {
diff --git a/hw/stellaris.c b/hw/stellaris.c
index 8d344c8..cebd224 100644
--- a/hw/stellaris.c
+++ b/hw/stellaris.c
@@ -1280,7 +1280,7 @@  static void stellaris_init(const char *kernel_filename, const char *cpu_model,
                       flash_size, sram_size, kernel_filename, cpu_model);
 
     if (board->dc1 & (1 << 16)) {
-        dev = sysbus_create_varargs("stellaris-adc", 0x40038000,
+        dev = sysbus_create_varargs("stellaris-adc", 0x40038000, NULL,
                                     pic[14], pic[15], pic[16], pic[17], NULL);
         adc = qdev_get_gpio_in(dev, 0);
     } else {
diff --git a/hw/strongarm.c b/hw/strongarm.c
index a532d52..1255dfb 100644
--- a/hw/strongarm.c
+++ b/hw/strongarm.c
@@ -1552,10 +1552,10 @@  StrongARMState *sa1110_init(unsigned int sdram_size, const char *rev)
                                                 sdram_size) | IO_MEM_RAM);
 
     pic = arm_pic_init_cpu(s->env);
-    s->pic = sysbus_create_varargs("strongarm_pic", 0x90050000,
+    s->pic = sysbus_create_varargs("strongarm_pic", 0x90050000, NULL,
                     pic[ARM_PIC_CPU_IRQ], pic[ARM_PIC_CPU_FIQ], NULL);
 
-    sysbus_create_varargs("pxa25x-timer", 0x90000000,
+    sysbus_create_varargs("pxa25x-timer", 0x90000000, NULL,
                     qdev_get_gpio_in(s->pic, SA_PIC_OSTC0),
                     qdev_get_gpio_in(s->pic, SA_PIC_OSTC1),
                     qdev_get_gpio_in(s->pic, SA_PIC_OSTC2),
@@ -1568,7 +1568,7 @@  StrongARMState *sa1110_init(unsigned int sdram_size, const char *rev)
 
     s->gpio = strongarm_gpio_init(0x90040000, s->pic);
 
-    s->ppc = sysbus_create_varargs("strongarm-ppc", 0x90060000, NULL);
+    s->ppc = sysbus_create_varargs("strongarm-ppc", 0x90060000, NULL, NULL);
 
     for (i = 0; sa_serial[i].io_base; i++) {
         DeviceState *dev = qdev_create(NULL, "strongarm-uart", NULL);
@@ -1581,7 +1581,9 @@  StrongARMState *sa1110_init(unsigned int sdram_size, const char *rev)
     }
 
     s->ssp = sysbus_create_varargs("strongarm-ssp", 0x80070000,
-                qdev_get_gpio_in(s->pic, SA_PIC_SSP), NULL);
+                                   NULL,
+                                   qdev_get_gpio_in(s->pic, SA_PIC_SSP),
+                                   NULL);
     s->ssp_bus = (SSIBus *)qdev_get_child_bus(s->ssp, "ssi");
 
     return s;
diff --git a/hw/sysbus.c b/hw/sysbus.c
index 7809aa1..f756731 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -174,7 +174,8 @@  void sysbus_register_dev(const char *name, size_t size, sysbus_initfn init)
 }
 
 DeviceState *sysbus_create_varargs(const char *name,
-                                   target_phys_addr_t addr, ...)
+                                   target_phys_addr_t addr,
+                                   const char *id, ...)
 {
     DeviceState *dev;
     SysBusDevice *s;
@@ -182,13 +183,18 @@  DeviceState *sysbus_create_varargs(const char *name,
     qemu_irq irq;
     int n;
 
-    dev = qdev_create(NULL, name, NULL);
+    if (id) {
+        dev = qdev_create(NULL, name, "%s", id);
+    } else {
+        dev = qdev_create(NULL, name, NULL);
+    }
+
     s = sysbus_from_qdev(dev);
     qdev_init_nofail(dev);
     if (addr != (target_phys_addr_t)-1) {
         sysbus_mmio_map(s, 0, addr);
     }
-    va_start(va, addr);
+    va_start(va, id);
     n = 0;
     while (1) {
         irq = va_arg(va, qemu_irq);
@@ -201,8 +207,57 @@  DeviceState *sysbus_create_varargs(const char *name,
     return dev;
 }
 
+DeviceState *sysbus_create_simple(const char *name,
+                                  target_phys_addr_t addr,
+                                  qemu_irq irq,
+                                  const char *id,
+                                  ...)
+{
+    DeviceState *dev;
+    char *fullname;
+    va_list ap;
+
+    va_start(ap, id);
+    if (id) {
+        fullname = g_strdup_vprintf(id, ap);
+    } else {
+        fullname = g_strdup("");
+    }
+    va_end(ap);
+
+    dev = sysbus_create_varargs(name, addr, fullname, irq, NULL);
+    g_free(fullname);
+
+    return dev;
+}
+
+DeviceState *sysbus_try_create_simple(const char *name,
+                                      target_phys_addr_t addr,
+                                      qemu_irq irq,
+                                      const char *id,
+                                      ...)
+{
+    DeviceState *dev;
+    char *fullname;
+    va_list ap;
+
+    va_start(ap, id);
+    if (id) {
+        fullname = g_strdup_vprintf(id, ap);
+    } else {
+        fullname = g_strdup("");
+    }
+    va_end(ap);
+
+    dev = sysbus_try_create_varargs(name, addr, fullname, irq, NULL);
+    g_free(fullname);
+
+    return dev;
+}
+
 DeviceState *sysbus_try_create_varargs(const char *name,
-                                       target_phys_addr_t addr, ...)
+                                       target_phys_addr_t addr,
+                                       const char *id, ...)
 {
     DeviceState *dev;
     SysBusDevice *s;
@@ -210,7 +265,7 @@  DeviceState *sysbus_try_create_varargs(const char *name,
     qemu_irq irq;
     int n;
 
-    dev = qdev_try_create(NULL, name, NULL);
+    dev = qdev_try_create(NULL, name, "%s", id);
     if (!dev) {
         return NULL;
     }
@@ -219,7 +274,7 @@  DeviceState *sysbus_try_create_varargs(const char *name,
     if (addr != (target_phys_addr_t)-1) {
         sysbus_mmio_map(s, 0, addr);
     }
-    va_start(va, addr);
+    va_start(va, id);
     n = 0;
     while (1) {
         irq = va_arg(va, qemu_irq);
diff --git a/hw/sysbus.h b/hw/sysbus.h
index 536e667..6f01d18 100644
--- a/hw/sysbus.h
+++ b/hw/sysbus.h
@@ -69,23 +69,24 @@  void sysbus_del_io(SysBusDevice *dev, MemoryRegion *mem);
 
 /* Legacy helper function for creating devices.  */
 DeviceState *sysbus_create_varargs(const char *name,
-                                 target_phys_addr_t addr, ...);
+                                   target_phys_addr_t addr,
+                                   const char *id, ...);
 DeviceState *sysbus_try_create_varargs(const char *name,
-                                       target_phys_addr_t addr, ...);
-static inline DeviceState *sysbus_create_simple(const char *name,
-                                                target_phys_addr_t addr,
-                                                qemu_irq irq,
-                                                const char *id,
-                                                ...)
-{
-    return sysbus_create_varargs(name, addr, irq, NULL);
-}
+                                       target_phys_addr_t addr,
+                                       const char *id, ...);
 
-static inline DeviceState *sysbus_try_create_simple(const char *name,
-                                                    target_phys_addr_t addr,
-                                                    qemu_irq irq)
-{
-    return sysbus_try_create_varargs(name, addr, irq, NULL);
-}
+DeviceState *sysbus_create_simple(const char *name,
+                                  target_phys_addr_t addr,
+                                  qemu_irq irq,
+                                  const char *id,
+                                  ...)
+    GCC_FMT_ATTR(4, 5);
+
+DeviceState *sysbus_try_create_simple(const char *name,
+                                      target_phys_addr_t addr,
+                                      qemu_irq irq,
+                                      const char *id,
+                                      ...)
+    GCC_FMT_ATTR(4, 5);
 
 #endif /* !HW_SYSBUS_H */
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 8df18ec..c753d1f 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -205,7 +205,7 @@  static void versatile_init(ram_addr_t ram_size,
     sysbus_mmio_map(sysbus_from_qdev(sysctl), 0, 0x10000000);
 
     cpu_pic = arm_pic_init_cpu(env);
-    dev = sysbus_create_varargs("pl190", 0x10140000,
+    dev = sysbus_create_varargs("pl190", 0x10140000, NULL,
                                 cpu_pic[0], cpu_pic[1], NULL);
     for (n = 0; n < 32; n++) {
         pic[n] = qdev_get_gpio_in(dev, n);
@@ -219,7 +219,7 @@  static void versatile_init(ram_addr_t ram_size,
     sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3], NULL);
     sysbus_create_simple("pl050_mouse", 0x10007000, sic[4], NULL);
 
-    dev = sysbus_create_varargs("versatile_pci", 0x40000000,
+    dev = sysbus_create_varargs("versatile_pci", 0x40000000, NULL,
                                 sic[27], sic[28], sic[29], sic[30], NULL);
     pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
 
@@ -259,8 +259,8 @@  static void versatile_init(ram_addr_t ram_size,
     /* Wire up the mux control signals from the SYS_CLCD register */
     qdev_connect_gpio_out(sysctl, 0, qdev_get_gpio_in(dev, 0));
 
-    sysbus_create_varargs("pl181", 0x10005000, sic[22], sic[1], NULL);
-    sysbus_create_varargs("pl181", 0x1000b000, sic[23], sic[2], NULL);
+    sysbus_create_varargs("pl181", 0x10005000, NULL, sic[22], sic[1], NULL);
+    sysbus_create_varargs("pl181", 0x1000b000, NULL, sic[23], sic[2], NULL);
 
     /* Add PL031 Real Time Clock. */
     sysbus_create_simple("pl031", 0x101e8000, pic[10], NULL);
diff --git a/hw/vexpress.c b/hw/vexpress.c
index 47265da..b9ad2de 100644
--- a/hw/vexpress.c
+++ b/hw/vexpress.c
@@ -119,7 +119,7 @@  static void vexpress_a9_init(ram_addr_t ram_size,
     /* 0x10002000 serial bus PCI */
     /* 0x10004000 PL041 audio */
 
-    dev = sysbus_create_varargs("pl181", 0x10005000, pic[9], pic[10], NULL);
+    dev = sysbus_create_varargs("pl181", 0x10005000, NULL, pic[9], pic[10], NULL);
     /* Wire up MMC card detect and read-only signals */
     qdev_connect_gpio_out(dev, 0,
                           qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT));