qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 06/11] sysbus: add realize() and unrealize()


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH 06/11] sysbus: add realize() and unrealize()
Date: Fri, 19 Jan 2018 16:03:02 -0200
User-agent: Mutt/1.9.1 (2017-09-22)

On Tue, Jan 16, 2018 at 10:15:50AM -0300, Philippe Mathieu-Daudé wrote:
[...]
> +static void sysbus_realize(DeviceState *dev, Error **errp)
> +{
> +    SysBusDevice *sd = SYS_BUS_DEVICE(dev);
> +    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
> +
> +    if (sbc->realize) {
> +        sbc->realize(sd, errp);
> +    }
> +}
> +
> +static void sysbus_unrealize(DeviceState *dev, Error **errp)
> +{
> +    SysBusDevice *sd = SYS_BUS_DEVICE(dev);
> +    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
> +
> +    if (sbc->unrealize) {
> +        sbc->unrealize(sd, errp);
> +    }
> +}

Why not just let the subclasses set DeviceClass::realize and
DeviceClass::unrealize directly?

> +
>  DeviceState *sysbus_create_varargs(const char *name,
>                                     hwaddr addr, ...)
>  {
> @@ -325,6 +346,8 @@ static void sysbus_device_class_init(ObjectClass *klass, 
> void *data)
>  {
>      DeviceClass *k = DEVICE_CLASS(klass);
>      k->init = sysbus_device_init;
> +    k->realize = sysbus_realize;
> +    k->unrealize = sysbus_unrealize;
>      k->bus_type = TYPE_SYSTEM_BUS;
>      /*
>       * device_add plugs devices into a suitable bus.  For "real" buses,
> -- 
> 2.15.1
> 
> 

-- 
Eduardo



reply via email to

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