From nobody Tue Feb 10 12:58:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507580033777279.5707645711831; Mon, 9 Oct 2017 13:13:53 -0700 (PDT) Received: from localhost ([::1]:59653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1eQo-0003rK-NH for importer@patchew.org; Mon, 09 Oct 2017 16:13:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1e5e-0003i8-E7 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1e5d-0006fT-Dj for qemu-devel@nongnu.org; Mon, 09 Oct 2017 15:51:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37612) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1e5d-0006ex-4j; Mon, 09 Oct 2017 15:51:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C2E5820ED; Mon, 9 Oct 2017 19:51:48 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id C44415C684; Mon, 9 Oct 2017 19:51:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1C2E5820ED Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 9 Oct 2017 21:51:08 +0200 Message-Id: <1507578671-158758-22-git-send-email-imammedo@redhat.com> In-Reply-To: <1507578671-158758-1-git-send-email-imammedo@redhat.com> References: <1507578671-158758-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 09 Oct 2017 19:51:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 21/24] ppc: pnv: drop PnvCoreClass::cpu_oc field X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:ppce500" , "Edgar E. Iglesias" , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" deduce cpu type directly from core type instead of maintaining type mapping in PnvCoreClass::cpu_oc and doing extra cpu_model parsing in pnv_core_class_init() Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- v2: - fix typo: s/pvn_core_cpu_typename/pnv_core_cpu_typename/ --- include/hw/ppc/pnv_core.h | 1 - hw/ppc/pnv_core.c | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h index 3360c4b..a336a1f 100644 --- a/include/hw/ppc/pnv_core.h +++ b/include/hw/ppc/pnv_core.h @@ -42,7 +42,6 @@ typedef struct PnvCore { =20 typedef struct PnvCoreClass { DeviceClass parent_class; - ObjectClass *cpu_oc; } PnvCoreClass; =20 #define PNV_CORE_TYPE_SUFFIX "-" TYPE_PNV_CORE diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index b3e3f23..bd7f2c9 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -27,6 +27,16 @@ #include "hw/ppc/pnv_xscom.h" #include "hw/ppc/xics.h" =20 +static const char *pnv_core_cpu_typename(PnvCore *pc) +{ + const char *core_type =3D object_class_get_name(object_get_class(OBJEC= T(pc))); + int len =3D strlen(core_type) - strlen(PNV_CORE_TYPE_SUFFIX); + char *s =3D g_strdup_printf(POWERPC_CPU_TYPE_NAME("%.*s"), len, core_t= ype); + const char *cpu_type =3D object_class_get_name(object_class_by_name(s)= ); + g_free(s); + return cpu_type; +} + static void powernv_cpu_reset(void *opaque) { PowerPCCPU *cpu =3D opaque; @@ -148,8 +158,7 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) { PnvCore *pc =3D PNV_CORE(OBJECT(dev)); CPUCore *cc =3D CPU_CORE(OBJECT(dev)); - PnvCoreClass *pcc =3D PNV_CORE_GET_CLASS(OBJECT(dev)); - const char *typename =3D object_class_get_name(pcc->cpu_oc); + const char *typename =3D pnv_core_cpu_typename(pc); size_t size =3D object_type_get_instance_size(typename); Error *local_err =3D NULL; void *obj; @@ -211,11 +220,9 @@ static Property pnv_core_properties[] =3D { static void pnv_core_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); - PnvCoreClass *pcc =3D PNV_CORE_CLASS(oc); =20 dc->realize =3D pnv_core_realize; dc->props =3D pnv_core_properties; - pcc->cpu_oc =3D cpu_class_by_name(TYPE_POWERPC_CPU, data); } =20 static const TypeInfo pnv_core_info =3D { @@ -223,6 +230,7 @@ static const TypeInfo pnv_core_info =3D { .parent =3D TYPE_CPU_CORE, .instance_size =3D sizeof(PnvCore), .class_size =3D sizeof(PnvCoreClass), + .class_init =3D pnv_core_class_init, .abstract =3D true, }; =20 @@ -239,8 +247,6 @@ static void pnv_core_register_types(void) TypeInfo ti =3D { .parent =3D TYPE_PNV_CORE, .instance_size =3D sizeof(PnvCore), - .class_init =3D pnv_core_class_init, - .class_data =3D (void *) pnv_core_models[i], }; ti.name =3D pnv_core_typename(pnv_core_models[i]); type_register(&ti); --=20 2.7.4