From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, "Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 7/8] hw/intc/pxa2xx: Pass CPU reference using QOM link property
Date: Wed, 18 Oct 2023 15:12:19 +0200 [thread overview]
Message-ID: <20231018131220.84380-8-philmd@linaro.org> (raw)
In-Reply-To: <20231018131220.84380-1-philmd@linaro.org>
QOM objects shouldn't access each other internals fields
except using the QOM API.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/arm/pxa2xx_pic.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c
index 2eb869a605..7e180635c2 100644
--- a/hw/arm/pxa2xx_pic.c
+++ b/hw/arm/pxa2xx_pic.c
@@ -15,6 +15,7 @@
#include "cpu.h"
#include "hw/arm/pxa.h"
#include "hw/sysbus.h"
+#include "hw/qdev-properties.h"
#include "migration/vmstate.h"
#include "qom/object.h"
#include "target/arm/cpregs.h"
@@ -288,7 +289,8 @@ DeviceState *pxa2xx_pic_init(hwaddr base, ARMCPU *cpu)
DeviceState *dev = qdev_new(TYPE_PXA2XX_PIC);
PXA2xxPICState *s = PXA2XX_PIC(dev);
- s->cpu = cpu;
+ object_property_set_link(OBJECT(dev), "arm-cpu",
+ OBJECT(cpu), &error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
@@ -321,11 +323,18 @@ static const VMStateDescription vmstate_pxa2xx_pic_regs = {
},
};
+static Property pxa2xx_pic_properties[] = {
+ DEFINE_PROP_LINK("arm-cpu", PXA2xxPICState, cpu,
+ TYPE_ARM_CPU, ARMCPU *),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static void pxa2xx_pic_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
ResettableClass *rc = RESETTABLE_CLASS(klass);
+ device_class_set_props(dc, pxa2xx_pic_properties);
dc->desc = "PXA2xx PIC";
dc->vmsd = &vmstate_pxa2xx_pic_regs;
rc->phases.hold = pxa2xx_pic_reset_hold;
--
2.41.0
next prev parent reply other threads:[~2023-10-18 13:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-18 13:12 [PATCH 0/8] hw/arm/pxa2xx: SysBus/QDev fixes Philippe Mathieu-Daudé
2023-10-18 13:12 ` [PATCH 1/8] hw/sd/pxa2xx: Realize sysbus device before accessing it Philippe Mathieu-Daudé
2023-10-18 13:12 ` [PATCH 2/8] hw/sd/pxa2xx: Do not open-code sysbus_create_simple() Philippe Mathieu-Daudé
2023-10-18 13:12 ` [PATCH 3/8] hw/pcmcia/pxa2xx: Realize sysbus device before accessing it Philippe Mathieu-Daudé
2023-10-18 13:12 ` [PATCH 4/8] hw/pcmcia/pxa2xx: Do not open-code sysbus_create_simple() Philippe Mathieu-Daudé
2023-10-18 13:12 ` [PATCH 5/8] hw/pcmcia/pxa2xx: Inline pxa2xx_pcmcia_init() Philippe Mathieu-Daudé
2023-10-18 13:12 ` [PATCH 6/8] hw/intc/pxa2xx: Convert to Resettable interface Philippe Mathieu-Daudé
2023-10-18 13:12 ` Philippe Mathieu-Daudé [this message]
2023-10-18 13:12 ` [PATCH 8/8] hw/intc/pxa2xx: Factor pxa2xx_pic_realize() out of pxa2xx_pic_init() Philippe Mathieu-Daudé
2023-10-18 13:13 ` [PATCH 0/8] hw/arm/pxa2xx: SysBus/QDev fixes Philippe Mathieu-Daudé
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=20231018131220.84380-8-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@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).