Blame SOURCES/kvm-pflash-Clean-up-after-commit-368a354f02b-part-2.patch

7711c0
From b64a99d86f7f10387f207b3fc52d04b6f1f0a818 Mon Sep 17 00:00:00 2001
7711c0
From: Markus Armbruster <armbru@redhat.com>
7711c0
Date: Fri, 17 May 2019 06:51:06 +0200
7711c0
Subject: [PATCH 39/53] pflash: Clean up after commit 368a354f02b, part 2
7711c0
MIME-Version: 1.0
7711c0
Content-Type: text/plain; charset=UTF-8
7711c0
Content-Transfer-Encoding: 8bit
7711c0
7711c0
RH-Author: Markus Armbruster <armbru@redhat.com>
7711c0
Message-id: <20190517065120.12028-18-armbru@redhat.com>
7711c0
Patchwork-id: 88006
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v3 17/31] pflash: Clean up after commit 368a354f02b, part 2
7711c0
Bugzilla: 1624009
7711c0
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7711c0
RH-Acked-by: Thomas Huth <thuth@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
Our pflash devices are simplistically modelled has having
7711c0
"num-blocks" sectors of equal size "sector-length".  Real hardware
7711c0
commonly has sectors of different sizes.  How our "sector-length"
7711c0
property is related to the physical device's multiple sector sizes
7711c0
is unclear.
7711c0
7711c0
Helper functions pflash_cfi01_register() and pflash_cfi02_register()
7711c0
create a pflash device, set properties including "sector-length" and
7711c0
"num-blocks", and realize.  They take parameters @size, @sector_len
7711c0
and @nb_blocs.
7711c0
7711c0
QOMification left parameter @size unused.  Obviously, @size should
7711c0
match @sector_len and @nb_blocs, i.e. size == sector_len * nb_blocs.
7711c0
All callers satisfy this.
7711c0
7711c0
Remove @nb_blocs and compute it from @size and @sector_len.
7711c0
7711c0
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7711c0
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
7711c0
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7711c0
Message-Id: <20190308094610.21210-16-armbru@redhat.com>
7711c0
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7711c0
(cherry picked from commit ce14710f4fdfca32123d7efd3ddcbee984ef0ae5)
7711c0
[Trivial conflicts in hw/microblaze/petalogix_ml605_mmu.c,
7711c0
hw/microblaze/petalogix_s3adsp1800_mmu.c, and hw/ppc/virtex_ml507.c
7711c0
due to lack of commit ab3dd749241.  Trivial conflict in
7711c0
hw/ppc/sam460ex.c due to lack of commit 371b74e2215.]
7711c0
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 hw/arm/collie.c                          | 5 +++--
7711c0
 hw/arm/digic_boards.c                    | 1 -
7711c0
 hw/arm/gumstix.c                         | 6 ++----
7711c0
 hw/arm/mainstone.c                       | 3 +--
7711c0
 hw/arm/musicpal.c                        | 4 ++--
7711c0
 hw/arm/omap_sx1.c                        | 6 ++----
7711c0
 hw/arm/versatilepb.c                     | 1 -
7711c0
 hw/arm/xilinx_zynq.c                     | 5 ++---
7711c0
 hw/arm/z2.c                              | 3 +--
7711c0
 hw/block/pflash_cfi01.c                  | 5 +++--
7711c0
 hw/block/pflash_cfi02.c                  | 5 +++--
7711c0
 hw/i386/pc_sysfw.c                       | 6 +-----
7711c0
 hw/lm32/lm32_boards.c                    | 4 ++--
7711c0
 hw/lm32/milkymist.c                      | 3 +--
7711c0
 hw/microblaze/petalogix_ml605_mmu.c      | 3 +--
7711c0
 hw/microblaze/petalogix_s3adsp1800_mmu.c | 3 +--
7711c0
 hw/mips/mips_malta.c                     | 2 +-
7711c0
 hw/mips/mips_r4k.c                       | 3 +--
7711c0
 hw/ppc/ppc405_boards.c                   | 6 +++---
7711c0
 hw/ppc/sam460ex.c                        | 5 ++---
7711c0
 hw/ppc/virtex_ml507.c                    | 3 +--
7711c0
 hw/sh4/r2d.c                             | 3 +--
