mirror of https://gitee.com/openkylin/qemu.git
pflash: Switch to byte-based block access
Sector-based blk_write() should die; switch to byte-based blk_pwrite() instead. Likewise for blk_read(). Signed-off-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
441692ddd8
commit
098e732dbe
|
@ -413,11 +413,11 @@ static void pflash_update(pflash_t *pfl, int offset,
|
||||||
int offset_end;
|
int offset_end;
|
||||||
if (pfl->blk) {
|
if (pfl->blk) {
|
||||||
offset_end = offset + size;
|
offset_end = offset + size;
|
||||||
/* round to sectors */
|
/* widen to sector boundaries */
|
||||||
offset = offset >> 9;
|
offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
|
||||||
offset_end = (offset_end + 511) >> 9;
|
offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
|
||||||
blk_write(pfl->blk, offset, pfl->storage + (offset << 9),
|
blk_pwrite(pfl->blk, offset, pfl->storage + offset,
|
||||||
offset_end - offset);
|
offset_end - offset, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,7 +739,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
|
||||||
|
|
||||||
if (pfl->blk) {
|
if (pfl->blk) {
|
||||||
/* read the initial flash content */
|
/* 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) {
|
if (ret < 0) {
|
||||||
vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
|
vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
|
||||||
|
|
|
@ -253,11 +253,11 @@ static void pflash_update(pflash_t *pfl, int offset,
|
||||||
int offset_end;
|
int offset_end;
|
||||||
if (pfl->blk) {
|
if (pfl->blk) {
|
||||||
offset_end = offset + size;
|
offset_end = offset + size;
|
||||||
/* round to sectors */
|
/* widen to sector boundaries */
|
||||||
offset = offset >> 9;
|
offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
|
||||||
offset_end = (offset_end + 511) >> 9;
|
offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
|
||||||
blk_write(pfl->blk, offset, pfl->storage + (offset << 9),
|
blk_pwrite(pfl->blk, offset, pfl->storage + offset,
|
||||||
offset_end - offset);
|
offset_end - offset, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,7 +622,7 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
|
||||||
pfl->chip_len = chip_len;
|
pfl->chip_len = chip_len;
|
||||||
if (pfl->blk) {
|
if (pfl->blk) {
|
||||||
/* read the initial flash content */
|
/* 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) {
|
if (ret < 0) {
|
||||||
vmstate_unregister_ram(&pfl->orig_mem, DEVICE(pfl));
|
vmstate_unregister_ram(&pfl->orig_mem, DEVICE(pfl));
|
||||||
error_setg(errp, "failed to read the initial flash content");
|
error_setg(errp, "failed to read the initial flash content");
|
||||||
|
|
Loading…
Reference in New Issue