[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RESEND v3 44/58] sysbus: New sysbus_realize(), sysbus_realize_and
From: |
Markus Armbruster |
Subject: |
[PATCH RESEND v3 44/58] sysbus: New sysbus_realize(), sysbus_realize_and_unref() |
Date: |
Wed, 10 Jun 2020 07:32:33 +0200 |
Sysbus devices almost always plug into the main system bus.
qdev_create() even has a convenience feature to make that easy: a null
bus argument gets replaced by the main system bus. qdev_realize() and
qdev_realize_and_unref() do the same.
We can do better. Provide convenience wrappers around qdev_realize()
and qdev_realize_and_unref() that don't take a @bus argument. They
always pass the main system bus.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/hw/sysbus.h | 4 +++-
hw/core/sysbus.c | 14 ++++++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index c4a1c0adfa..606095ba35 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -90,6 +90,9 @@ void sysbus_add_io(SysBusDevice *dev, hwaddr addr,
MemoryRegion *mem);
MemoryRegion *sysbus_address_space(SysBusDevice *dev);
+bool sysbus_realize(SysBusDevice *dev, Error **errp);
+bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp);
+
/**
* sysbus_init_child_obj:
* @parent: The parent object
@@ -121,5 +124,4 @@ static inline DeviceState *sysbus_create_simple(const char
*name,
return sysbus_create_varargs(name, addr, irq, NULL);
}
-
#endif /* HW_SYSBUS_H */
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index e8d08d349b..68b837ac85 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -217,7 +217,7 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t
ioport, uint32_t size)
* from being set to NULL to break the normal init/realize
* of some devices.
*/
-static void sysbus_realize(DeviceState *dev, Error **errp)
+static void sysbus_device_realize(DeviceState *dev, Error **errp)
{
}
@@ -250,6 +250,16 @@ DeviceState *sysbus_create_varargs(const char *name,
return dev;
}
+bool sysbus_realize(SysBusDevice *dev, Error **errp)
+{
+ return qdev_realize(DEVICE(dev), sysbus_get_default(), errp);
+}
+
+bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp)
+{
+ return qdev_realize_and_unref(DEVICE(dev), sysbus_get_default(), errp);
+}
+
static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
{
SysBusDevice *s = SYS_BUS_DEVICE(dev);
@@ -301,7 +311,7 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
static void sysbus_device_class_init(ObjectClass *klass, void *data)
{
DeviceClass *k = DEVICE_CLASS(klass);
- k->realize = sysbus_realize;
+ k->realize = sysbus_device_realize;
k->bus_type = TYPE_SYSTEM_BUS;
/*
* device_add plugs devices into a suitable bus. For "real" buses,
--
2.26.2
- [PATCH RESEND v3 29/58] usb: Eliminate usb_try_create_simple(), (continued)
- [PATCH RESEND v3 29/58] usb: Eliminate usb_try_create_simple(), Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 21/58] isa: isa_create(), isa_try_create() are now unused, drop, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 32/58] auxbus: New aux_bus_realize(), pairing with aux_bus_init(), Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 33/58] auxbus: Convert a use of qdev_set_parent_bus(), Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 17/58] pci: pci_create(), pci_create_multifunction() are now unused, drop, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 46/58] qdev: Drop qdev_realize() support for null bus, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 13/58] pci: New pci_new(), pci_realize_and_unref() etc., Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 42/58] hw/arm/armsse: Pass correct child size to sysbus_init_child_obj(), Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 25/58] ssi: ssi_create_slave_no_init() is now unused, drop, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 15/58] pci: Convert uses of pci_create() etc. with Coccinelle, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 44/58] sysbus: New sysbus_realize(), sysbus_realize_and_unref(),
Markus Armbruster <=
- [PATCH RESEND v3 37/58] macio: Convert use of qdev_set_parent_bus(), Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 40/58] microbit: Tidy up sysbus_init_child_obj() @child argument, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 39/58] sysbus: Drop useless OBJECT() in sysbus_init_child_obj() calls, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 41/58] sysbus: Tidy up sysbus_init_child_obj()'s @childsize arg, part 1, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 43/58] sysbus: Tidy up sysbus_init_child_obj()'s @childsize arg, part 2, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 50/58] sysbus: Convert qdev_set_parent_bus() use with Coccinelle, part 4, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 51/58] sysbus: sysbus_init_child_obj() is now unused, drop, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 28/58] usb: usb_create() is now unused, drop, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 54/58] qdev: Make qdev_realize() support bus-less devices, Markus Armbruster, 2020/06/10
- [PATCH RESEND v3 11/58] qdev: Convert uses of qdev_set_parent_bus() with Coccinelle, Markus Armbruster, 2020/06/10