staging: unisys: visorbus: Replace parser_param_start with parser_name_get
authorDavid Kershner <david.kershner@unisys.com>
Mon, 9 Jan 2017 18:02:23 +0000 (13:02 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Jan 2017 16:29:46 +0000 (17:29 +0100)
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 <bryan.thompson@unisys.com>
Signed-off-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/visorbus/visorchipset.c

index f883bc32e2cf7938f900ea96a9c31170296ab77d..9c7617275532a5322b5f0efb8104a07a9fc6c738 100644 (file)
@@ -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);