On 11/23/18 5:02 PM, Peter Maydell wrote:
On 23 November 2018 at 03:10, maozy <maozhon...@cmss.chinamobile.com> wrote:
In order to void the subclasses whose parent_realize field is
set to NULL, the k->realize function must be retained even
though it doesn't do anything practical. Just like this:
-/* TODO remove once all sysbus devices have been converted to realize*/
static void sysbus_realize(DeviceState *dev, Error **errp)
{
- SysBusDevice *sd = SYS_BUS_DEVICE(dev);
- SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
-
- if (!sbc->init) {
- return;
- }
- if (sbc->init(sd) < 0) {
- error_setg(errp, "Device initialization failed");
- }
}
it doesn't look elegant, but I didn't think of a better way, if you
can give me some hints, I really appreciate it. :)
If we do take this approach, we should have a comment which
says why we have an empty realize function, so that we don't
in future forget and delete the apparently unnecessary code...
OK, I got you, will do it.
Thanks,
Mao
thanks
-- PMM