From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Eduardo Habkost <ehabkost@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Eric Blake <eblake@redhat.com>,
Marcel Apfelbaum <marcel@redhat.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 06/11] sysbus: add realize() and unrealize()
Date: Tue, 16 Jan 2018 10:15:50 -0300 [thread overview]
Message-ID: <20180116131555.14242-7-f4bug@amsat.org> (raw)
In-Reply-To: <20180116131555.14242-1-f4bug@amsat.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/sysbus.h | 4 ++++
hw/core/sysbus.c | 23 +++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index e88bb6dae0..c87a6df29e 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -40,6 +40,10 @@ typedef struct SysBusDeviceClass {
DeviceClass parent_class;
/*< public >*/
+ void (*realize)(SysBusDevice *dev, Error **errp);
+ void (*unrealize)(SysBusDevice *dev, Error **errp);
+
+ /* TODO remove, once users are converted to realize */
int (*init)(SysBusDevice *dev);
/*
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 5d0887f499..04d6061f76 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -200,6 +200,7 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t ioport, uint32_t size)
}
}
+/* TODO remove, once users are converted to realize */
static int sysbus_device_init(DeviceState *dev)
{
SysBusDevice *sd = SYS_BUS_DEVICE(dev);
@@ -211,6 +212,26 @@ static int sysbus_device_init(DeviceState *dev)
return sbc->init(sd);
}
+static void sysbus_realize(DeviceState *dev, Error **errp)
+{
+ SysBusDevice *sd = SYS_BUS_DEVICE(dev);
+ SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
+
+ if (sbc->realize) {
+ sbc->realize(sd, errp);
+ }
+}
+
+static void sysbus_unrealize(DeviceState *dev, Error **errp)
+{
+ SysBusDevice *sd = SYS_BUS_DEVICE(dev);
+ SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd);
+
+ if (sbc->unrealize) {
+ sbc->unrealize(sd, errp);
+ }
+}
+
DeviceState *sysbus_create_varargs(const char *name,
hwaddr addr, ...)
{
@@ -325,6 +346,8 @@ 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->unrealize = sysbus_unrealize;
k->bus_type = TYPE_SYSTEM_BUS;
/*
* device_add plugs devices into a suitable bus. For "real" buses,
--
2.15.1
next prev parent reply other threads:[~2018-01-16 13:16 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-16 13:15 [Qemu-devel] [PATCH 00/11] qdev: remove DeviceClass::init/exit() Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 01/11] smbus: add a NULL check for SMBusDeviceClass::init callbacks Philippe Mathieu-Daudé
2018-01-19 17:58 ` Eduardo Habkost
2018-01-16 13:15 ` [Qemu-devel] [PATCH 02/11] smbus_eeprom: replace SMBusDeviceClass::init by DeviceClass::reset Philippe Mathieu-Daudé
2018-01-19 18:15 ` Eduardo Habkost
2018-01-19 21:41 ` Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 03/11] hw/i2c: convert I2CSlaveClass::init -> realize Philippe Mathieu-Daudé
2018-01-16 14:09 ` Philippe Mathieu-Daudé
2018-01-19 18:18 ` Eduardo Habkost
2018-01-19 18:53 ` Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 04/11] usb-ccid: convert CCIDCardClass::init " Philippe Mathieu-Daudé
2018-01-18 17:05 ` Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 05/11] virtio-ccw: convert VirtIOCCWDeviceClass::init " Philippe Mathieu-Daudé
2018-01-16 13:41 ` Farhan Ali
2018-01-16 14:07 ` Philippe Mathieu-Daudé
2018-01-16 16:11 ` Farhan Ali
2018-01-16 16:52 ` Cornelia Huck
2018-01-17 12:30 ` Philippe Mathieu-Daudé
2018-01-16 13:15 ` Philippe Mathieu-Daudé [this message]
2018-01-19 18:03 ` [Qemu-devel] [PATCH 06/11] sysbus: add realize() and unrealize() Eduardo Habkost
2018-01-19 19:03 ` Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 07/11] qdev: simplify the SysBusDeviceClass::init path Philippe Mathieu-Daudé
2018-01-19 18:24 ` Eduardo Habkost
2018-01-16 13:15 ` [Qemu-devel] [PATCH 08/11] qdev: remove DeviceClass::init Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 09/11] qdev: remove DeviceClass::exit Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 10/11] qdev: remove empty realize/unrealize stubs Philippe Mathieu-Daudé
2018-01-16 13:15 ` [Qemu-devel] [PATCH 11/11] qdev: rename typedef qdev_resetfn() -> DeviceReset() Philippe Mathieu-Daudé
2018-01-17 5:45 ` [Qemu-devel] [PATCH 00/11] qdev: remove DeviceClass::init/exit() no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180116131555.14242-7-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=marcel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).