aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2015-07-08 14:47:43 -0400
committerMark Brown <broonie@kernel.org>2015-07-08 15:05:04 -0400
commit1b7c12316982f74a5b8e7704c24cf5524d0723a3 (patch)
tree0ea498ff7130f099881cfa8043a52e56aece0956
parent6e78108bda78adbb2d4ef55ec60a388aba975797 (diff)
ASoC: Prevent components from being bound to multiple cards
A component can only be bound to a single card at a time. Binding it to card while it is already bound to another will result in undefined behavior. As the undefined behavior might only manifest itself later on it is not necessarily always straight forward to find the cause. To prevent this add a check that refuses to bind a component to multiple cards as well as prints a error describing the problem. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/soc-core.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 6ce621749f8d..96bb71aea529 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1102,9 +1102,19 @@ static int soc_probe_component(struct snd_soc_card *card,
1102 struct snd_soc_dai *dai; 1102 struct snd_soc_dai *dai;
1103 int ret; 1103 int ret;
1104 1104
1105 if (!strcmp(component->name, "snd-soc-dummy") || component->probed) 1105 if (!strcmp(component->name, "snd-soc-dummy"))
1106 return 0; 1106 return 0;
1107 1107
1108 if (component->probed) {
1109 if (component->card != card) {
1110 dev_err(component->dev,
1111 "Trying to bind component to card \"%s\" but is already bound to card \"%s\"\n",
1112 card->name, component->card->name);
1113 return -ENODEV;
1114 }
1115 return 0;
1116 }
1117
1108 component->card = card; 1118 component->card = card;
1109 dapm->card = card; 1119 dapm->card = card;
1110 soc_set_name_prefix(card, component); 1120 soc_set_name_prefix(card, component);