Skip to contentSkip to conversation

hw: make *_exit return void/convert to unrealize in sclp/virtio-ccw

PATCH New Zihan Yang 1 participant 4 messages Apr 28, 2017

lore
Share & tools
lore

Zihan Yang

author
#0 lore raw

cover hw: make *_exit return void/convert to unrealize in sclp/virtio-ccw

These first patch remove the console_exit function in sclp since it actually does nothing, the callback return type in SCLPEventClass is changed to void. The second patch convert return type of *_exit function
of virtio-ccw to void. The third patch replace the exit callback with
unrealize in the class init function of virtio-ccw, because the exit callback of DeviceClass will be removed in the future.

Zihan Yang (3):
hw/char/sclp*: remove console_exit function in sclp hw/s390x: make virtio_ccw_exit function in virtio-ccw return void hw/s390: replace exit with unrealize during class init of virtio-ccw

 hw/char/sclpconsole-lm.c          | 6 ------
 hw/char/sclpconsole.c             | 6 ------
 hw/s390x/event-facility.c         | 6 +-----
 hw/s390x/virtio-ccw.c             | 9 ++++-----
 hw/s390x/virtio-ccw.h             | 2 +-
 include/hw/s390x/event-facility.h | 2 +-
 6 files changed, 7 insertions(+), 24 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/3 hw/char/sclp*: remove console_exit function in sclp

Currently the console_exit function in sclpconsole-lm.c and sclpconsole.c does nothing, so remove them and convert the callback in SCLPEventClass to void. Since there is a NULL check on the DeviceClass exit callback, it should be ok to simply remove them.

---
 hw/char/sclpconsole-lm.c          | 6 ------
 hw/char/sclpconsole.c             | 6 ------
 hw/s390x/event-facility.c         | 6 +-----
 include/hw/s390x/event-facility.h | 2 +-
 4 files changed, 2 insertions(+), 18 deletions(-)
hw/char/sclpconsole-lm.c +0 -6
index 07d6ebd..86ddda6 100644
@@ -318,11 +318,6 @@ static int console_init(SCLPEvent *event)
     return 0;
 }
 
-static int console_exit(SCLPEvent *event)
-{
-    return 0;
-}
-
 static void console_reset(DeviceState *dev)
 {
    SCLPEvent *event = SCLP_EVENT(dev);
@@ -349,7 +344,6 @@ static void console_class_init(ObjectClass *klass, void *data)
     dc->reset = console_reset;
     dc->vmsd = &vmstate_sclplmconsole;
     ec->init = console_init;
-    ec->exit = console_exit;
     ec->get_send_mask = send_mask;
     ec->get_receive_mask = receive_mask;
     ec->can_handle_event = can_handle_event;
hw/char/sclpconsole.c +0 -6
index b78f240..e916cac 100644
@@ -246,11 +246,6 @@ static void console_reset(DeviceState *dev)
    scon->notify = false;
 }
 
-static int console_exit(SCLPEvent *event)
-{
-    return 0;
-}
-
 static Property console_properties[] = {
     DEFINE_PROP_CHR("chardev", SCLPConsole, chr),
     DEFINE_PROP_END_OF_LIST(),
@@ -265,7 +260,6 @@ static void console_class_init(ObjectClass *klass, void *data)
     dc->reset = console_reset;
     dc->vmsd = &vmstate_sclpconsole;
     ec->init = console_init;
-    ec->exit = console_exit;
     ec->get_send_mask = send_mask;
     ec->get_receive_mask = receive_mask;
     ec->can_handle_event = can_handle_event;
hw/s390x/event-facility.c +1 -5
index 34b2faf..f7c509c 100644
@@ -413,11 +413,7 @@ static void event_unrealize(DeviceState *qdev, Error **errp)
     SCLPEvent *event = SCLP_EVENT(qdev);
     SCLPEventClass *child = SCLP_EVENT_GET_CLASS(event);
     if (child->exit) {
-        int rc = child->exit(event);
-        if (rc < 0) {
-            error_setg(errp, "SCLP event exit failed.");
-            return;
-        }
+        child->exit(event);
     }
 }
 
