[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v3 13/44] pflash: Switch to byte-based block access
From: |
Eric Blake |
Subject: |
[Qemu-block] [PATCH v3 13/44] pflash: Switch to byte-based block access |
Date: |
Fri, 22 Apr 2016 17:40:21 -0600 |
Sector-based blk_write() should die; switch to byte-based
blk_pwrite() instead. Likewise for blk_read().
Signed-off-by: Eric Blake <address@hidden>
---
hw/block/pflash_cfi01.c | 12 ++++++------
hw/block/pflash_cfi02.c | 12 ++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 106a775..3a1f85d 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -413,11 +413,11 @@ static void pflash_update(pflash_t *pfl, int offset,
int offset_end;
if (pfl->blk) {
offset_end = offset + size;
- /* round to sectors */
- offset = offset >> 9;
- offset_end = (offset_end + 511) >> 9;
- blk_write(pfl->blk, offset, pfl->storage + (offset << 9),
- offset_end - offset);
+ /* widen to sector boundaries */
+ offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
+ offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
+ blk_pwrite(pfl->blk, offset, pfl->storage + offset,
+ offset_end - offset, 0);
}
}
@@ -739,7 +739,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Error
**errp)
if (pfl->blk) {
/* read the initial flash content */
- ret = blk_read(pfl->blk, 0, pfl->storage, total_len >> 9);
+ ret = blk_pread(pfl->blk, 0, pfl->storage, total_len);
if (ret < 0) {
vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index b13172c..5f10610 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -253,11 +253,11 @@ static void pflash_update(pflash_t *pfl, int offset,
int offset_end;
if (pfl->blk) {
offset_end = offset + size;
- /* round to sectors */
- offset = offset >> 9;
- offset_end = (offset_end + 511) >> 9;
- blk_write(pfl->blk, offset, pfl->storage + (offset << 9),
- offset_end - offset);
+ /* widen to sector boundaries */
+ offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
+ offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
+ blk_pwrite(pfl->blk, offset, pfl->storage + offset,
+ offset_end - offset, 0);
}
}
@@ -622,7 +622,7 @@ static void pflash_cfi02_realize(DeviceState *dev, Error
**errp)
pfl->chip_len = chip_len;
if (pfl->blk) {
/* read the initial flash content */
- ret = blk_read(pfl->blk, 0, pfl->storage, chip_len >> 9);
+ ret = blk_pread(pfl->blk, 0, pfl->storage, chip_len);
if (ret < 0) {
vmstate_unregister_ram(&pfl->orig_mem, DEVICE(pfl));
error_setg(errp, "failed to read the initial flash content");
--
2.5.5
- [Qemu-block] [PATCH v3 06/44] nbd: Clean up ioctl handling of qemu-nbd -c, (continued)
- [Qemu-block] [PATCH v3 06/44] nbd: Clean up ioctl handling of qemu-nbd -c, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 07/44] nbd: Limit nbdflags to 16 bits, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 08/44] nbd: Add qemu-nbd -D for human-readable description, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 14/44] sd: Switch to byte-based block access, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 10/44] fdc: Switch to byte-based block access, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 09/44] block: Allow BDRV_REQ_FUA through blk_pwrite(), Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 17/44] nbd: Switch to byte-based block access, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 13/44] pflash: Switch to byte-based block access,
Eric Blake <=
- [Qemu-block] [PATCH v3 12/44] onenand: Switch to byte-based block access, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 16/44] atapi: Switch to byte-based block access, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 11/44] nand: Switch to byte-based block access, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 15/44] m25p80: Switch to byte-based block access, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 18/44] qemu-img: Switch to byte-based block access, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 23/44] qemu-io: Add missing option documentation, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 20/44] block: Switch blk_read_unthrottled() to byte interface, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 24/44] qemu-io: Add 'write -f' to test FUA flag, Eric Blake, 2016/04/22
- [Qemu-block] [PATCH v3 19/44] qemu-io: Switch to byte-based block access, Eric Blake, 2016/04/22