Skip to contentSkip to conversation

hw/char: remove console_exit function in sclp

PATCH In review Zihan Yang 2 participants 4 messages Apr 19, 2017 – Apr 24, 2017

lore
Share & tools
lore

Zihan Yang

author
#0 lore raw

PATCH 1/2 hw/char: remove console_exit function in sclp

Currently, the console_exit function in sclpconsole-lm.c and sclpconsole.c does nothing, just remove them. Since there is a NULL check on the DeviceClass exit callback as suggested by Frederic Konrad, it should be safe to simply remove them.

---
 hw/char/sclpconsole-lm.c          | 6 ------
 hw/char/sclpconsole.c             | 6 ------
 include/hw/s390x/event-facility.h | 2 +-
 3 files changed, 1 insertion(+), 13 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;
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
#1 lore raw

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

Note that only the virtio_ccw_exit, which is the exit function of VirtIOCCWDeviceClass, is modified to return void in this patch. 'virtio_ccw_busdev_exit' belongs to DeviceClass so it remains unchanged for the moment to give a split-out patch, because modifying it would involve some other folders like hw/audio.

---
 hw/s390x/event-facility.c | 6 +-----
 hw/s390x/virtio-ccw.c     | 6 +++---
 hw/s390x/virtio-ccw.h     | 2 +-
 3 files changed, 5 insertions(+), 9 deletions(-)
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);
     }
 }
 
hw/s390x/virtio-ccw.c +3 -3
index 00b3bde..0dbd3ee 100644
@@ -722,7 +722,7 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *dev, Error **errp)
     }
 }
 
-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;
@@ -735,7 +735,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)
@@ -1621,7 +1620,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; /* TODO workaround, should remove once converted to unrealize */
 }
 
 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
#3 lore raw
In reply to Zihan Yang
Quoted 4 lines · On Thu, 20 Apr 2017 02:21:29 +0800 Zihan Yang <[email protected]> wrote:

Currently, the console_exit function in sclpconsole-lm.c and sclpconsole.c does nothing, just remove them. Since there is a NULL check on the DeviceClass exit callback as suggested by Frederic Konrad, it should be safe to simply remove them.

Something strange happened to the commit message (leading whitespace).

You should also mention that you convert the callback to void.

Quoted 61 lines
---
 hw/char/sclpconsole-lm.c          | 6 ------
 hw/char/sclpconsole.c             | 6 ------
 include/hw/s390x/event-facility.h | 2 +-
 3 files changed, 1 insertion(+), 13 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;
include/hw/s390x/event-facility.h +0 -0
index def1bb0..1a32f3a 100644

include/hw/s390x/event-facility.h typedef struct SCLPEvent { · line 168

Quoted 8 lines
include/hw/s390x/event-facility.h +1 -1
@@ -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);

You missed one:

/home/cohuck/git/qemu/hw/s390x/event-facility.c: In function ‘event_unrealize’:
/home/cohuck/git/qemu/hw/s390x/event-facility.c:416:18: error: void value not ignored as it ought to be

#2 lore raw

Re: [Qemu-devel] [PATCH 2/2] hw/s390x: make virtio_ccw_exit function in virtio-ccw return void

In reply to Zihan Yang
Quoted 5 lines · On Thu, 20 Apr 2017 02:21:30 +0800 Zihan Yang <[email protected]> wrote:

Note that only the virtio_ccw_exit, which is the exit function of VirtIOCCWDeviceClass, is modified to return void in this patch. 'virtio_ccw_busdev_exit' belongs to DeviceClass so it remains unchanged for the moment to give a split-out patch, because modifying it would involve some other folders like hw/audio.

Change the last sentence to "DeviceClass::exit will be converted to void in another patch" or so.

Also, the same leading whitespace as in your previous patch.

Quoted 14 lines
---
 hw/s390x/event-facility.c | 6 +-----
 hw/s390x/virtio-ccw.c     | 6 +++---
 hw/s390x/virtio-ccw.h     | 2 +-
 3 files changed, 5 insertions(+), 9 deletions(-)
hw/s390x/event-facility.c +0 -0
index 34b2faf..f7c509c 100644
@@ -413,11 +413,7 @@ static void event_unrealize(DeviceState *qdev, Error **errp)
     SCLPEvent *event = SCLP_EVENT(qdev);

hw/s390x/event-facility.c static void event_unrealize(DeviceState *qdev, Error **errp) · line 418

Quoted 10 lines
hw/s390x/event-facility.c +1 -5
     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);
     }
 }

Ah, here's the hunk that should have been in the previous patch.

Quoted 23 lines
hw/s390x/virtio-ccw.c +1 -2
index 00b3bde..0dbd3ee 100644
@@ -722,7 +722,7 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *dev, Error **errp)
     }
 }
 
-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;
@@ -735,7 +735,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)

hw/s390x/virtio-ccw.c static int virtio_ccw_busdev_exit(DeviceState *dev) · line 1624

Quoted 6 lines
hw/s390x/virtio-ccw.c +2 -1
@@ -1621,7 +1620,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; /* TODO workaround, should remove once converted to unrealize */

I find that comment a bit confusing - just omit it?

Quoted 16 lines
hw/s390x/virtio-ccw.c +0 -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