From patchwork Wed Jul 29 11:54:44 2015
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pavel Fedin
X-Patchwork-Id: 501674
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 B435A14030E
for ;
Wed, 29 Jul 2015 21:55:28 +1000 (AEST)
Received: from localhost ([::1]:34745 helo=lists.gnu.org)
by lists.gnu.org with esmtp (Exim 4.71) (envelope-from
)
id 1ZKPxG-0005cS-MN
for incoming@patchwork.ozlabs.org; Wed, 29 Jul 2015 07:55:26 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:38254)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1ZKPwh-0004b9-AN
for qemu-devel@nongnu.org; Wed, 29 Jul 2015 07:54:52 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from ) id 1ZKPwg-00042n-5p
for qemu-devel@nongnu.org; Wed, 29 Jul 2015 07:54:51 -0400
Received: from mailout3.w1.samsung.com ([210.118.77.13]:32678)
by eggs.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1ZKPwg-00042V-09
for qemu-devel@nongnu.org; Wed, 29 Jul 2015 07:54:50 -0400
Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245])
by mailout3.w1.samsung.com
(Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5
2014)) with ESMTP id <0NS800GZ1ZRC4H40@mailout3.w1.samsung.com> for
qemu-devel@nongnu.org; Wed, 29 Jul 2015 12:54:48 +0100 (BST)
X-AuditID: cbfec7f5-f794b6d000001495-55-55b8bf08db36
Received: from eusync3.samsung.com ( [203.254.199.213])
by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 20.ED.05269.80FB8B55;
Wed, 29 Jul 2015 12:54:48 +0100 (BST)
Received: from localhost ([106.109.131.169])
by eusync3.samsung.com (Oracle Communications Messaging Server
7.0.5.31.0 64bit (built May 5 2014))
with ESMTPA id <0NS800AQSZRB4720@eusync3.samsung.com>; Wed,
29 Jul 2015 12:54:48 +0100 (BST)
From: Pavel Fedin
To: qemu-devel@nongnu.org
Date: Wed, 29 Jul 2015 14:54:44 +0300
Message-id:
<782dce2edcfae8270985249146ebe79671ad9385.1438170554.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+NgFupnluLIzCtJLcpLzFFi42I5/e/4VV2O/TtCDVbsMLJ48fofo8X8LWdY
LeacecBicbx3B4sDi8eda3vYPJ5c28wUwBTFZZOSmpNZllqkb5fAlXF1yxqWglkiFa/ufmFv
YJwj0MXIySEhYCLR+KCVGcIWk7hwbz1bFyMXh5DAUkaJvncHmCGcb4wSOxYsAqtiE1CXOP31
AwuILSIgKfG76zRYEbNAC6PEz733wIqEBfwk/vbsYgKxWQRUJRq+zACKc3DwCkRLHP3oAbFN
Q2LRlzlsIDangLnE6c7zYDOFBMwkLn/5wI5LfAIj/wJGhlWMoqmlyQXFSem5RnrFibnFpXnp
esn5uZsYIcH0dQfj0mNWhxgFOBiVeHhn6OwIFWJNLCuuzD3EKMHBrCTCGzQDKMSbklhZlVqU
H19UmpNafIhRmoNFSZx35q73IUIC6YklqdmpqQWpRTBZJg5OqQbGS/GHc9+EixsX6J6qWiPI
0RhTXMW9/fb/ZOkfF3xl2Io3qsq+LFmxUfmCnd73h7u+n+9+nemQUxLcfu3wjwcCy4zn6+8z
7u96c1jT4o7bkjuzsh94nWnfrbLwwMb0Oy1bX6/QPXT1+sXn353Mb87cyjsxpOQup8usU/lr
e7fc3ZXZdl8hqM7uuBJLcUaioRZzUXEiAM7ino0iAgAA
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
recognized.
X-Received-From: 210.118.77.13
Cc: Peter Maydell ,
Christoffer Dall ,
Eric Auger
Subject: [Qemu-devel] [PATCH 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