qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 1/1] core/register: Specify instance_size in the TypeInfo


From: Alistair Francis
Subject: Re: [PATCH v1 1/1] core/register: Specify instance_size in the TypeInfo
Date: Tue, 25 Aug 2020 10:29:25 -0700

On Sat, Aug 22, 2020 at 3:25 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Hi Alistair,
>
> On 8/22/20 7:33 AM, Alistair Francis wrote:
> > Reported-by: Eduardo Habkost <ehabkost@redhat.com>
> > Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> > ---
> >  hw/core/register.c | 14 +++++++++-----
> >  1 file changed, 9 insertions(+), 5 deletions(-)
> >
> > diff --git a/hw/core/register.c b/hw/core/register.c
> > index ddf91eb445..5e8e8199d0 100644
> > --- a/hw/core/register.c
> > +++ b/hw/core/register.c
> > @@ -180,11 +180,7 @@ void register_init(RegisterInfo *reg)
> >  {
> >      assert(reg);
> >
> > -    if (!reg->data || !reg->access) {
> > -        return;
> > -    }
> >
> > -    object_initialize((void *)reg, sizeof(*reg), TYPE_REGISTER);
>
> Can we remove register_init()? Are concerned is it is declared
> publicly in "hw/register.h"?

Argh, I just missed this. Fixed in v2.

Alistair

>
> >  }
> >
> >  void register_write_memory(void *opaque, hwaddr addr,
> > @@ -269,13 +265,20 @@ static RegisterInfoArray 
> > *register_init_block(DeviceState *owner,
> >          int index = rae[i].addr / data_size;
> >          RegisterInfo *r = &ri[index];
> >
> > +        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 = (RegisterInfo) {
> >              .data = data + data_size * index,
> >              .data_size = data_size,
> >              .access = &rae[i],
> >              .opaque = owner,
> >          };
> > -        register_init(r);
> >
> >          r_array->r[i] = r;
> >      }
> > @@ -329,6 +332,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)
> >
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]