aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@redhat.com>2019-05-05 23:21:19 +0200
committerPhilippe Mathieu-Daudé <philmd@redhat.com>2019-07-02 02:31:13 +0200
commit3e4bcf89b7acea62e248ee048c1c67767be88f98 (patch)
treeb67fb33d0892e9ad754297d29ece6bc96fdec3e6
parentc3d25271b2117a1416f5818d9d2b399b4e1e77b3 (diff)
hw/block/pflash_cfi02: Use the ldst API in pflash_read()
The load/store API eases code review. Signed-off-by: Stephen Checkoway <stephen.checkoway@oberlin.edu> Message-Id: <20190426162624.55977-3-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, simplified tracing] Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
-rw-r--r--hw/block/pflash_cfi02.c32
1 files changed, 5 insertions, 27 deletions
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index ae38ed0bae..49afecb921 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -196,33 +196,11 @@ static uint32_t pflash_read(PFlashCFI02 *pfl, hwaddr offset,
case 0x00:
flash_read:
/* Flash area read */
- p = pfl->storage;
- switch (width) {
- case 1:
- ret = p[offset];
- break;
- case 2:
- if (be) {
- ret = p[offset] << 8;
- ret |= p[offset + 1];
- } else {
- ret = p[offset];
- ret |= p[offset + 1] << 8;
- }
- break;
- case 4:
- if (be) {
- ret = p[offset] << 24;
- ret |= p[offset + 1] << 16;
- ret |= p[offset + 2] << 8;
- ret |= p[offset + 3];
- } else {
- ret = p[offset];
- ret |= p[offset + 1] << 8;
- ret |= p[offset + 2] << 16;
- ret |= p[offset + 3] << 24;
- }
- break;
+ p = (uint8_t *)pfl->storage + offset;
+ if (pfl->be) {
+ ret = ldn_be_p(p, width);
+ } else {
+ ret = ldn_le_p(p, width);
}
trace_pflash_data_read(offset, width << 1, ret);
break;