diff options
author | Peter Crosthwaite <peter.crosthwaite@xilinx.com> | 2014-06-18 00:56:31 -0700 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2014-07-01 04:02:53 +0200 |
commit | f173d57a4cd3bb2a8362fe376cd9fd776b2f57d5 (patch) | |
tree | f4b392449f53293e948ec32edbbfc01865bb78ca /hw/core/irq.c | |
parent | f3c7d0389fe8a2792fd4c1cf151b885de03c8f62 (diff) |
irq: Allocate IRQs individually
Allocate each IRQ individually on array allocations. This prepares for
QOMification of IRQs, where pointers to individual IRQs may be taken
and handed around for usage as QOM Links. The g_renew() scheme used here
is too fragile and would break all existing links should an IRQ list
be extended.
We now have to pass the IRQ count to qemu_free_irqs(). We have so few
call sites however, so this change is reasonably trivial.
Cc: agarcia@igalia.com
Cc: mst@redhat.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Alberto Garcia <agarcia@igalia.com>
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/core/irq.c')
-rw-r--r-- | hw/core/irq.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/hw/core/irq.c b/hw/core/irq.c index 3d284c6482..bc982a7dfa 100644 --- a/hw/core/irq.c +++ b/hw/core/irq.c @@ -42,23 +42,14 @@ qemu_irq *qemu_extend_irqs(qemu_irq *old, int n_old, qemu_irq_handler handler, void *opaque, int n) { qemu_irq *s; - struct IRQState *p; int i; if (!old) { n_old = 0; } s = old ? g_renew(qemu_irq, old, n + n_old) : g_new(qemu_irq, n); - p = old ? g_renew(struct IRQState, s[0], n + n_old) : - g_new(struct IRQState, n); - for (i = 0; i < n + n_old; i++) { - if (i >= n_old) { - p->handler = handler; - p->opaque = opaque; - p->n = i; - } - s[i] = p; - p++; + for (i = n_old; i < n + n_old; i++) { + s[i] = qemu_allocate_irq(handler, opaque, i); } return s; } @@ -80,9 +71,12 @@ qemu_irq qemu_allocate_irq(qemu_irq_handler handler, void *opaque, int n) return irq; } -void qemu_free_irqs(qemu_irq *s) +void qemu_free_irqs(qemu_irq *s, int n) { - g_free(s[0]); + int i; + for (i = 0; i < n; i++) { + qemu_free_irq(s[i]); + } g_free(s); } |