7711c0
 include/hw/block/flash.h                 | 4 ++--
7711c0
 23 files changed, 36 insertions(+), 53 deletions(-)
7711c0
7711c0
diff --git a/hw/arm/collie.c b/hw/arm/collie.c
7711c0
index 9cf4538..29cacd8 100644
7711c0
--- a/hw/arm/collie.c
7711c0
+++ b/hw/arm/collie.c
7711c0
@@ -9,6 +9,7 @@
7711c0
  * GNU GPL, version 2 or (at your option) any later version.
7711c0
  */
7711c0
 #include "qemu/osdep.h"
7711c0
+#include "qemu/units.h"
7711c0
 #include "hw/hw.h"
7711c0
 #include "hw/sysbus.h"
7711c0
 #include "hw/boards.h"
7711c0
@@ -39,12 +40,12 @@ static void collie_init(MachineState *machine)
7711c0
     dinfo = drive_get(IF_PFLASH, 0, 0);
7711c0
     pflash_cfi01_register(SA_CS0, "collie.fl1", 0x02000000,
7711c0
                     dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                    (64 * 1024), 512, 4, 0x00, 0x00, 0x00, 0x00, 0);
7711c0
+                    64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0);
7711c0
 
7711c0
     dinfo = drive_get(IF_PFLASH, 0, 1);
7711c0
     pflash_cfi01_register(SA_CS1, "collie.fl2", 0x02000000,
7711c0
                     dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                    (64 * 1024), 512, 4, 0x00, 0x00, 0x00, 0x00, 0);
7711c0
+                    64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0);
7711c0
 
7711c0
     sysbus_create_simple("scoop", 0x40800000, NULL);
7711c0
 
7711c0
diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c
7711c0
index 15a00a1..304e4d1 100644
7711c0
--- a/hw/arm/digic_boards.c
7711c0
+++ b/hw/arm/digic_boards.c
7711c0
@@ -131,7 +131,6 @@ static void digic4_add_k8p3215uqb_rom(DigicBoardState *s, hwaddr addr,
7711c0
 
7711c0
     pflash_cfi02_register(addr, "pflash", FLASH_K8P3215UQB_SIZE,
7711c0
                           NULL, FLASH_K8P3215UQB_SECTOR_SIZE,
7711c0
-                          FLASH_K8P3215UQB_SIZE / FLASH_K8P3215UQB_SECTOR_SIZE,
7711c0
                           DIGIC4_ROM_MAX_SIZE / FLASH_K8P3215UQB_SIZE,
7711c0
                           4,
7711c0
                           0x00EC, 0x007E, 0x0003, 0x0001,
7711c0
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
7711c0
index 68a0376..03f6ef0 100644
7711c0
--- a/hw/arm/gumstix.c
7711c0
+++ b/hw/arm/gumstix.c
7711c0
@@ -75,8 +75,7 @@ static void connex_init(MachineState *machine)
7711c0
 #endif
7711c0
     if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
7711c0
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                               sector_len, connex_rom / sector_len,
7711c0
-                               2, 0, 0, 0, 0, be)) {
7711c0
+                               sector_len, 2, 0, 0, 0, 0, be)) {
7711c0
         error_report("Error registering flash memory");
7711c0
         exit(1);
7711c0
     }
7711c0
@@ -112,8 +111,7 @@ static void verdex_init(MachineState *machine)
7711c0
 #endif
7711c0
     if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
7711c0
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                               sector_len, verdex_rom / sector_len,
7711c0
-                               2, 0, 0, 0, 0, be)) {
7711c0
+                               sector_len, 2, 0, 0, 0, 0, be)) {
7711c0
         error_report("Error registering flash memory");
7711c0
         exit(1);
7711c0
     }
7711c0
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
7711c0
index cb1116b..62cca6a 100644
7711c0
--- a/hw/arm/mainstone.c
7711c0
+++ b/hw/arm/mainstone.c
7711c0
@@ -153,8 +153,7 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
7711c0
                                    i ? "mainstone.flash1" : "mainstone.flash0",
7711c0
                                    MAINSTONE_FLASH,
7711c0
                                    blk_by_legacy_dinfo(dinfo),
