From patchwork Wed Aug 5 07:05:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Fedin X-Patchwork-Id: 503905 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2C0741402C7 for ; Wed, 5 Aug 2015 17:07:43 +1000 (AEST) Received: from localhost ([::1]:39372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMsnd-0000PN-9T for incoming@patchwork.ozlabs.org; Wed, 05 Aug 2015 03:07:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMslw-0005qW-Tk for qemu-devel@nongnu.org; Wed, 05 Aug 2015 03:05:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMslr-00046i-7h for qemu-devel@nongnu.org; Wed, 05 Aug 2015 03:05:56 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:40881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMslr-00045f-2F for qemu-devel@nongnu.org; Wed, 05 Aug 2015 03:05:51 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NSL00APDL1PSZ60@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Wed, 05 Aug 2015 08:05:49 +0100 (BST) X-AuditID: cbfec7f5-f794b6d000001495-25-55c1b5cdd59c Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id A7.83.05269.DC5B1C55; Wed, 5 Aug 2015 08:05:49 +0100 (BST) Received: from localhost ([106.109.131.169]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NSL00JP4L1PAO70@eusync2.samsung.com>; Wed, 05 Aug 2015 08:05:49 +0100 (BST) From: Pavel Fedin To: qemu-devel@nongnu.org Date: Wed, 05 Aug 2015 10:05:46 +0300 Message-id: <4f26901be9b844b563673ce3ad08eeedbb7a7132.1438758065.git.p.fedin@samsung.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-reply-to: References: In-reply-to: References: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplluLIzCtJLcpLzFFi42I5/e/4Fd2zWw+GGhzpUrR48fofo8X8LWdY LeacecBicbx3B4sDi8eda3vYPJ5c28wUwBTFZZOSmpNZllqkb5fAlfH8/h7WgosiFdsetLE0 MJ4T6GLk5JAQMJF4OeEDG4QtJnHh3nowW0hgKaPEmp+qXYxcQPY3RonbD54zgSTYBNQlTn/9 wAJiiwhISvzuOs0MUsQs0MIo8XPvPWaQhLBAsETDzTtgk1gEVCVO3ToJZvMKREv8vdzCDrFN Q2LRlzlgcU4Bc4mDK36zdjFyAG0zk1i2wAWH8ARG/gWMDKsYRVNLkwuKk9JzjfSKE3OLS/PS 9ZLzczcxQgLp6w7GpcesDjEKcDAq8fB6uB0MFWJNLCuuzD3EKMHBrCTCmzYBKMSbklhZlVqU H19UmpNafIhRmoNFSZx35q73IUIC6YklqdmpqQWpRTBZJg5OqQZGOcMb4s9nTm/e3/z1guzE ybe8zrDkTf6p6H2gS+qP7Ka7YtMuhoV+W6stI/l9t5ul17mXTL9j68+9tFj2g4/71MvN8W0i B0p+6eV/YtM/cTJpzVvuqpCp59oShZZLu01auPNaiLJ4zGXrublfH2jPWpxXxXTbTtup79/S mp2TL3OKLZwiW5uRpcRSnJFoqMVcVJwIABGzDO8gAgAA X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 210.118.77.14 Cc: Peter Maydell , Christoffer Dall , Eric Auger Subject: [Qemu-devel] [PATCH v2 3/3] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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 4846892..943e523 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -48,6 +48,7 @@ #include "hw/arm/sysbus-fdt.h" #include "hw/platform-bus.h" #include "hw/arm/fdt.h" +#include "kvm_arm.h" /* Number of external interrupt lines to configure the GIC with */ #define NUM_IRQS 256 @@ -365,12 +366,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