From patchwork Tue Oct 15 06:30:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 283497 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8D0692C00B1 for ; Tue, 15 Oct 2013 17:30:11 +1100 (EST) Received: from localhost ([::1]:40048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVy8u-00023G-N7 for incoming@patchwork.ozlabs.org; Tue, 15 Oct 2013 02:30:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVy6g-0006wv-6U for qemu-devel@nongnu.org; Tue, 15 Oct 2013 02:27:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVy6a-0004tf-72 for qemu-devel@nongnu.org; Tue, 15 Oct 2013 02:27:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14323) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVy6Z-0004tb-U5 for qemu-devel@nongnu.org; Tue, 15 Oct 2013 02:27:44 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9F6Redw012961 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Oct 2013 02:27:40 -0400 Received: from redhat.com (vpn1-6-139.ams2.redhat.com [10.36.6.139]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id r9F6RbRT016025; Tue, 15 Oct 2013 02:27:38 -0400 Date: Tue, 15 Oct 2013 09:30:14 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, Anthony Liguori Message-ID: <1381818560-18367-5-git-send-email-mst@redhat.com> References: <1381818560-18367-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1381818560-18367-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, imammedo@redhat.com, mst@redhat.com, kraxel@redhat.com, marcel.a@redhat.com Subject: [Qemu-devel] [PULL v2 04/39] hw/core: Add interface to allocate and free a single IRQ X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Marcel Apfelbaum qemu_allocate_irq returns a single qemu_irq. The interface allows to specify an interrupt number. qemu_free_irq frees it. Signed-off-by: Marcel Apfelbaum Signed-off-by: Michael S. Tsirkin --- include/hw/irq.h | 7 +++++++ hw/core/irq.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/hw/irq.h b/include/hw/irq.h index 610e6b7..d08bc02 100644 --- a/include/hw/irq.h +++ b/include/hw/irq.h @@ -30,6 +30,12 @@ static inline void qemu_irq_pulse(qemu_irq irq) */ qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n); +/* + * Allocates a single IRQ. The irq is assigned with a handler, an opaque + * data and the interrupt number. + */ +qemu_irq qemu_allocate_irq(qemu_irq_handler handler, void *opaque, int n); + /* Extends an Array of IRQs. Old IRQs have their handlers and opaque data * preserved. New IRQs are assigned the argument handler and opaque data. */ @@ -37,6 +43,7 @@ qemu_irq *qemu_extend_irqs(qemu_irq *old, int n_old, qemu_irq_handler handler, void *opaque, int n); void qemu_free_irqs(qemu_irq *s); +void qemu_free_irq(qemu_irq irq); /* Returns a new IRQ with opposite polarity. */ qemu_irq qemu_irq_invert(qemu_irq irq); diff --git a/hw/core/irq.c b/hw/core/irq.c index 2078542..03c8cb3 100644 --- a/hw/core/irq.c +++ b/hw/core/irq.c @@ -68,6 +68,17 @@ qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n) return qemu_extend_irqs(NULL, 0, handler, opaque, n); } +qemu_irq qemu_allocate_irq(qemu_irq_handler handler, void *opaque, int n) +{ + struct IRQState *irq; + + irq = g_new(struct IRQState, 1); + irq->handler = handler; + irq->opaque = opaque; + irq->n = n; + + return irq; +} void qemu_free_irqs(qemu_irq *s) { @@ -75,6 +86,11 @@ void qemu_free_irqs(qemu_irq *s) g_free(s); } +void qemu_free_irq(qemu_irq irq) +{ + g_free(irq); +} + static void qemu_notirq(void *opaque, int line, int level) { struct IRQState *irq = opaque;