[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.2.1 44/54] hw/pflash: refactor pflash_data_write()
From: |
Michael Tokarev |
Subject: |
[Stable-8.2.1 44/54] hw/pflash: refactor pflash_data_write() |
Date: |
Tue, 23 Jan 2024 18:46:45 +0300 |
From: Gerd Hoffmann <kraxel@redhat.com>
Move the offset calculation, do it once at the start of the function and
let the 'p' variable point directly to the memory location which should
be updated. This makes it simpler to update other buffers than
pfl->storage in an upcoming patch. No functional change.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240108160900.104835-2-kraxel@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
(cherry picked from commit 3b14a555fdb627ac091559ef5931c887d06590d8)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 62056b1d74..82f592d420 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -403,33 +403,35 @@ static void pflash_update(PFlashCFI01 *pfl, int offset,
static inline void pflash_data_write(PFlashCFI01 *pfl, hwaddr offset,
uint32_t value, int width, int be)
{
- uint8_t *p = pfl->storage;
+ uint8_t *p;
trace_pflash_data_write(pfl->name, offset, width, value, pfl->counter);
+ p = pfl->storage + offset;
+
switch (width) {
case 1:
- p[offset] = value;
+ p[0] = value;
break;
case 2:
if (be) {
- p[offset] = value >> 8;
- p[offset + 1] = value;
+ p[0] = value >> 8;
+ p[1] = value;
} else {
- p[offset] = value;
- p[offset + 1] = value >> 8;
+ p[0] = value;
+ p[1] = value >> 8;
}
break;
case 4:
if (be) {
- p[offset] = value >> 24;
- p[offset + 1] = value >> 16;
- p[offset + 2] = value >> 8;
- p[offset + 3] = value;
+ p[0] = value >> 24;
+ p[1] = value >> 16;
+ p[2] = value >> 8;
+ p[3] = value;
} else {
- p[offset] = value;
- p[offset + 1] = value >> 8;
- p[offset + 2] = value >> 16;
- p[offset + 3] = value >> 24;
+ p[0] = value;
+ p[1] = value >> 8;
+ p[2] = value >> 16;
+ p[3] = value >> 24;
}
break;
}
--
2.39.2
- [Stable-8.2.1 v2 00/54] Patch Round-up for stable 8.2.1, freeze on 2024-01-27, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 39/54] load_elf: fix iterator's type for elf file processing, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 40/54] target/i386: Do not re-compute new pc with CF_PCREL, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 42/54] target/i386: pcrel: store low bits of physical address in data[0], Michael Tokarev, 2024/01/23
- [Stable-8.2.1 41/54] target/i386: fix incorrect EIP in PC-relative translation blocks, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 47/54] migration/rdma: define htonll/ntohll only if not predefined, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 43/54] backends/cryptodev: Do not ignore throttle/backends Errors, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 45/54] hw/pflash: use ldn_{be,le}_p and stn_{be,le}_p, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 44/54] hw/pflash: refactor pflash_data_write(),
Michael Tokarev <=
- [Stable-8.2.1 51/54] hw/scsi/esp-pci: set DMA_STAT_BCMBLT when BLAST command issued, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 48/54] hw/scsi/esp-pci: use correct address register for PCI DMA transfers, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 49/54] hw/scsi/esp-pci: generate PCI interrupt from separate ESP and PCI sources, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 52/54] s390x/pci: avoid double enable/disable of aif, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 54/54] s390x/pci: drive ISM reset from subsystem reset, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 46/54] hw/pflash: implement update buffer for block writes, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 50/54] hw/scsi/esp-pci: synchronise setting of DMA_STAT_DONE with ESP completion interrupt, Michael Tokarev, 2024/01/23
- [Stable-8.2.1 53/54] s390x/pci: refresh fh before disabling aif, Michael Tokarev, 2024/01/23