[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 19/28] hw/block/pflash_cfi02: Extract pflash_regi
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-devel] [PATCH v5 19/28] hw/block/pflash_cfi02: Extract pflash_regions_count() |
Date: |
Thu, 27 Jun 2019 22:27:10 +0200 |
Extract the pflash_regions_count() function, the code will be
easier to review.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/block/pflash_cfi02.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index 1f096ec185..a0d3bd60dc 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -157,6 +157,11 @@ static void pflash_register_memory(PFlashCFI02 *pfl, int
rom_mode)
pfl->rom_mode = rom_mode;
}
+static size_t pflash_regions_count(PFlashCFI02 *pfl)
+{
+ return pfl->cfi_table[0x2c];
+}
+
static void pflash_timer (void *opaque)
{
PFlashCFI02 *pfl = opaque;
@@ -192,9 +197,8 @@ static uint64_t pflash_data_read(PFlashCFI02 *pfl, hwaddr
offset,
static uint32_t pflash_sector_len(PFlashCFI02 *pfl, hwaddr offset)
{
assert(offset < pfl->chip_len);
- int nb_regions = pfl->cfi_table[0x2C];
hwaddr addr = 0;
- for (int i = 0; i < nb_regions; ++i) {
+ for (int i = 0; i < pflash_regions_count(pfl); ++i) {
uint64_t region_size = (uint64_t)pfl->nb_blocs[i] * pfl->sector_len[i];
if (addr <= offset && offset < addr + region_size) {
return pfl->sector_len[i];
--
2.20.1
- [Qemu-devel] [PATCH v5 13/28] tests/pflash-cfi02: Refactor to support testing multiple configurations, (continued)
- [Qemu-devel] [PATCH v5 13/28] tests/pflash-cfi02: Refactor to support testing multiple configurations, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-devel] [PATCH v5 15/28] hw/block/pflash_cfi02: Document the current CFI values, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-devel] [PATCH v5 16/28] hw/block/pflash_cfi02: Hold the PRI table offset in a variable, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-devel] [PATCH v5 17/28] hw/block/pflash_cfi02: Document 'Page Mode' operations are not supported, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-devel] [PATCH v5 18/28] hw/block/pflash_cfi02: Implement nonuniform sector sizes, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-devel] [PATCH v5 19/28] hw/block/pflash_cfi02: Extract pflash_regions_count(),
Philippe Mathieu-Daudé <=
- [Qemu-devel] [PATCH v5 20/28] hw/block/pflash_cfi02: Split if() condition, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-devel] [PATCH v5 22/28] hw/block/pflash_cfi02: Fix reset command not ignored during erase, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-devel] [PATCH v5 21/28] hw/block/pflash_cfi02: Fix CFI in autoselect mode, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-devel] [PATCH v5 25/28] hw/block/pflash_cfi02: Use chip erase time specified in the CFI table, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-devel] [PATCH v5 24/28] hw/block/pflash_cfi02: Implement erase suspend/resume, Philippe Mathieu-Daudé, 2019/06/27