From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v4 1/6] hw/misc/edu: Convert type_init() -> DEFINE_TYPES()
Date: Thu, 24 Apr 2025 21:49:00 +0200 [thread overview]
Message-ID: <20250424194905.82506-2-philmd@linaro.org> (raw)
In-Reply-To: <20250424194905.82506-1-philmd@linaro.org>
Prefer DEFINE_TYPES() macro over type_init() to register
QOM types.
Initialize the .interfaces struct field as compound literal
casted to InterfaceInfo type like the rest of our code base.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/misc/edu.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index 504178b4a22..5723ef0ed13 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -429,21 +429,18 @@ static void edu_class_init(ObjectClass *class, void *data)
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
}
-static void pci_edu_register_types(void)
-{
- static InterfaceInfo interfaces[] = {
- { INTERFACE_CONVENTIONAL_PCI_DEVICE },
- { },
- };
- static const TypeInfo edu_info = {
+static const TypeInfo edu_types[] = {
+ {
.name = TYPE_PCI_EDU_DEVICE,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(EduState),
.instance_init = edu_instance_init,
.class_init = edu_class_init,
- .interfaces = interfaces,
- };
+ .interfaces = (InterfaceInfo[]) {
+ { INTERFACE_CONVENTIONAL_PCI_DEVICE },
+ { },
+ },
+ }
+};
- type_register_static(&edu_info);
-}
-type_init(pci_edu_register_types)
+DEFINE_TYPES(edu_types)
--
2.47.1
next prev parent reply other threads:[~2025-04-24 19:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 19:48 [PATCH v4 0/6] qom: Constify class_data Philippe Mathieu-Daudé
2025-04-24 19:49 ` Philippe Mathieu-Daudé [this message]
2025-04-24 21:16 ` [PATCH v4 1/6] hw/misc/edu: Convert type_init() -> DEFINE_TYPES() Richard Henderson
2025-04-24 19:49 ` [PATCH v4 2/6] qom: Have class_base_init() take a const data argument Philippe Mathieu-Daudé
2025-04-24 19:49 ` [PATCH v4 4/6] qom: Constify TypeInfo::class_data Philippe Mathieu-Daudé
2025-04-24 19:49 ` [PATCH v4 5/6] qom: Constify TypeInfo::interfaces Philippe Mathieu-Daudé
2025-04-24 19:49 ` [PATCH v4 6/6] qom: Make InterfaceInfo[] uses const Philippe Mathieu-Daudé
2025-04-25 10:42 ` [PATCH v4 0/6] qom: Constify class_data 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=20250424194905.82506-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).