mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 15:39:42 -04:00
ASoC: audio-graph-card: use snd_soc_ret()
We can use snd_soc_ret() to indicate error message when return. Let's use it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://patch.msgid.link/878qql2qlc.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
2d7395b23d
commit
74a0ca4c7f
@@ -20,6 +20,13 @@
|
||||
|
||||
#define DPCM_SELECTABLE 1
|
||||
|
||||
#define graph_ret(priv, ret) _graph_ret(priv, __func__, ret)
|
||||
static inline int _graph_ret(struct simple_util_priv *priv,
|
||||
const char *func, int ret)
|
||||
{
|
||||
return snd_soc_ret(simple_priv_to_dev(priv), ret, "at %s()\n", func);
|
||||
}
|
||||
|
||||
#define ep_to_port(ep) of_get_parent(ep)
|
||||
static struct device_node *port_to_ports(struct device_node *port)
|
||||
{
|
||||
@@ -113,17 +120,15 @@ static int graph_parse_node(struct simple_util_priv *priv,
|
||||
|
||||
ret = graph_util_parse_dai(priv, ep, dlc, cpu);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = simple_util_parse_tdm(ep, dai);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = simple_util_parse_clk(dev, ep, dai, dlc);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
end:
|
||||
return graph_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int graph_link_init(struct simple_util_priv *priv,
|
||||
@@ -148,7 +153,7 @@ static int graph_link_init(struct simple_util_priv *priv,
|
||||
ret = simple_util_parse_daifmt(dev, ep_cpu, ep_codec,
|
||||
NULL, &dai_link->dai_fmt);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
graph_util_parse_link_direction(top, &playback_only, &capture_only);
|
||||
graph_util_parse_link_direction(port_cpu, &playback_only, &capture_only);
|
||||
@@ -183,7 +188,9 @@ static int graph_link_init(struct simple_util_priv *priv,
|
||||
if (priv->ops)
|
||||
dai_link->ops = priv->ops;
|
||||
|
||||
return simple_util_set_dailink_name(priv, dai_link, name);
|
||||
ret = simple_util_set_dailink_name(priv, dai_link, name);
|
||||
end:
|
||||
return graph_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int graph_dai_link_of_dpcm(struct simple_util_priv *priv,
|
||||
@@ -215,7 +222,7 @@ static int graph_dai_link_of_dpcm(struct simple_util_priv *priv,
|
||||
|
||||
ret = graph_parse_node(priv, cpu_ep, li, &is_single_links);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
snprintf(dai_name, sizeof(dai_name),
|
||||
"fe.%pOFP.%s", cpus->of_node, cpus->dai_name);
|
||||
@@ -248,7 +255,7 @@ static int graph_dai_link_of_dpcm(struct simple_util_priv *priv,
|
||||
|
||||
ret = graph_parse_node(priv, codec_ep, li, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
snprintf(dai_name, sizeof(dai_name),
|
||||
"be.%pOFP.%s", codecs->of_node, codecs->dai_name);
|
||||
@@ -267,8 +274,8 @@ static int graph_dai_link_of_dpcm(struct simple_util_priv *priv,
|
||||
ret = graph_link_init(priv, cpu_ep, codec_ep, li, dai_name);
|
||||
|
||||
li->link++;
|
||||
|
||||
return ret;
|
||||
end:
|
||||
return graph_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int graph_dai_link_of(struct simple_util_priv *priv,
|
||||
@@ -288,11 +295,11 @@ static int graph_dai_link_of(struct simple_util_priv *priv,
|
||||
|
||||
ret = graph_parse_node(priv, cpu_ep, li, &is_single_links);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = graph_parse_node(priv, codec_ep, li, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
snprintf(dai_name, sizeof(dai_name),
|
||||
"%s-%s", cpus->dai_name, codecs->dai_name);
|
||||
@@ -302,11 +309,11 @@ static int graph_dai_link_of(struct simple_util_priv *priv,
|
||||
|
||||
ret = graph_link_init(priv, cpu_ep, codec_ep, li, dai_name);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
li->link++;
|
||||
|
||||
return 0;
|
||||
end:
|
||||
return graph_ret(priv, ret);
|
||||
}
|
||||
|
||||
static inline bool parse_as_dpcm_link(struct simple_util_priv *priv,
|
||||
@@ -383,13 +390,13 @@ static int __graph_for_each_link(struct simple_util_priv *priv,
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
codec_port_old = codec_port;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
end:
|
||||
return graph_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int graph_for_each_link(struct simple_util_priv *priv,
|
||||
@@ -422,7 +429,7 @@ static int graph_for_each_link(struct simple_util_priv *priv,
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return graph_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int graph_count_noml(struct simple_util_priv *priv,
|
||||
@@ -431,11 +438,10 @@ static int graph_count_noml(struct simple_util_priv *priv,
|
||||
struct link_info *li)
|
||||
{
|
||||
struct device *dev = simple_priv_to_dev(priv);
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (li->link >= SNDRV_MAX_LINKS) {
|
||||
dev_err(dev, "too many links\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (li->link >= SNDRV_MAX_LINKS)
|
||||
goto end;
|
||||
|
||||
/*
|
||||
* DON'T REMOVE platforms
|
||||
@@ -450,8 +456,9 @@ static int graph_count_noml(struct simple_util_priv *priv,
|
||||
li->link += 1; /* 1xCPU-Codec */
|
||||
|
||||
dev_dbg(dev, "Count As Normal\n");
|
||||
|
||||
return 0;
|
||||
ret = 0;
|
||||
end:
|
||||
return graph_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int graph_count_dpcm(struct simple_util_priv *priv,
|
||||
@@ -460,11 +467,10 @@ static int graph_count_dpcm(struct simple_util_priv *priv,
|
||||
struct link_info *li)
|
||||
{
|
||||
struct device *dev = simple_priv_to_dev(priv);
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (li->link >= SNDRV_MAX_LINKS) {
|
||||
dev_err(dev, "too many links\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (li->link >= SNDRV_MAX_LINKS)
|
||||
goto end;
|
||||
|
||||
if (li->cpu) {
|
||||
/*
|
||||
@@ -483,8 +489,9 @@ static int graph_count_dpcm(struct simple_util_priv *priv,
|
||||
}
|
||||
|
||||
dev_dbg(dev, "Count As DPCM\n");
|
||||
|
||||
return 0;
|
||||
ret = 0;
|
||||
end:
|
||||
return graph_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int graph_get_dais_count(struct simple_util_priv *priv,
|
||||
@@ -544,40 +551,41 @@ static int graph_get_dais_count(struct simple_util_priv *priv,
|
||||
int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev)
|
||||
{
|
||||
struct snd_soc_card *card = simple_priv_to_card(priv);
|
||||
int ret;
|
||||
int ret = -ENOMEM;
|
||||
|
||||
struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL);
|
||||
if (!li)
|
||||
return -ENOMEM;
|
||||
goto end;
|
||||
|
||||
card->owner = THIS_MODULE;
|
||||
card->dev = dev;
|
||||
|
||||
ret = graph_get_dais_count(priv, li);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = -EINVAL;
|
||||
if (!li->link)
|
||||
return -EINVAL;
|
||||
goto end;
|
||||
|
||||
ret = simple_util_init_priv(priv, li);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(priv->pa_gpio)) {
|
||||
ret = PTR_ERR(priv->pa_gpio);
|
||||
dev_err(dev, "failed to get amplifier gpio: %d\n", ret);
|
||||
return ret;
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = simple_util_parse_widgets(card, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = simple_util_parse_routing(card, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
memset(li, 0, sizeof(*li));
|
||||
ret = graph_for_each_link(priv, li,
|
||||
@@ -599,10 +607,9 @@ int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev)
|
||||
goto err;
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
simple_util_clean_reference(card);
|
||||
|
||||
end:
|
||||
return dev_err_probe(dev, ret, "parse error\n");
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(audio_graph_parse_of);
|
||||
|
||||
Reference in New Issue
Block a user