diff options
author | Alistair Francis | 2020-08-21 00:46:11 +0200 |
---|---|---|
committer | Alistair Francis | 2020-09-26 01:52:24 +0200 |
commit | e8a612b7e3cdbdface1e34a27300ca2f8521dee0 (patch) | |
tree | 3fdac6080746719e005a9518cf22f0cd3a3ec541 /hw/core/register.c | |
parent | load_elf: Remove unused address variables from callers (diff) | |
download | qemu-e8a612b7e3cdbdface1e34a27300ca2f8521dee0.tar.gz qemu-e8a612b7e3cdbdface1e34a27300ca2f8521dee0.tar.xz qemu-e8a612b7e3cdbdface1e34a27300ca2f8521dee0.zip |
core/register: Specify instance_size in the TypeInfo
Reported-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <4cf1beb7dafb9143c261d266557d3173bf160524.1598376594.git.alistair.francis@wdc.com>
Diffstat (limited to 'hw/core/register.c')
-rw-r--r-- | hw/core/register.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/hw/core/register.c b/hw/core/register.c index ddf91eb445..31038bd7cc 100644 --- a/hw/core/register.c +++ b/hw/core/register.c @@ -176,17 +176,6 @@ void register_reset(RegisterInfo *reg) } } -void register_init(RegisterInfo *reg) -{ - assert(reg); - - if (!reg->data || !reg->access) { - return; - } - - object_initialize((void *)reg, sizeof(*reg), TYPE_REGISTER); -} - void register_write_memory(void *opaque, hwaddr addr, uint64_t value, unsigned size) { @@ -269,13 +258,18 @@ static RegisterInfoArray *register_init_block(DeviceState *owner, int index = rae[i].addr / data_size; RegisterInfo *r = &ri[index]; - *r = (RegisterInfo) { - .data = data + data_size * index, - .data_size = data_size, - .access = &rae[i], - .opaque = owner, - }; - register_init(r); + if (data + data_size * index == 0 || !&rae[i]) { + continue; + } + + /* 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; r_array->r[i] = r; } @@ -329,6 +323,7 @@ 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) |