7711c0
-                                   sector_len, MAINSTONE_FLASH / sector_len,
7711c0
-                                   4, 0, 0, 0, 0, be)) {
7711c0
+                                   sector_len, 4, 0, 0, 0, 0, be)) {
7711c0
             error_report("Error registering flash memory");
7711c0
             exit(1);
7711c0
         }
7711c0
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
7711c0
index fd7a7a9..bf8062b 100644
7711c0
--- a/hw/arm/musicpal.c
7711c0
+++ b/hw/arm/musicpal.c
7711c0
@@ -1639,14 +1639,14 @@ static void musicpal_init(MachineState *machine)
7711c0
 #ifdef TARGET_WORDS_BIGENDIAN
7711c0
         pflash_cfi02_register(0x100000000ULL - MP_FLASH_SIZE_MAX,
7711c0
                               "musicpal.flash", flash_size,
7711c0
-                              blk, 0x10000, (flash_size + 0xffff) >> 16,
7711c0
+                              blk, 0x10000,
7711c0
                               MP_FLASH_SIZE_MAX / flash_size,
7711c0
                               2, 0x00BF, 0x236D, 0x0000, 0x0000,
7711c0
                               0x5555, 0x2AAA, 1);
7711c0
 #else
7711c0
         pflash_cfi02_register(0x100000000ULL - MP_FLASH_SIZE_MAX,
7711c0
                               "musicpal.flash", flash_size,
7711c0
-                              blk, 0x10000, (flash_size + 0xffff) >> 16,
7711c0
+                              blk, 0x10000,
7711c0
                               MP_FLASH_SIZE_MAX / flash_size,
7711c0
                               2, 0x00BF, 0x236D, 0x0000, 0x0000,
7711c0
                               0x5555, 0x2AAA, 0);
7711c0
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
7711c0
index a7a3e7d..082d811 100644
7711c0
--- a/hw/arm/omap_sx1.c
7711c0
+++ b/hw/arm/omap_sx1.c
7711c0
@@ -156,8 +156,7 @@ static void sx1_init(MachineState *machine, const int version)
7711c0
         if (!pflash_cfi01_register(OMAP_CS0_BASE,
7711c0
                                    "omap_sx1.flash0-1", flash_size,
7711c0
                                    blk_by_legacy_dinfo(dinfo),
7711c0
-                                   sector_size, flash_size / sector_size,
7711c0
-                                   4, 0, 0, 0, 0, be)) {
7711c0
+                                   sector_size, 4, 0, 0, 0, 0, be)) {
7711c0
             fprintf(stderr, "qemu: Error registering flash memory %d.\n",
7711c0
                            fl_idx);
7711c0
         }
7711c0
@@ -180,8 +179,7 @@ static void sx1_init(MachineState *machine, const int version)
7711c0
         if (!pflash_cfi01_register(OMAP_CS1_BASE,
7711c0
                                    "omap_sx1.flash1-1", flash1_size,
7711c0
                                    blk_by_legacy_dinfo(dinfo),
7711c0
-                                   sector_size, flash1_size / sector_size,
7711c0
-                                   4, 0, 0, 0, 0, be)) {
7711c0
+                                   sector_size, 4, 0, 0, 0, 0, be)) {
7711c0
             fprintf(stderr, "qemu: Error registering flash memory %d.\n",
7711c0
                            fl_idx);
7711c0
         }
7711c0
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
7711c0
index 99d8ff9..acb408d 100644
7711c0
--- a/hw/arm/versatilepb.c
7711c0
+++ b/hw/arm/versatilepb.c
7711c0
@@ -362,7 +362,6 @@ static void versatile_init(MachineState *machine, int board_id)
7711c0
                           VERSATILE_FLASH_SIZE,
7711c0
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
                           VERSATILE_FLASH_SECT_SIZE,
7711c0
-                          VERSATILE_FLASH_SIZE / VERSATILE_FLASH_SECT_SIZE,
7711c0
                           4, 0x0089, 0x0018, 0x0000, 0x0, 0)) {
7711c0
         fprintf(stderr, "qemu: Error registering flash memory.\n");
7711c0
     }
7711c0
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
7711c0
index 4a05e1c..3234cf6 100644
7711c0
--- a/hw/arm/xilinx_zynq.c
7711c0
+++ b/hw/arm/xilinx_zynq.c
7711c0
@@ -208,10 +208,9 @@ static void zynq_init(MachineState *machine)
7711c0
     /* AMD */
