hw/nvram/eeprom_at24c: Remove ERR macro that calls fprintf to stderr

In the realize method error_setg can be used like other places there
already do. The other usage can be replaced with error_report which is
the preferred way instead of directly printing to stderr.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <637b92984795a385b648a84208f093947cc261e4.1740839457.git.balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
BALATON Zoltan 2025-03-01 15:35:34 +01:00 committed by Philippe Mathieu-Daudé
parent f94a158c70
commit bf042a6a2a

View File

@ -10,6 +10,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu/module.h"
#include "hw/i2c/i2c.h"
#include "hw/nvram/eeprom_at24c.h"
@ -26,9 +27,6 @@
#define DPRINTK(FMT, ...) do {} while (0)
#endif
#define ERR(FMT, ...) fprintf(stderr, TYPE_AT24C_EE " : " FMT, \
## __VA_ARGS__)
#define TYPE_AT24C_EE "at24c-eeprom"
OBJECT_DECLARE_SIMPLE_TYPE(EEPROMState, AT24C_EE)
@ -75,8 +73,7 @@ int at24c_eeprom_event(I2CSlave *s, enum i2c_event event)
if (ee->blk && ee->changed) {
int ret = blk_pwrite(ee->blk, 0, ee->rsize, ee->mem, 0);
if (ret < 0) {
ERR(TYPE_AT24C_EE
" : failed to write backing file\n");
error_report("%s: failed to write backing file", __func__);
}
DPRINTK("Wrote to backing file\n");
}
@ -203,8 +200,9 @@ static void at24c_eeprom_realize(DeviceState *dev, Error **errp)
int ret = blk_pread(ee->blk, 0, ee->rsize, ee->mem, 0);
if (ret < 0) {
ERR(TYPE_AT24C_EE
" : Failed initial sync with backing file\n");
error_setg(errp, "%s: Failed initial sync with backing file",
TYPE_AT24C_EE);
return;
}
DPRINTK("Reset read backing file\n");
}