[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/27] hw: Use PFLASH_CFI0{1, 2} and TYPE_PFLASH_CFI0
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 05/27] hw: Use PFLASH_CFI0{1, 2} and TYPE_PFLASH_CFI0{1, 2} |
Date: |
Mon, 11 Mar 2019 23:08:21 +0100 |
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 <address@hidden>
Reviewed-by: Laszlo Ersek <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
Message-Id: <address@hidden>
---
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_info
*info, void *fdt)
static PFlashCFI01 *ve_pflash_cfi01_register(hwaddr base, const char *name,
DriveInfo *di)
{
- DeviceState *dev = qdev_create(NULL, "cfi.pflash01");
+ DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01);
if (di) {
qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(di),
@@ -536,7 +536,7 @@ static PFlashCFI01 *ve_pflash_cfi01_register(hwaddr base,
const char *name,
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
- return OBJECT_CHECK(PFlashCFI01, (dev), "cfi.pflash01");
+ return PFLASH_CFI01(dev);
}
static void vexpress_common_init(MachineState *machine)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 7f66ddad89..1e8485ff7c 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -35,6 +35,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"
@@ -878,7 +879,7 @@ static void create_one_flash(const char *name, hwaddr
flashbase,
* parameters as the flash devices on the Versatile Express board.
*/
DriveInfo *dinfo = drive_get_next(IF_PFLASH);
- DeviceState *dev = qdev_create(NULL, "cfi.pflash01");
+ DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01);
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
const uint64_t sectorlength = 256 * 1024;
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
-#define PFLASH_CFI01(obj) \
- OBJECT_CHECK(PFlashCFI01, (obj), TYPE_PFLASH_CFI01)
-
#define PFLASH_BE 0
#define PFLASH_SECURE 1
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index 933de99d6a..915c6171a0 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -57,9 +57,6 @@ do { \
#define PFLASH_LAZY_ROMD_THRESHOLD 42
-#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
*address_space,
DriveInfo *dinfo, int be)
{
SysBusDevice *s;
- DeviceState *dev = qdev_create(NULL, "cfi.pflash01");
+ DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01);
qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo),
&error_abort);
@@ -181,7 +181,7 @@ static PFlashCFI01 *xtfpga_flash_init(MemoryRegion
*address_space,
s = 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);
}
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 */
#define TYPE_PFLASH_CFI01 "cfi.pflash01"
+#define PFLASH_CFI01(obj) \
+ OBJECT_CHECK(PFlashCFI01, (obj), TYPE_PFLASH_CFI01)
typedef struct PFlashCFI01 PFlashCFI01;
@@ -25,6 +27,8 @@ MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl);
/* pflash_cfi02.c */
#define TYPE_PFLASH_CFI02 "cfi.pflash02"
+#define PFLASH_CFI02(obj) \
+ OBJECT_CHECK(PFlashCFI02, (obj), TYPE_PFLASH_CFI02)
typedef struct PFlashCFI02 PFlashCFI02;
--
2.17.2
- [Qemu-devel] [PULL 00/27] Pflash and firmware configuration patches for 2019-03-11, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 02/27] pflash_cfi01: Do not exit() on guest aborting "write to buffer", Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 10/27] mips_malta: Delete disabled, broken DEBUG_BOARD_INIT code, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 03/27] pflash_cfi01: Log use of flawed "write to buffer", Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 01/27] pflash: Rename pflash_t to PFlashCFI01, PFlashCFI02, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 09/27] r2d: Fix flash memory size, sector size, width, device ID, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 06/27] sam460ex: Don't size flash memory to match backing image, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 08/27] ppc405_boards: Don't size flash memory to match backing image, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 20/27] vl: Improve legibility of BlockdevOptions queue, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 16/27] qdev: Fix latent bug with compat_props and onboard devices, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 05/27] hw: Use PFLASH_CFI0{1, 2} and TYPE_PFLASH_CFI0{1, 2},
Markus Armbruster <=
- [Qemu-devel] [PULL 24/27] pc_sysfw: Remove unused PcSysFwDevice, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 17/27] qom: Move compat_props machinery from qdev to QOM, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 04/27] pflash: Rename *CFI_PFLASH* to *PFLASH_CFI*, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 11/27] hw/mips/malta: Remove fl_sectors variable, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 19/27] sysbus: Fix latent bug with onboard devices, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 12/27] hw/mips/malta: Restrict 'bios_size' variable scope, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 07/27] ppc405_boards: Delete stale, disabled DEBUG_BOARD_INIT code, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 21/27] vl: Factor configure_blockdev() out of main(), Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 26/27] pc: Support firmware configuration with -blockdev, Markus Armbruster, 2019/03/11