7711c0
     pflash_cfi02_register(0xe2000000, "zynq.pflash", FLASH_SIZE,
7711c0
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                          FLASH_SECTOR_SIZE,
7711c0
-                          FLASH_SIZE/FLASH_SECTOR_SIZE, 1,
7711c0
+                          FLASH_SECTOR_SIZE, 1,
7711c0
                           1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa,
7711c0
-                              0);
7711c0
+                          0);
7711c0
 
7711c0
     dev = qdev_create(NULL, "xilinx,zynq_slcr");
7711c0
     qdev_init_nofail(dev);
7711c0
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
7711c0
index f5f1903..394e7a8 100644
7711c0
--- a/hw/arm/z2.c
7711c0
+++ b/hw/arm/z2.c
7711c0
@@ -327,8 +327,7 @@ static void z2_init(MachineState *machine)
7711c0
 
7711c0
     if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
7711c0
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                               sector_len, Z2_FLASH_SIZE / sector_len,
7711c0
-                               4, 0, 0, 0, 0, be)) {
7711c0
+                               sector_len, 4, 0, 0, 0, 0, be)) {
7711c0
         error_report("Error registering flash memory");
7711c0
         exit(1);
7711c0
     }
7711c0
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
7711c0
index 31926e2..0101127 100644
7711c0
--- a/hw/block/pflash_cfi01.c
7711c0
+++ b/hw/block/pflash_cfi01.c
7711c0
@@ -953,7 +953,7 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base,
7711c0
                                    const char *name,
7711c0
                                    hwaddr size,
7711c0
                                    BlockBackend *blk,
7711c0
-                                   uint32_t sector_len, int nb_blocs,
7711c0
+                                   uint32_t sector_len,
7711c0
                                    int bank_width,
7711c0
                                    uint16_t id0, uint16_t id1,
7711c0
                                    uint16_t id2, uint16_t id3,
7711c0
@@ -964,7 +964,8 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base,
7711c0
     if (blk) {
7711c0
         qdev_prop_set_drive(dev, "drive", blk, &error_abort);
7711c0
     }
7711c0
-    qdev_prop_set_uint32(dev, "num-blocks", nb_blocs);
7711c0
+    assert(size % sector_len == 0);
7711c0
+    qdev_prop_set_uint32(dev, "num-blocks", size / sector_len);
7711c0
     qdev_prop_set_uint64(dev, "sector-length", sector_len);
7711c0
     qdev_prop_set_uint8(dev, "width", bank_width);
7711c0
     qdev_prop_set_bit(dev, "big-endian", !!be);
