diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2025-08-21 16:40:51 +0100 |
|---|---|---|
| committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-09-02 17:57:05 +0200 |
| commit | 01941107ebda4756e63a841ff5c457bc6a77c6ce (patch) | |
| tree | 8fccef2ce408e7879eac60e3e4e26610981e34fb /hw/core | |
| parent | 46d03bb23dde86513465724760d85f42eb17539e (diff) | |
| download | focaccia-qemu-01941107ebda4756e63a841ff5c457bc6a77c6ce.tar.gz focaccia-qemu-01941107ebda4756e63a841ff5c457bc6a77c6ce.zip | |
hw/irq: New qemu_init_irq_child() function
The qemu_init_irq() function initializes a TYPE_IRQ QOM object. The caller is therefore responsible for eventually calling qemu_free_irq() to unref (and thus free) it. In many places where we want to initialize an IRQ we are in the init/realize of some other QOM object; if we have a variant of this function that calls object_initialize_child() then the IRQ will be automatically cleaned up when its parent object is destroyed, and we don't need to remember to manually free it. Implement qemu_init_irq_child(), which is to qemu_init_irq() what object_initialize_child() is to object_initialize(). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20250821154053.2417090-2-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'hw/core')
| -rw-r--r-- | hw/core/irq.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/hw/core/irq.c b/hw/core/irq.c index 6dd8d47bd6..0c768f7704 100644 --- a/hw/core/irq.c +++ b/hw/core/irq.c @@ -49,6 +49,14 @@ void qemu_init_irq(IRQState *irq, qemu_irq_handler handler, void *opaque, init_irq_fields(irq, handler, opaque, n); } +void qemu_init_irq_child(Object *parent, const char *propname, + IRQState *irq, qemu_irq_handler handler, + void *opaque, int n) +{ + object_initialize_child(parent, propname, irq, TYPE_IRQ); + init_irq_fields(irq, handler, opaque, n); +} + void qemu_init_irqs(IRQState irq[], size_t count, qemu_irq_handler handler, void *opaque) { |