Skip to contentSkip to conversation

Initialise IRQ pointers as Zero

PATCH Applied Peter Crosthwaite 2 participants 5 messages Aug 15, 2014 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

cover Initialise IRQ pointers as Zero

Hi,

I'm working on some QOM stuff that requires output IRQ pointers to be initialised to zero. I have a catch-all workaround to the problem in the series proper, but this is the startings of a more complete solution.

Sending to trivial, as I think the change is an improvement independently, just due to the fact its easier to debug with NULL pointers rather than undefined pointer values.

Regards,
Peter

Peter Crosthwaite (3):
ssi: xilinx_spi: Initialise CS GPIOs as NULL
ppc: convert g_new(qemu_irq usages to g_new0
intc: i8259: Convert Array allocation to g_new0

 hw/intc/i8259.c       | 2 +-
 hw/intc/openpic.c     | 2 +-
 hw/ppc/e500.c         | 2 +-
 hw/ppc/mac_newworld.c | 2 +-
 hw/ssi/xilinx_spi.c   | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.0.1.1.gfbfc394
#1 lore raw

PATCH 1/3 ssi: xilinx_spi: Initialise CS GPIOs as NULL

To properly indicate they are unconnected.

---

 hw/ssi/xilinx_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ssi/xilinx_spi.c +1 -1
index 207f47a..620573c 100644
@@ -329,7 +329,7 @@ static int xilinx_spi_init(SysBusDevice *sbd)
     s->spi = ssi_create_bus(dev, "spi");
 
     sysbus_init_irq(sbd, &s->irq);
-    s->cs_lines = g_new(qemu_irq, s->num_cs);
+    s->cs_lines = g_new0(qemu_irq, s->num_cs);
     ssi_auto_connect_slaves(dev, s->cs_lines, s->spi);
     for (i = 0; i < s->num_cs; ++i) {
         sysbus_init_irq(sbd, &s->cs_lines[i]);
Signature · 1 line
2.0.1.1.gfbfc394
#2 lore raw

PATCH 2/3 ppc: convert g_new(qemu_irq usages to g_new0

In reply to Peter Crosthwaite

To indicate the IRQs are initially disconnected.

---

 hw/intc/openpic.c     | 2 +-
 hw/ppc/e500.c         | 2 +-
 hw/ppc/mac_newworld.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/intc/openpic.c +1 -1
index 028529e..7d1f3b9 100644
@@ -1627,7 +1627,7 @@ static void openpic_realize(DeviceState *dev, Error **errp)
     }
 
     for (i = 0; i < opp->nb_cpus; i++) {
-        opp->dst[i].irqs = g_new(qemu_irq, OPENPIC_OUTPUT_NB);
+        opp->dst[i].irqs = g_new0(qemu_irq, OPENPIC_OUTPUT_NB);
         for (j = 0; j < OPENPIC_OUTPUT_NB; j++) {
             sysbus_init_irq(d, &opp->dst[i].irqs[j]);
         }
hw/ppc/e500.c +1 -1
index 1a5b30d..16c85ef 100644
@@ -583,7 +583,7 @@ static qemu_irq *ppce500_init_mpic(PPCE500Params *params, MemoryRegion *ccsr,
     SysBusDevice *s;
     int i;
 
-    mpic = g_new(qemu_irq, 256);
+    mpic = g_new0(qemu_irq, 256);
 
     if (kvm_enabled()) {
         QemuOpts *machine_opts = qemu_get_machine_opts();
hw/ppc/mac_newworld.c +1 -1
index f5bccd2..1ec4bb4 100644
@@ -346,7 +346,7 @@ static void ppc_core99_init(MachineState *machine)
         }
     }
 
-    pic = g_new(qemu_irq, 64);
+    pic = g_new0(qemu_irq, 64);
 
     dev = qdev_create(NULL, TYPE_OPENPIC);
     qdev_prop_set_uint32(dev, "model", OPENPIC_MODEL_RAVEN);
Signature · 1 line
2.0.1.1.gfbfc394
#3 lore raw

PATCH 3/3 intc: i8259: Convert Array allocation to g_new0

In reply to Peter Crosthwaite

To be more array friendly and to indicate the IRQs are initially disconnected.

---

 hw/intc/i8259.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/i8259.c +1 -1
index d0b0c52..a563b82 100644
@@ -472,7 +472,7 @@ qemu_irq *i8259_init(ISABus *bus, qemu_irq parent_irq)
     ISADevice *isadev;
     int i;
 
-    irq_set = g_malloc(ISA_NUM_IRQS * sizeof(qemu_irq));
+    irq_set = g_new0(qemu_irq, ISA_NUM_IRQS);
 
     isadev = i8259_init_chip(TYPE_I8259, bus, true);
     dev = DEVICE(isadev);
Signature · 1 line
2.0.1.1.gfbfc394
#4 lore raw
In reply to Peter Crosthwaite
Quoted 10 lines · Peter Crosthwaite

Hi,

I'm working on some QOM stuff that requires output IRQ pointers to be initialised to zero. I have a catch-all workaround to the problem in the series proper, but this is the startings of a more complete solution.

Sending to trivial, as I think the change is an improvement independently, just due to the fact its easier to debug with NULL pointers rather than undefined pointer values.

Applied all 3 to -trivial, thank you!