diff mbox series

[v2,46/58] qdev: Drop qdev_realize() support for null bus

Message ID 20200529134523.8477-47-armbru@redhat.com
State New
Headers show
Series qdev: Rework how we plug into the parent bus | expand

Commit Message

Markus Armbruster May 29, 2020, 1:45 p.m. UTC
The "null @bus means main system bus" convenience feature is no longer
used.  Drop it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/core/qdev.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

Comments

Philippe Mathieu-Daudé June 9, 2020, 8:45 a.m. UTC | #1
On 5/29/20 3:45 PM, Markus Armbruster wrote:
> The "null @bus means main system bus" convenience feature is no longer
> used.  Drop it.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hw/core/qdev.c | 16 ++--------------
>  1 file changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index a1fdebb3aa..78a06db76e 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -408,8 +408,7 @@ void qdev_init_nofail(DeviceState *dev)
>  /*
>   * Realize @dev.
>   * @dev must not be plugged into a bus.
> - * Plug @dev into @bus if non-null, else into the main system bus.
> - * This takes a reference to @dev.
> + * Plug @dev into @bus.  This takes a reference to @dev.
>   * If @dev has no QOM parent, make one up, taking another reference.
>   * On success, return true.
>   * On failure, store an error through @errp and return false.
> @@ -419,18 +418,7 @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
>      Error *err = NULL;
>  
>      assert(!dev->realized && !dev->parent_bus);
> -
> -    if (!bus) {
> -        /*
> -         * Assert that the device really is a SysBusDevice before we
> -         * put it onto the sysbus.  Non-sysbus devices which aren't
> -         * being put onto a bus should be realized with
> -         * object_property_set_bool(OBJECT(dev), true, "realized",
> -         * errp);
> -         */
> -        g_assert(object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE));
> -        bus = sysbus_get_default();
> -    }
> +    assert(bus);

Hmm what about renaming that to sysbus_init_nofail() and keep
qdev_init_nofail() (without the bus part)?

>  
>      qdev_set_parent_bus(dev, bus);
>  
>
Markus Armbruster June 9, 2020, 10:05 a.m. UTC | #2
Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> On 5/29/20 3:45 PM, Markus Armbruster wrote:
>> The "null @bus means main system bus" convenience feature is no longer
>> used.  Drop it.
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  hw/core/qdev.c | 16 ++--------------
>>  1 file changed, 2 insertions(+), 14 deletions(-)
>> 
>> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
>> index a1fdebb3aa..78a06db76e 100644
>> --- a/hw/core/qdev.c
>> +++ b/hw/core/qdev.c
>> @@ -408,8 +408,7 @@ void qdev_init_nofail(DeviceState *dev)
>>  /*
>>   * Realize @dev.
>>   * @dev must not be plugged into a bus.
>> - * Plug @dev into @bus if non-null, else into the main system bus.
>> - * This takes a reference to @dev.
>> + * Plug @dev into @bus.  This takes a reference to @dev.
>>   * If @dev has no QOM parent, make one up, taking another reference.
>>   * On success, return true.
>>   * On failure, store an error through @errp and return false.
>> @@ -419,18 +418,7 @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
>>      Error *err = NULL;
>>  
>>      assert(!dev->realized && !dev->parent_bus);
>> -
>> -    if (!bus) {
>> -        /*
>> -         * Assert that the device really is a SysBusDevice before we
>> -         * put it onto the sysbus.  Non-sysbus devices which aren't
>> -         * being put onto a bus should be realized with
>> -         * object_property_set_bool(OBJECT(dev), true, "realized",
>> -         * errp);
>> -         */
>> -        g_assert(object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE));
>> -        bus = sysbus_get_default();
>> -    }
>> +    assert(bus);
>
> Hmm what about renaming that to sysbus_init_nofail() and keep
> qdev_init_nofail() (without the bus part)?

I'm dense.  What are you proposing?

>>  
>>      qdev_set_parent_bus(dev, bus);
>>  
>>
diff mbox series

Patch

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index a1fdebb3aa..78a06db76e 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -408,8 +408,7 @@  void qdev_init_nofail(DeviceState *dev)
 /*
  * Realize @dev.
  * @dev must not be plugged into a bus.
- * Plug @dev into @bus if non-null, else into the main system bus.
- * This takes a reference to @dev.
+ * Plug @dev into @bus.  This takes a reference to @dev.
  * If @dev has no QOM parent, make one up, taking another reference.
  * On success, return true.
  * On failure, store an error through @errp and return false.
@@ -419,18 +418,7 @@  bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
     Error *err = NULL;
 
     assert(!dev->realized && !dev->parent_bus);
-
-    if (!bus) {
-        /*
-         * Assert that the device really is a SysBusDevice before we
-         * put it onto the sysbus.  Non-sysbus devices which aren't
-         * being put onto a bus should be realized with
-         * object_property_set_bool(OBJECT(dev), true, "realized",
-         * errp);
-         */
-        g_assert(object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE));
-        bus = sysbus_get_default();
-    }
+    assert(bus);
 
     qdev_set_parent_bus(dev, bus);