diff mbox series

[3/4] hw/arm/stellaris: Add missing QOM 'machine' parent

Message ID 20240130190317.25692-4-philmd@linaro.org
State Superseded
Headers show
Series hw/arm/stellaris: QOM/QDev cleanups | expand

Commit Message

Philippe Mathieu-Daudé Jan. 30, 2024, 7:03 p.m. UTC
QDev objects created with qdev_new() need to manually add
their parent relationship with object_property_add_child().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/stellaris.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Peter Maydell Feb. 1, 2024, 4:28 p.m. UTC | #1
On Tue, 30 Jan 2024 at 19:03, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> QDev objects created with qdev_new() need to manually add
> their parent relationship with object_property_add_child().
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/arm/stellaris.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
> index 284b95005f..bb88b3ebde 100644
> --- a/hw/arm/stellaris.c
> +++ b/hw/arm/stellaris.c
> @@ -1247,10 +1247,13 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
>                                     &error_fatal);
>
>              ssddev = qdev_new("ssd0323");
> +            object_property_add_child(OBJECT(ms), "oled", OBJECT(ssddev));
>              qdev_prop_set_uint8(ssddev, "cs", 1);
>              qdev_realize_and_unref(ssddev, bus, &error_fatal);
>
>              gpio_d_splitter = qdev_new(TYPE_SPLIT_IRQ);
> +            object_property_add_child(OBJECT(ms), "splitter",
> +                                      OBJECT(gpio_d_splitter));
>              qdev_prop_set_uint32(gpio_d_splitter, "num-lines", 2);
>              qdev_realize_and_unref(gpio_d_splitter, NULL, &error_fatal);
>              qdev_connect_gpio_out(
> @@ -1287,6 +1290,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
>          DeviceState *gpad;
>
>          gpad = qdev_new(TYPE_STELLARIS_GAMEPAD);
> +        object_property_add_child(OBJECT(ms), "gamepad", OBJECT(gpad));
>          for (i = 0; i < ARRAY_SIZE(gpad_keycode); i++) {
>              qlist_append_int(gpad_keycode_list, gpad_keycode[i]);
>          }
> --

We create almost all the devices in this board with
qdev_new(), and we don't use object_property_add_child()
on any of them. What is it about these three devices in
particular that means we need to call that function?

thanks
-- PMM
Peter Maydell Feb. 1, 2024, 4:47 p.m. UTC | #2
On Tue, 30 Jan 2024 at 19:03, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> QDev objects created with qdev_new() need to manually add
> their parent relationship with object_property_add_child().
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/arm/stellaris.c | 4 ++++
>  1 file changed, 4 insertions(+)
>

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

thanks
-- PMM
Philippe Mathieu-Daudé Feb. 13, 2024, 3:40 p.m. UTC | #3
On 1/2/24 17:28, Peter Maydell wrote:
> On Tue, 30 Jan 2024 at 19:03, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> QDev objects created with qdev_new() need to manually add
>> their parent relationship with object_property_add_child().
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   hw/arm/stellaris.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
>> index 284b95005f..bb88b3ebde 100644
>> --- a/hw/arm/stellaris.c
>> +++ b/hw/arm/stellaris.c
>> @@ -1247,10 +1247,13 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
>>                                      &error_fatal);
>>
>>               ssddev = qdev_new("ssd0323");
>> +            object_property_add_child(OBJECT(ms), "oled", OBJECT(ssddev));
>>               qdev_prop_set_uint8(ssddev, "cs", 1);
>>               qdev_realize_and_unref(ssddev, bus, &error_fatal);
>>
>>               gpio_d_splitter = qdev_new(TYPE_SPLIT_IRQ);
>> +            object_property_add_child(OBJECT(ms), "splitter",
>> +                                      OBJECT(gpio_d_splitter));
>>               qdev_prop_set_uint32(gpio_d_splitter, "num-lines", 2);
>>               qdev_realize_and_unref(gpio_d_splitter, NULL, &error_fatal);
>>               qdev_connect_gpio_out(
>> @@ -1287,6 +1290,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
>>           DeviceState *gpad;
>>
>>           gpad = qdev_new(TYPE_STELLARIS_GAMEPAD);
>> +        object_property_add_child(OBJECT(ms), "gamepad", OBJECT(gpad));
>>           for (i = 0; i < ARRAY_SIZE(gpad_keycode); i++) {
>>               qlist_append_int(gpad_keycode_list, gpad_keycode[i]);
>>           }
>> --
> 
> We create almost all the devices in this board with
> qdev_new(), and we don't use object_property_add_child()
> on any of them. What is it about these three devices in
> particular that means we need to call that function?

In v2 I added to the description:

     This commit plug the devices which aren't part of the SoC;
     they will be plugged into a SoC container in the next one.
diff mbox series

Patch

diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index 284b95005f..bb88b3ebde 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -1247,10 +1247,13 @@  static void stellaris_init(MachineState *ms, stellaris_board_info *board)
                                    &error_fatal);
 
             ssddev = qdev_new("ssd0323");
+            object_property_add_child(OBJECT(ms), "oled", OBJECT(ssddev));
             qdev_prop_set_uint8(ssddev, "cs", 1);
             qdev_realize_and_unref(ssddev, bus, &error_fatal);
 
             gpio_d_splitter = qdev_new(TYPE_SPLIT_IRQ);
+            object_property_add_child(OBJECT(ms), "splitter",
+                                      OBJECT(gpio_d_splitter));
             qdev_prop_set_uint32(gpio_d_splitter, "num-lines", 2);
             qdev_realize_and_unref(gpio_d_splitter, NULL, &error_fatal);
             qdev_connect_gpio_out(
@@ -1287,6 +1290,7 @@  static void stellaris_init(MachineState *ms, stellaris_board_info *board)
         DeviceState *gpad;
 
         gpad = qdev_new(TYPE_STELLARIS_GAMEPAD);
+        object_property_add_child(OBJECT(ms), "gamepad", OBJECT(gpad));
         for (i = 0; i < ARRAY_SIZE(gpad_keycode); i++) {
             qlist_append_int(gpad_keycode_list, gpad_keycode[i]);
         }