[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v5 08/28] hw/block/pflash_cfi02: Use the ldst API in p
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-ppc] [PATCH v5 08/28] hw/block/pflash_cfi02: Use the ldst API in pflash_write() |
Date: |
Thu, 27 Jun 2019 22:26:59 +0200 |
The load/store API eases code review.
Signed-off-by: Stephen Checkoway <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Tested-by: Philippe Mathieu-Daudé <address@hidden>
[PMD: Extracted from bigger patch]
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/block/pflash_cfi02.c | 38 ++++++++------------------------------
1 file changed, 8 insertions(+), 30 deletions(-)
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index 9e8c28af8f..ae38ed0bae 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -365,38 +365,16 @@ static void pflash_write(PFlashCFI02 *pfl, hwaddr offset,
goto check_unlock0;
case 0xA0:
trace_pflash_data_write(offset, width << 1, value, 0);
- p = pfl->storage;
if (!pfl->ro) {
- switch (width) {
- case 1:
- p[offset] &= value;
- pflash_update(pfl, offset, 1);
- break;
- case 2:
- if (be) {
- p[offset] &= value >> 8;
- p[offset + 1] &= value;
- } else {
- p[offset] &= value;
- p[offset + 1] &= value >> 8;
- }
- pflash_update(pfl, offset, 2);
- break;
- case 4:
- if (be) {
- p[offset] &= value >> 24;
- p[offset + 1] &= value >> 16;
- p[offset + 2] &= value >> 8;
- p[offset + 3] &= value;
- } else {
- p[offset] &= value;
- p[offset + 1] &= value >> 8;
- p[offset + 2] &= value >> 16;
- p[offset + 3] &= value >> 24;
- }
- pflash_update(pfl, offset, 4);
- break;
+ p = (uint8_t *)pfl->storage + offset;
+ if (pfl->be) {
+ uint64_t current = ldn_be_p(p, width);
+ stn_be_p(p, width, current & value);
+ } else {
+ uint64_t current = ldn_le_p(p, width);
+ stn_le_p(p, width, current & value);
}
+ pflash_update(pfl, offset, width);
}
/*
* While programming, status bit DQ7 should hold the opposite
--
2.20.1
- [Qemu-ppc] [PATCH v5 06/28] hw/block/pflash_cfi02: Add helpers to manipulate the status bits, (continued)
- [Qemu-ppc] [PATCH v5 06/28] hw/block/pflash_cfi02: Add helpers to manipulate the status bits, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-ppc] [PATCH v5 09/28] hw/block/pflash_cfi02: Use the ldst API in pflash_read(), Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-ppc] [PATCH v5 07/28] hw/block/pflash_cfi02: Simplify a statement using fall through, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-ppc] [PATCH v5 12/28] hw/block/pflash_cfi02: Fix command address comparison, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-ppc] [PATCH v5 10/28] hw/block/pflash_cfi02: Extract the pflash_data_read() function, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-ppc] [PATCH v5 08/28] hw/block/pflash_cfi02: Use the ldst API in pflash_write(),
Philippe Mathieu-Daudé <=
- [Qemu-ppc] [PATCH v5 11/28] hw/block/pflash_cfi02: Unify the MemoryRegionOps, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-ppc] [PATCH v5 14/28] hw/block/pflash_cfi02: Remove pointless local variable, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-ppc] [PATCH v5 15/28] hw/block/pflash_cfi02: Document the current CFI values, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-ppc] [PATCH v5 13/28] tests/pflash-cfi02: Refactor to support testing multiple configurations, Philippe Mathieu-Daudé, 2019/06/27
- [Qemu-ppc] [PATCH v5 16/28] hw/block/pflash_cfi02: Hold the PRI table offset in a variable, Philippe Mathieu-Daudé, 2019/06/27