From patchwork Thu Aug 13 10:44:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 52372 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 70AAB22EC6 for ; Thu, 13 Aug 2015 10:57:13 +0000 (UTC) Received: by labia3 with SMTP id ia3sf15586442lab.1 for ; Thu, 13 Aug 2015 03:57:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=Fy46vUOY3TzfDfIOnU4pQiVQzInZN9/UIEEbnV3gcQY=; b=VWgRFruydAknExXqy9QpaHWsJV0F1aw36ubWa2wyZ5St5RS4xENMcuaErk/zWfeM9i FodsGlb35xoIzrkTSM4K4Iizz/Uo8qrWgCOxTnUyIr752vxsoCXD4xw11tunZb3kpAbG fCuAkwCu73Ht+RdBPXxT4eBAfVLIr0FgU/LZubvdxUvs4pfUIDrag21qA7UYlTcDeuC8 VPqnuZlwd44HUfwvL2inihJrJzcn7YIZqTB14Z11RIGCa5q28KKCQWZ1QYEBeC1p11pO EaQY88HfpB1MYio+d0ImRttcJGTtOFLKMCBEC0Vi41JRJmkeAaWkDF/lSRNk3998NnJz KEJQ== X-Gm-Message-State: ALoCoQnzPPdToR+fQ9J63izpmDaGLtdztYJHP3Yap+hjwMlVSuB45+51Qa77HUXc5GhiVVXkQHYQ X-Received: by 10.152.120.138 with SMTP id lc10mr5329637lab.3.1439463432414; Thu, 13 Aug 2015 03:57:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.1 with SMTP id o1ls163612lao.12.gmail; Thu, 13 Aug 2015 03:57:12 -0700 (PDT) X-Received: by 10.112.166.2 with SMTP id zc2mr35356824lbb.29.1439463431978; Thu, 13 Aug 2015 03:57:11 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id r2si1828602lae.66.2015.08.13.03.57.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Aug 2015 03:57:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbbsx3 with SMTP id sx3so24824372lbb.0 for ; Thu, 13 Aug 2015 03:57:11 -0700 (PDT) X-Received: by 10.152.44.196 with SMTP id g4mr17462277lam.56.1439463431875; Thu, 13 Aug 2015 03:57:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp862469lba; Thu, 13 Aug 2015 03:57:10 -0700 (PDT) X-Received: by 10.107.31.134 with SMTP id f128mr35179750iof.19.1439463429796; Thu, 13 Aug 2015 03:57:09 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u84si1196550ioi.167.2015.08.13.03.57.09 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 13 Aug 2015 03:57:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:41734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPqC4-0001an-OZ for patch@linaro.org; Thu, 13 Aug 2015 06:57:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPq0K-0005QQ-Qa for qemu-devel@nongnu.org; Thu, 13 Aug 2015 06:45:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPq0H-0005Hb-GS for qemu-devel@nongnu.org; Thu, 13 Aug 2015 06:45:00 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:34909) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPq0H-0005DT-9C for qemu-devel@nongnu.org; Thu, 13 Aug 2015 06:44:57 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZPq08-00071k-8m for qemu-devel@nongnu.org; Thu, 13 Aug 2015 11:44:48 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 13 Aug 2015 11:44:41 +0100 Message-Id: <1439462687-26903-22-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1439462687-26903-1-git-send-email-peter.maydell@linaro.org> References: <1439462687-26903-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 21/27] Introduce gic_class_name() instead of repeating condition 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Pavel Fedin This small inline returns correct GIC class name depending on whether we use KVM acceleration or not. Avoids duplicating the condition everywhere. Signed-off-by: Pavel Fedin Reviewed-by: Peter Maydell Message-id: 4f26901be9b844b563673ce3ad08eeedbb7a7132.1438758065.git.p.fedin@samsung.com Signed-off-by: Peter Maydell --- hw/arm/virt.c | 7 +++---- hw/cpu/a15mpcore.c | 8 ++------ target-arm/kvm_arm.h | 5 +++++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index aab99f7..94694d6 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -49,6 +49,7 @@ #include "hw/platform-bus.h" #include "hw/arm/fdt.h" #include "hw/intc/arm_gic_common.h" +#include "kvm_arm.h" /* Number of external interrupt lines to configure the GIC with */ #define NUM_IRQS 256 @@ -366,12 +367,10 @@ static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic) /* We create a standalone GIC v2 */ DeviceState *gicdev; SysBusDevice *gicbusdev; - const char *gictype = "arm_gic"; + const char *gictype; int i; - if (kvm_irqchip_in_kernel()) { - gictype = "kvm-arm-gic"; - } + gictype = gic_class_name(); gicdev = qdev_create(NULL, gictype); qdev_prop_set_uint32(gicdev, "revision", 2); diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c index acc419e..e31a1f9 100644 --- a/hw/cpu/a15mpcore.c +++ b/hw/cpu/a15mpcore.c @@ -20,6 +20,7 @@ #include "hw/cpu/a15mpcore.h" #include "sysemu/kvm.h" +#include "kvm_arm.h" static void a15mp_priv_set_irq(void *opaque, int irq, int level) { @@ -33,16 +34,11 @@ static void a15mp_priv_initfn(Object *obj) SysBusDevice *sbd = SYS_BUS_DEVICE(obj); A15MPPrivState *s = A15MPCORE_PRIV(obj); DeviceState *gicdev; - const char *gictype = "arm_gic"; - - if (kvm_irqchip_in_kernel()) { - gictype = "kvm-arm-gic"; - } memory_region_init(&s->container, obj, "a15mp-priv-container", 0x8000); sysbus_init_mmio(sbd, &s->container); - object_initialize(&s->gic, sizeof(s->gic), gictype); + object_initialize(&s->gic, sizeof(s->gic), gic_class_name()); gicdev = DEVICE(&s->gic); qdev_set_parent_bus(gicdev, sysbus_get_default()); qdev_prop_set_uint32(gicdev, "revision", 2); diff --git a/target-arm/kvm_arm.h b/target-arm/kvm_arm.h index 7912d74..b3e0ab7 100644 --- a/target-arm/kvm_arm.h +++ b/target-arm/kvm_arm.h @@ -191,4 +191,9 @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu); #endif +static inline const char *gic_class_name(void) +{ + return kvm_irqchip_in_kernel() ? "kvm-arm-gic" : "arm_gic"; +} + #endif