7711c0
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
7711c0
index 8c6c6e1..31b2e6c 100644
7711c0
--- a/hw/block/pflash_cfi02.c
7711c0
+++ b/hw/block/pflash_cfi02.c
7711c0
@@ -789,7 +789,7 @@ PFlashCFI02 *pflash_cfi02_register(hwaddr base,
7711c0
                                    const char *name,
7711c0
                                    hwaddr size,
7711c0
                                    BlockBackend *blk,
7711c0
-                                   uint32_t sector_len, int nb_blocs,
7711c0
+                                   uint32_t sector_len,
7711c0
                                    int nb_mappings, int width,
7711c0
                                    uint16_t id0, uint16_t id1,
7711c0
                                    uint16_t id2, uint16_t id3,
7711c0
@@ -802,7 +802,8 @@ PFlashCFI02 *pflash_cfi02_register(hwaddr base,
7711c0
     if (blk) {
7711c0
         qdev_prop_set_drive(dev, "drive", blk, &error_abort);
7711c0
     }
7711c0
-    qdev_prop_set_uint32(dev, "num-blocks", nb_blocs);
7711c0
+    assert(size % sector_len == 0);
7711c0
+    qdev_prop_set_uint32(dev, "num-blocks", size / sector_len);
7711c0
     qdev_prop_set_uint32(dev, "sector-length", sector_len);
7711c0
     qdev_prop_set_uint8(dev, "width", width);
7711c0
     qdev_prop_set_uint8(dev, "mappings", nb_mappings);
7711c0
diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
7711c0
index 721a867..20eed89 100644
7711c0
--- a/hw/i386/pc_sysfw.c
7711c0
+++ b/hw/i386/pc_sysfw.c
7711c0
@@ -109,16 +109,13 @@ static void pc_system_flash_init(MemoryRegion *rom_memory)
7711c0
     int64_t size;
7711c0
     char *fatal_errmsg = NULL;
7711c0
     hwaddr phys_addr = 0x100000000ULL;
7711c0
-    int sector_bits, sector_size;
7711c0
+    uint32_t sector_size = 4096;
7711c0
     PFlashCFI01 *system_flash;
7711c0
     MemoryRegion *flash_mem;
7711c0
     char name[64];
7711c0
     void *flash_ptr;
7711c0
     int ret, flash_size;
7711c0
 
7711c0
-    sector_bits = 12;
7711c0
-    sector_size = 1 << sector_bits;
7711c0
-
7711c0
     for (unit = 0;
7711c0
          (unit < FLASH_MAP_UNIT_MAX &&
7711c0
           (pflash_drv = drive_get(IF_PFLASH, 0, unit)) != NULL);
7711c0
@@ -161,7 +158,6 @@ static void pc_system_flash_init(MemoryRegion *rom_memory)
7711c0
         snprintf(name, sizeof name, "system.flash%d", unit);
7711c0
         system_flash = pflash_cfi01_register(phys_addr, name,
7711c0
                                              size, blk, sector_size,
7711c0
-                                             size >> sector_bits,
7711c0
                                              1      /* width */,
7711c0
                                              0x0000 /* id0 */,
7711c0
                                              0x0000 /* id1 */,
7711c0
diff --git a/hw/lm32/lm32_boards.c b/hw/lm32/lm32_boards.c
7711c0
index 0a1b6e9..92fe920 100644
7711c0
--- a/hw/lm32/lm32_boards.c
7711c0
+++ b/hw/lm32/lm32_boards.c
7711c0
@@ -116,7 +116,7 @@ static void lm32_evr_init(MachineState *machine)
7711c0
     /* Spansion S29NS128P */
7711c0
     pflash_cfi02_register(flash_base, "lm32_evr.flash", flash_size,
7711c0
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                          flash_sector_size, flash_size / flash_sector_size,
7711c0
+                          flash_sector_size,
7711c0
                           1, 2, 0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1);
7711c0
 
7711c0
     /* create irq lines */
7711c0
@@ -208,7 +208,7 @@ static void lm32_uclinux_init(MachineState *machine)
7711c0
     /* Spansion S29NS128P */
7711c0
     pflash_cfi02_register(flash_base, "lm32_uclinux.flash", flash_size,
7711c0
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                          flash_sector_size, flash_size / flash_sector_size,
7711c0
+                          flash_sector_size,
7711c0
                           1, 2, 0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1);
7711c0
 
7711c0
     /* create irq lines */
7711c0
diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c
7711c0
index 3e38313..ac62a63 100644
7711c0
--- a/hw/lm32/milkymist.c
7711c0
+++ b/hw/lm32/milkymist.c
7711c0
@@ -123,8 +123,7 @@ milkymist_init(MachineState *machine)
7711c0
     /* Numonyx JS28F256J3F105 */
7711c0
     pflash_cfi01_register(flash_base, "milkymist.flash", flash_size,
7711c0
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                          flash_sector_size, flash_size / flash_sector_size,
7711c0
-                          2, 0x00, 0x89, 0x00, 0x1d, 1);
7711c0
+                          flash_sector_size, 2, 0x00, 0x89, 0x00, 0x1d, 1);
7711c0
 
7711c0
     /* create irq lines */
7711c0
     env->pic_state = lm32_pic_init(qemu_allocate_irq(cpu_irq_handler, cpu, 0));
7711c0
diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
7711c0
index a2bc9fc..2a2c772 100644
7711c0
--- a/hw/microblaze/petalogix_ml605_mmu.c
7711c0
+++ b/hw/microblaze/petalogix_ml605_mmu.c
7711c0
@@ -109,8 +109,7 @@ petalogix_ml605_init(MachineState *machine)
7711c0
      * 10th paremeter 0 means little-endian */
7711c0
     pflash_cfi01_register(FLASH_BASEADDR, "petalogix_ml605.flash", FLASH_SIZE,
7711c0
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                          (64 * 1024), FLASH_SIZE >> 16,
7711c0
-                          2, 0x89, 0x18, 0x0000, 0x0, 0);
7711c0
+                          64 * KiB, 2, 0x89, 0x18, 0x0000, 0x0, 0);
7711c0
 
7711c0
 
7711c0
     dev = qdev_create(NULL, "xlnx.xps-intc");
7711c0
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
7711c0
index 37090c5..eab6eb9 100644
7711c0
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
7711c0
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
7711c0
@@ -88,8 +88,7 @@ petalogix_s3adsp1800_init(MachineState *machine)
7711c0
     pflash_cfi01_register(FLASH_BASEADDR,
7711c0
                           "petalogix_s3adsp1800.flash", FLASH_SIZE,
7711c0
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                          (64 * 1024), FLASH_SIZE >> 16,
7711c0
-                          1, 0x89, 0x18, 0x0000, 0x0, 1);
7711c0
+                          64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1);
7711c0
 
7711c0
     dev = qdev_create(NULL, "xlnx.xps-intc");
7711c0
     qdev_prop_set_uint32(dev, "kind-of-intr",
7711c0
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
7711c0
index 6b09258..921eb22 100644
7711c0
--- a/hw/mips/mips_malta.c
7711c0
+++ b/hw/mips/mips_malta.c
7711c0
@@ -1065,7 +1065,7 @@ void mips_malta_init(MachineState *machine)
7711c0
     fl = pflash_cfi01_register(FLASH_ADDRESS, "mips_malta.bios",
7711c0
                                FLASH_SIZE,
7711c0
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                               65536, FLASH_SIZE >> 16,
7711c0
+                               65536,
7711c0
                                4, 0x0000, 0x0000, 0x0000, 0x0000, be);
7711c0
     bios = pflash_cfi01_get_memory(fl);
7711c0
     fl_idx++;
7711c0
diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
7711c0
index 4ac5471..0aca7f9 100644
7711c0
--- a/hw/mips/mips_r4k.c
7711c0
+++ b/hw/mips/mips_r4k.c
7711c0
@@ -236,8 +236,7 @@ void mips_r4k_init(MachineState *machine)
7711c0
         uint32_t mips_rom = 0x00400000;
7711c0
         if (!pflash_cfi01_register(0x1fc00000, "mips_r4k.bios", mips_rom,
7711c0
                                    blk_by_legacy_dinfo(dinfo),
7711c0
-                                   sector_len, mips_rom / sector_len,
7711c0
-                                   4, 0, 0, 0, 0, be)) {
7711c0
+                                   sector_len, 4, 0, 0, 0, 0, be)) {
7711c0
             fprintf(stderr, "qemu: Error registering flash memory.\n");
7711c0
 	}
7711c0
     } else if (!qtest_enabled()) {
7711c0
diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
7711c0
index d2ad8cd..4575043 100644
7711c0
--- a/hw/ppc/ppc405_boards.c
7711c0
+++ b/hw/ppc/ppc405_boards.c
7711c0
@@ -231,7 +231,7 @@ static void ref405ep_init(MachineState *machine)
7711c0
         pflash_cfi02_register((uint32_t)(-bios_size),
7711c0
                               "ef405ep.bios", bios_size,
7711c0
                               dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                              64 * KiB, bios_size / (64 * KiB), 1,
7711c0
+                              64 * KiB, 1,
7711c0
                               2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
7711c0
                               1);
7711c0
     } else
