From bf06664368408d26c0af1dec7de80a5fdbf5bf98 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Fri, 26 May 2017 12:54:28 +1000 Subject: opal-prd: split prd message reading from handling Signed-off-by: Jeremy Kerr Reviewed-by: Vasant Hegde Signed-off-by: Stewart Smith --- external/opal-prd/opal-prd.c | 47 ++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'external') diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c index 68d9cbc..8077c67 100644 --- a/external/opal-prd/opal-prd.c +++ b/external/opal-prd/opal-prd.c @@ -1239,7 +1239,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; @@ -1304,22 +1326,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; } @@ -1614,8 +1620,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); -- cgit v1.1