qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 03/11] hw/i2c: convert I2CSlaveClass::init -> re


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH 03/11] hw/i2c: convert I2CSlaveClass::init -> realize
Date: Fri, 19 Jan 2018 16:18:27 -0200
User-agent: Mutt/1.9.1 (2017-09-22)

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?

> -
> -    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;
[...]

-- 
Eduardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]