From: Luc Michel <luc.michel@amd.com>
To: <qemu-devel@nongnu.org>, <qemu-arm@nongnu.org>
Cc: "Luc Michel" <luc.michel@amd.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Francisco Iglesias" <francisco.iglesias@amd.com>,
"Edgar E . Iglesias" <edgar.iglesias@amd.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Alistair Francis" <alistair@alistair23.me>
Subject: [PATCH 1/7] hw/core/register: remove the REGISTER device type
Date: Wed, 17 Sep 2025 13:44:42 +0200 [thread overview]
Message-ID: <20250917114450.175892-2-luc.michel@amd.com> (raw)
In-Reply-To: <20250917114450.175892-1-luc.michel@amd.com>
The REGISTER class (RegisterInfo struct) is currently a QOM type
inheriting from DEVICE. This class has no real purpose:
- the qdev API is not used,
- according to the comment preceding it, the object_initialize call
is here to zero-initialize the struct. However all the effective
struct attributes are then initialized explicitly.
- the object is never parented.
This commits drops the REGISTER QOM type completely, leaving the
RegisterInfo struct as a bare C struct.
The register_register_types function is left empty here because it is
reused in the next commit.
Signed-off-by: Luc Michel <luc.michel@amd.com>
---
include/hw/register.h | 7 -------
hw/core/register.c | 18 ------------------
2 files changed, 25 deletions(-)
diff --git a/include/hw/register.h b/include/hw/register.h
index a913c52aee5..4d13ea183c7 100644
--- a/include/hw/register.h
+++ b/include/hw/register.h
@@ -73,25 +73,18 @@ struct RegisterAccessInfo {
*
* @opaque: Opaque data for the register
*/
struct RegisterInfo {
- /* <private> */
- DeviceState parent_obj;
-
- /* <public> */
void *data;
int data_size;
const RegisterAccessInfo *access;
void *opaque;
};
-#define TYPE_REGISTER "qemu-register"
-DECLARE_INSTANCE_CHECKER(RegisterInfo, REGISTER,
- TYPE_REGISTER)
/**
* This structure is used to group all of the individual registers which are
* modeled using the RegisterInfo structure.
*
diff --git a/hw/core/register.c b/hw/core/register.c
index 8f63d9f227c..57dde29710c 100644
--- a/hw/core/register.c
+++ b/hw/core/register.c
@@ -256,13 +256,10 @@ static RegisterInfoArray *register_init_block(DeviceState *owner,
for (i = 0; i < num; i++) {
int index = rae[i].addr / data_size;
RegisterInfo *r = &ri[index];
- /* Init the register, this will zero it. */
- object_initialize((void *)r, sizeof(*r), TYPE_REGISTER);
-
/* Set the properties of the register */
r->data = data + data_size * index;
r->data_size = data_size;
r->access = &rae[i];
r->opaque = owner;
@@ -317,26 +314,11 @@ void register_finalize_block(RegisterInfoArray *r_array)
object_unparent(OBJECT(&r_array->mem));
g_free(r_array->r);
g_free(r_array);
}
-static void register_class_init(ObjectClass *oc, const void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(oc);
-
- /* Reason: needs to be wired up to work */
- dc->user_creatable = false;
-}
-
-static const TypeInfo register_info = {
- .name = TYPE_REGISTER,
- .parent = TYPE_DEVICE,
- .class_init = register_class_init,
- .instance_size = sizeof(RegisterInfo),
-};
static void register_register_types(void)
{
- type_register_static(®ister_info);
}
type_init(register_register_types)
--
2.50.1
next prev parent reply other threads:[~2025-09-17 11:50 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-17 11:44 [PATCH 0/7] Register API leaks fixes Luc Michel
2025-09-17 11:44 ` Luc Michel [this message]
2025-09-19 8:49 ` [PATCH 1/7] hw/core/register: remove the REGISTER device type Francisco Iglesias
2025-09-28 23:32 ` Alistair Francis
2025-09-17 11:44 ` [PATCH 2/7] hw/core/register: add the REGISTER_ARRAY type Luc Michel
2025-09-19 8:50 ` Francisco Iglesias
2025-09-28 23:34 ` Alistair Francis
2025-09-17 11:44 ` [PATCH 3/7] hw/core/register: remove the calls to `register_finalize_block' Luc Michel
2025-09-19 8:51 ` Francisco Iglesias
2025-09-28 23:35 ` Alistair Francis
2025-09-17 11:44 ` [PATCH 4/7] hw/core/register: remove the `register_finalize_block' function Luc Michel
2025-09-19 8:52 ` Francisco Iglesias
2025-09-28 23:35 ` Alistair Francis
2025-09-17 11:44 ` [PATCH 5/7] hw/net/can/xlnx-versal-canfd: remove unused include directives Luc Michel
2025-09-19 8:47 ` Francisco Iglesias
2025-09-28 23:36 ` Alistair Francis
2025-09-17 11:44 ` [PATCH 6/7] hw/net/can/xlnx-versal-canfd: refactor the banked registers logic Luc Michel
2025-09-19 8:48 ` Francisco Iglesias
2025-09-17 11:44 ` [PATCH 7/7] hw/net/can/xlnx-versal-canfd: remove register API usage for banked regs Luc Michel
2025-09-19 8:48 ` Francisco Iglesias
2025-09-18 6:21 ` [PATCH 0/7] Register API leaks fixes Edgar E. Iglesias
2025-09-29 10:19 ` Philippe Mathieu-Daudé
2025-10-01 21:07 ` Luc Michel
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=20250917114450.175892-2-luc.michel@amd.com \
--to=luc.michel@amd.com \
--cc=alistair@alistair23.me \
--cc=edgar.iglesias@amd.com \
--cc=francisco.iglesias@amd.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@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).