diff mbox

[1/5] sysbus: make SysBusDeviceClass::init optional

Message ID 1360928706-13041-2-git-send-email-peter.maydell@linaro.org
State Superseded
Headers show

Commit Message

Peter Maydell Feb. 15, 2013, 11:45 a.m. UTC
Make the SysBusDeviceClass::init optional, for devices which
genuinely don't need to do anything here. In particular, simple
devices which can do all their initialization in their
instance_init method don't need either a DeviceClass::realize
or SysBusDeviceClass::init method.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/sysbus.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Andreas Färber Feb. 15, 2013, 12:41 p.m. UTC | #1
Am 15.02.2013 12:45, schrieb Peter Maydell:
> Make the SysBusDeviceClass::init optional, for devices which
> genuinely don't need to do anything here. In particular, simple
> devices which can do all their initialization in their
> instance_init method don't need either a DeviceClass::realize
> or SysBusDeviceClass::init method.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Acked-by: Andreas Färber <afaerber@suse.de>

Andreas
diff mbox

Patch

diff --git a/hw/sysbus.c b/hw/sysbus.c
index 6d9d1df..e9a16ac 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -118,6 +118,9 @@  static int sysbus_device_init(DeviceState *dev)
     SysBusDevice *sd = SYS_BUS_DEVICE(dev);
     SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
 
+    if (!sbc->init) {
+        return 0;
+    }
     return sbc->init(sd);
 }