summaryrefslogtreecommitdiff
path: root/hw/nvram/eeprom_at24c.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2018-05-28 16:45:07 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2018-06-01 15:14:31 +0200
commitc8c9e1039434b907ee982f3be04f81576bd1f588 (patch)
tree3cdbf978b8234f0676c6cbeea0ea110b3fbd1f3c /hw/nvram/eeprom_at24c.c
parent19473e51cc1b019b1987261e1af8bc8b4a858f12 (diff)
downloadqemu-c8c9e1039434b907ee982f3be04f81576bd1f588.zip
hw/i2c: Use DeviceClass::realize instead of I2CSlaveClass::init
I2CSlaveClass::init is no more used, remove it. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20180419212727.26095-3-f4bug@amsat.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20180528144509.15812-3-armbru@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/nvram/eeprom_at24c.c')
-rw-r--r--hw/nvram/eeprom_at24c.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
index 22183f5360..27cd01e615 100644
--- a/hw/nvram/eeprom_at24c.c
+++ b/hw/nvram/eeprom_at24c.c
@@ -116,31 +116,29 @@ int at24c_eeprom_send(I2CSlave *s, uint8_t data)
return 0;
}
-static
-int at24c_eeprom_init(I2CSlave *i2c)
+static void at24c_eeprom_realize(DeviceState *dev, Error **errp)
{
- EEPROMState *ee = AT24C_EE(i2c);
-
- ee->mem = g_malloc0(ee->rsize);
+ EEPROMState *ee = AT24C_EE(dev);
if (ee->blk) {
int64_t len = blk_getlength(ee->blk);
if (len != ee->rsize) {
- ERR(TYPE_AT24C_EE " : Backing file size %lu != %u\n",
- (unsigned long)len, (unsigned)ee->rsize);
- exit(1);
+ error_setg(errp, "%s: Backing file size %" PRId64 " != %u",
+ TYPE_AT24C_EE, len, ee->rsize);
+ return;
}
if (blk_set_perm(ee->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE,
BLK_PERM_ALL, &error_fatal) < 0)
{
- ERR(TYPE_AT24C_EE
- " : Backing file incorrect permission\n");
- exit(1);
+ error_setg(errp, "%s: Backing file incorrect permission",
+ TYPE_AT24C_EE);
+ return;
}
}
- return 0;
+
+ ee->mem = g_malloc0(ee->rsize);
}
static
@@ -178,7 +176,7 @@ void at24c_eeprom_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
- k->init = &at24c_eeprom_init;
+ dc->realize = &at24c_eeprom_realize;
k->event = &at24c_eeprom_event;
k->recv = &at24c_eeprom_recv;
k->send = &at24c_eeprom_send;