From e27c2e3bb765958c217e46429776a0386c5b089f Mon Sep 17 00:00:00 2001
From: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Date: Tue, 13 Dec 2016 18:08:39 +0300
Subject: [PATCH 017/122] ASoC: Modify check condition of multiple bindings of
 components

https://patchwork.kernel.org/patch/7385501/
...and some more hacks to bind one component (with several DAIs)
to more than one sound card.

KF has 4 sound cards (pcm3168a, ak4613, radio, wl18xx) and just one
compinent ec500000.sound that can not be bound to all 4 cards.
This is a lack of current implementation of sound/soc/sh/rcar/* ASoC stack
The ec500000.sound resources (PCM/DMA, dais) needs to be shared between
all 4 sound cards if we want all cards work runtime.
Or we have to enable only one of them in dts file as it is designed.

Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
---
 sound/soc/soc-core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 8771405..0ec3674 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1516,7 +1516,8 @@ static int soc_probe_component(struct snd_soc_card *card,
 		return 0;
 
 	if (component->card) {
-		if (component->card != card) {
+		if (component->card != card &&
+		    component->registered_as_component) {
 			dev_err(component->dev,
 				"Trying to bind component to card \"%s\" but is already bound to card \"%s\"\n",
 				card->name, component->card->name);
@@ -3471,7 +3472,8 @@ int snd_soc_add_component(struct device *dev,
 		goto err_free;
 
 	component->ignore_pmdown_time = true;
-	component->registered_as_component = true;
+	if (num_dai == 1)
+		component->registered_as_component = true;
 
 	if (component_driver->endianness) {
 		for (i = 0; i < num_dai; i++) {
-- 
2.7.4

