qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	qemu-riscv@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Paul Burton" <paulburton@kernel.org>,
	"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>
Subject: [RFC PATCH 15/19] hw/mips: Set QDev properties using QDev API
Date: Fri,  3 Feb 2023 19:09:10 +0100	[thread overview]
Message-ID: <20230203180914.49112-16-philmd@linaro.org> (raw)
In-Reply-To: <20230203180914.49112-1-philmd@linaro.org>

No need to use the low-level QOM API when an object
inherits from QDev. Directly use the QDev API to set
its properties.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/mips/boston.c |  6 ++----
 hw/mips/cps.c    | 42 ++++++++++++++----------------------------
 hw/mips/jazz.c   |  3 +--
 hw/mips/malta.c  |  6 ++----
 4 files changed, 19 insertions(+), 38 deletions(-)

diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index 21ad844519..f3c2179f66 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -700,10 +700,8 @@ static void boston_mach_init(MachineState *machine)
     }
 
     object_initialize_child(OBJECT(machine), "cps", &s->cps, TYPE_MIPS_CPS);
-    object_property_set_str(OBJECT(&s->cps), "cpu-type", machine->cpu_type,
-                            &error_fatal);
-    object_property_set_uint(OBJECT(&s->cps), "num-vp", machine->smp.cpus,
-                            &error_fatal);
+    qdev_prop_set_string(DEVICE(&s->cps), "cpu-type", machine->cpu_type);
+    qdev_prop_set_uint32(DEVICE(&s->cps), "num-vp", machine->smp.cpus);
     qdev_connect_clock_in(DEVICE(&s->cps), "clk-in",
                           qdev_get_clock_out(dev, "cpu-refclk"));
     sysbus_realize(SYS_BUS_DEVICE(&s->cps), &error_fatal);
diff --git a/hw/mips/cps.c b/hw/mips/cps.c
index 2b5269ebf1..3109644c5e 100644
--- a/hw/mips/cps.c
+++ b/hw/mips/cps.c
@@ -79,10 +79,8 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
         CPUMIPSState *env = &cpu->env;
 
         /* All VPs are halted on reset. Leave powering up to CPC. */
-        if (!object_property_set_bool(OBJECT(cpu), "start-powered-off", true,
-                                      errp)) {
-            return;
-        }
+        qdev_prop_set_bit(DEVICE(cpu), "start-powered-off", true);
+
         /* All cores use the same clock tree */
         qdev_connect_clock_in(DEVICE(cpu), "clk-in", s->clock);
 
@@ -106,12 +104,9 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
     /* Inter-Thread Communication Unit */
     if (itu_present) {
         object_initialize_child(OBJECT(dev), "itu", &s->itu, TYPE_MIPS_ITU);
-        object_property_set_link(OBJECT(&s->itu), "cpu[0]",
-                                 OBJECT(first_cpu), &error_abort);
-        object_property_set_uint(OBJECT(&s->itu), "num-fifo", 16,
-                                &error_abort);
-        object_property_set_uint(OBJECT(&s->itu), "num-semaphores", 16,
-                                &error_abort);
+        qdev_prop_set_link(DEVICE(&s->itu), "cpu[0]", OBJECT(first_cpu));
+        qdev_prop_set_uint32(DEVICE(&s->itu), "num-fifo", 16);
+        qdev_prop_set_uint32(DEVICE(&s->itu), "num-semaphores", 16);
         if (!sysbus_realize(SYS_BUS_DEVICE(&s->itu), errp)) {
             return;
         }
@@ -122,10 +117,8 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
 
     /* Cluster Power Controller */
     object_initialize_child(OBJECT(dev), "cpc", &s->cpc, TYPE_MIPS_CPC);
-    object_property_set_uint(OBJECT(&s->cpc), "num-vp", s->num_vp,
-                            &error_abort);
-    object_property_set_int(OBJECT(&s->cpc), "vp-start-running", 1,
-                            &error_abort);
+    qdev_prop_set_uint32(DEVICE(&s->cpc), "num-vp", s->num_vp);
+    qdev_prop_set_uint64(DEVICE(&s->cpc), "vp-start-running", 0x1);
     if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpc), errp)) {
         return;
     }
