Skip to content

Commit

Permalink
ASoC: topology: Align tplg pointer increment across all kcontrols
Browse files Browse the repository at this point in the history
This aligns all kcontrol tplg pointer increments to be consistent
in the respective create methods and ensures that the position is
pointing to the next widget rather the current invalid widget.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Liam Girdwood authored and Mark Brown committed Apr 2, 2019
1 parent e194098 commit 02b6424
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions sound/soc/soc-topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,6 @@ static int soc_tplg_denum_create(struct soc_tplg *tplg, unsigned int count,

for (i = 0; i < count; i++) {
ec = (struct snd_soc_tplg_enum_control *)tplg->pos;
tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) +
ec->priv.size);

/* validate kcontrol */
if (strnlen(ec->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) ==
Expand All @@ -1008,6 +1006,9 @@ static int soc_tplg_denum_create(struct soc_tplg *tplg, unsigned int count,
if (se == NULL)
return -ENOMEM;

tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) +
ec->priv.size);

dev_dbg(tplg->dev, "ASoC: adding enum kcontrol %s size %d\n",
ec->hdr.name, ec->items);

Expand Down Expand Up @@ -1284,14 +1285,14 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create(
if (sm == NULL)
goto err;

tplg->pos += (sizeof(struct snd_soc_tplg_mixer_control) +
mc->priv.size);

/* validate kcontrol */
if (strnlen(mc->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) ==
SNDRV_CTL_ELEM_ID_NAME_MAXLEN)
goto err_str;

tplg->pos += (sizeof(struct snd_soc_tplg_mixer_control) +
mc->priv.size);

dev_dbg(tplg->dev, " adding DAPM widget mixer control %s at %d\n",
mc->hdr.name, i);

Expand Down Expand Up @@ -1377,6 +1378,9 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
if (se == NULL)
goto err;

tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) +
ec->priv.size);

dev_dbg(tplg->dev, " adding DAPM widget enum control %s\n",
ec->hdr.name);

Expand Down Expand Up @@ -1441,9 +1445,6 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
ec->hdr.name);
goto err_se;
}

tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) +
ec->priv.size);
}

return kc;
Expand Down

0 comments on commit 02b6424

Please sign in to comment.