提交 c3d9f24a 编写于 作者: C Christian Borntraeger

s390/eventfacility: allow childs to handle more than 1 event type

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: NChristian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: NAlexander Graf <agraf@suse.de>
上级 8b8b1138
...@@ -79,9 +79,9 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) ...@@ -79,9 +79,9 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
/* functions to be called by event facility */ /* 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) static unsigned int send_mask(void)
...@@ -272,7 +272,7 @@ static void console_class_init(ObjectClass *klass, void *data) ...@@ -272,7 +272,7 @@ static void console_class_init(ObjectClass *klass, void *data)
ec->exit = console_exit; ec->exit = console_exit;
ec->get_send_mask = send_mask; ec->get_send_mask = send_mask;
ec->get_receive_mask = receive_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->read_event_data = read_event_data;
ec->write_event_data = write_event_data; ec->write_event_data = write_event_data;
} }
......
...@@ -120,7 +120,7 @@ static uint16_t handle_write_event_buf(SCLPEventFacility *ef, ...@@ -120,7 +120,7 @@ static uint16_t handle_write_event_buf(SCLPEventFacility *ef,
ec = SCLP_EVENT_GET_CLASS(event); ec = SCLP_EVENT_GET_CLASS(event);
if (ec->write_event_data && 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); rc = ec->write_event_data(event, event_buf);
break; break;
} }
......
...@@ -22,9 +22,9 @@ typedef struct SignalQuiesce { ...@@ -22,9 +22,9 @@ typedef struct SignalQuiesce {
uint8_t unit; uint8_t unit;
} QEMU_PACKED SignalQuiesce; } 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) static unsigned int send_mask(void)
...@@ -121,7 +121,7 @@ static void quiesce_class_init(ObjectClass *klass, void *data) ...@@ -121,7 +121,7 @@ static void quiesce_class_init(ObjectClass *klass, void *data)
k->get_send_mask = send_mask; k->get_send_mask = send_mask;
k->get_receive_mask = receive_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->read_event_data = read_event_data;
k->write_event_data = NULL; k->write_event_data = NULL;
} }
......
...@@ -87,9 +87,8 @@ typedef struct SCLPEventClass { ...@@ -87,9 +87,8 @@ typedef struct SCLPEventClass {
int (*write_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr); int (*write_event_data)(SCLPEvent *event, EventBufferHeader *evt_buf_hdr);
/* returns the supported event type */ /* can we handle this event type? */
int (*event_type)(void); bool (*can_handle_event)(uint8_t type);
} SCLPEventClass; } SCLPEventClass;
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册