qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/3] qdev: irq allocation in generic code.


From: Gerd Hoffmann
Subject: [Qemu-devel] [PATCH 2/3] qdev: irq allocation in generic code.
Date: Tue, 9 Jun 2009 13:01:00 +0200

Almost all devices have a static number of irqs, so we can easily move
the setup into generic code by adding some fields to DeviceInfo.

Signed-off-by: Gerd Hoffmann <address@hidden>
---
 hw/qdev.c |    9 +++++++++
 hw/qdev.h |    4 ++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 9fd22cf..c70ae8f 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -99,6 +99,15 @@ DeviceState *qdev_create(BusState *bus, const char *name)
     }
     dev->parent_bus = bus;
     LIST_INSERT_HEAD(&bus->children, dev, sibling);
+
+    if (t->info->num_gpio_in) {
+        qdev_init_gpio_in(dev, t->info->irq, t->info->num_gpio_in);
+    }
+    if (t->info->num_gpio_out) {
+        qemu_irq *irqs = qemu_mallocz(sizeof(irqs[0]) * t->info->num_gpio_out);
+        qdev_init_gpio_out(dev, irqs, t->info->num_gpio_out);
+    }
+
     return dev;
 }
 
diff --git a/hw/qdev.h b/hw/qdev.h
index 7b523b6..bed3d6a 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -82,6 +82,10 @@ struct DeviceInfo {
     const char *name;
     size_t size;
 
+    int num_gpio_in;
+    int num_gpio_out;
+    qemu_irq_handler irq;
+
     /* private to qdev / bus */
     qdev_initfn init;
     BusType bus_type;
-- 
1.6.2.2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]