aboutsummaryrefslogtreecommitdiff
path: root/hw/block
diff options
context:
space:
mode:
authorAlberto Faria <afaria@redhat.com>2022-07-05 17:15:11 +0100
committerHanna Reitz <hreitz@redhat.com>2022-07-12 12:14:56 +0200
commita9262f551eba44d4d0f9e396d7124c059a93e204 (patch)
treedb282f0d5ffab8fbaa90e42077a8ea1b12635185 /hw/block
parent3b35d4542c8537a9269f6372df531ced6c960084 (diff)
downloadqemu-a9262f551eba44d4d0f9e396d7124c059a93e204.zip
qemu-a9262f551eba44d4d0f9e396d7124c059a93e204.tar.gz
qemu-a9262f551eba44d4d0f9e396d7124c059a93e204.tar.bz2
block: Change blk_{pread,pwrite}() param order
Swap 'buf' and 'bytes' around for consistency with blk_co_{pread,pwrite}(), and in preparation to implement these functions using generated_co_wrapper. Callers were updated using this Coccinelle script: @@ expression blk, offset, buf, bytes, flags; @@ - blk_pread(blk, offset, buf, bytes, flags) + blk_pread(blk, offset, bytes, buf, flags) @@ expression blk, offset, buf, bytes, flags; @@ - blk_pwrite(blk, offset, buf, bytes, flags) + blk_pwrite(blk, offset, bytes, buf, flags) It had no effect on hw/block/nand.c, presumably due to the #if, so that file was updated manually. Overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria <afaria@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220705161527.1054072-4-afaria@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Diffstat (limited to 'hw/block')
-rw-r--r--hw/block/block.c2
-rw-r--r--hw/block/fdc.c20
-rw-r--r--hw/block/hd-geometry.c2
-rw-r--r--hw/block/m25p80.c2
-rw-r--r--hw/block/nand.c47
-rw-r--r--hw/block/onenand.c32
-rw-r--r--hw/block/pflash_cfi01.c4
-rw-r--r--hw/block/pflash_cfi02.c4
8 files changed, 57 insertions, 56 deletions
diff --git a/hw/block/block.c b/hw/block/block.c
index effb899..0427916 100644
--- a/hw/block/block.c
+++ b/hw/block/block.c
@@ -53,7 +53,7 @@ bool blk_check_size_and_read_all(BlockBackend *blk, void *buf, hwaddr size,
* block device and read only on demand.
*/
assert(size <= BDRV_REQUEST_MAX_BYTES);
- ret = blk_pread(blk, 0, buf, size, 0);
+ ret = blk_pread(blk, 0, size, buf, 0);
if (ret < 0) {
error_setg_errno(errp, -ret, "can't read block backend");
return false;
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 52f278e..64ae4a6 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -1628,8 +1628,8 @@ int fdctrl_transfer_handler(void *opaque, int nchan, int dma_pos, int dma_len)
if (fdctrl->data_dir != FD_DIR_WRITE ||
len < FD_SECTOR_LEN || rel_pos != 0) {
/* READ & SCAN commands and realign to a sector for WRITE */
- if (blk_pread(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo,
- BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pread(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SIZE,
+ fdctrl->fifo, 0) < 0) {
FLOPPY_DPRINTF("Floppy: error getting sector %d\n",
fd_sector(cur_drv));
/* Sure, image size is too small... */
@@ -1656,8 +1656,8 @@ int fdctrl_transfer_handler(void *opaque, int nchan, int dma_pos, int dma_len)
k->read_memory(fdctrl->dma, nchan, fdctrl->fifo + rel_pos,
fdctrl->data_pos, len);
- if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv),
- fdctrl->fifo, BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SIZE,
+ fdctrl->fifo, 0) < 0) {
FLOPPY_DPRINTF("error writing sector %d\n",
fd_sector(cur_drv));
fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK, 0x00, 0x00);
@@ -1740,8 +1740,8 @@ static uint32_t fdctrl_read_data(FDCtrl *fdctrl)
fd_sector(cur_drv));
return 0;
}
- if (blk_pread(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo,
- BDRV_SECTOR_SIZE, 0)
+ if (blk_pread(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SIZE,
+ fdctrl->fifo, 0)
< 0) {
FLOPPY_DPRINTF("error getting sector %d\n",
fd_sector(cur_drv));
@@ -1820,8 +1820,8 @@ static void fdctrl_format_sector(FDCtrl *fdctrl)
}
memset(fdctrl->fifo, 0, FD_SECTOR_LEN);
if (cur_drv->blk == NULL ||
- blk_pwrite(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo,
- BDRV_SECTOR_SIZE, 0) < 0) {
+ blk_pwrite(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SIZE,
+ fdctrl->fifo, 0) < 0) {
FLOPPY_DPRINTF("error formatting sector %d\n", fd_sector(cur_drv));
fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK, 0x00, 0x00);
} else {
@@ -2244,8 +2244,8 @@ static void fdctrl_write_data(FDCtrl *fdctrl, uint32_t value)
if (pos == FD_SECTOR_LEN - 1 ||
fdctrl->data_pos == fdctrl->data_len) {
cur_drv = get_cur_drv(fdctrl);
- if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo,
- BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SIZE,
+ fdctrl->fifo, 0) < 0) {
FLOPPY_DPRINTF("error writing sector %d\n",
fd_sector(cur_drv));
break;
diff --git a/hw/block/hd-geometry.c b/hw/block/hd-geometry.c
index 24933ea..1120943 100644
--- a/hw/block/hd-geometry.c
+++ b/hw/block/hd-geometry.c
@@ -63,7 +63,7 @@ static int guess_disk_lchs(BlockBackend *blk,
blk_get_geometry(blk, &nb_sectors);
- if (blk_pread(blk, 0, buf, BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pread(blk, 0, BDRV_SECTOR_SIZE, buf, 0) < 0) {
return -1;
}
/* test msdos magic */
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 7e476b8..46dd9ee 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -1532,7 +1532,7 @@ static void m25p80_realize(SSIPeripheral *ss, Error **errp)
trace_m25p80_binding(s);
s->storage = blk_blockalign(s->blk, s->size);
- if (blk_pread(s->blk, 0, s->storage, s->size, 0) < 0) {
+ if (blk_pread(s->blk, 0, s->size, s->storage, 0) < 0) {
error_setg(errp, "failed to read the initial flash content");
return;
}
diff --git a/hw/block/nand.c b/hw/block/nand.c
index ea3d33a..1aee1cb 100644
--- a/hw/block/nand.c
+++ b/hw/block/nand.c
@@ -666,8 +666,8 @@ static void glue(nand_blk_write_, NAND_PAGE_SIZE)(NANDFlashState *s)
sector = SECTOR(s->addr);
off = (s->addr & PAGE_MASK) + s->offset;
soff = SECTOR_OFFSET(s->addr);
- if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS, iobuf,
- PAGE_SECTORS << BDRV_SECTOR_BITS, 0) < 0) {
+ if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS,
+ PAGE_SECTORS << BDRV_SECTOR_BITS, iobuf, 0) < 0) {
printf("%s: read error in sector %" PRIu64 "\n", __func__, sector);
return;
}
@@ -679,24 +679,24 @@ static void glue(nand_blk_write_, NAND_PAGE_SIZE)(NANDFlashState *s)
MIN(OOB_SIZE, off + s->iolen - NAND_PAGE_SIZE));
}
- if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS, iobuf,
- PAGE_SECTORS << BDRV_SECTOR_BITS, 0) < 0) {
+ if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS,
+ PAGE_SECTORS << BDRV_SECTOR_BITS, iobuf, 0) < 0) {
printf("%s: write error in sector %" PRIu64 "\n", __func__, sector);
}
} else {
off = PAGE_START(s->addr) + (s->addr & PAGE_MASK) + s->offset;
sector = off >> 9;
soff = off & 0x1ff;
- if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS, iobuf,
- (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, 0) < 0) {
+ if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS,
+ (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, iobuf, 0) < 0) {
printf("%s: read error in sector %" PRIu64 "\n", __func__, sector);
return;
}
mem_and(iobuf + soff, s->io, s->iolen);
- if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS, iobuf,
- (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, 0) < 0) {
+ if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS,
+ (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, iobuf, 0) < 0) {
printf("%s: write error in sector %" PRIu64 "\n", __func__, sector);
}
}
@@ -723,20 +723,20 @@ static void glue(nand_blk_erase_, NAND_PAGE_SIZE)(NANDFlashState *s)
i = SECTOR(addr);
page = SECTOR(addr + (1 << (ADDR_SHIFT + s->erase_shift)));
for (; i < page; i ++)
- if (blk_pwrite(s->blk, i << BDRV_SECTOR_BITS, iobuf,
- BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pwrite(s->blk, i << BDRV_SECTOR_BITS,
+ BDRV_SECTOR_SIZE, iobuf, 0) < 0) {
printf("%s: write error in sector %" PRIu64 "\n", __func__, i);
}
} else {
addr = PAGE_START(addr);
page = addr >> 9;
- if (blk_pread(s->blk, page << BDRV_SECTOR_BITS, iobuf,
- BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pread(s->blk, page << BDRV_SECTOR_BITS,
+ BDRV_SECTOR_SIZE, iobuf, 0) < 0) {
printf("%s: read error in sector %" PRIu64 "\n", __func__, page);
}
memset(iobuf + (addr & 0x1ff), 0xff, (~addr & 0x1ff) + 1);
- if (blk_pwrite(s->blk, page << BDRV_SECTOR_BITS, iobuf,
- BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pwrite(s->blk, page << BDRV_SECTOR_BITS,
+ BDRV_SECTOR_SIZE, iobuf, 0) < 0) {
printf("%s: write error in sector %" PRIu64 "\n", __func__, page);
}
@@ -744,20 +744,20 @@ static void glue(nand_blk_erase_, NAND_PAGE_SIZE)(NANDFlashState *s)
i = (addr & ~0x1ff) + 0x200;
for (addr += ((NAND_PAGE_SIZE + OOB_SIZE) << s->erase_shift) - 0x200;
i < addr; i += 0x200) {
- if (blk_pwrite(s->blk, i, iobuf, BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pwrite(s->blk, i, BDRV_SECTOR_SIZE, iobuf, 0) < 0) {
printf("%s: write error in sector %" PRIu64 "\n",
__func__, i >> 9);
}
}
page = i >> 9;
- if (blk_pread(s->blk, page << BDRV_SECTOR_BITS, iobuf,
- BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pread(s->blk, page << BDRV_SECTOR_BITS,
+ BDRV_SECTOR_SIZE, iobuf, 0) < 0) {
printf("%s: read error in sector %" PRIu64 "\n", __func__, page);
}
memset(iobuf, 0xff, ((addr - 1) & 0x1ff) + 1);
- if (blk_pwrite(s->blk, page << BDRV_SECTOR_BITS, iobuf,
- BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pwrite(s->blk, page << BDRV_SECTOR_BITS,
+ BDRV_SECTOR_SIZE, iobuf, 0) < 0) {
printf("%s: write error in sector %" PRIu64 "\n", __func__, page);
}
}
@@ -772,8 +772,8 @@ static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
if (s->blk) {
if (s->mem_oob) {
- if (blk_pread(s->blk, SECTOR(addr) << BDRV_SECTOR_BITS, s->io,
- PAGE_SECTORS << BDRV_SECTOR_BITS, 0) < 0) {
+ if (blk_pread(s->blk, SECTOR(addr) << BDRV_SECTOR_BITS,
+ PAGE_SECTORS << BDRV_SECTOR_BITS, s->io, 0) < 0) {
printf("%s: read error in sector %" PRIu64 "\n",
__func__, SECTOR(addr));
}
@@ -782,8 +782,9 @@ static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
OOB_SIZE);
s->ioaddr = s->io + SECTOR_OFFSET(s->addr) + offset;
} else {
- if (blk_pread(s->blk, PAGE_START(addr), s->io,
- (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, 0) < 0) {
+ if (blk_pread(s->blk, PAGE_START(addr),
+ (PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, s->io, 0)
+ < 0) {
printf("%s: read error in sector %" PRIu64 "\n",
__func__, PAGE_START(addr) >> 9);
}
diff --git a/hw/block/onenand.c b/hw/block/onenand.c
index 1225ec8..1fde975 100644
--- a/hw/block/onenand.c
+++ b/hw/block/onenand.c
@@ -229,8 +229,8 @@ static void onenand_reset(OneNANDState *s, int cold)
/* Lock the whole flash */
memset(s->blockwp, ONEN_LOCK_LOCKED, s->blocks);
- if (s->blk_cur && blk_pread(s->blk_cur, 0, s->boot[0],
- 8 << BDRV_SECTOR_BITS, 0) < 0) {
+ if (s->blk_cur && blk_pread(s->blk_cur, 0, 8 << BDRV_SECTOR_BITS,
+ s->boot[0], 0) < 0) {
hw_error("%s: Loading the BootRAM failed.\n", __func__);
}
}
@@ -249,8 +249,8 @@ static inline int onenand_load_main(OneNANDState *s, int sec, int secn,
assert(UINT32_MAX >> BDRV_SECTOR_BITS > sec);
assert(UINT32_MAX >> BDRV_SECTOR_BITS > secn);
if (s->blk_cur) {
- return blk_pread(s->blk_cur, sec << BDRV_SECTOR_BITS, dest,
- secn << BDRV_SECTOR_BITS, 0) < 0;
+ return blk_pread(s->blk_cur, sec << BDRV_SECTOR_BITS,
+ secn << BDRV_SECTOR_BITS, dest, 0) < 0;
} else if (sec + secn > s->secs_cur) {
return 1;
}
@@ -274,7 +274,7 @@ static inline int onenand_prog_main(OneNANDState *s, int sec, int secn,
uint8_t *dp = 0;
if (s->blk_cur) {
dp = g_malloc(size);
- if (!dp || blk_pread(s->blk_cur, offset, dp, size, 0) < 0) {
+ if (!dp || blk_pread(s->blk_cur, offset, size, dp, 0) < 0) {
result = 1;
}
} else {
@@ -290,7 +290,7 @@ static inline int onenand_prog_main(OneNANDState *s, int sec, int secn,
dp[i] &= sp[i];
}
if (s->blk_cur) {
- result = blk_pwrite(s->blk_cur, offset, dp, size, 0) < 0;
+ result = blk_pwrite(s->blk_cur, offset, size, dp, 0) < 0;
}
}
if (dp && s->blk_cur) {
@@ -308,7 +308,7 @@ static inline int onenand_load_spare(OneNANDState *s, int sec, int secn,
if (s->blk_cur) {
uint32_t offset = (s->secs_cur + (sec >> 5)) << BDRV_SECTOR_BITS;
- if (blk_pread(s->blk_cur, offset, buf, BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pread(s->blk_cur, offset, BDRV_SECTOR_SIZE, buf, 0) < 0) {
return 1;
}
memcpy(dest, buf + ((sec & 31) << 4), secn << 4);
@@ -333,7 +333,7 @@ static inline int onenand_prog_spare(OneNANDState *s, int sec, int secn,
if (s->blk_cur) {
dp = g_malloc(512);
if (!dp
- || blk_pread(s->blk_cur, offset, dp, BDRV_SECTOR_SIZE, 0) < 0) {
+ || blk_pread(s->blk_cur, offset, BDRV_SECTOR_SIZE, dp, 0) < 0) {
result = 1;
} else {
dpp = dp + ((sec & 31) << 4);
@@ -351,8 +351,8 @@ static inline int onenand_prog_spare(OneNANDState *s, int sec, int secn,
dpp[i] &= sp[i];
}
if (s->blk_cur) {
- result = blk_pwrite(s->blk_cur, offset, dp,
- BDRV_SECTOR_SIZE, 0) < 0;
+ result = blk_pwrite(s->blk_cur, offset, BDRV_SECTOR_SIZE, dp,
+ 0) < 0;
}
}
g_free(dp);
@@ -370,17 +370,17 @@ static inline int onenand_erase(OneNANDState *s, int sec, int num)
for (; num > 0; num--, sec++) {
if (s->blk_cur) {
int erasesec = s->secs_cur + (sec >> 5);
- if (blk_pwrite(s->blk_cur, sec << BDRV_SECTOR_BITS, blankbuf,
- BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pwrite(s->blk_cur, sec << BDRV_SECTOR_BITS,
+ BDRV_SECTOR_SIZE, blankbuf, 0) < 0) {
goto fail;
}
- if (blk_pread(s->blk_cur, erasesec << BDRV_SECTOR_BITS, tmpbuf,
- BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pread(s->blk_cur, erasesec << BDRV_SECTOR_BITS,
+ BDRV_SECTOR_SIZE, tmpbuf, 0) < 0) {
goto fail;
}
memcpy(tmpbuf + ((sec & 31) << 4), blankbuf, 1 << 4);
- if (blk_pwrite(s->blk_cur, erasesec << BDRV_SECTOR_BITS, tmpbuf,
- BDRV_SECTOR_SIZE, 0) < 0) {
+ if (blk_pwrite(s->blk_cur, erasesec << BDRV_SECTOR_BITS,
+ BDRV_SECTOR_SIZE, tmpbuf, 0) < 0) {
goto fail;
}
} else {
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 74c7190..0cbc2fb 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -392,8 +392,8 @@ static void pflash_update(PFlashCFI01 *pfl, int offset,
/* widen to sector boundaries */
offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
- ret = blk_pwrite(pfl->blk, offset, pfl->storage + offset,
- offset_end - offset, 0);
+ ret = blk_pwrite(pfl->blk, offset, offset_end - offset,
+ pfl->storage + offset, 0);
if (ret < 0) {
/* TODO set error bit in status */
error_report("Could not update PFLASH: %s", strerror(-ret));
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index 02c514f..2a99b28 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -400,8 +400,8 @@ static void pflash_update(PFlashCFI02 *pfl, int offset, int size)
/* widen to sector boundaries */
offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
- ret = blk_pwrite(pfl->blk, offset, pfl->storage + offset,
- offset_end - offset, 0);
+ ret = blk_pwrite(pfl->blk, offset, offset_end - offset,
+ pfl->storage + offset, 0);
if (ret < 0) {
/* TODO set error bit in status */
error_report("Could not update PFLASH: %s", strerror(-ret));