ASoC: soc-link: remove unneeded parameter from snd_soc_link_xxx()
[linux-2.6-block.git] / sound / soc / soc-link.c
CommitLineData
02e75636
KM
1// SPDX-License-Identifier: GPL-2.0
2//
3// soc-link.c
4//
5// Copyright (C) 2019 Renesas Electronics Corp.
6// Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7//
8#include <sound/soc.h>
9#include <sound/soc-link.h>
10
11#define soc_link_ret(rtd, ret) _soc_link_ret(rtd, __func__, ret)
12static inline int _soc_link_ret(struct snd_soc_pcm_runtime *rtd,
13 const char *func, int ret)
14{
15 switch (ret) {
16 case -EPROBE_DEFER:
17 case -ENOTSUPP:
18 case 0:
19 break;
20 default:
21 dev_err(rtd->dev,
22 "ASoC: error at %s on %s: %d\n",
23 func, rtd->dai_link->name, ret);
24 }
25
26 return ret;
27}
28
29int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd)
30{
31 int ret = 0;
32
33 if (rtd->dai_link->init)
34 ret = rtd->dai_link->init(rtd);
35
36 return soc_link_ret(rtd, ret);
37}
a5e6c109 38
7cf3c5b4 39int snd_soc_link_startup(struct snd_pcm_substream *substream)
a5e6c109 40{
7cf3c5b4 41 struct snd_soc_pcm_runtime *rtd = substream->private_data;
a5e6c109
KM
42 int ret = 0;
43
44 if (rtd->dai_link->ops &&
45 rtd->dai_link->ops->startup)
46 ret = rtd->dai_link->ops->startup(substream);
47
48 return soc_link_ret(rtd, ret);
49}
50
7cf3c5b4 51void snd_soc_link_shutdown(struct snd_pcm_substream *substream)
a5e6c109 52{
7cf3c5b4
KM
53 struct snd_soc_pcm_runtime *rtd = substream->private_data;
54
a5e6c109
KM
55 if (rtd->dai_link->ops &&
56 rtd->dai_link->ops->shutdown)
57 rtd->dai_link->ops->shutdown(substream);
58}
59
7cf3c5b4 60int snd_soc_link_prepare(struct snd_pcm_substream *substream)
a5e6c109 61{
7cf3c5b4 62 struct snd_soc_pcm_runtime *rtd = substream->private_data;
a5e6c109
KM
63 int ret = 0;
64
65 if (rtd->dai_link->ops &&
66 rtd->dai_link->ops->prepare)
67 ret = rtd->dai_link->ops->prepare(substream);
68
69 return soc_link_ret(rtd, ret);
70}
71
7cf3c5b4 72int snd_soc_link_hw_params(struct snd_pcm_substream *substream,
a5e6c109
KM
73 struct snd_pcm_hw_params *params)
74{
7cf3c5b4 75 struct snd_soc_pcm_runtime *rtd = substream->private_data;
a5e6c109
KM
76 int ret = 0;
77
78 if (rtd->dai_link->ops &&
79 rtd->dai_link->ops->hw_params)
80 ret = rtd->dai_link->ops->hw_params(substream, params);
81
82 return soc_link_ret(rtd, ret);
83}
84
7cf3c5b4 85void snd_soc_link_hw_free(struct snd_pcm_substream *substream)
a5e6c109 86{
7cf3c5b4
KM
87 struct snd_soc_pcm_runtime *rtd = substream->private_data;
88
a5e6c109
KM
89 if (rtd->dai_link->ops &&
90 rtd->dai_link->ops->hw_free)
91 rtd->dai_link->ops->hw_free(substream);
92}
93
7cf3c5b4 94int snd_soc_link_trigger(struct snd_pcm_substream *substream, int cmd)
a5e6c109 95{
7cf3c5b4 96 struct snd_soc_pcm_runtime *rtd = substream->private_data;
a5e6c109
KM
97 int ret = 0;
98
99 if (rtd->dai_link->ops &&
100 rtd->dai_link->ops->trigger)
101 ret = rtd->dai_link->ops->trigger(substream, cmd);
102
103 return soc_link_ret(rtd, ret);
104}