qemu-e2k/hw/intc
Philippe Mathieu-Daudé 23d1f360f3 hw/intc/nvic: Use object_initialize_child for correct reference counting
As explained in commit aff39be0ed:

  Both functions, object_initialize() and object_property_add_child()
  increase the reference counter of the new object, so one of the
  references has to be dropped afterwards to get the reference
  counting right. Otherwise the child object will not be properly
  cleaned up when the parent gets destroyed.
  Thus let's use now object_initialize_child() instead to get the
  reference counting here right.

This patch was generated using the following Coccinelle script:

 @use_sysbus_init_child_obj_missing_parent@
 expression child_ptr;
 expression child_type;
 expression child_size;
 @@
 -   object_initialize(child_ptr, child_size, child_type);
     ...
 -   qdev_set_parent_bus(DEVICE(child_ptr), sysbus_get_default());
     ...
 ?-  object_unref(OBJECT(child_ptr));
 +   sysbus_init_child_obj(OBJECT(PARENT_OBJ), "CHILD_NAME", child_ptr,
 +                         child_size, child_type);

We let NVIC adopt the SysTick timer.

While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.
This choice also matches when using sysbus_init_child_obj(),
since its code is:

  void sysbus_init_child_obj(Object *parent,
                             const char *childname, void *child,
                             size_t childsize, const char *childtype)
  {
      object_initialize_child(parent, childname, child, childsize,
                              childtype, &error_abort, NULL);

      qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
  }

Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-17-philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-24 15:29:02 -03:00
..
allwinner-a10-pic.c hw: Remove unused 'hw/devices.h' include 2019-03-07 22:16:11 +01:00
apic_common.c
apic.c avoid TABs in files that only contain a few 2019-01-11 15:46:56 +01:00
arm_gic_common.c hw/intc/arm_gic: Drop GIC_BASE_IRQ macro 2018-09-25 15:13:24 +01:00
arm_gic_kvm.c
arm_gic.c hw/intc/arm_gic: Drop GIC_BASE_IRQ macro 2018-09-25 15:13:24 +01:00
arm_gicv2m.c
arm_gicv3_common.c
arm_gicv3_cpuif.c hw/intc/arm_gicv3: Fix writes to ICC_CTLR_EL3 2019-05-23 14:47:44 +01:00
arm_gicv3_dist.c
arm_gicv3_its_common.c
arm_gicv3_its_kvm.c hw/intc/arm_gicv3_its: downgrade error_report to warn_report in kvm_arm_its_reset 2018-08-20 11:24:31 +01:00
arm_gicv3_kvm.c
arm_gicv3_redist.c
arm_gicv3.c
armv7m_nvic.c hw/intc/nvic: Use object_initialize_child for correct reference counting 2019-05-24 15:29:02 -03:00
aspeed_vic.c
bcm2835_ic.c
bcm2836_control.c hw/intc/bcm2836_control: Implement local timer 2019-03-15 11:12:28 +00:00
etraxfs_pic.c
exynos4210_combiner.c
exynos4210_gic.c
gic_internal.h hw/intc/arm_gic: Drop GIC_BASE_IRQ macro 2018-09-25 15:13:24 +01:00
gicv3_internal.h
grlib_irqmp.c grlib, irqmp: get rid of the old-style create function 2019-05-17 09:17:11 +01:00
heathrow_pic.c
i8259_common.c
i8259.c
imx_avic.c
imx_gpcv2.c
intc.c
ioapic_common.c
ioapic.c ioapic: allow buggy guests mishandling level-triggered interrupts to make progress 2019-05-17 15:19:39 +02:00
Kconfig kconfig: add CONFIG_MSI_NONBROKEN 2019-03-18 09:39:57 +01:00
lm32_pic.c
Makefile.objs ppc/pnv: add a XIVE interrupt controller model for POWER9 2019-03-12 14:33:04 +11:00
mips_gic.c
nios2_iic.c
omap_intc.c
ompic.c
openpic_kvm.c
openpic.c
pl190.c
pnv_xive_regs.h ppc/pnv: add a XIVE interrupt controller model for POWER9 2019-03-12 14:33:04 +11:00
pnv_xive.c ppc/pnv: add a XIVE interrupt controller model for POWER9 2019-03-12 14:33:04 +11:00
puv3_intc.c intc/puv3_intc: Convert sysbus init function to realize function 2018-12-13 13:47:59 +00:00
realview_gic.c
s390_flic_kvm.c vmstate: constify VMStateField 2018-11-27 15:35:15 +01:00
s390_flic.c
sh_intc.c
slavio_intctl.c
spapr_xive.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
trace-events ioapic: allow buggy guests mishandling level-triggered interrupts to make progress 2019-05-17 15:19:39 +02:00
vgic_common.h
xics_kvm.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
xics_pnv.c
xics_spapr.c ppc/xics/spapr: Fix H_IPOLL implementation 2019-03-19 15:20:14 +11:00
xics.c xics: Write source state to KVM at claim time 2019-02-26 09:21:25 +11:00
xilinx_intc.c
xive.c ppc/xive: activate HV support 2019-03-12 14:33:04 +11:00
xlnx-pmu-iomod-intc.c
xlnx-zynqmp-ipi.c