[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 50/53] qdev: Simplify the SysBusDeviceClass::init pat
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 50/53] qdev: Simplify the SysBusDeviceClass::init path |
Date: |
Thu, 31 May 2018 19:16:03 +0200 |
From: Philippe Mathieu-Daudé <address@hidden>
Instead of using
SysBusDeviceClass::realize
-> DeviceClass::realize
-> DeviceClass::init
-> sysbus_device_init
-> SysBusDeviceClass::init
Simplify the path by directly calling SysBusDeviceClass::init
in SysBusDeviceClass::realize:
SysBusDeviceClass::realize
-> SysBusDeviceClass::init
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
[Removal of DeviceClass::init() moved into next patch,
sysbus_realize() tweaked for clarity]
Signed-off-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/core/sysbus.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 5d0887f499..ecfb0cfc0e 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
+#include "qapi/error.h"
#include "hw/sysbus.h"
#include "monitor/monitor.h"
#include "exec/address-spaces.h"
@@ -200,15 +201,18 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t
ioport, uint32_t size)
}
}
-static int sysbus_device_init(DeviceState *dev)
+/* 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 0;
+ return;
+ }
+ if (sbc->init(sd) < 0) {
+ error_setg(errp, "Device initialization failed");
}
- return sbc->init(sd);
}
DeviceState *sysbus_create_varargs(const char *name,
@@ -324,7 +328,7 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
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->bus_type = TYPE_SYSTEM_BUS;
/*
* device_add plugs devices into a suitable bus. For "real" buses,
--
2.17.0
- [Qemu-devel] [PULL 40/53] docs/interop: add "firmware.json", (continued)
- [Qemu-devel] [PULL 40/53] docs/interop: add "firmware.json", Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 44/53] scripts/update-linux-headers: Handle kernel license no longer being one file, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 47/53] target/i386/kvm.c: Remove compatibility shim for KVM_HINTS_REALTIME, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 42/53] virtio-gpu-3d: Define VIRTIO_GPU_CAPSET_VIRGL2 elsewhere, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 48/53] hw/i2c/smbus: Use DeviceClass::realize instead of SMBusDeviceClass::init, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 52/53] char: Remove unwanted crlf conversion, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 51/53] qdev: Remove DeviceClass::init() and ::exit(), Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 53/53] memory: Make operations using MemoryRegionIoeventfd struct pass by pointer., Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 49/53] hw/i2c: Use DeviceClass::realize instead of I2CSlaveClass::init, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 50/53] qdev: Simplify the SysBusDeviceClass::init path,
Paolo Bonzini <=
- [Qemu-devel] [PULL 46/53] Update Linux headers to 4.17-rc6, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 37/53] tcg: remove softfloat from --disable-tcg builds, Paolo Bonzini, 2018/05/31
- Re: [Qemu-devel] [PULL 00/53] Misc patches for 2018-05-31, Peter Maydell, 2018/05/31