From nobody Sun Nov 9 15:57:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551209825052956.5896038795788; Tue, 26 Feb 2019 11:37:05 -0800 (PST) Received: from localhost ([127.0.0.1]:60234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyiX9-0003dn-Qo for importer@patchew.org; Tue, 26 Feb 2019 14:36:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyiV0-0002IS-E2 for qemu-devel@nongnu.org; Tue, 26 Feb 2019 14:34:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyiUu-0006MK-Oh for qemu-devel@nongnu.org; Tue, 26 Feb 2019 14:34:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49794) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gyiUd-0005x2-C8; Tue, 26 Feb 2019 14:34:21 -0500 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 0C8E269062; Tue, 26 Feb 2019 19:34:13 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9FE365C28E; Tue, 26 Feb 2019 19:34:12 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1C2511133040; Tue, 26 Feb 2019 20:34:08 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 26 Feb 2019 20:34:02 +0100 Message-Id: <20190226193408.23862-6-armbru@redhat.com> In-Reply-To: <20190226193408.23862-1-armbru@redhat.com> References: <20190226193408.23862-1-armbru@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.28]); Tue, 26 Feb 2019 19:34:13 +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 v2 05/11] hw: Use PFLASH_CFI0{1, 2} and TYPE_PFLASH_CFI0{1, 2} 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: kwolf@redhat.com, qemu-block@nongnu.org, alex.bennee@linaro.org, mreitz@redhat.com, qemu-ppc@nongnu.org, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We have two open-coded copies of macro PFLASH_CFI01(). Move the macro to the header, so we can ditch the copies. Move PFLASH_CFI02() to the header for symmetry. We define macros TYPE_PFLASH_CFI01 and TYPE_PFLASH_CFI02 for type name strings, then mostly use the strings. If the macros are worth defining, they are worth using. Replace the strings by the macros. Signed-off-by: Markus Armbruster Reviewed-by: Laszlo Ersek Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e --- hw/arm/vexpress.c | 4 ++-- hw/arm/virt.c | 3 ++- hw/block/pflash_cfi01.c | 3 --- hw/block/pflash_cfi02.c | 3 --- hw/xtensa/xtfpga.c | 4 ++-- include/hw/block/flash.h | 4 ++++ 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index ed46d2e730..f07134c424 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -515,7 +515,7 @@ static void vexpress_modify_dtb(const struct arm_boot_i= nfo *info, void *fdt) static PFlashCFI01 *ve_pflash_cfi01_register(hwaddr base, const char *name, DriveInfo *di) { - DeviceState *dev =3D qdev_create(NULL, "cfi.pflash01"); + DeviceState *dev =3D qdev_create(NULL, TYPE_PFLASH_CFI01); =20 if (di) { qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(di), @@ -536,7 +536,7 @@ static PFlashCFI01 *ve_pflash_cfi01_register(hwaddr bas= e, const char *name, qdev_init_nofail(dev); =20 sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); - return OBJECT_CHECK(PFlashCFI01, (dev), "cfi.pflash01"); + return PFLASH_CFI01(dev); } =20 static void vexpress_common_init(MachineState *machine) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 99c2b6e60d..f2e5fc1ce1 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -34,6 +34,7 @@ #include "hw/arm/arm.h" #include "hw/arm/primecell.h" #include "hw/arm/virt.h" +#include "hw/block/flash.h" #include "hw/vfio/vfio-calxeda-xgmac.h" #include "hw/vfio/vfio-amd-xgbe.h" #include "hw/display/ramfb.h" @@ -874,7 +875,7 @@ static void create_one_flash(const char *name, hwaddr f= lashbase, * parameters as the flash devices on the Versatile Express board. */ DriveInfo *dinfo =3D drive_get_next(IF_PFLASH); - DeviceState *dev =3D qdev_create(NULL, "cfi.pflash01"); + DeviceState *dev =3D qdev_create(NULL, TYPE_PFLASH_CFI01); SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); const uint64_t sectorlength =3D 256 * 1024; =20 diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index f75f0a6998..1c99aa6e4a 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -59,9 +59,6 @@ do { = \ #define DPRINTF(fmt, ...) do { } while (0) #endif =20 -#define PFLASH_CFI01(obj) \ - OBJECT_CHECK(PFlashCFI01, (obj), TYPE_PFLASH_CFI01) - #define PFLASH_BE 0 #define PFLASH_SECURE 1 =20 diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index c0869fc417..5ef40154b9 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -57,9 +57,6 @@ do { = \ =20 #define PFLASH_LAZY_ROMD_THRESHOLD 42 =20 -#define PFLASH_CFI02(obj) \ - OBJECT_CHECK(PFlashCFI02, (obj), TYPE_PFLASH_CFI02) - struct PFlashCFI02 { /*< private >*/ SysBusDevice parent_obj; diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 3d59a7a356..e05ef75a75 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -167,7 +167,7 @@ static PFlashCFI01 *xtfpga_flash_init(MemoryRegion *add= ress_space, DriveInfo *dinfo, int be) { SysBusDevice *s; - DeviceState *dev =3D qdev_create(NULL, "cfi.pflash01"); + DeviceState *dev =3D qdev_create(NULL, TYPE_PFLASH_CFI01); =20 qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo), &error_abort); @@ -181,7 +181,7 @@ static PFlashCFI01 *xtfpga_flash_init(MemoryRegion *add= ress_space, s =3D SYS_BUS_DEVICE(dev); memory_region_add_subregion(address_space, board->flash->base, sysbus_mmio_get_region(s, 0)); - return OBJECT_CHECK(PFlashCFI01, (dev), "cfi.pflash01"); + return PFLASH_CFI01(dev); } =20 static uint64_t translate_phys_addr(void *opaque, uint64_t addr) diff --git a/include/hw/block/flash.h b/include/hw/block/flash.h index 333005d9ff..aeea3ca99d 100644 --- a/include/hw/block/flash.h +++ b/include/hw/block/flash.h @@ -8,6 +8,8 @@ /* pflash_cfi01.c */ =20 #define TYPE_PFLASH_CFI01 "cfi.pflash01" +#define PFLASH_CFI01(obj) \ + OBJECT_CHECK(PFlashCFI01, (obj), TYPE_PFLASH_CFI01) =20 typedef struct PFlashCFI01 PFlashCFI01; =20 @@ -25,6 +27,8 @@ MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl); /* pflash_cfi02.c */ =20 #define TYPE_PFLASH_CFI02 "cfi.pflash02" +#define PFLASH_CFI02(obj) \ + OBJECT_CHECK(PFlashCFI02, (obj), TYPE_PFLASH_CFI02) =20 typedef struct PFlashCFI02 PFlashCFI02; =20 --=20 2.17.2