diff mbox series

[02/23] armv7m: Make cpu object a child of the armv7m container

Message ID 20190121185118.18550-3-peter.maydell@linaro.org
State Superseded
Headers show
Series arm: Implement MPS2 AN521 FPGA image | expand

Commit Message

Peter Maydell Jan. 21, 2019, 6:50 p.m. UTC
Rather than just creating the CPUs with object_new, make them child
objects of the armv7m container. This will allow the cluster code to
find the CPUs if an armv7m object is made a child of a cluster object.
object_new_with_props() will do the parenting for us.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
 hw/arm/armv7m.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

-- 
2.20.1

Comments

Philippe Mathieu-Daudé Jan. 21, 2019, 8:30 p.m. UTC | #1
On 1/21/19 7:50 PM, Peter Maydell wrote:
> Rather than just creating the CPUs with object_new, make them child

> objects of the armv7m container. This will allow the cluster code to

> find the CPUs if an armv7m object is made a child of a cluster object.

> object_new_with_props() will do the parenting for us.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> ---

>  hw/arm/armv7m.c | 7 ++++++-

>  1 file changed, 6 insertions(+), 1 deletion(-)

> 

> diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c

> index f9aa83d20ef..0f2c8e066cf 100644

> --- a/hw/arm/armv7m.c

> +++ b/hw/arm/armv7m.c

> @@ -158,7 +158,12 @@ static void armv7m_realize(DeviceState *dev, Error **errp)

>  

>      memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1);

>  

> -    s->cpu = ARM_CPU(object_new(s->cpu_type));

> +    s->cpu = ARM_CPU(object_new_with_props(s->cpu_type, OBJECT(s), "cpu",

> +                                           &err, NULL));

> +    if (err != NULL) {

> +        error_propagate(errp, err);

> +        return;

> +    }

>  

>      object_property_set_link(OBJECT(s->cpu), OBJECT(&s->container), "memory",

>                               &error_abort);

> 


Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Richard Henderson Jan. 23, 2019, 11:44 p.m. UTC | #2
On 1/21/19 10:50 AM, Peter Maydell wrote:
> Rather than just creating the CPUs with object_new, make them child

> objects of the armv7m container. This will allow the cluster code to

> find the CPUs if an armv7m object is made a child of a cluster object.

> object_new_with_props() will do the parenting for us.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> ---

>  hw/arm/armv7m.c | 7 ++++++-

>  1 file changed, 6 insertions(+), 1 deletion(-)


Reviewed-by: Richard Henderson <richard.henderson@linaro.org>



r~
diff mbox series

Patch

diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index f9aa83d20ef..0f2c8e066cf 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -158,7 +158,12 @@  static void armv7m_realize(DeviceState *dev, Error **errp)
 
     memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1);
 
-    s->cpu = ARM_CPU(object_new(s->cpu_type));
+    s->cpu = ARM_CPU(object_new_with_props(s->cpu_type, OBJECT(s), "cpu",
+                                           &err, NULL));
+    if (err != NULL) {
+        error_propagate(errp, err);
+        return;
+    }
 
     object_property_set_link(OBJECT(s->cpu), OBJECT(&s->container), "memory",
                              &error_abort);