diff options
author | Thomas Huth <thuth@redhat.com> | 2018-07-25 14:20:15 +0200 |
---|---|---|
committer | Cornelia Huck <cohuck@redhat.com> | 2018-08-28 17:37:01 +0200 |
commit | 2d6ff33a03332d2a7dc0ece31a8eb8d49c0194ee (patch) | |
tree | ce6aac0fb32675c8672d0274a452be3ebc15cb60 /hw/s390x/virtio-ccw.c | |
parent | 3cea09271b3b3a0c4d0ffa3b56ea671bf75d82c3 (diff) |
hw/s390x/virtio-ccw: Consolidate calls to virtio_ccw_unrealize()
Currently, every virtio-ccw device explicitely sets its unrealize
function to virtio_ccw_unrealize() in its class_init function.
We can simplify this by using a common unrealize function, just like
it is already done for the realize functions.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1532521224-27235-2-git-send-email-thuth@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Diffstat (limited to 'hw/s390x/virtio-ccw.c')
-rw-r--r-- | hw/s390x/virtio-ccw.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 2713b7feaa..8de797743f 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -747,11 +747,16 @@ out_err: g_free(sch); } -static void virtio_ccw_unrealize(VirtioCcwDevice *dev, Error **errp) +static void virtio_ccw_device_unrealize(VirtioCcwDevice *dev, Error **errp) { + VirtIOCCWDeviceClass *dc = VIRTIO_CCW_DEVICE_GET_CLASS(dev); CcwDevice *ccw_dev = CCW_DEVICE(dev); SubchDev *sch = ccw_dev->sch; + if (dc->unrealize) { + dc->unrealize(dev, errp); + } + if (sch) { css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL); g_free(sch); @@ -1346,7 +1351,6 @@ static void virtio_ccw_net_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_net_realize; - k->unrealize = virtio_ccw_unrealize; dc->props = virtio_ccw_net_properties; set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); } @@ -1373,7 +1377,6 @@ static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_blk_realize; - k->unrealize = virtio_ccw_unrealize; dc->props = virtio_ccw_blk_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } @@ -1400,7 +1403,6 @@ static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_serial_realize; - k->unrealize = virtio_ccw_unrealize; dc->props = virtio_ccw_serial_properties; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } @@ -1427,7 +1429,6 @@ static void virtio_ccw_balloon_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_balloon_realize; - k->unrealize = virtio_ccw_unrealize; dc->props = virtio_ccw_balloon_properties; set_bit(DEVICE_CATEGORY_MISC, dc->categories); } @@ -1454,7 +1455,6 @@ static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_scsi_realize; - k->unrealize = virtio_ccw_unrealize; dc->props = virtio_ccw_scsi_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } @@ -1480,7 +1480,6 @@ static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = vhost_ccw_scsi_realize; - k->unrealize = virtio_ccw_unrealize; dc->props = vhost_ccw_scsi_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } @@ -1516,7 +1515,6 @@ static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_rng_realize; - k->unrealize = virtio_ccw_unrealize; dc->props = virtio_ccw_rng_properties; set_bit(DEVICE_CATEGORY_MISC, dc->categories); } @@ -1553,7 +1551,6 @@ static void virtio_ccw_crypto_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_crypto_realize; - k->unrealize = virtio_ccw_unrealize; dc->props = virtio_ccw_crypto_properties; set_bit(DEVICE_CATEGORY_MISC, dc->categories); } @@ -1590,7 +1587,6 @@ static void virtio_ccw_gpu_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_gpu_realize; - k->unrealize = virtio_ccw_unrealize; dc->props = virtio_ccw_gpu_properties; dc->hotpluggable = false; set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); @@ -1618,7 +1614,6 @@ static void virtio_ccw_input_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_input_realize; - k->unrealize = virtio_ccw_unrealize; dc->props = virtio_ccw_input_properties; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } @@ -1700,9 +1695,8 @@ static void virtio_ccw_busdev_realize(DeviceState *dev, Error **errp) static void virtio_ccw_busdev_unrealize(DeviceState *dev, Error **errp) { VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev; - VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev); - _info->unrealize(_dev, errp); + virtio_ccw_device_unrealize(_dev, errp); } static void virtio_ccw_busdev_unplug(HotplugHandler *hotplug_dev, @@ -1798,7 +1792,6 @@ static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); - k->unrealize = virtio_ccw_unrealize; k->realize = virtio_ccw_9p_realize; dc->props = virtio_ccw_9p_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); @@ -1844,7 +1837,6 @@ static void vhost_vsock_ccw_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = vhost_vsock_ccw_realize; - k->unrealize = virtio_ccw_unrealize; set_bit(DEVICE_CATEGORY_MISC, dc->categories); dc->props = vhost_vsock_ccw_properties; } |