hal: fix set_parameter() returning -2 error

When setparameters() is called and if the known keys are not found,
the implementation returns -2 error.Fix this by setting error only
when keys are found and there is an error while executing corresponding
implemention.

CRs-fixed: 589280
Change-Id: If5544d6fdeac47ddfc1f7e8e18bfa81e2ef5cbc2
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 9ba3b94..0976c1c 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -1,8 +1,8 @@
 /*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
- * Copyright (C) 2013 The Android Open Source Project
+ * Copyright (C) 2013-2014 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1358,12 +1358,12 @@
     char *str;
     char value[256] = {0};
     int val;
-    int ret = 0;
+    int ret = 0, err;
 
     ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
 
-    ret = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_BTSCO, &val);
-    if (ret >= 0) {
+    err = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_BTSCO, &val);
+    if (err >= 0) {
         str_parms_del(parms, AUDIO_PARAMETER_KEY_BTSCO);
         my_data->btsco_sample_rate = val;
         if (val == SAMPLE_RATE_16KHZ) {
@@ -1373,8 +1373,8 @@
         }
     }
 
-    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SLOWTALK, value, sizeof(value));
-    if (ret >= 0) {
+    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SLOWTALK, value, sizeof(value));
+    if (err >= 0) {
         bool state = false;
         if (!strncmp("true", value, sizeof("true"))) {
             state = true;
@@ -1386,9 +1386,9 @@
             ALOGE("%s: Failed to set slow talk err: %d", __func__, ret);
     }
 
-    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOLUME_BOOST,
+    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOLUME_BOOST,
                             value, sizeof(value));
-    if (ret >= 0) {
+    if (err >= 0) {
         str_parms_del(parms, AUDIO_PARAMETER_KEY_VOLUME_BOOST);
 
         if (my_data->acdb_reload_vocvoltable == NULL) {