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 366 struct snd_soc_dapm_widget *w) 367 367 { 368 368 int i, ret = 0; 369 - size_t name_len; 369 + size_t name_len, prefix_len; 370 370 struct snd_soc_dapm_path *path; 371 371 struct snd_card *card = dapm->card->snd_card; 372 372 const char *prefix; ··· 375 375 prefix = dapm->codec->name_prefix; 376 376 else 377 377 prefix = NULL; 378 + 379 + if (prefix) 380 + prefix_len = strlen(prefix) + 1; 381 + else 382 + prefix_len = 0; 378 383 379 384 /* add kcontrol */ 380 385 for (i = 0; i < w->num_kcontrols; i++) { ··· 408 403 409 404 switch (w->id) { 410 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 + */ 411 412 snprintf(path->long_name, name_len, "%s %s", 412 - w->name, w->kcontrols[i].name); 413 + w->name + prefix_len, 414 + w->kcontrols[i].name); 413 415 break; 414 416 case snd_soc_dapm_mixer_named_ctl: 415 417 snprintf(path->long_name, name_len, "%s", ··· 450 438 struct snd_kcontrol *kcontrol; 451 439 struct snd_card *card = dapm->card->snd_card; 452 440 const char *prefix; 441 + size_t prefix_len; 453 442 int ret = 0; 454 443 455 444 if (!w->num_kcontrols) { ··· 463 450 else 464 451 prefix = NULL; 465 452 466 - kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name, prefix); 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); 467 464 ret = snd_ctl_add(card, kcontrol); 468 465 469 466 if (ret < 0)