From ce14710f4fdfca32123d7efd3ddcbee984ef0ae5 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 8 Mar 2019 10:46:10 +0100 Subject: pflash: Clean up after commit 368a354f02b, part 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our pflash devices are simplistically modelled has having "num-blocks" sectors of equal size "sector-length". Real hardware commonly has sectors of different sizes. How our "sector-length" property is related to the physical device's multiple sector sizes is unclear. Helper functions pflash_cfi01_register() and pflash_cfi02_register() create a pflash device, set properties including "sector-length" and "num-blocks", and realize. They take parameters @size, @sector_len and @nb_blocs. QOMification left parameter @size unused. Obviously, @size should match @sector_len and @nb_blocs, i.e. size == sector_len * nb_blocs. All callers satisfy this. Remove @nb_blocs and compute it from @size and @sector_len. Signed-off-by: Markus Armbruster Reviewed-by: Laszlo Ersek Reviewed-by: Alex Bennée Message-Id: <20190308094610.21210-16-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé --- hw/i386/pc_sysfw.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'hw/i386') diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 9a5be54a85..34727c5b1f 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -110,16 +110,13 @@ static void pc_system_flash_init(MemoryRegion *rom_memory) int64_t size; char *fatal_errmsg = NULL; hwaddr phys_addr = 0x100000000ULL; - int sector_bits, sector_size; + uint32_t sector_size = 4096; PFlashCFI01 *system_flash; MemoryRegion *flash_mem; char name[64]; void *flash_ptr; int ret, flash_size; - sector_bits = 12; - sector_size = 1 << sector_bits; - for (unit = 0; (unit < FLASH_MAP_UNIT_MAX && (pflash_drv = drive_get(IF_PFLASH, 0, unit)) != NULL); @@ -162,7 +159,6 @@ static void pc_system_flash_init(MemoryRegion *rom_memory) snprintf(name, sizeof name, "system.flash%d", unit); system_flash = pflash_cfi01_register(phys_addr, name, size, blk, sector_size, - size >> sector_bits, 1 /* width */, 0x0000 /* id0 */, 0x0000 /* id1 */, -- cgit v1.2.3