From 046f93dc727ab390bf951e52236debd710e58a7d Mon Sep 17 00:00:00 2001 From: David Kershner Date: Mon, 9 Jan 2017 13:02:23 -0500 Subject: [PATCH] staging: unisys: visorbus: Replace parser_param_start with parser_name_get Replace the general CONTROLVM string parser setup which only handled the name string with a specific name string retrieval function. Signed-off-by: Bryan Thompson Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchipset.c | 53 ++++++------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index f883bc32e2cf..9c7617275532 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -352,45 +352,12 @@ parser_id_get(struct parser_context *ctx) { struct spar_controlvm_parameters_header *phdr = NULL; - if (!ctx) - return NULL_UUID_LE; phdr = (struct spar_controlvm_parameters_header *)(ctx->data); return phdr->id; } -/* - * Describes the state from the perspective of which controlvm messages have - * been received for a bus or device. - */ - -enum PARSER_WHICH_STRING { - PARSERSTRING_NAME -}; - -static void -parser_param_start(struct parser_context *ctx, - enum PARSER_WHICH_STRING which_string) -{ - struct spar_controlvm_parameters_header *phdr = NULL; - - if (!ctx) - return; - - phdr = (struct spar_controlvm_parameters_header *)(ctx->data); - switch (which_string) { - case PARSERSTRING_NAME: - ctx->curr = ctx->data + phdr->name_offset; - ctx->bytes_remaining = phdr->name_length; - break; - default: - break; - } -} - static void parser_done(struct parser_context *ctx) { - if (!ctx) - return; controlvm_payload_bytes_buffered -= ctx->param_bytes; kfree(ctx); } @@ -404,8 +371,6 @@ parser_string_get(struct parser_context *ctx) void *value = NULL; int i; - if (!ctx) - return NULL; pscan = ctx->curr; nscan = ctx->bytes_remaining; if (nscan == 0) @@ -428,6 +393,17 @@ parser_string_get(struct parser_context *ctx) return value; } +static void * +parser_name_get(struct parser_context *ctx) +{ + struct spar_controlvm_parameters_header *phdr = NULL; + + phdr = (struct spar_controlvm_parameters_header *)(ctx->data); + ctx->curr = ctx->data + phdr->name_offset; + ctx->bytes_remaining = phdr->name_length; + return parser_string_get(ctx); +} + struct visor_busdev { u32 bus_no; u32 dev_no; @@ -850,9 +826,10 @@ bus_configure(struct controlvm_message *inmsg, if (err) goto err_respond; - bus_info->partition_uuid = parser_id_get(parser_ctx); - parser_param_start(parser_ctx, PARSERSTRING_NAME); - bus_info->name = parser_string_get(parser_ctx); + if (parser_ctx) { + bus_info->partition_uuid = parser_id_get(parser_ctx); + bus_info->name = parser_name_get(parser_ctx); + } POSTCODE_LINUX(BUS_CONFIGURE_EXIT_PC, 0, bus_no, DIAG_SEVERITY_PRINT);