@@ -135,10 +128,8 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
 
     /* Global Interrupt Controller */
     object_initialize_child(OBJECT(dev), "gic", &s->gic, TYPE_MIPS_GIC);
-    object_property_set_uint(OBJECT(&s->gic), "num-vp", s->num_vp,
-                            &error_abort);
-    object_property_set_uint(OBJECT(&s->gic), "num-irq", 128,
-                            &error_abort);
+    qdev_prop_set_uint32(DEVICE(&s->gic), "num-vp", s->num_vp);
+    qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", 128);
     if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) {
         return;
     }
@@ -150,16 +141,11 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
     gcr_base = MIPS_CPU(first_cpu)->env.CP0_CMGCRBase << 4;
 
     object_initialize_child(OBJECT(dev), "gcr", &s->gcr, TYPE_MIPS_GCR);
-    object_property_set_uint(OBJECT(&s->gcr), "num-vp", s->num_vp,
-                            &error_abort);
-    object_property_set_int(OBJECT(&s->gcr), "gcr-rev", 0x800,
-                            &error_abort);
-    object_property_set_int(OBJECT(&s->gcr), "gcr-base", gcr_base,
-                            &error_abort);
-    object_property_set_link(OBJECT(&s->gcr), "gic", OBJECT(&s->gic.mr),
-                             &error_abort);
-    object_property_set_link(OBJECT(&s->gcr), "cpc", OBJECT(&s->cpc.mr),
-                             &error_abort);
+    qdev_prop_set_uint32(DEVICE(&s->gcr), "num-vp", s->num_vp);
+    qdev_prop_set_int32(DEVICE(&s->gcr), "gcr-rev", 0x800);
+    qdev_prop_set_uint64(DEVICE(&s->gcr), "gcr-base", gcr_base);
+    qdev_prop_set_link(DEVICE(&s->gcr), "gic", OBJECT(&s->gic.mr));
+    qdev_prop_set_link(DEVICE(&s->gcr), "cpc", OBJECT(&s->cpc.mr));
     if (!sysbus_realize(SYS_BUS_DEVICE(&s->gcr), errp)) {
         return;
     }
diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c
index 6aefe9a61b..d18aeb439b 100644
--- a/hw/mips/jazz.c
+++ b/hw/mips/jazz.c
@@ -302,8 +302,7 @@ static void mips_jazz_init(MachineState *machine,
             qdev_set_nic_properties(dev, nd);
             qdev_prop_set_uint8(dev, "it_shift", 2);
             qdev_prop_set_bit(dev, "big_endian", big_endian > 0);
-            object_property_set_link(OBJECT(dev), "dma_mr",
-                                     OBJECT(rc4030_dma_mr), &error_abort);
+            qdev_prop_set_link(dev, "dma_mr", OBJECT(rc4030_dma_mr));
             sysbus = SYS_BUS_DEVICE(dev);
             sysbus_realize_and_unref(sysbus, &error_fatal);
             sysbus_mmio_map(sysbus, 0, 0x80001000);
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index af9021316d..3b88668bae 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -1064,10 +1064,8 @@ static void create_cps(MachineState *ms, MaltaState *s,
                        qemu_irq *cbus_irq, qemu_irq *i8259_irq)
 {
     object_initialize_child(OBJECT(s), "cps", &s->cps, TYPE_MIPS_CPS);
-    object_property_set_str(OBJECT(&s->cps), "cpu-type", ms->cpu_type,
-                            &error_fatal);
-    object_property_set_uint(OBJECT(&s->cps), "num-vp", ms->smp.cpus,
-                            &error_fatal);
+    qdev_prop_set_string(DEVICE(&s->cps), "cpu-type", ms->cpu_type);
+    qdev_prop_set_uint32(DEVICE(&s->cps), "num-vp", ms->smp.cpus);
     qdev_connect_clock_in(DEVICE(&s->cps), "clk-in", s->cpuclk);
     sysbus_realize(SYS_BUS_DEVICE(&s->cps), &error_fatal);
 
-- 
2.38.1



  parent reply	other threads:[~2023-02-03 18:11 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 18:08 [PATCH 00/19] hw: Set QDev properties using QDev API (part 1/3) Philippe Mathieu-Daudé
2023-02-03 18:08 ` [PATCH 01/19] NOTFORMERGE scripts/coccinelle: Add qom-qdev-prop.cocci Philippe Mathieu-Daudé
2023-02-03 18:08 ` [PATCH 02/19] hw/qdev: Introduce qdev_prop_set_link() Philippe Mathieu-Daudé
2023-02-05 22:53   ` Mark Cave-Ayland
2023-02-03 18:08 ` [PATCH 03/19] hw/acpi: Set QDev properties using QDev API Philippe Mathieu-Daudé
2023-03-01 14:07   ` Igor Mammedov
2023-02-03 18:08 ` [PATCH 04/19] hw/audio: " Philippe Mathieu-Daudé
2023-02-03 18:09 ` [RFC PATCH 05/19] hw/core/numa: " Philippe Mathieu-Daudé
2023-03-01 14:09   ` Igor Mammedov
2023-02-03 18:09 ` [PATCH 06/19] hw/core/gpio: " Philippe Mathieu-Daudé
2023-02-03 18:09 ` [RFC PATCH 07/19] hw/scsi: " Philippe Mathieu-Daudé
2023-03-01 14:13   ` Igor Mammedov
2023-02-03 18:09 ` [PATCH 08/19] hw/usb: " Philippe Mathieu-Daudé
2023-02-03 18:09 ` [PATCH 09/19] hw/virtio: " Philippe Mathieu-Daudé
2023-02-03 18:09 ` [PATCH 10/19] hw/avr: " Philippe Mathieu-Daudé
2023-02-03 18:09 ` [PATCH 11/19] hw/hppa: " Philippe Mathieu-Daudé
2023-02-03 18:09 ` [RFC PATCH 12/19] hw/i386: " Philippe Mathieu-Daudé
2023-02-04 13:23   ` Bernhard Beschow
2023-03-01 14:00   ` Igor Mammedov
2023-02-03 18:09 ` [PATCH 13/19] hw/m68k: " Philippe Mathieu-Daudé
2023-02-05  9:14   ` Thomas Huth
2023-02-03 18:09 ` [PATCH 14/19] hw/microblaze: " Philippe Mathieu-Daudé
2023-02-03 18:09 ` Philippe Mathieu-Daudé [this message]
2023-02-03 18:09 ` [PATCH 16/19] hw/nios2: " Philippe Mathieu-Daudé
2023-02-03 18:09 ` [RFC PATCH 17/19] hw/riscv: " Philippe Mathieu-Daudé
2023-02-03 18:09 ` [PATCH 18/19] hw/rx: " Philippe Mathieu-Daudé
2023-02-06 13:01   ` Yoshinori Sato
2023-02-03 18:09 ` [PATCH 19/19] hw/sparc: " Philippe Mathieu-Daudé
2023-02-03 18:12 ` [PATCH 00/19] hw: Set QDev properties using QDev API (part 1/3) Philippe Mathieu-Daudé
2023-02-03 18:52   ` BALATON Zoltan
2023-03-01 13:42 ` Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230203180914.49112-16-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=aleksandar.rikalo@syrmia.com \
    --cc=armbru@redhat.com \
    --cc=aurelien@aurel32.net \
    --cc=eduardo@habkost.net \
    --cc=hpoussin@reactos.org \
    --cc=jiaxun.yang@flygoat.com \
    --cc=paulburton@kernel.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).