aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/block/m25p80.c2
-rw-r--r--hw/misc/mac_via.c4
-rw-r--r--hw/misc/sifive_u_otp.c2
-rw-r--r--hw/nvram/eeprom_at24c.c8
-rw-r--r--hw/nvram/spapr_nvram.c14
-rw-r--r--hw/ppc/pnv_pnor.c2
6 files changed, 16 insertions, 16 deletions
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 3045dda53b..755134313d 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) != s->size) {
+ if (blk_pread(s->blk, 0, s->storage, s->size) < 0) {
error_setg(errp, "failed to read the initial flash content");
return;
}
diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c
index 525e38ce93..c32325dcaf 100644
--- a/hw/misc/mac_via.c
+++ b/hw/misc/mac_via.c
@@ -1029,8 +1029,8 @@ static void mos6522_q800_via1_realize(DeviceState *dev, Error **errp)
return;
}
- len = blk_pread(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM));
- if (len != sizeof(v1s->PRAM)) {
+ ret = blk_pread(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM));
+ if (ret < 0) {
error_setg(errp, "can't read PRAM contents");
return;
}
diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c
index 6d5f84e6c2..535acde08b 100644
--- a/hw/misc/sifive_u_otp.c
+++ b/hw/misc/sifive_u_otp.c
@@ -240,7 +240,7 @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
return;
}
- if (blk_pread(s->blk, 0, s->fuse, filesize) != filesize) {
+ if (blk_pread(s->blk, 0, s->fuse, filesize) < 0) {
error_setg(errp, "failed to read the initial flash content");
return;
}
diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
index d695f6ae89..8fd9f97eee 100644
--- a/hw/nvram/eeprom_at24c.c
+++ b/hw/nvram/eeprom_at24c.c
@@ -64,8 +64,8 @@ int at24c_eeprom_event(I2CSlave *s, enum i2c_event event)
case I2C_START_RECV:
DPRINTK("clear\n");
if (ee->blk && ee->changed) {
- int len = blk_pwrite(ee->blk, 0, ee->mem, ee->rsize, 0);
- if (len != ee->rsize) {
+ int ret = blk_pwrite(ee->blk, 0, ee->mem, ee->rsize, 0);
+ if (ret < 0) {
ERR(TYPE_AT24C_EE
" : failed to write backing file\n");
}
@@ -165,9 +165,9 @@ void at24c_eeprom_reset(DeviceState *state)
memset(ee->mem, 0, ee->rsize);
if (ee->blk) {
- int len = blk_pread(ee->blk, 0, ee->mem, ee->rsize);
+ int ret = blk_pread(ee->blk, 0, ee->mem, ee->rsize);
- if (len != ee->rsize) {
+ if (ret < 0) {
ERR(TYPE_AT24C_EE
" : Failed initial sync with backing file\n");
}
diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c
index 18b43be7f6..59d2e7b705 100644
--- a/hw/nvram/spapr_nvram.c
+++ b/hw/nvram/spapr_nvram.c
@@ -103,7 +103,7 @@ static void rtas_nvram_store(PowerPCCPU *cpu, SpaprMachineState *spapr,
{
SpaprNvram *nvram = spapr->nvram;
hwaddr offset, buffer, len;
- int alen;
+ int ret;
void *membuf;
if ((nargs != 3) || (nret != 2)) {
@@ -128,9 +128,9 @@ static void rtas_nvram_store(PowerPCCPU *cpu, SpaprMachineState *spapr,
membuf = cpu_physical_memory_map(buffer, &len, false);
- alen = len;
+ ret = 0;
if (nvram->blk) {
- alen = blk_pwrite(nvram->blk, offset, membuf, len, 0);
+ ret = blk_pwrite(nvram->blk, offset, membuf, len, 0);
}
assert(nvram->buf);
@@ -138,8 +138,8 @@ static void rtas_nvram_store(PowerPCCPU *cpu, SpaprMachineState *spapr,
cpu_physical_memory_unmap(membuf, len, 0, len);
- rtas_st(rets, 0, (alen < len) ? RTAS_OUT_HW_ERROR : RTAS_OUT_SUCCESS);
- rtas_st(rets, 1, (alen < 0) ? 0 : alen);
+ rtas_st(rets, 0, (ret < 0) ? RTAS_OUT_HW_ERROR : RTAS_OUT_SUCCESS);
+ rtas_st(rets, 1, (ret < 0) ? 0 : len);
}
static void spapr_nvram_realize(SpaprVioDevice *dev, Error **errp)
@@ -179,9 +179,9 @@ static void spapr_nvram_realize(SpaprVioDevice *dev, Error **errp)
}
if (nvram->blk) {
- int alen = blk_pread(nvram->blk, 0, nvram->buf, nvram->size);
+ ret = blk_pread(nvram->blk, 0, nvram->buf, nvram->size);
- if (alen != nvram->size) {
+ if (ret < 0) {
error_setg(errp, "can't read spapr-nvram contents");
return;
}
diff --git a/hw/ppc/pnv_pnor.c b/hw/ppc/pnv_pnor.c
index 83ecccca28..1fb748afef 100644
--- a/hw/ppc/pnv_pnor.c
+++ b/hw/ppc/pnv_pnor.c
@@ -99,7 +99,7 @@ static void pnv_pnor_realize(DeviceState *dev, Error **errp)
s->storage = blk_blockalign(s->blk, s->size);
- if (blk_pread(s->blk, 0, s->storage, s->size) != s->size) {
+ if (blk_pread(s->blk, 0, s->storage, s->size) < 0) {
error_setg(errp, "failed to read the initial flash content");
return;
}