From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MDz4q-0002rX-0d for qemu-devel@nongnu.org; Tue, 09 Jun 2009 07:01:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MDz4l-0002gZ-2T for qemu-devel@nongnu.org; Tue, 09 Jun 2009 07:01:11 -0400 Received: from [199.232.76.173] (port=41986 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MDz4k-0002g6-Mh for qemu-devel@nongnu.org; Tue, 09 Jun 2009 07:01:06 -0400 Received: from mx2.redhat.com ([66.187.237.31]:51417) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MDz4j-0002vH-UF for qemu-devel@nongnu.org; Tue, 09 Jun 2009 07:01:06 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n59B15T2007835 for ; Tue, 9 Jun 2009 07:01:05 -0400 From: Gerd Hoffmann Date: Tue, 9 Jun 2009 13:01:00 +0200 Message-Id: <1244545261-23679-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1244545261-23679-1-git-send-email-kraxel@redhat.com> References: <1244545261-23679-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 2/3] qdev: irq allocation in generic code. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann 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 --- 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