[PATCH v3 2/6] hw/vfio/ccw: Simplify using DEVICE() macro

Philippe Mathieu-Daudé posted 6 patches 2 years, 12 months ago
Maintainers: Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Alex Williamson <alex.williamson@redhat.com>
[PATCH v3 2/6] hw/vfio/ccw: Simplify using DEVICE() macro
Posted by Philippe Mathieu-Daudé 2 years, 12 months ago
QOM parenthood relationship is:

  VFIOCCWDevice -> S390CCWDevice -> CcwDevice -> DeviceState

We can directly use the QOM DEVICE() macro to get the parent object.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/vfio/ccw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 0354737666..503de94ce1 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -618,7 +618,7 @@ static void vfio_ccw_get_device(VFIOGroup *group, VFIOCCWDevice *vcdev,
     vcdev->vdev.ops = &vfio_ccw_ops;
     vcdev->vdev.type = VFIO_DEVICE_TYPE_CCW;
     vcdev->vdev.name = name;
-    vcdev->vdev.dev = &vcdev->cdev.parent_obj.parent_obj;
+    vcdev->vdev.dev = DEVICE(vcdev);
 
     return;
 
-- 
2.38.1


Re: [PATCH v3 2/6] hw/vfio/ccw: Simplify using DEVICE() macro
Posted by Eric Farman 2 years, 12 months ago
On Mon, 2023-02-13 at 18:01 +0100, Philippe Mathieu-Daudé wrote:
> QOM parenthood relationship is:
> 
>   VFIOCCWDevice -> S390CCWDevice -> CcwDevice -> DeviceState
> 
> We can directly use the QOM DEVICE() macro to get the parent object.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Eric Farman <farman@linux.ibm.com>

> ---
>  hw/vfio/ccw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
> index 0354737666..503de94ce1 100644
> --- a/hw/vfio/ccw.c
> +++ b/hw/vfio/ccw.c
> @@ -618,7 +618,7 @@ static void vfio_ccw_get_device(VFIOGroup *group,
> VFIOCCWDevice *vcdev,
>      vcdev->vdev.ops = &vfio_ccw_ops;
>      vcdev->vdev.type = VFIO_DEVICE_TYPE_CCW;
>      vcdev->vdev.name = name;
> -    vcdev->vdev.dev = &vcdev->cdev.parent_obj.parent_obj;
> +    vcdev->vdev.dev = DEVICE(vcdev);
>  
>      return;
>