hw/block/pflash_cfi02: Remove pointless local variable

We can directly use pfl->total_len, remove the local 'chip_len'
variable.

Signed-off-by: Stephen Checkoway <stephen.checkoway@oberlin.edu>
Message-Id: <20190426162624.55977-6-stephen.checkoway@oberlin.edu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
[PMD: Extracted from bigger patch]
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2019-05-18 14:45:35 +02:00
parent 91d0231213
commit 1eb27d692e

View File

@ -409,7 +409,7 @@ static void pflash_write(void *opaque, hwaddr offset, uint64_t value,
/* Chip erase */ /* Chip erase */
DPRINTF("%s: start chip erase\n", __func__); DPRINTF("%s: start chip erase\n", __func__);
if (!pfl->ro) { if (!pfl->ro) {
memset(pfl->storage, 0xFF, pfl->chip_len); memset(pfl->storage, 0xff, pfl->chip_len);
pflash_update(pfl, 0, pfl->chip_len); pflash_update(pfl, 0, pfl->chip_len);
} }
set_dq7(pfl, 0x00); set_dq7(pfl, 0x00);
@ -490,7 +490,6 @@ static const MemoryRegionOps pflash_cfi02_ops = {
static void pflash_cfi02_realize(DeviceState *dev, Error **errp) static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
{ {
PFlashCFI02 *pfl = PFLASH_CFI02(dev); PFlashCFI02 *pfl = PFLASH_CFI02(dev);
uint32_t chip_len;
int ret; int ret;
Error *local_err = NULL; Error *local_err = NULL;
@ -507,18 +506,17 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
return; return;
} }
chip_len = pfl->sector_len * pfl->nb_blocs; pfl->chip_len = pfl->sector_len * pfl->nb_blocs;
memory_region_init_rom_device(&pfl->orig_mem, OBJECT(pfl), memory_region_init_rom_device(&pfl->orig_mem, OBJECT(pfl),
&pflash_cfi02_ops, pfl, pfl->name, &pflash_cfi02_ops, pfl, pfl->name,
chip_len, &local_err); pfl->chip_len, &local_err);
if (local_err) { if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
return; return;
} }
pfl->storage = memory_region_get_ram_ptr(&pfl->orig_mem); pfl->storage = memory_region_get_ram_ptr(&pfl->orig_mem);
pfl->chip_len = chip_len;
if (pfl->blk) { if (pfl->blk) {
uint64_t perm; uint64_t perm;
@ -533,8 +531,8 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
} }
if (pfl->blk) { if (pfl->blk) {
if (!blk_check_size_and_read_all(pfl->blk, pfl->storage, chip_len, if (!blk_check_size_and_read_all(pfl->blk, pfl->storage,
errp)) { pfl->chip_len, errp)) {
vmstate_unregister_ram(&pfl->orig_mem, DEVICE(pfl)); vmstate_unregister_ram(&pfl->orig_mem, DEVICE(pfl));
return; return;
} }
@ -594,7 +592,7 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
/* Max timeout for chip erase */ /* Max timeout for chip erase */
pfl->cfi_table[0x26] = 0x0D; pfl->cfi_table[0x26] = 0x0D;
/* Device size */ /* Device size */
pfl->cfi_table[0x27] = ctz32(chip_len); pfl->cfi_table[0x27] = ctz32(pfl->chip_len);
/* Flash device interface (8 & 16 bits) */ /* Flash device interface (8 & 16 bits) */
pfl->cfi_table[0x28] = 0x02; pfl->cfi_table[0x28] = 0x02;
pfl->cfi_table[0x29] = 0x00; pfl->cfi_table[0x29] = 0x00;