Every bus-layer *_orphan() wrapper is gone and the last direct
caller, qdev_device_add_from_qdict(), now uses object_new() plus
qdev_set_id() to place -device instances under
/machine/peripheral{,-anon} as before. There is no remaining
legitimate way to create a device without picking its parent, so
drop the transitional *_orphan() spellings and update the doc
comments that still referenced them.
Assisted-by: Kiro
Signed-off-by: Alexander Graf <[email protected]>
---
hw/core/qdev.c | 13 -------------
include/hw/core/qdev.h | 30 +++---------------------------
system/qdev-monitor.c | 2 +-
3 files changed, 4 insertions(+), 41 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index d2c89d0310..f7b512eb35 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -164,19 +164,6 @@ DeviceState *qdev_try_new(Object *parent, const char *id,
const char *type)
return DEVICE(obj);
}
-DeviceState *qdev_new_orphan(const char *name)
-{
- return DEVICE(object_new(name));
-}
-
-DeviceState *qdev_try_new_orphan(const char *name)
-{
- ObjectClass *oc = module_object_class_by_name(name);
- if (!oc) {
- return NULL;
- }
- return DEVICE(object_new_with_class(oc));
-}
static QTAILQ_HEAD(, DeviceListener) device_listeners
= QTAILQ_HEAD_INITIALIZER(device_listeners);
diff --git a/include/hw/core/qdev.h b/include/hw/core/qdev.h
index e692a1d48e..9220e9e3b1 100644
--- a/include/hw/core/qdev.h
+++ b/include/hw/core/qdev.h
@@ -440,30 +440,6 @@ DeviceState *qdev_new(Object *parent, const char *id,
const char *type);
*/
DeviceState *qdev_try_new(Object *parent, const char *id, const char *type);
-/**
- * qdev_new_orphan: Create a device on the heap
- * @name: device type to create (we assert() that this type exists)
- *
- * This only allocates the memory and initializes the device state
- * structure, ready for the caller to set properties if they wish.
- * The device still needs to be realized.
- *
- * Return: a derived DeviceState object with a reference count of 1.
- */
-DeviceState *qdev_new_orphan(const char *name);
-
-/**
- * qdev_try_new_orphan: Try to create a device on the heap
- * @name: device type to create
- *
- * This is like qdev_new_orphan(), except it returns %NULL when type @name
- * does not exist, rather than asserting.
- *
- * Return: a derived DeviceState object with a reference count of 1 or
- * NULL if type @name does not exist.
- */
-DeviceState *qdev_try_new_orphan(const char *name);
-
/**
* qdev_is_realized() - check if device is realized
* @dev: The device to check.
@@ -488,8 +464,8 @@ static inline bool qdev_is_realized(DeviceState *dev)
* If @bus, plug @dev into @bus. This takes a reference to @dev.
* If @dev has no QOM parent, make one up, taking another reference.
*
- * If you created @dev using qdev_new_orphan(), you probably want to use
- * qdev_realize_and_unref() instead.
+ * If you created @dev via object_new() directly (holding a floating
+ * reference), you probably want to use qdev_realize_and_unref() instead.
*
* Return: true on success, else false setting @errp with error
*/
@@ -506,7 +482,7 @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error
**errp);
* (private) reference, which is dropped on return regardless of
* success or failure. Intended use::
*
- * dev = qdev_new_orphan();
+ * dev = DEVICE(object_new(TYPE_FOO));
* [...]
* qdev_realize_and_unref(dev, bus, errp);
*
diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index adc37d6a89..0e13b1540c 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -707,7 +707,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
}
/* create device */
- dev = qdev_new_orphan(driver);
+ dev = DEVICE(object_new(driver));
/* Check whether the hotplug is allowed by the machine */
if (phase_check(PHASE_MACHINE_READY) &&
--
2.47.1