On Wed, Sep 17, 2025 at 9:51 PM Luc Michel <[email protected]> wrote:
>
> 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 <[email protected]>

Reviewed-by: Alistair Francis <[email protected]>

Alistair

> ---
>  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(&register_info);
>  }
>
>  type_init(register_register_types)
> --
> 2.50.1
>
>

Reply via email to