[alsa-devel] [PATCH 21/25] ASoC: soc-component: add snd_soc_component_of_xlate_dai_id()
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Wed Jul 24 03:52:58 CEST 2019
From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
Current ALSA SoC is directly using component->driver->xxx,
thus, it is deep nested, and makes code difficult to read,
and is not good for encapsulation.
This patch adds new snd_soc_component_of_xlate_dai_id() and use it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
include/sound/soc-component.h | 2 ++
sound/soc/soc-component.c | 8 ++++++++
sound/soc/soc-core.c | 5 ++---
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 7cef7ed..b8553aa 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -361,5 +361,7 @@ void snd_soc_component_resume(struct snd_soc_component *component);
int snd_soc_component_is_suspended(struct snd_soc_component *component);
int snd_soc_component_probe(struct snd_soc_component *component);
void snd_soc_component_remove(struct snd_soc_component *component);
+int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
+ struct device_node *ep);
#endif /* __SOC_COMPONENT_H */
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index af26e8e..7dabcf7 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -451,3 +451,11 @@ void snd_soc_component_remove(struct snd_soc_component *component)
if (component->driver->remove)
component->driver->remove(component);
}
+
+int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
+ struct device_node *ep)
+{
+ if (component->driver->of_xlate_dai_id)
+ return component->driver->of_xlate_dai_id(component, ep);
+ return -ENOTSUPP;
+}
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 067c340..9ec34a6 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3380,9 +3380,8 @@ int snd_soc_get_dai_id(struct device_node *ep)
ret = -ENOTSUPP;
mutex_lock(&client_mutex);
component = soc_find_component(&dlc);
- if (component &&
- component->driver->of_xlate_dai_id)
- ret = component->driver->of_xlate_dai_id(component, ep);
+ if (component)
+ ret = snd_soc_component_of_xlate_dai_id(component, ep);
mutex_unlock(&client_mutex);
of_node_put(dlc.of_node);
--
2.7.4
More information about the Alsa-devel
mailing list