ASoC: Intel: Skylake: Optimize UUID handling to fill pin info
authorSriram Periyasamy <sriramx.periyasamy@intel.com>
Tue, 7 Nov 2017 10:46:22 +0000 (16:16 +0530)
committerMark Brown <broonie@kernel.org>
Wed, 8 Nov 2017 18:58:12 +0000 (18:58 +0000)
Modify skl_tplg_get_uuid() to copy just UUID rather than only
for module UUID and skl_tplg_fill_pin() to fill the pin info
which can include UUID token also.

Signed-off-by: Sriram Periyasamy <sriramx.periyasamy@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/skylake/skl-topology.c

index 1200b7c6af561e0ba61da0daf84bd36001fbd256..90f8c839bcef27e3cbe86bb5bfbc1ca4b1371181 100644 (file)
@@ -2036,21 +2036,35 @@ static int skl_tplg_add_pipe(struct device *dev,
        return 0;
 }
 
-static int skl_tplg_fill_pin(struct device *dev, u32 tkn,
+static int skl_tplg_get_uuid(struct device *dev, u8 *guid,
+             struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn)
+{
+       if (uuid_tkn->token == SKL_TKN_UUID) {
+               memcpy(guid, &uuid_tkn->uuid, 16);
+               return 0;
+       }
+
+       dev_err(dev, "Not an UUID token %d\n", uuid_tkn->token);
+
+       return -EINVAL;
+}
+
+static int skl_tplg_fill_pin(struct device *dev,
+                       struct snd_soc_tplg_vendor_value_elem *tkn_elem,
                        struct skl_module_pin *m_pin,
-                       int pin_index, u32 value)
+                       int pin_index)
 {
-       switch (tkn) {
+       switch (tkn_elem->token) {
        case SKL_TKN_U32_PIN_MOD_ID:
-               m_pin[pin_index].id.module_id = value;
+               m_pin[pin_index].id.module_id = tkn_elem->value;
                break;
 
        case SKL_TKN_U32_PIN_INST_ID:
-               m_pin[pin_index].id.instance_id = value;
+               m_pin[pin_index].id.instance_id = tkn_elem->value;
                break;
 
        default:
-               dev_err(dev, "%d Not a pin token\n", value);
+               dev_err(dev, "%d Not a pin token\n", tkn_elem->token);
                return -EINVAL;
        }
 
@@ -2083,9 +2097,7 @@ static int skl_tplg_fill_pins_info(struct device *dev,
                return -EINVAL;
        }
 
-       ret = skl_tplg_fill_pin(dev, tkn_elem->token,
-                       m_pin, pin_count, tkn_elem->value);
-
+       ret = skl_tplg_fill_pin(dev, tkn_elem, m_pin, pin_count);
        if (ret < 0)
                return ret;
 
@@ -2170,19 +2182,6 @@ static int skl_tplg_widget_fill_fmt(struct device *dev,
        return skl_tplg_fill_fmt(dev, dst_fmt, tkn, val);
 }
 
-static int skl_tplg_get_uuid(struct device *dev, struct skl_module_cfg *mconfig,
-             struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn)
-{
-       if (uuid_tkn->token == SKL_TKN_UUID)
-               memcpy(&mconfig->guid, &uuid_tkn->uuid, 16);
-       else {
-               dev_err(dev, "Not an UUID token tkn %d\n", uuid_tkn->token);
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
 static void skl_tplg_fill_pin_dynamic_val(
                struct skl_module_pin *mpin, u32 pin_count, u32 value)
 {
@@ -2565,7 +2564,8 @@ static int skl_tplg_get_tokens(struct device *dev,
                        continue;
 
                case SND_SOC_TPLG_TUPLE_TYPE_UUID:
-                       ret = skl_tplg_get_uuid(dev, mconfig, array->uuid);
+                       ret = skl_tplg_get_uuid(dev, mconfig->guid,
+                                       array->uuid);
                        if (ret < 0)
                                return ret;