[Skiboot] [PATCH RFC v2 09/12] opal-prd: split prd message reading from handling
Jeremy Kerr
jk at ozlabs.org
Fri May 26 12:54:28 AEST 2017
Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
---
external/opal-prd/opal-prd.c | 47 ++++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 19 deletions(-)
diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c
index 349363d..e6cd353 100644
--- a/external/opal-prd/opal-prd.c
+++ b/external/opal-prd/opal-prd.c
@@ -1228,7 +1228,29 @@ static int handle_msg_occ_reset(struct opal_prd_ctx *ctx,
return 0;
}
-static int handle_prd_msg(struct opal_prd_ctx *ctx)
+static int handle_prd_msg(struct opal_prd_ctx *ctx, struct opal_prd_msg *msg)
+{
+ int rc = -1;
+
+ switch (msg->hdr.type) {
+ case OPAL_PRD_MSG_TYPE_ATTN:
+ rc = handle_msg_attn(ctx, msg);
+ break;
+ case OPAL_PRD_MSG_TYPE_OCC_RESET:
+ rc = handle_msg_occ_reset(ctx, msg);
+ break;
+ case OPAL_PRD_MSG_TYPE_OCC_ERROR:
+ rc = handle_msg_occ_error(ctx, msg);
+ break;
+ default:
+ pr_log(LOG_WARNING, "Invalid incoming message type 0x%x",
+ msg->hdr.type);
+ }
+
+ return rc;
+}
+
+static int read_prd_msg(struct opal_prd_ctx *ctx)
{
struct opal_prd_msg *msg;
int size;
@@ -1293,22 +1315,6 @@ static int handle_prd_msg(struct opal_prd_ctx *ctx)
}
}
- switch (msg->hdr.type) {
- case OPAL_PRD_MSG_TYPE_ATTN:
- rc = handle_msg_attn(ctx, msg);
- break;
- case OPAL_PRD_MSG_TYPE_OCC_RESET:
- rc = handle_msg_occ_reset(ctx, msg);
- break;
- case OPAL_PRD_MSG_TYPE_OCC_ERROR:
- rc = handle_msg_occ_error(ctx, msg);
- break;
- default:
- pr_log(LOG_WARNING, "Invalid incoming message type 0x%x",
- msg->hdr.type);
- return -1;
- }
-
return 0;
}
@@ -1603,8 +1609,11 @@ static int run_attn_loop(struct opal_prd_ctx *ctx)
if (!rc)
continue;
- if (pollfds[0].revents & POLLIN)
- handle_prd_msg(ctx);
+ if (pollfds[0].revents & POLLIN) {
+ rc = read_prd_msg(ctx);
+ if (!rc)
+ handle_prd_msg(ctx, ctx->msg);
+ }
if (pollfds[1].revents & POLLIN) {
fd = accept(ctx->socket, NULL, NULL);
--
2.7.4
More information about the Skiboot
mailing list