diff mbox series

[v3,3/6] hw/vfio/ccw: Use intermediate S390CCWDevice variable

Message ID 20230213170145.45666-4-philmd@linaro.org
State New
Headers show
Series hw/vfio/ccw: hw: Use QOM macros and remove DO_UPCAST() uses | expand

Commit Message

Philippe Mathieu-Daudé Feb. 13, 2023, 5:01 p.m. UTC
'cdev' is VFIOCCWDevice's private parent object.
Access it using the S390_CCW_DEVICE() QOM macro.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/vfio/ccw.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Eric Farman Feb. 13, 2023, 6:40 p.m. UTC | #1
On Mon, 2023-02-13 at 18:01 +0100, Philippe Mathieu-Daudé wrote:
> 'cdev' is VFIOCCWDevice's private parent object.
> Access it using the S390_CCW_DEVICE() QOM macro.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

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

> ---
>  hw/vfio/ccw.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
> index 503de94ce1..2c20e3c202 100644
> --- a/hw/vfio/ccw.c
> +++ b/hw/vfio/ccw.c
> @@ -588,9 +588,10 @@ static void vfio_ccw_put_device(VFIOCCWDevice
> *vcdev)
>  static void vfio_ccw_get_device(VFIOGroup *group, VFIOCCWDevice
> *vcdev,
>                                  Error **errp)
>  {
> -    char *name = g_strdup_printf("%x.%x.%04x", vcdev-
> >cdev.hostid.cssid,
> -                                 vcdev->cdev.hostid.ssid,
> -                                 vcdev->cdev.hostid.devid);
> +    S390CCWDevice *cdev = S390_CCW_DEVICE(vcdev);
> +    char *name = g_strdup_printf("%x.%x.%04x", cdev->hostid.cssid,
> +                                 cdev->hostid.ssid,
> +                                 cdev->hostid.devid);
>      VFIODevice *vbasedev;
>  
>      QLIST_FOREACH(vbasedev, &group->device_list, next) {
> @@ -611,7 +612,7 @@ static void vfio_ccw_get_device(VFIOGroup *group,
> VFIOCCWDevice *vcdev,
>       */
>      vcdev->vdev.ram_block_discard_allowed = true;
>  
> -    if (vfio_get_device(group, vcdev->cdev.mdevid, &vcdev->vdev,
> errp)) {
> +    if (vfio_get_device(group, cdev->mdevid, &vcdev->vdev, errp)) {
>          goto out_err;
>      }
>
diff mbox series

Patch

diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 503de94ce1..2c20e3c202 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -588,9 +588,10 @@  static void vfio_ccw_put_device(VFIOCCWDevice *vcdev)
 static void vfio_ccw_get_device(VFIOGroup *group, VFIOCCWDevice *vcdev,
                                 Error **errp)
 {
-    char *name = g_strdup_printf("%x.%x.%04x", vcdev->cdev.hostid.cssid,
-                                 vcdev->cdev.hostid.ssid,
-                                 vcdev->cdev.hostid.devid);
+    S390CCWDevice *cdev = S390_CCW_DEVICE(vcdev);
+    char *name = g_strdup_printf("%x.%x.%04x", cdev->hostid.cssid,
+                                 cdev->hostid.ssid,
+                                 cdev->hostid.devid);
     VFIODevice *vbasedev;
 
     QLIST_FOREACH(vbasedev, &group->device_list, next) {
@@ -611,7 +612,7 @@  static void vfio_ccw_get_device(VFIOGroup *group, VFIOCCWDevice *vcdev,
      */
     vcdev->vdev.ram_block_discard_allowed = true;
 
-    if (vfio_get_device(group, vcdev->cdev.mdevid, &vcdev->vdev, errp)) {
+    if (vfio_get_device(group, cdev->mdevid, &vcdev->vdev, errp)) {
         goto out_err;
     }