diff mbox series

[17/21] hw/i386/iommu: Prefer object_initialize_child over object_initialize

Message ID 20240216110313.17039-18-philmd@linaro.org
State New
Headers show
Series hw: More QDev cleanups | expand

Commit Message

Philippe Mathieu-Daudé Feb. 16, 2024, 11:03 a.m. UTC
When the QOM parent is available, prefer object_initialize_child()
over object_initialize(), since it create the parent relationship.

Rename the 'klass' variable as 'obj' since the argument holds a
reference to an instance object and not a class one.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/i386/amd_iommu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Zhao Liu Feb. 22, 2024, 9:24 a.m. UTC | #1
Hi Philippe,

On Fri, Feb 16, 2024 at 12:03:08PM +0100, Philippe Mathieu-Daudé wrote:
> Date: Fri, 16 Feb 2024 12:03:08 +0100
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH 17/21] hw/i386/iommu: Prefer object_initialize_child over
>  object_initialize
> X-Mailer: git-send-email 2.41.0
> 
> When the QOM parent is available, prefer object_initialize_child()
> over object_initialize(), since it create the parent relationship.
> 
> Rename the 'klass' variable as 'obj' since the argument holds a
> reference to an instance object and not a class one.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/i386/amd_iommu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
> index 7329553ad3..c3afbc4130 100644
> --- a/hw/i386/amd_iommu.c
> +++ b/hw/i386/amd_iommu.c
> @@ -1616,11 +1616,11 @@ static const VMStateDescription vmstate_amdvi_sysbus = {
>      .unmigratable = 1
>  };
>  
> -static void amdvi_sysbus_instance_init(Object *klass)
> +static void amdvi_sysbus_instance_init(Object *obj)
>  {
> -    AMDVIState *s = AMD_IOMMU_DEVICE(klass);
> +    AMDVIState *s = AMD_IOMMU_DEVICE(obj);
>  
> -    object_initialize(&s->pci, sizeof(s->pci), TYPE_AMD_IOMMU_PCI);
> +    object_initialize_child(obj, "iommu", &s->pci, TYPE_AMD_IOMMU_PCI);

What about this name "amd-iommu"?

This is more accurate and differentiates it from the other intel-iommu
related implementations.

>  }
>  
>  static void amdvi_sysbus_class_init(ObjectClass *klass, void *data)
> -- 
> 2.41.0
> 
>
diff mbox series

Patch

diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index 7329553ad3..c3afbc4130 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -1616,11 +1616,11 @@  static const VMStateDescription vmstate_amdvi_sysbus = {
     .unmigratable = 1
 };
 
-static void amdvi_sysbus_instance_init(Object *klass)
+static void amdvi_sysbus_instance_init(Object *obj)
 {
-    AMDVIState *s = AMD_IOMMU_DEVICE(klass);
+    AMDVIState *s = AMD_IOMMU_DEVICE(obj);
 
-    object_initialize(&s->pci, sizeof(s->pci), TYPE_AMD_IOMMU_PCI);
+    object_initialize_child(obj, "iommu", &s->pci, TYPE_AMD_IOMMU_PCI);
 }
 
 static void amdvi_sysbus_class_init(ObjectClass *klass, void *data)