On 01/19/2018 03:18 PM, Eduardo Habkost wrote: > On Tue, Jan 16, 2018 at 10:15:47AM -0300, Philippe Mathieu-Daudé wrote: > [...] >> -static int i2c_slave_qdev_init(DeviceState *dev) >> +static void i2c_slave_realize(DeviceState *dev, Error **errp) >> { >> I2CSlave *s = I2C_SLAVE(dev); >> I2CSlaveClass *sc = I2C_SLAVE_GET_CLASS(s); >> >> - if (sc->init) { >> - return sc->init(s); >> + if (sc->realize) { >> + return sc->realize(s, errp); >> } > > Do you think i2c_slave_realize() will perform additional actions > in the future? If not, why not let subclasses set > DeviceClass::realize directly?
Good idea, also with SMBusDeviceClass::realize. >> - >> - return 0; >> } >> >> DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr) >> @@ -301,7 +299,7 @@ DeviceState *i2c_create_slave(I2CBus *bus, const char >> *name, uint8_t addr) >> static void i2c_slave_class_init(ObjectClass *klass, void *data) >> { >> DeviceClass *k = DEVICE_CLASS(klass); >> - k->init = i2c_slave_qdev_init; >> + k->realize = i2c_slave_realize; >> set_bit(DEVICE_CATEGORY_MISC, k->categories); >> k->bus_type = TYPE_I2C_BUS; >> k->props = i2c_props; > [...] >