From nobody Wed Nov 5 23:06:48 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537528646398339.4685081314643; Fri, 21 Sep 2018 04:17:26 -0700 (PDT) Received: from localhost ([::1]:55124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3JR6-00088v-5k for importer@patchew.org; Fri, 21 Sep 2018 07:17:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3JNz-0005QC-NQ for qemu-devel@nongnu.org; Fri, 21 Sep 2018 07:14:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3JNv-0008Dx-NR for qemu-devel@nongnu.org; Fri, 21 Sep 2018 07:14:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35254) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g3JNv-0008CL-DC for qemu-devel@nongnu.org; Fri, 21 Sep 2018 07:14:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AD4B9C05D3E3; Fri, 21 Sep 2018 11:14:06 +0000 (UTC) Received: from localhost (ovpn-112-64.ams2.redhat.com [10.36.112.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6857D7E6BB; Fri, 21 Sep 2018 11:14:00 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 15:13:32 +0400 Message-Id: <20180921111332.12973-3-marcandre.lureau@redhat.com> In-Reply-To: <20180921111332.12973-1-marcandre.lureau@redhat.com> References: <20180921111332.12973-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 21 Sep 2018 11:14:06 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] nvdimm: use IS_NVDIMM macro 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: Eduardo Habkost , "Michael S. Tsirkin" , Xiao Guangrong , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Igor Mammedov , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Put into use the macros proposed in the previous Object documentation chang= e. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Zhang Yi --- include/hw/mem/nvdimm.h | 1 + hw/acpi/ich9.c | 2 +- hw/acpi/nvdimm.c | 2 +- hw/acpi/piix4.c | 2 +- hw/i386/pc.c | 8 +++----- hw/mem/pc-dimm.c | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index c5c9b3c7f8..e56be1d492 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -47,6 +47,7 @@ #define NVDIMM_CLASS(oc) OBJECT_CLASS_CHECK(NVDIMMClass, (oc), TYPE_NVDIMM) #define NVDIMM_GET_CLASS(obj) OBJECT_GET_CLASS(NVDIMMClass, (obj), \ TYPE_NVDIMM) +#define IS_NVDIMM(obj) object_dynamic_cast(OBJECT(obj), TYPE_NVDIMM) =20 #define NVDIMM_LABEL_SIZE_PROP "label-size" #define NVDIMM_UNARMED_PROP "unarmed" diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index c5d8646abc..b6fd20fd5a 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -490,7 +490,7 @@ void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev= , DeviceState *dev, =20 if (lpc->pm.acpi_memory_hotplug.is_enabled && object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) { + if (IS_NVDIMM(dev)) { nvdimm_acpi_plug_cb(hotplug_dev, dev); } else { acpi_memory_plug_cb(hotplug_dev, &lpc->pm.acpi_memory_hotplug, diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 27eeb6609f..03ba0402af 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -37,7 +37,7 @@ static int nvdimm_device_list(Object *obj, void *opaque) { GSList **list =3D opaque; =20 - if (object_dynamic_cast(obj, TYPE_NVDIMM)) { + if (IS_NVDIMM(obj)) { *list =3D g_slist_append(*list, DEVICE(obj)); } =20 diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index e330f24c71..de1ae0360a 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -377,7 +377,7 @@ static void piix4_device_plug_cb(HotplugHandler *hotplu= g_dev, =20 if (s->acpi_memory_hotplug.is_enabled && object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) { + if (IS_NVDIMM(dev)) { nvdimm_acpi_plug_cb(hotplug_dev, dev); } else { acpi_memory_plug_cb(hotplug_dev, &s->acpi_memory_hotplug, diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 03148450c8..7addf05197 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1680,7 +1680,6 @@ static void pc_memory_pre_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, { const PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); const PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); - const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); const uint64_t legacy_align =3D TARGET_PAGE_SIZE; =20 /* @@ -1694,7 +1693,7 @@ static void pc_memory_pre_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, return; } =20 - if (is_nvdimm && !pcms->acpi_nvdimm_state.is_enabled) { + if (IS_NVDIMM(dev) && !pcms->acpi_nvdimm_state.is_enabled) { error_setg(errp, "nvdimm is not enabled: missing 'nvdimm' in '-M'"= ); return; } @@ -1709,14 +1708,13 @@ static void pc_memory_plug(HotplugHandler *hotplug_= dev, HotplugHandlerClass *hhc; Error *local_err =3D NULL; PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); - bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); =20 pc_dimm_plug(dev, MACHINE(pcms), &local_err); if (local_err) { goto out; } =20 - if (is_nvdimm) { + if (IS_NVDIMM(dev)) { nvdimm_plug(&pcms->acpi_nvdimm_state); } =20 @@ -1744,7 +1742,7 @@ static void pc_memory_unplug_request(HotplugHandler *= hotplug_dev, goto out; } =20 - if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) { + if (IS_NVDIMM(dev)) { error_setg(&local_err, "nvdimm device hot unplug is not supported yet."); goto out; diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index fb6bcaedc4..e25762dbda 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -272,7 +272,7 @@ static void pc_dimm_md_fill_device_info(const MemoryDev= iceState *md, NULL); di->memdev =3D object_get_canonical_path(OBJECT(dimm->hostmem)); =20 - if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) { + if (IS_NVDIMM(dev)) { info->u.nvdimm.data =3D di; info->type =3D MEMORY_DEVICE_INFO_KIND_NVDIMM; } else { --=20 2.19.0