7711c0
@@ -502,7 +502,7 @@ static void taihu_405ep_init(MachineState *machine)
7711c0
         pflash_cfi02_register(0xFFE00000,
7711c0
                               "taihu_405ep.bios", bios_size,
7711c0
                               dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                              64 * KiB, bios_size / (64 * KiB), 1,
7711c0
+                              64 * KiB, 1,
7711c0
                               4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
7711c0
                               1);
7711c0
         fl_idx++;
7711c0
@@ -536,7 +536,7 @@ static void taihu_405ep_init(MachineState *machine)
7711c0
         bios_size = 32 * MiB;
7711c0
         pflash_cfi02_register(0xfc000000, "taihu_405ep.flash", bios_size,
7711c0
                               dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                              64 * KiB, bios_size / (64 * KiB), 1,
7711c0
+                              64 * KiB, 1,
7711c0
                               4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
7711c0
                               1);
7711c0
         fl_idx++;
7711c0
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
7711c0
index 0c1790f..4ec934f 100644
7711c0
--- a/hw/ppc/sam460ex.c
7711c0
+++ b/hw/ppc/sam460ex.c
7711c0
@@ -236,9 +236,8 @@ static int sam460ex_load_uboot(void)
7711c0
     if (!pflash_cfi01_register(FLASH_BASE | ((hwaddr)FLASH_BASE_H << 32),
7711c0
                                "sam460ex.flash", FLASH_SIZE,
7711c0
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                               64 * KiB, FLASH_SIZE / (64 * KiB),
7711c0
-                               1, 0x89, 0x18, 0x0000, 0x0, 1)) {
7711c0
-        error_report("qemu: Error registering flash memory.");
7711c0
+                               64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1)) {
7711c0
+        error_report("Error registering flash memory");
7711c0
         /* XXX: return an error instead? */
7711c0
         exit(1);
7711c0
     }
