mirror of https://github.com/torvalds/linux.git
ASoC: simple-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/87bjvh2qlk.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
be61cd4242
commit
a0ef5b4b10
|
|
@ -29,7 +29,16 @@ static const struct snd_soc_ops simple_ops = {
|
|||
.hw_params = simple_util_hw_params,
|
||||
};
|
||||
|
||||
static int simple_parse_platform(struct device_node *node, struct snd_soc_dai_link_component *dlc)
|
||||
#define simple_ret(priv, ret) _simple_ret(priv, __func__, ret)
|
||||
static inline int _simple_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);
|
||||
}
|
||||
|
||||
static int simple_parse_platform(struct simple_util_priv *priv,
|
||||
struct device_node *node,
|
||||
struct snd_soc_dai_link_component *dlc)
|
||||
{
|
||||
struct of_phandle_args args;
|
||||
int ret;
|
||||
|
|
@ -43,7 +52,7 @@ static int simple_parse_platform(struct device_node *node, struct snd_soc_dai_li
|
|||
*/
|
||||
ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args);
|
||||
if (ret)
|
||||
return ret;
|
||||
return simple_ret(priv, ret);
|
||||
|
||||
/* dai_name is not required and may not exist for plat component */
|
||||
|
||||
|
|
@ -52,11 +61,12 @@ static int simple_parse_platform(struct device_node *node, struct snd_soc_dai_li
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int simple_parse_dai(struct device *dev,
|
||||
static int simple_parse_dai(struct simple_util_priv *priv,
|
||||
struct device_node *node,
|
||||
struct snd_soc_dai_link_component *dlc,
|
||||
int *is_single_link)
|
||||
{
|
||||
struct device *dev = simple_priv_to_dev(priv);
|
||||
struct of_phandle_args args;
|
||||
struct snd_soc_dai *dai;
|
||||
int ret;
|
||||
|
|
@ -70,17 +80,18 @@ static int simple_parse_dai(struct device *dev,
|
|||
*/
|
||||
ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
/*
|
||||
* Try to find from DAI args
|
||||
*/
|
||||
dai = snd_soc_get_dai_via_args(&args);
|
||||
if (dai) {
|
||||
ret = -ENOMEM;
|
||||
dlc->dai_name = snd_soc_dai_name_get(dai);
|
||||
dlc->dai_args = snd_soc_copy_dai_args(dev, &args);
|
||||
if (!dlc->dai_args)
|
||||
return -ENOMEM;
|
||||
goto end;
|
||||
|
||||
goto parse_dai_end;
|
||||
}
|
||||
|
|
@ -106,13 +117,14 @@ static int simple_parse_dai(struct device *dev,
|
|||
*/
|
||||
ret = snd_soc_get_dlc(&args, dlc);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
parse_dai_end:
|
||||
if (is_single_link)
|
||||
*is_single_link = !args.args_count;
|
||||
|
||||
return 0;
|
||||
ret = 0;
|
||||
end:
|
||||
return simple_ret(priv, ret);
|
||||
}
|
||||
|
||||
static void simple_parse_convert(struct device *dev,
|
||||
|
|
@ -149,19 +161,17 @@ static int simple_parse_node(struct simple_util_priv *priv,
|
|||
dai = simple_props_to_dai_codec(dai_props, 0);
|
||||
}
|
||||
|
||||
ret = simple_parse_dai(dev, np, dlc, cpu);
|
||||
ret = simple_parse_dai(priv, np, dlc, cpu);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = simple_util_parse_clk(dev, np, dai, dlc);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = simple_util_parse_tdm(np, dai);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
end:
|
||||
return simple_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int simple_link_init(struct simple_util_priv *priv,
|
||||
|
|
@ -183,7 +193,7 @@ static int simple_link_init(struct simple_util_priv *priv,
|
|||
ret = simple_util_parse_daifmt(dev, node, codec,
|
||||
prefix, &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(node, &playback_only, &capture_only);
|
||||
|
|
@ -213,7 +223,9 @@ static int simple_link_init(struct simple_util_priv *priv,
|
|||
dai_link->init = simple_util_dai_init;
|
||||
dai_link->ops = &simple_ops;
|
||||
|
||||
return simple_util_set_dailink_name(dev, dai_link, name);
|
||||
ret = simple_util_set_dailink_name(dev, dai_link, name);
|
||||
end:
|
||||
return simple_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int simple_dai_link_of_dpcm(struct simple_util_priv *priv,
|
||||
|
|
@ -290,7 +302,7 @@ static int simple_dai_link_of_dpcm(struct simple_util_priv *priv,
|
|||
out_put_node:
|
||||
li->link++;
|
||||
|
||||
return ret;
|
||||
return simple_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int simple_dai_link_of(struct simple_util_priv *priv,
|
||||
|
|
@ -330,7 +342,7 @@ static int simple_dai_link_of(struct simple_util_priv *priv,
|
|||
if (ret < 0)
|
||||
goto dai_link_of_err;
|
||||
|
||||
ret = simple_parse_platform(plat, platforms);
|
||||
ret = simple_parse_platform(priv, plat, platforms);
|
||||
if (ret < 0)
|
||||
goto dai_link_of_err;
|
||||
|
||||
|
|
@ -345,7 +357,7 @@ static int simple_dai_link_of(struct simple_util_priv *priv,
|
|||
dai_link_of_err:
|
||||
li->link++;
|
||||
|
||||
return ret;
|
||||
return simple_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int __simple_for_each_link(struct simple_util_priv *priv,
|
||||
|
|
@ -443,10 +455,10 @@ static int __simple_for_each_link(struct simple_util_priv *priv,
|
|||
node = of_get_next_child(top, node);
|
||||
} while (!is_top && node);
|
||||
|
||||
error:
|
||||
error:
|
||||
of_node_put(node);
|
||||
|
||||
return ret;
|
||||
return simple_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int simple_for_each_link(struct simple_util_priv *priv,
|
||||
|
|
@ -479,7 +491,7 @@ static int simple_for_each_link(struct simple_util_priv *priv,
|
|||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return simple_ret(priv, ret);
|
||||
}
|
||||
|
||||
static void simple_depopulate_aux(void *data)
|
||||
|
|
@ -500,9 +512,11 @@ static int simple_populate_aux(struct simple_util_priv *priv)
|
|||
|
||||
ret = of_platform_populate(node, NULL, NULL, dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
return devm_add_action_or_reset(dev, simple_depopulate_aux, priv);
|
||||
ret = devm_add_action_or_reset(dev, simple_depopulate_aux, priv);
|
||||
end:
|
||||
return simple_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int simple_parse_of(struct simple_util_priv *priv, struct link_info *li)
|
||||
|
|
@ -512,15 +526,15 @@ static int simple_parse_of(struct simple_util_priv *priv, struct link_info *li)
|
|||
|
||||
ret = simple_util_parse_widgets(card, PREFIX);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = simple_util_parse_routing(card, PREFIX);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = simple_util_parse_pin_switches(card, PREFIX);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
/* Single/Muti DAI link(s) & New style of DT node */
|
||||
memset(li, 0, sizeof(*li));
|
||||
|
|
@ -528,19 +542,19 @@ static int simple_parse_of(struct simple_util_priv *priv, struct link_info *li)
|
|||
simple_dai_link_of,
|
||||
simple_dai_link_of_dpcm);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = simple_util_parse_card_name(card, PREFIX);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = simple_populate_aux(priv);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs");
|
||||
|
||||
return ret;
|
||||
end:
|
||||
return simple_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int simple_count_noml(struct simple_util_priv *priv,
|
||||
|
|
@ -548,12 +562,10 @@ static int simple_count_noml(struct simple_util_priv *priv,
|
|||
struct device_node *codec,
|
||||
struct link_info *li, bool is_top)
|
||||
{
|
||||
if (li->link >= SNDRV_MAX_LINKS) {
|
||||
struct device *dev = simple_priv_to_dev(priv);
|
||||
int ret = -EINVAL;
|
||||
|
||||
dev_err(dev, "too many links\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (li->link >= SNDRV_MAX_LINKS)
|
||||
goto end;
|
||||
|
||||
/*
|
||||
* DON'T REMOVE platforms
|
||||
|
|
@ -575,8 +587,9 @@ static int simple_count_noml(struct simple_util_priv *priv,
|
|||
li->num[li->link].codecs = 1;
|
||||
|
||||
li->link += 1;
|
||||
|
||||
return 0;
|
||||
ret = 0;
|
||||
end:
|
||||
return simple_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int simple_count_dpcm(struct simple_util_priv *priv,
|
||||
|
|
@ -584,12 +597,10 @@ static int simple_count_dpcm(struct simple_util_priv *priv,
|
|||
struct device_node *codec,
|
||||
struct link_info *li, bool is_top)
|
||||
{
|
||||
if (li->link >= SNDRV_MAX_LINKS) {
|
||||
struct device *dev = simple_priv_to_dev(priv);
|
||||
int ret = -EINVAL;
|
||||
|
||||
dev_err(dev, "too many links\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (li->link >= SNDRV_MAX_LINKS)
|
||||
goto end;
|
||||
|
||||
if (li->cpu) {
|
||||
/*
|
||||
|
|
@ -606,8 +617,9 @@ static int simple_count_dpcm(struct simple_util_priv *priv,
|
|||
|
||||
li->link++; /* dummy-Codec */
|
||||
}
|
||||
|
||||
return 0;
|
||||
ret = 0;
|
||||
end:
|
||||
return simple_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int simple_get_dais_count(struct simple_util_priv *priv,
|
||||
|
|
@ -683,17 +695,15 @@ static int simple_soc_probe(struct snd_soc_card *card)
|
|||
|
||||
ret = simple_util_init_hp(card, &priv->hp_jack, PREFIX);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = simple_util_init_mic(card, &priv->mic_jack, PREFIX);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
goto end;
|
||||
|
||||
ret = simple_util_init_aux_jacks(priv, PREFIX);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
end:
|
||||
return simple_ret(priv, ret);
|
||||
}
|
||||
|
||||
static int simple_probe(struct platform_device *pdev)
|
||||
|
|
@ -715,20 +725,22 @@ static int simple_probe(struct platform_device *pdev)
|
|||
card->probe = simple_soc_probe;
|
||||
card->driver_name = "simple-card";
|
||||
|
||||
ret = -ENOMEM;
|
||||
struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL);
|
||||
if (!li)
|
||||
return -ENOMEM;
|
||||
goto end;
|
||||
|
||||
ret = simple_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;
|
||||
|
||||
if (np && of_device_is_available(np)) {
|
||||
|
||||
|
|
@ -795,8 +807,8 @@ static int simple_probe(struct platform_device *pdev)
|
|||
return 0;
|
||||
err:
|
||||
simple_util_clean_reference(card);
|
||||
|
||||
return ret;
|
||||
end:
|
||||
return dev_err_probe(dev, ret, "parse error\n");
|
||||
}
|
||||
|
||||
static const struct of_device_id simple_of_match[] = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue