diff mbox

[v7,1/6] qdev: get_child_bus(): Use QOM lookup if available

Message ID de67cc151dcaa355946bca494306edec4199ba4f.1452896266.git.alistair.francis@xilinx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alistair Francis Jan. 15, 2016, 10:38 p.m. UTC
From: Peter Crosthwaite <crosthwaitepeter@gmail.com>

qbus_realize() adds busses as a QOM child of the device in addition to
adding it to the qdev bus list. Change get_child_bus() to use the QOM
child if it is available. This takes priority over the bus-list, but
the child object is checked for type correctness.

This prepares support for aliasing of buses. The use case is SoCs,
where a SoC container needs to present buses to the board level, but
the buses are implemented by controller IP we already model as self
contained qbus-containing devices.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Acked-by: Alistair Francis <alistair.francis@xilinx.com>
---
 hw/core/qdev.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Peter Crosthwaite Jan. 15, 2016, 10:47 p.m. UTC | #1
On Fri, Jan 15, 2016 at 2:38 PM, Alistair Francis
<alistair.francis@xilinx.com> wrote:
> From: Peter Crosthwaite <crosthwaitepeter@gmail.com>
>
> qbus_realize() adds busses as a QOM child of the device in addition to
> adding it to the qdev bus list. Change get_child_bus() to use the QOM
> child if it is available. This takes priority over the bus-list, but
> the child object is checked for type correctness.
>
> This prepares support for aliasing of buses. The use case is SoCs,
> where a SoC container needs to present buses to the board level, but
> the buses are implemented by controller IP we already model as self
> contained qbus-containing devices.
>
> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
> Acked-by: Alistair Francis <alistair.francis@xilinx.com>

As a re-sender, you need to Signed-off-by as well. I'm guessing you
can just do this on list like a review to avoid the respin.

Regards,
Peter

> ---
>  hw/core/qdev.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 2c7101d..75d1227 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -580,6 +580,12 @@ void qdev_pass_gpios(DeviceState *dev, DeviceState *container,
>  BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
>  {
>      BusState *bus;
> +    Object *child = object_resolve_path_component(OBJECT(dev), name);
> +
> +    bus = (BusState *)object_dynamic_cast(child, TYPE_BUS);
> +    if (bus) {
> +        return bus;
> +    }
>
>      QLIST_FOREACH(bus, &dev->child_bus, sibling) {
>          if (strcmp(name, bus->name) == 0) {
> --
> 2.5.0
>
Alistair Francis Jan. 16, 2016, midnight UTC | #2
On Fri, Jan 15, 2016 at 2:47 PM, Peter Crosthwaite
<crosthwaitepeter@gmail.com> wrote:
> On Fri, Jan 15, 2016 at 2:38 PM, Alistair Francis
> <alistair.francis@xilinx.com> wrote:
>> From: Peter Crosthwaite <crosthwaitepeter@gmail.com>
>>
>> qbus_realize() adds busses as a QOM child of the device in addition to
>> adding it to the qdev bus list. Change get_child_bus() to use the QOM
>> child if it is available. This takes priority over the bus-list, but
>> the child object is checked for type correctness.
>>
>> This prepares support for aliasing of buses. The use case is SoCs,
>> where a SoC container needs to present buses to the board level, but
>> the buses are implemented by controller IP we already model as self
>> contained qbus-containing devices.
>>
>> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
>> Acked-by: Alistair Francis <alistair.francis@xilinx.com>
>
> As a re-sender, you need to Signed-off-by as well. I'm guessing you
> can just do this on list like a review to avoid the respin.

Ok, here it is:

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>

Thanks,

Alistair
diff mbox

Patch

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 2c7101d..75d1227 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -580,6 +580,12 @@  void qdev_pass_gpios(DeviceState *dev, DeviceState *container,
 BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
 {
     BusState *bus;
+    Object *child = object_resolve_path_component(OBJECT(dev), name);
+
+    bus = (BusState *)object_dynamic_cast(child, TYPE_BUS);
+    if (bus) {
+        return bus;
+    }
 
     QLIST_FOREACH(bus, &dev->child_bus, sibling) {
         if (strcmp(name, bus->name) == 0) {