7711c0
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
7711c0
index 66fa766..2fd8efe 100644
7711c0
--- a/hw/ppc/virtex_ml507.c
7711c0
+++ b/hw/ppc/virtex_ml507.c
7711c0
@@ -237,8 +237,7 @@ static void virtex_init(MachineState *machine)
7711c0
     dinfo = drive_get(IF_PFLASH, 0, 0);
7711c0
     pflash_cfi01_register(PFLASH_BASEADDR, "virtex.flash", FLASH_SIZE,
7711c0
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                          (64 * 1024), FLASH_SIZE >> 16,
7711c0
-                          1, 0x89, 0x18, 0x0000, 0x0, 1);
7711c0
+                          64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1);
7711c0
 
7711c0
     cpu_irq = (qemu_irq *) &env->irq_inputs[PPC40x_INPUT_INT];
7711c0
     dev = qdev_create(NULL, "xlnx.xps-intc");
7711c0
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
7711c0
index 7016d6f..d6e6515 100644
7711c0
--- a/hw/sh4/r2d.c
7711c0
+++ b/hw/sh4/r2d.c
7711c0
@@ -300,8 +300,7 @@ static void r2d_init(MachineState *machine)
7711c0
     dinfo = drive_get(IF_PFLASH, 0, 0);
7711c0
     pflash_cfi02_register(0x0, "r2d.flash", FLASH_SIZE,
7711c0
                           dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
7711c0
-                          64 * KiB, FLASH_SIZE >> 16,
7711c0
-                          1, 2, 0x0001, 0x227e, 0x2220, 0x2200,
7711c0
+                          64 * KiB, 1, 2, 0x0001, 0x227e, 0x2220, 0x2200,
7711c0
                           0x555, 0x2aa, 0);
7711c0
 
7711c0
     /* NIC: rtl8139 on-board, and 2 slots. */
7711c0
diff --git a/include/hw/block/flash.h b/include/hw/block/flash.h
7711c0
index 3e48901..914932e 100644
7711c0
--- a/include/hw/block/flash.h
7711c0
+++ b/include/hw/block/flash.h
7711c0
@@ -17,7 +17,7 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base,
7711c0
                                    const char *name,
7711c0
                                    hwaddr size,
7711c0
                                    BlockBackend *blk,
7711c0
-                                   uint32_t sector_len, int nb_blocs,
7711c0
+                                   uint32_t sector_len,
7711c0
                                    int width,
7711c0
                                    uint16_t id0, uint16_t id1,
7711c0
                                    uint16_t id2, uint16_t id3,
7711c0
@@ -36,7 +36,7 @@ PFlashCFI02 *pflash_cfi02_register(hwaddr base,
7711c0
                                    const char *name,
7711c0
                                    hwaddr size,
7711c0
                                    BlockBackend *blk,
7711c0
-                                   uint32_t sector_len, int nb_blocs,
7711c0
+                                   uint32_t sector_len,
7711c0
                                    int nb_mappings,
7711c0
                                    int width,
7711c0
                                    uint16_t id0, uint16_t id1,
7711c0
-- 
7711c0
1.8.3.1
7711c0