Am 04.02.2013 14:44, schrieb Peter Maydell: > Convert this device from old-style qdev init to an instance_init > function. We don't need a realize function yet, though. > > Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> > --- > hw/arm_sysctl.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/hw/arm_sysctl.c b/hw/arm_sysctl.c > index bb56238..ecee6fe 100644 > --- a/hw/arm_sysctl.c > +++ b/hw/arm_sysctl.c > @@ -525,15 +525,15 @@ static void arm_sysctl_gpio_set(void *opaque, int line, > int level) > } > } > > -static int arm_sysctl_init(SysBusDevice *dev) > +static void arm_sysctl_init(Object *obj) > { > + SysBusDevice *dev = SYS_BUS_DEVICE(obj); > arm_sysctl_state *s = FROM_SYSBUS(arm_sysctl_state, dev); > > memory_region_init_io(&s->iomem, &arm_sysctl_ops, s, "arm-sysctl", > 0x1000); > sysbus_init_mmio(dev, &s->iomem); > qdev_init_gpio_in(&s->busdev.qdev, arm_sysctl_gpio_set, 2); > qdev_init_gpio_out(&s->busdev.qdev, &s->pl110_mux_ctrl, 1); > - return 0; > }
Since there is only one user of SysBusDevice "dev" suggest to do DeviceState *dev = DEVICE(obj); SysBusDevice *d = SYS_BUS_DEVICE(obj); // or whatever pleases ... sysbus_init_mmio(d, ...); qdev_init_gpio_in(dev, ...); Also the FROM_SYSBUS() should be replaced, but not necessarily in this patch. (Sorry if I'm duplicating comments, I only see this one patch currently). > > static Property arm_sysctl_properties[] = { > @@ -545,9 +545,7 @@ static Property arm_sysctl_properties[] = { > static void arm_sysctl_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); > > - k->init = arm_sysctl_init; > dc->reset = arm_sysctl_reset; > dc->vmsd = &vmstate_arm_sysctl; > dc->props = arm_sysctl_properties; > @@ -557,6 +555,7 @@ static const TypeInfo arm_sysctl_info = { > .name = "realview_sysctl", > .parent = TYPE_SYS_BUS_DEVICE, > .instance_size = sizeof(arm_sysctl_state), > + .instance_init = arm_sysctl_init, > .class_init = arm_sysctl_class_init, > }; > The change itself looks correct, only thing I wonder is whether we should standardize on _initfn or on _init naming. I think for QOM we've been using _class_init but _initfn mostly. Cheers, Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg