summaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2017-10-02 05:09:52 +0000
committerMark Brown <broonie@kernel.org>2017-10-04 12:27:18 +0100
commit7dd5d0d954611c05a38bdf843054c639f45ce08b (patch)
tree1e9e2017e3edea3aed231b3a8947565b0a388db0 /sound/soc/soc-core.c
parent7ba236ce58bd7ac8e360de81f834d9c446f7b063 (diff)
downloadlinux-stable-7dd5d0d954611c05a38bdf843054c639f45ce08b.tar.gz
linux-stable-7dd5d0d954611c05a38bdf843054c639f45ce08b.tar.bz2
linux-stable-7dd5d0d954611c05a38bdf843054c639f45ce08b.zip
ASoC: soc-core: add component lookup functions
ALSA SoC platform/codec will be replaced to component soon. This means 1 device might have multiple components. But current unregister component function only checks "dev" to find it. This means, unexpected component might be unregistered by current function. But, it is no problem if driver registered only 1 component. To prepare avoid this issue, this patch adds new component lookup function. it finds component by "dev" and "driver name". Here, the reason why it uses "driver name" is that "component name" was created by fmt_single_name() and difficult to use it from driver. Driver of course knows its "driver name", thus, using it is more easy. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index fb3435121172..6ec127346e9c 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3481,6 +3481,32 @@ void snd_soc_unregister_component(struct device *dev)
}
EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
+struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
+ const char *driver_name)
+{
+ struct snd_soc_component *component;
+ struct snd_soc_component *ret;
+
+ ret = NULL;
+ mutex_lock(&client_mutex);
+ list_for_each_entry(component, &component_list, list) {
+ if (dev != component->dev)
+ continue;
+
+ if (driver_name &&
+ (driver_name != component->driver->name) &&
+ (strcmp(component->driver->name, driver_name) != 0))
+ continue;
+
+ ret = component;
+ break;
+ }
+ mutex_unlock(&client_mutex);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
+
static int snd_soc_platform_drv_probe(struct snd_soc_component *component)
{
struct snd_soc_platform *platform = snd_soc_component_to_platform(component);