]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ASoC: soc-component: add snd_soc_component_open()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Fri, 26 Jul 2019 04:50:01 +0000 (13:50 +0900)
committerMark Brown <broonie@kernel.org>
Mon, 5 Aug 2019 15:17:40 +0000 (16:17 +0100)
Current ALSA SoC is directly using component->driver->ops->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_open() and use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87ftmt5rnx.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-component.h
sound/soc/soc-component.c
sound/soc/soc-pcm.c

index a76cadf49a164ad08c26436b10173feddcf8e35f..156b1a5b6ddd43c0e2e8bfc3fdb163dec0061da3 100644 (file)
@@ -338,4 +338,8 @@ int snd_soc_component_force_enable_pin_unlocked(
        struct snd_soc_component *component,
        const char *pin);
 
+/* component driver ops */
+int snd_soc_component_open(struct snd_soc_component *component,
+                          struct snd_pcm_substream *substream);
+
 #endif /* __SOC_COMPONENT_H */
index ac2d7bd5d84427617a84d9666909052fd0182033..ada46f9729b2abd51efa904f821bda6da0ec2b7d 100644 (file)
@@ -285,3 +285,13 @@ void snd_soc_component_module_put(struct snd_soc_component *component,
        if (component->driver->module_get_upon_open == !!upon_open)
                module_put(component->dev->driver->owner);
 }
+
+int snd_soc_component_open(struct snd_soc_component *component,
+                          struct snd_pcm_substream *substream)
+{
+       if (component->driver->ops &&
+           component->driver->ops->open)
+               return component->driver->ops->open(substream);
+
+       return 0;
+}
index 5fef18507286499b52c5c7fa2d50854c5f57ed99..caf7028cee622c0b33b5b26668a9fc4f3aef368c 100644 (file)
@@ -447,11 +447,7 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream,
                        return ret;
                }
 
-               if (!component->driver->ops ||
-                   !component->driver->ops->open)
-                       continue;
-
-               ret = component->driver->ops->open(substream);
+               ret = snd_soc_component_open(component, substream);
                if (ret < 0) {
                        dev_err(component->dev,
                                "ASoC: can't open component %s: %d\n",