Skip to contentSkip to conversation

s390x/sclpconsole: Remove dead code - delete error handlers

PATCH Superseded Nia Alarie 3 participants 3 messages Mar 5, 2018 – Mar 6, 2018

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Nia Alarie

author
#0 lore raw

PATCH v2 1/1 s390x/sclpconsole: Remove dead code - delete error handlers

The other event handlers (quiesce and cpu) do not define these handlers, and this one does nothing, so it can be removed.

virtio_ccw_exit always returns 0, so change its return type to void.

---
 hw/char/sclpconsole-lm.c          |  6 ------
 hw/char/sclpconsole.c             |  6 ------
 hw/s390x/event-facility.c         | 14 --------------
 hw/s390x/virtio-ccw.c             |  6 +++---
 hw/s390x/virtio-ccw.h             |  2 +-
 include/hw/s390x/event-facility.h |  1 -
 6 files changed, 4 insertions(+), 31 deletions(-)
hw/char/sclpconsole-lm.c +0 -6
index c500bdaf29..84efd8df73 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 d0265dfa7a..e6ba0a46bd 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 +0 -14
index 155a69467b..79de3c738f 100644
@@ -431,26 +431,12 @@ static void event_realize(DeviceState *qdev, Error **errp)
     }
 }
 
-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;
-        }
-    }
-}
-
 static void event_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->bus_type = TYPE_SCLP_EVENTS_BUS;
     dc->realize = event_realize;
-    dc->unrealize = event_unrealize;
 }
 
 static const TypeInfo sclp_event_type_info = {
hw/s390x/virtio-ccw.c +3 -3
index 8f7fbc2ab7..0773818a82 100644
@@ -752,7 +752,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;
@@ -765,7 +765,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)
@@ -1710,7 +1709,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 3905f3a3d6..8ffe7fe095 100644
@@ -76,7 +76,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
include/hw/s390x/event-facility.h +0 -1
index 5119b9b7f0..b913f85edc 100644
@@ -174,7 +174,6 @@ typedef struct SCLPEvent {
 typedef struct SCLPEventClass {
     DeviceClass parent_class;
     int (*init)(SCLPEvent *event);
-    int (*exit)(SCLPEvent *event);
 
     /* get SCLP's send mask */
     unsigned int (*get_send_mask)(void);
Signature · 1 line
2.16.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Nia Alarie

The other event handlers (quiesce and cpu) do not define these handlers, and this one does nothing, so it can be removed.

virtio_ccw_exit always returns 0, so change its return type to void.

I would like to have 2 patches to make the subject non-misleading.

patch1: sclp/event
patch2: virtio-ccw

With that

Quoted 145 lines
---
 hw/char/sclpconsole-lm.c          |  6 ------
 hw/char/sclpconsole.c             |  6 ------
 hw/s390x/event-facility.c         | 14 --------------
 hw/s390x/virtio-ccw.c             |  6 +++---
 hw/s390x/virtio-ccw.h             |  2 +-
 include/hw/s390x/event-facility.h |  1 -
 6 files changed, 4 insertions(+), 31 deletions(-)
hw/char/sclpconsole-lm.c +0 -6
index c500bdaf29..84efd8df73 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 d0265dfa7a..e6ba0a46bd 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 +0 -14
index 155a69467b..79de3c738f 100644
@@ -431,26 +431,12 @@ static void event_realize(DeviceState *qdev, Error **errp)
     }
 }
 
-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;
-        }
-    }
-}
-
 static void event_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->bus_type = TYPE_SCLP_EVENTS_BUS;
     dc->realize = event_realize;
-    dc->unrealize = event_unrealize;
 }
 
 static const TypeInfo sclp_event_type_info = {
hw/s390x/virtio-ccw.c +3 -3
index 8f7fbc2ab7..0773818a82 100644
@@ -752,7 +752,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;
@@ -765,7 +765,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)
@@ -1710,7 +1709,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 3905f3a3d6..8ffe7fe095 100644
@@ -76,7 +76,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
include/hw/s390x/event-facility.h +0 -1
index 5119b9b7f0..b913f85edc 100644
@@ -174,7 +174,6 @@ typedef struct SCLPEvent {
 typedef struct SCLPEventClass {
     DeviceClass parent_class;
     int (*init)(SCLPEvent *event);
-    int (*exit)(SCLPEvent *event);
 
     /* get SCLP's send mask */
     unsigned int (*get_send_mask)(void);
#2 lore raw
Quoted 7 lines · On Tue, 6 Mar 2018 09:13:33 +0100 Christian Borntraeger…
Quoted 6 lines · Nia Alarie

The other event handlers (quiesce and cpu) do not define these handlers, and this one does nothing, so it can be removed.

virtio_ccw_exit always returns 0, so change its return type to void.

Quoted 7 lines
Quoted 1 line

I would like to have 2 patches to make the subject non-misleading.

patch1: sclp/event
patch2: virtio-ccw

Yes, please. sclp/event and virtio-ccw are two different code paths.

Also, looking at the virtio-ccw part: Rather than modifying exit handlers, the code should be converted to unrealize instead.

Quoted 12 lines

With that

Quoted 8 lines
---
 hw/char/sclpconsole-lm.c          |  6 ------
 hw/char/sclpconsole.c             |  6 ------
 hw/s390x/event-facility.c         | 14 --------------
 hw/s390x/virtio-ccw.c             |  6 +++---
 hw/s390x/virtio-ccw.h             |  2 +-
 include/hw/s390x/event-facility.h |  1 -
 6 files changed, 4 insertions(+), 31 deletions(-)

I'd be happy to merge the sclp part for 2.12 if I get the patch Thursday morning CET latest.

I'd be happy to merge an unrealize conversion for virtio-ccw as well, but I'm not sure how much work that is (although it looks manageable).