From patchwork Wed Dec 8 08:46:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 74652 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 79570B70D6 for ; Wed, 8 Dec 2010 19:48:04 +1100 (EST) Received: from localhost ([127.0.0.1]:58474 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQFgv-0002Dy-My for incoming@patchwork.ozlabs.org; Wed, 08 Dec 2010 03:48:01 -0500 Received: from [140.186.70.92] (port=43053 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQFff-0002DE-4e for qemu-devel@nongnu.org; Wed, 08 Dec 2010 03:46:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PQFfX-0000ZC-1z for qemu-devel@nongnu.org; Wed, 08 Dec 2010 03:46:43 -0500 Received: from mail.valinux.co.jp ([210.128.90.3]:47630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PQFfW-0000YO-LV for qemu-devel@nongnu.org; Wed, 08 Dec 2010 03:46:34 -0500 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 5F11C27FBA; Wed, 8 Dec 2010 17:46:33 +0900 (JST) Received: (nullmailer pid 32035 invoked by uid 1000); Wed, 08 Dec 2010 08:46:28 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org Date: Wed, 8 Dec 2010 17:46:28 +0900 Message-Id: X-Mailer: git-send-email 1.7.1.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: yamahata@valinux.co.jp, mst@redhat.com Subject: [Qemu-devel] [PATTCH v2 6/6] pci/aer: factor out common code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Michael S. Tsirkin Same logic is used to assert interrupts and send msix messages, so add a static functin for this. Signed-off-by: Michael S. Tsirkin --- hw/pcie_aer.c | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-) diff --git a/hw/pcie_aer.c b/hw/pcie_aer.c index 0fb21ab..2ceb00a 100644 --- a/hw/pcie_aer.c +++ b/hw/pcie_aer.c @@ -273,6 +273,17 @@ static uint32_t pcie_aer_status_to_cmd(uint32_t status) return cmd; } +static void pcie_aer_root_notify(PCIDevice *dev) +{ + if (msix_enabled(dev)) { + msix_notify(dev, pcie_aer_root_get_vector(dev)); + } else if (msi_enabled(dev)) { + msi_notify(dev, pcie_aer_root_get_vector(dev)); + } else { + qemu_set_irq(dev->irq[dev->exp.aer_intx], 1); + } +} + /* * 6.2.6 Error Message Control * Figure 6-3 @@ -344,13 +355,7 @@ static void pcie_aer_msg_root_port(PCIDevice *dev, const PCIEAERMsg *msg) return; } - if (msix_enabled(dev)) { - msix_notify(dev, pcie_aer_root_get_vector(dev)); - } else if (msi_enabled(dev)) { - msi_notify(dev, pcie_aer_root_get_vector(dev)); - } else { - qemu_set_irq(dev->irq[dev->exp.aer_intx], 1); - } + pcie_aer_root_notify(dev); } /* @@ -760,13 +765,7 @@ void pcie_aer_root_write_config(PCIDevice *dev, return; } - if (msix_enabled(dev)) { - msix_notify(dev, pcie_aer_root_get_vector(dev)); - } else if (msi_enabled(dev)) { - msi_notify(dev, pcie_aer_root_get_vector(dev)); - } else { - abort(); - } + pcie_aer_root_notify(dev); } static const VMStateDescription vmstate_pcie_aer_err = {