[PATCH 06/21] hw: Replace DEVICE(object_new) -> qdev_new()

Philippe Mathieu-Daudé posted 21 patches 8 months, 2 weeks ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Jan Kiszka <jan.kiszka@web.de>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Alistair Francis <alistair@alistair23.me>, Richard Henderson <richard.henderson@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Pavel Pisa <pisa@cmp.felk.cvut.cz>, Vikram Garhwal <fnu.vikram@xilinx.com>, Francisco Iglesias <francisco.iglesias@amd.com>, Jason Wang <jasowang@redhat.com>, Chris Wulff <crwulff@gmail.com>, Marek Vasut <marex@denx.de>, "Hervé Poussineau" <hpoussin@reactos.org>, "Cédric Le Goater" <clg@kaod.org>, Nicholas Piggin <npiggin@gmail.com>, "Frédéric Barrat" <fbarrat@linux.ibm.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, David Gibson <david@gibson.dropbear.id.au>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Gerd Hoffmann <kraxel@redhat.com>, Samuel Thibault <samuel.thibault@ens-lyon.org>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Max Filippov <jcmvbkbc@gmail.com>
[PATCH 06/21] hw: Replace DEVICE(object_new) -> qdev_new()
Posted by Philippe Mathieu-Daudé 8 months, 2 weeks ago
Prefer QDev API for QDev objects, avoid the underlying QOM layer.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/musicpal.c | 2 +-
 hw/core/qdev.c    | 2 +-
 hw/sparc/sun4m.c  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 2020f73a57..74e4d24aab 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -1238,7 +1238,7 @@ static void musicpal_init(MachineState *machine)
                           qdev_get_gpio_in(pic, MP_TIMER4_IRQ), NULL);
 
     /* Logically OR both UART IRQs together */
-    uart_orgate = DEVICE(object_new(TYPE_OR_IRQ));
+    uart_orgate = qdev_new(TYPE_OR_IRQ);
     object_property_set_int(OBJECT(uart_orgate), "num-lines", 2, &error_fatal);
     qdev_realize_and_unref(uart_orgate, NULL, &error_fatal);
     qdev_connect_gpio_out(uart_orgate, 0,
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index c68d0f7c51..a271380d20 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -171,7 +171,7 @@ DeviceState *qdev_try_new(const char *name)
     if (!module_object_class_by_name(name)) {
         return NULL;
     }
-    return DEVICE(object_new(name));
+    return qdev_new(name);
 }
 
 static QTAILQ_HEAD(, DeviceListener) device_listeners
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index d52e6a7213..fedc4b8b3f 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -979,7 +979,7 @@ static void sun4m_hw_init(MachineState *machine)
     sysbus_mmio_map(s, 0, hwdef->ms_kb_base);
 
     /* Logically OR both its IRQs together */
-    ms_kb_orgate = DEVICE(object_new(TYPE_OR_IRQ));
+    ms_kb_orgate = qdev_new(TYPE_OR_IRQ);
     object_property_set_int(OBJECT(ms_kb_orgate), "num-lines", 2, &error_fatal);
     qdev_realize_and_unref(ms_kb_orgate, NULL, &error_fatal);
     sysbus_connect_irq(s, 0, qdev_get_gpio_in(ms_kb_orgate, 0));
@@ -1000,7 +1000,7 @@ static void sun4m_hw_init(MachineState *machine)
     sysbus_mmio_map(s, 0, hwdef->serial_base);
 
     /* Logically OR both its IRQs together */
-    serial_orgate = DEVICE(object_new(TYPE_OR_IRQ));
+    serial_orgate = qdev_new(TYPE_OR_IRQ);
     object_property_set_int(OBJECT(serial_orgate), "num-lines", 2,
                             &error_fatal);
     qdev_realize_and_unref(serial_orgate, NULL, &error_fatal);
-- 
2.41.0


Re: [PATCH 06/21] hw: Replace DEVICE(object_new) -> qdev_new()
Posted by Zhao Liu 8 months, 1 week ago
On Fri, Feb 16, 2024 at 12:02:57PM +0100, Philippe Mathieu-Daudé wrote:
> Date: Fri, 16 Feb 2024 12:02:57 +0100
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH 06/21] hw: Replace DEVICE(object_new) -> qdev_new()
> X-Mailer: git-send-email 2.41.0
> 
> Prefer QDev API for QDev objects, avoid the underlying QOM layer.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/arm/musicpal.c | 2 +-
>  hw/core/qdev.c    | 2 +-
>  hw/sparc/sun4m.c  | 4 ++--
>  3 files changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>

> 
> diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
> index 2020f73a57..74e4d24aab 100644
> --- a/hw/arm/musicpal.c
> +++ b/hw/arm/musicpal.c
> @@ -1238,7 +1238,7 @@ static void musicpal_init(MachineState *machine)
>                            qdev_get_gpio_in(pic, MP_TIMER4_IRQ), NULL);
>  
>      /* Logically OR both UART IRQs together */
> -    uart_orgate = DEVICE(object_new(TYPE_OR_IRQ));
> +    uart_orgate = qdev_new(TYPE_OR_IRQ);
>      object_property_set_int(OBJECT(uart_orgate), "num-lines", 2, &error_fatal);
>      qdev_realize_and_unref(uart_orgate, NULL, &error_fatal);
>      qdev_connect_gpio_out(uart_orgate, 0,
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index c68d0f7c51..a271380d20 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -171,7 +171,7 @@ DeviceState *qdev_try_new(const char *name)
>      if (!module_object_class_by_name(name)) {
>          return NULL;
>      }
> -    return DEVICE(object_new(name));
> +    return qdev_new(name);
>  }
>  
>  static QTAILQ_HEAD(, DeviceListener) device_listeners
> diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
> index d52e6a7213..fedc4b8b3f 100644
> --- a/hw/sparc/sun4m.c
> +++ b/hw/sparc/sun4m.c
> @@ -979,7 +979,7 @@ static void sun4m_hw_init(MachineState *machine)
>      sysbus_mmio_map(s, 0, hwdef->ms_kb_base);
>  
>      /* Logically OR both its IRQs together */
> -    ms_kb_orgate = DEVICE(object_new(TYPE_OR_IRQ));
> +    ms_kb_orgate = qdev_new(TYPE_OR_IRQ);
>      object_property_set_int(OBJECT(ms_kb_orgate), "num-lines", 2, &error_fatal);
>      qdev_realize_and_unref(ms_kb_orgate, NULL, &error_fatal);
>      sysbus_connect_irq(s, 0, qdev_get_gpio_in(ms_kb_orgate, 0));
> @@ -1000,7 +1000,7 @@ static void sun4m_hw_init(MachineState *machine)
>      sysbus_mmio_map(s, 0, hwdef->serial_base);
>  
>      /* Logically OR both its IRQs together */
> -    serial_orgate = DEVICE(object_new(TYPE_OR_IRQ));
> +    serial_orgate = qdev_new(TYPE_OR_IRQ);
>      object_property_set_int(OBJECT(serial_orgate), "num-lines", 2,
>                              &error_fatal);
>      qdev_realize_and_unref(serial_orgate, NULL, &error_fatal);
> -- 
> 2.41.0
> 
>