ASoC: Fix double addition of prefixes due to widget prefixing

We're not only prefixing all controls, we're also prefixing the widget
names in the runtime data. This causes us to add the prefix twice - once
when using the widget name to generate the control name and once when
adding the control.

Really we shouldn't be prefixing the widget names at all, the matching
code should be handing this as we always know which DAPM context a
widget came from and always display the widget name in terms of a DAPM
context. However, we're quite close to the merge window and that's
relatively invasive.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Reported-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Liam Girdwood <lrg@ti.com>

+26 -3
+26 -3
sound/soc/soc-dapm.c
··· 366 struct snd_soc_dapm_widget *w) 367 { 368 int i, ret = 0; 369 - size_t name_len; 370 struct snd_soc_dapm_path *path; 371 struct snd_card *card = dapm->card->snd_card; 372 const char *prefix; ··· 375 prefix = dapm->codec->name_prefix; 376 else 377 prefix = NULL; 378 379 /* add kcontrol */ 380 for (i = 0; i < w->num_kcontrols; i++) { ··· 408 409 switch (w->id) { 410 default: 411 snprintf(path->long_name, name_len, "%s %s", 412 - w->name, w->kcontrols[i].name); 413 break; 414 case snd_soc_dapm_mixer_named_ctl: 415 snprintf(path->long_name, name_len, "%s", ··· 450 struct snd_kcontrol *kcontrol; 451 struct snd_card *card = dapm->card->snd_card; 452 const char *prefix; 453 int ret = 0; 454 455 if (!w->num_kcontrols) { ··· 463 else 464 prefix = NULL; 465 466 - kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name, prefix); 467 ret = snd_ctl_add(card, kcontrol); 468 469 if (ret < 0)
··· 366 struct snd_soc_dapm_widget *w) 367 { 368 int i, ret = 0; 369 + size_t name_len, prefix_len; 370 struct snd_soc_dapm_path *path; 371 struct snd_card *card = dapm->card->snd_card; 372 const char *prefix; ··· 375 prefix = dapm->codec->name_prefix; 376 else 377 prefix = NULL; 378 + 379 + if (prefix) 380 + prefix_len = strlen(prefix) + 1; 381 + else 382 + prefix_len = 0; 383 384 /* add kcontrol */ 385 for (i = 0; i < w->num_kcontrols; i++) { ··· 403 404 switch (w->id) { 405 default: 406 + /* The control will get a prefix from 407 + * the control creation process but 408 + * we're also using the same prefix 409 + * for widgets so cut the prefix off 410 + * the front of the widget name. 411 + */ 412 snprintf(path->long_name, name_len, "%s %s", 413 + w->name + prefix_len, 414 + w->kcontrols[i].name); 415 break; 416 case snd_soc_dapm_mixer_named_ctl: 417 snprintf(path->long_name, name_len, "%s", ··· 438 struct snd_kcontrol *kcontrol; 439 struct snd_card *card = dapm->card->snd_card; 440 const char *prefix; 441 + size_t prefix_len; 442 int ret = 0; 443 444 if (!w->num_kcontrols) { ··· 450 else 451 prefix = NULL; 452 453 + if (prefix) 454 + prefix_len = strlen(prefix) + 1; 455 + else 456 + prefix_len = 0; 457 + 458 + /* The control will get a prefix from the control creation 459 + * process but we're also using the same prefix for widgets so 460 + * cut the prefix off the front of the widget name. 461 + */ 462 + kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name + prefix_len, 463 + prefix); 464 ret = snd_ctl_add(card, kcontrol); 465 466 if (ret < 0)