Message ID | 20230213170145.45666-5-philmd@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | hw/vfio/ccw: hw: Use QOM macros and remove DO_UPCAST() uses | expand |
On 13/2/23 18:01, Philippe Mathieu-Daudé wrote: > Use the S390_CCW_DEVICE() QOM type-checking macro to avoid DO_UPCAST(). > I forgot Eric R-b here: Reviewed-by: Eric Farman <farman@linux.ibm.com> > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > hw/vfio/ccw.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c > index 2c20e3c202..2ea7b4a63c 100644 > --- a/hw/vfio/ccw.c > +++ b/hw/vfio/ccw.c > @@ -251,8 +251,7 @@ again: > > static void vfio_ccw_reset(DeviceState *dev) > { > - CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev); > - S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev); > + S390CCWDevice *cdev = S390_CCW_DEVICE(dev); > VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); > > ioctl(vcdev->vdev.fd, VFIO_DEVICE_RESET); > @@ -657,8 +656,7 @@ static VFIOGroup *vfio_ccw_get_group(S390CCWDevice *cdev, Error **errp) > static void vfio_ccw_realize(DeviceState *dev, Error **errp) > { > VFIOGroup *group; > - CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev); > - S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev); > + S390CCWDevice *cdev = S390_CCW_DEVICE(dev); > VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); > S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev); > Error *err = NULL; > @@ -729,8 +727,7 @@ out_err_propagate: > > static void vfio_ccw_unrealize(DeviceState *dev) > { > - CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev); > - S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev); > + S390CCWDevice *cdev = S390_CCW_DEVICE(dev); > VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); > S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev); > VFIOGroup *group = vcdev->vdev.group;
On 13/02/2023 18.01, Philippe Mathieu-Daudé wrote: > Use the S390_CCW_DEVICE() QOM type-checking macro to avoid DO_UPCAST(). > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > hw/vfio/ccw.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c > index 2c20e3c202..2ea7b4a63c 100644 > --- a/hw/vfio/ccw.c > +++ b/hw/vfio/ccw.c > @@ -251,8 +251,7 @@ again: > > static void vfio_ccw_reset(DeviceState *dev) > { > - CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev); > - S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev); > + S390CCWDevice *cdev = S390_CCW_DEVICE(dev); > VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); > > ioctl(vcdev->vdev.fd, VFIO_DEVICE_RESET); > @@ -657,8 +656,7 @@ static VFIOGroup *vfio_ccw_get_group(S390CCWDevice *cdev, Error **errp) > static void vfio_ccw_realize(DeviceState *dev, Error **errp) > { > VFIOGroup *group; > - CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev); > - S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev); > + S390CCWDevice *cdev = S390_CCW_DEVICE(dev); > VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); > S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev); > Error *err = NULL; > @@ -729,8 +727,7 @@ out_err_propagate: > > static void vfio_ccw_unrealize(DeviceState *dev) > { > - CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev); > - S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev); > + S390CCWDevice *cdev = S390_CCW_DEVICE(dev); > VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); > S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev); > VFIOGroup *group = vcdev->vdev.group; Reviewed-by: Thomas Huth <thuth@redhat.com>
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 2c20e3c202..2ea7b4a63c 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -251,8 +251,7 @@ again: static void vfio_ccw_reset(DeviceState *dev) { - CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev); - S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev); + S390CCWDevice *cdev = S390_CCW_DEVICE(dev); VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); ioctl(vcdev->vdev.fd, VFIO_DEVICE_RESET); @@ -657,8 +656,7 @@ static VFIOGroup *vfio_ccw_get_group(S390CCWDevice *cdev, Error **errp) static void vfio_ccw_realize(DeviceState *dev, Error **errp) { VFIOGroup *group; - CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev); - S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev); + S390CCWDevice *cdev = S390_CCW_DEVICE(dev); VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev); Error *err = NULL; @@ -729,8 +727,7 @@ out_err_propagate: static void vfio_ccw_unrealize(DeviceState *dev) { - CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev); - S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev); + S390CCWDevice *cdev = S390_CCW_DEVICE(dev); VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev); VFIOGroup *group = vcdev->vdev.group;
Use the S390_CCW_DEVICE() QOM type-checking macro to avoid DO_UPCAST(). Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/vfio/ccw.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)