]> xenbits.xensource.com Git - qemu-upstream-4.5-testing.git/commitdiff
s390/eventfacility: allow childs to handle more than 1 event type
authorChristian Borntraeger <borntraeger@de.ibm.com>
Tue, 17 Sep 2013 11:07:30 +0000 (13:07 +0200)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Fri, 20 Sep 2013 11:55:30 +0000 (13:55 +0200)
Currently all handlers (quiesce, console) only handle one event type.
Some drivers will handle multiple (compatible) event types. Rework the
code accordingly.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
hw/char/sclpconsole.c
hw/s390x/event-facility.c
hw/s390x/sclpquiesce.c
include/hw/s390x/event-facility.h

index 8cb0e41fa01648ac6e718f8f98b3b93b098dee5c..16d77c5e275a9789635b3d2dd255cb68d9bad72f 100644 (file)
@@ -79,9 +79,9 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
 
 /* functions to be called by event facility */
 
-static int event_type(void)
+static bool can_handle_event(uint8_t type)
 {
-    return SCLP_EVENT_ASCII_CONSOLE_DATA;
+    return type == SCLP_EVENT_ASCII_CONSOLE_DATA;
 }
 
 static unsigned int send_mask(void)
@@ -272,7 +272,7 @@ static void console_class_init(ObjectClass *klass, void *data)
     ec->exit = console_exit;
     ec->get_send_mask = send_mask;
     ec->get_receive_mask = receive_mask;
-    ec->event_type = event_type;
+    ec->can_handle_event = can_handle_event;
     ec->read_event_data = read_event_data;
     ec->write_event_data = write_event_data;
 }
index d2fd22776b1b21b8eed741941d05cde875316837..25951a020ab9d2f3f2359ef885166c24a3973eec 100644 (file)
@@ -120,7 +120,7 @@ static uint16_t handle_write_event_buf(SCLPEventFacility *ef,
         ec = SCLP_EVENT_GET_CLASS(event);
 
         if (ec->write_event_data &&
-            ec->event_type() == event_buf->type) {
+            ec->can_handle_event(event_buf->type)) {
             rc = ec->write_event_data(event, event_buf);
             break;
         }
index 616267883c35b2afd71b2d052c195dacb234f047..a3c4bd62727255aa9f02ec1c1fff30aa5c4233ef 100644 (file)
@@ -22,9 +22,9 @@ typedef struct SignalQuiesce {
     uint8_t unit;
 } QEMU_PACKED SignalQuiesce;
 
-static int event_type(void)
+static bool can_handle_event(uint8_t type)
 {
-    return SCLP_EVENT_SIGNAL_QUIESCE;
+    return type == SCLP_EVENT_SIGNAL_QUIESCE;
 }
 
 static unsigned int send_mask(void)
@@ -121,7 +121,7 @@ static void quiesce_class_init(ObjectClass *klass, void *data)
 
     k->get_send_mask = send_mask;
     k->get_receive_mask = receive_mask;
-    k->event_type = event_type;
+    k->can_handle_event = can_handle_event;
     k->read_event_data = read_event_data;
     k->write_event_data = NULL;
 }
index ff0f625860a51b69ddab47da96c7af27648e2bb7..c0f5d196f57238389c43989c18d1964f57dcc282 100644 (file)
@@ -87,9 +87,8 @@ typedef struct SCLPEventClass {
 
     int (*write_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr);
 
-    /* returns the supported event type */
-    int (*event_type)(void);
-
+    /* can we handle this event type? */
+    bool (*can_handle_event)(uint8_t type);
 } SCLPEventClass;
 
 #endif