hw: Use PFLASH_CFI0{1,2} and TYPE_PFLASH_CFI0{1,2}
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 <armbru@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20190308094610.21210-6-armbru@redhat.com>
This commit is contained in:
parent
e7b6274197
commit
81c7db723e
@ -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,
|
static PFlashCFI01 *ve_pflash_cfi01_register(hwaddr base, const char *name,
|
||||||
DriveInfo *di)
|
DriveInfo *di)
|
||||||
{
|
{
|
||||||
DeviceState *dev = qdev_create(NULL, "cfi.pflash01");
|
DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01);
|
||||||
|
|
||||||
if (di) {
|
if (di) {
|
||||||
qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(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);
|
qdev_init_nofail(dev);
|
||||||
|
|
||||||
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
|
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)
|
static void vexpress_common_init(MachineState *machine)
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "hw/arm/arm.h"
|
#include "hw/arm/arm.h"
|
||||||
#include "hw/arm/primecell.h"
|
#include "hw/arm/primecell.h"
|
||||||
#include "hw/arm/virt.h"
|
#include "hw/arm/virt.h"
|
||||||
|
#include "hw/block/flash.h"
|
||||||
#include "hw/vfio/vfio-calxeda-xgmac.h"
|
#include "hw/vfio/vfio-calxeda-xgmac.h"
|
||||||
#include "hw/vfio/vfio-amd-xgbe.h"
|
#include "hw/vfio/vfio-amd-xgbe.h"
|
||||||
#include "hw/display/ramfb.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.
|
* parameters as the flash devices on the Versatile Express board.
|
||||||
*/
|
*/
|
||||||
DriveInfo *dinfo = drive_get_next(IF_PFLASH);
|
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);
|
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
|
||||||
const uint64_t sectorlength = 256 * 1024;
|
const uint64_t sectorlength = 256 * 1024;
|
||||||
|
|
||||||
|
@ -59,9 +59,6 @@ do { \
|
|||||||
#define DPRINTF(fmt, ...) do { } while (0)
|
#define DPRINTF(fmt, ...) do { } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PFLASH_CFI01(obj) \
|
|
||||||
OBJECT_CHECK(PFlashCFI01, (obj), TYPE_PFLASH_CFI01)
|
|
||||||
|
|
||||||
#define PFLASH_BE 0
|
#define PFLASH_BE 0
|
||||||
#define PFLASH_SECURE 1
|
#define PFLASH_SECURE 1
|
||||||
|
|
||||||
|
@ -57,9 +57,6 @@ do { \
|
|||||||
|
|
||||||
#define PFLASH_LAZY_ROMD_THRESHOLD 42
|
#define PFLASH_LAZY_ROMD_THRESHOLD 42
|
||||||
|
|
||||||
#define PFLASH_CFI02(obj) \
|
|
||||||
OBJECT_CHECK(PFlashCFI02, (obj), TYPE_PFLASH_CFI02)
|
|
||||||
|
|
||||||
struct PFlashCFI02 {
|
struct PFlashCFI02 {
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
SysBusDevice parent_obj;
|
SysBusDevice parent_obj;
|
||||||
|
@ -167,7 +167,7 @@ static PFlashCFI01 *xtfpga_flash_init(MemoryRegion *address_space,
|
|||||||
DriveInfo *dinfo, int be)
|
DriveInfo *dinfo, int be)
|
||||||
{
|
{
|
||||||
SysBusDevice *s;
|
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),
|
qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo),
|
||||||
&error_abort);
|
&error_abort);
|
||||||
@ -181,7 +181,7 @@ static PFlashCFI01 *xtfpga_flash_init(MemoryRegion *address_space,
|
|||||||
s = SYS_BUS_DEVICE(dev);
|
s = SYS_BUS_DEVICE(dev);
|
||||||
memory_region_add_subregion(address_space, board->flash->base,
|
memory_region_add_subregion(address_space, board->flash->base,
|
||||||
sysbus_mmio_get_region(s, 0));
|
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)
|
static uint64_t translate_phys_addr(void *opaque, uint64_t addr)
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
/* pflash_cfi01.c */
|
/* pflash_cfi01.c */
|
||||||
|
|
||||||
#define TYPE_PFLASH_CFI01 "cfi.pflash01"
|
#define TYPE_PFLASH_CFI01 "cfi.pflash01"
|
||||||
|
#define PFLASH_CFI01(obj) \
|
||||||
|
OBJECT_CHECK(PFlashCFI01, (obj), TYPE_PFLASH_CFI01)
|
||||||
|
|
||||||
typedef struct PFlashCFI01 PFlashCFI01;
|
typedef struct PFlashCFI01 PFlashCFI01;
|
||||||
|
|
||||||
@ -25,6 +27,8 @@ MemoryRegion *pflash_cfi01_get_memory(PFlashCFI01 *fl);
|
|||||||
/* pflash_cfi02.c */
|
/* pflash_cfi02.c */
|
||||||
|
|
||||||
#define TYPE_PFLASH_CFI02 "cfi.pflash02"
|
#define TYPE_PFLASH_CFI02 "cfi.pflash02"
|
||||||
|
#define PFLASH_CFI02(obj) \
|
||||||
|
OBJECT_CHECK(PFlashCFI02, (obj), TYPE_PFLASH_CFI02)
|
||||||
|
|
||||||
typedef struct PFlashCFI02 PFlashCFI02;
|
typedef struct PFlashCFI02 PFlashCFI02;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user