include/hw/s390x/event-facility.h +1 -1
index def1bb0..1a32f3a 100644
@@ -162,7 +162,7 @@ typedef struct SCLPEvent {
 typedef struct SCLPEventClass {
     DeviceClass parent_class;
     int (*init)(SCLPEvent *event);
-    int (*exit)(SCLPEvent *event);
+    void (*exit)(SCLPEvent *event);
 
     /* get SCLP's send mask */
     unsigned int (*get_send_mask)(void);
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 2/3 hw/s390x: make virtio_ccw_exit function in virtio-ccw return void

In reply to Zihan Yang

Only virtio_ccw_exit and the exit callback in VirtIOCCWDeviceClass are converted to void in this patch. 'virtio_ccw_busdev_exit' belongs to DeviceClass so it still returns int, DeviceClass::exit will return void in future patches.

---
 hw/s390x/virtio-ccw.c | 6 +++---
 hw/s390x/virtio-ccw.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
hw/s390x/virtio-ccw.c +3 -3
index e7167e3..91b43ac 100644
@@ -731,7 +731,7 @@ out_err:
     g_free(sch);
 }
 
-static int virtio_ccw_exit(VirtioCcwDevice *dev)
+static void virtio_ccw_exit(VirtioCcwDevice *dev)
 {
     CcwDevice *ccw_dev = CCW_DEVICE(dev);
     SubchDev *sch = ccw_dev->sch;
@@ -744,7 +744,6 @@ static int virtio_ccw_exit(VirtioCcwDevice *dev)
         release_indicator(&dev->routes.adapter, dev->indicators);
         dev->indicators = NULL;
     }
-    return 0;
 }
 
 static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp)
@@ -1627,7 +1626,8 @@ static int virtio_ccw_busdev_exit(DeviceState *dev)
     VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
     VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
 
-    return _info->exit(_dev);
+    _info->exit(_dev);
+    return 0;
 }
 
 static void virtio_ccw_busdev_unplug(HotplugHandler *hotplug_dev,
hw/s390x/virtio-ccw.h +1 -1
index 41d4010..ce8baa3 100644
@@ -74,7 +74,7 @@ typedef struct VirtioCcwDevice VirtioCcwDevice;
 typedef struct VirtIOCCWDeviceClass {
     CCWDeviceClass parent_class;
     void (*realize)(VirtioCcwDevice *dev, Error **errp);
-    int (*exit)(VirtioCcwDevice *dev);
+    void (*exit)(VirtioCcwDevice *dev);
 } VirtIOCCWDeviceClass;
 
 /* Performance improves when virtqueue kick processing is decoupled from the
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH 3/3 hw/s390: replace exit with unrealize during class init of virtio-ccw

In reply to Zihan Yang

Currently the virtio_ccw_device_class_init function sets dc->exit, which is the exit callback of DeviceClass. It should be converted to dc->unrealize since exit callback of DeviceClass will be removed in the future.

---
 hw/s390x/virtio-ccw.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
hw/s390x/virtio-ccw.c +2 -3
index 91b43ac..5c193a8 100644
@@ -1621,13 +1621,12 @@ static void virtio_ccw_busdev_realize(DeviceState *dev, Error **errp)
     virtio_ccw_device_realize(_dev, errp);
 }
 
-static int virtio_ccw_busdev_exit(DeviceState *dev)
+static void virtio_ccw_busdev_unrealize(DeviceState *dev, Error **errp)
 {
     VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
     VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
 
     _info->exit(_dev);
-    return 0;
 }
 
 static void virtio_ccw_busdev_unplug(HotplugHandler *hotplug_dev,
@@ -1645,7 +1644,7 @@ static void virtio_ccw_device_class_init(ObjectClass *klass, void *data)
 
     k->unplug = virtio_ccw_busdev_unplug;
     dc->realize = virtio_ccw_busdev_realize;
-    dc->exit = virtio_ccw_busdev_exit;
+    dc->unrealize = virtio_ccw_busdev_unrealize;
     dc->bus_type = TYPE_VIRTUAL_CSS_BUS;
 }
 
Signature · 1 line
2.7.4