> >> -static void ioapic_reset(void *opaque) > >> +static void ioapic_reset(DeviceState *d) > >> { > >> - IOAPICState *s = opaque; > >> + IOAPICState *s = container_of(d, IOAPICState, busdev.qdev); > > > > DO_UPCAST()? I hate it, but it's what the other devices do... > > Both are used: > grep container_of hw/*.[ch]|wc -l > 81 > grep DO_UPCAST hw/*.[ch]|wc -l > 246
Which is appropriate depends on the context. DO_UPCAST is appropriate when we're dealing with polymorphic types. In this case IOAPICState is derived from DeviceState (via SysBusDevice). There is an implicit assumption that these are all the same object, so DO_UPCAST is approprate. container_of is approriate when we're embedding one object in annother, but without any inheritance relationship between the two. Paul