OSDN Git Service

ASoC: add soc-link.c
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 25 May 2020 00:57:14 +0000 (09:57 +0900)
committerMark Brown <broonie@kernel.org>
Mon, 25 May 2020 13:22:08 +0000 (14:22 +0100)
Current ALSA SoC has many dai_link->xxx() functions.
But, it is implemented randomly at random place.

This patch creats new soc-link.c and collect dai_link related
operation into it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/871rn84ys5.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-link.h [new file with mode: 0644]
sound/soc/Makefile
sound/soc/soc-core.c
sound/soc/soc-link.c [new file with mode: 0644]

diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h
new file mode 100644 (file)
index 0000000..7fc5cea
--- /dev/null
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * soc-link.h
+ *
+ * Copyright (C) 2019 Renesas Electronics Corp.
+ * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ */
+#ifndef __SOC_LINK_H
+#define __SOC_LINK_H
+
+int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd);
+
+#endif /* __SOC_LINK_H */
index 861a21b..70a5f19 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-utils.o soc-dai.o soc-component.o
-snd-soc-core-objs += soc-pcm.o soc-io.o soc-devres.o soc-ops.o
+snd-soc-core-objs += soc-pcm.o soc-io.o soc-devres.o soc-ops.o soc-link.o
 snd-soc-core-$(CONFIG_SND_SOC_COMPRESS) += soc-compress.o
 
 ifneq ($(CONFIG_SND_SOC_TOPOLOGY),)
index e697258..955e175 100644 (file)
@@ -38,6 +38,7 @@
 #include <sound/soc.h>
 #include <sound/soc-dpcm.h>
 #include <sound/soc-topology.h>
+#include <sound/soc-link.h>
 #include <sound/initval.h>
 
 #define CREATE_TRACE_POINTS
@@ -1049,14 +1050,9 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
        rtd->pmdown_time = pmdown_time;
 
        /* do machine specific initialization */
-       if (dai_link->init) {
-               ret = dai_link->init(rtd);
-               if (ret < 0) {
-                       dev_err(card->dev, "ASoC: failed to init %s: %d\n",
-                               dai_link->name, ret);
-                       return ret;
-               }
-       }
+       ret = snd_soc_link_init(rtd);
+       if (ret < 0)
+               return ret;
 
        if (dai_link->dai_fmt) {
                ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c
new file mode 100644 (file)
index 0000000..bba6f35
--- /dev/null
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// soc-link.c
+//
+// Copyright (C) 2019 Renesas Electronics Corp.
+// Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+//
+#include <sound/soc.h>
+#include <sound/soc-link.h>
+
+#define soc_link_ret(rtd, ret) _soc_link_ret(rtd, __func__, ret)
+static inline int _soc_link_ret(struct snd_soc_pcm_runtime *rtd,
+                               const char *func, int ret)
+{
+       switch (ret) {
+       case -EPROBE_DEFER:
+       case -ENOTSUPP:
+       case 0:
+               break;
+       default:
+               dev_err(rtd->dev,
+                       "ASoC: error at %s on %s: %d\n",
+                       func, rtd->dai_link->name, ret);
+       }
+
+       return ret;
+}
+
+int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd)
+{
+       int ret = 0;
+
+       if (rtd->dai_link->init)
+               ret = rtd->dai_link->init(rtd);
+
+       return soc_link_ret(rtd, ret);
+}