aboutsummaryrefslogtreecommitdiff
path: root/sound/soc
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/fsl/imx-card.c14
-rw-r--r--sound/soc/fsl/imx-rpmsg.c3
-rw-r--r--sound/soc/generic/simple-card-utils.c4
-rw-r--r--sound/soc/generic/simple-card.c4
-rw-r--r--sound/soc/loongson/loongson_card.c34
-rw-r--r--sound/soc/mediatek/mt8173/mt8173-rt5650.c2
-rw-r--r--sound/soc/meson/axg-card.c3
-rw-r--r--sound/soc/meson/gx-card.c3
-rw-r--r--sound/soc/meson/meson-card-utils.c16
-rw-r--r--sound/soc/meson/meson-card.h3
-rw-r--r--sound/soc/qcom/common.c13
-rw-r--r--sound/soc/samsung/odroid.c16
-rw-r--r--sound/soc/soc-core.c77
13 files changed, 72 insertions, 120 deletions
diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c
index 78e2e3932ba5..356a0bc3b126 100644
--- a/sound/soc/fsl/imx-card.c
+++ b/sound/soc/fsl/imx-card.c
@@ -551,10 +551,10 @@ static int imx_card_parse_of(struct imx_card_data *data)
goto err;
}
- ret = of_parse_phandle_with_args(cpu, "sound-dai",
- "#sound-dai-cells", 0, &args);
+ ret = snd_soc_of_get_dlc(cpu, &args, link->cpus, 0);
if (ret) {
- dev_err(card->dev, "%s: error getting cpu phandle\n", link->name);
+ dev_err_probe(card->dev, ret,
+ "%s: error getting cpu dai info\n", link->name);
goto err;
}
@@ -582,17 +582,9 @@ static int imx_card_parse_of(struct imx_card_data *data)
}
}
- link->cpus->of_node = args.np;
link->platforms->of_node = link->cpus->of_node;
link->id = args.args[0];
- ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name);
- if (ret) {
- dev_err_probe(card->dev, ret,
- "%s: error getting cpu dai name\n", link->name);
- goto err;
- }
-
codec = of_get_child_by_name(np, "codec");
if (codec) {
ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index 93fc976e98dc..3c7b95db2eac 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -96,8 +96,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
} else {
struct clk *clk;
- data->dai.codecs->of_node = args.np;
- ret = snd_soc_get_dai_name(&args, &data->dai.codecs->dai_name);
+ ret = snd_soc_get_dlc(&args, data->dai.codecs);
if (ret) {
dev_err(&pdev->dev, "Unable to get codec_dai_name\n");
goto fail;
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 3af056026fa2..3019626b0592 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -1103,14 +1103,12 @@ int asoc_graph_parse_dai(struct device_node *ep,
* 2) user need to rebind Sound Card everytime
* if he unbinded CPU or Codec.
*/
- ret = snd_soc_get_dai_name(&args, &dlc->dai_name);
+ ret = snd_soc_get_dlc(&args, dlc);
if (ret < 0) {
of_node_put(node);
return ret;
}
- dlc->of_node = node;
-
if (is_single_link)
*is_single_link = of_graph_get_endpoint_count(node) == 1;
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 5a5e4ecd0f61..0745bf6a09aa 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -89,12 +89,10 @@ static int asoc_simple_parse_dai(struct device_node *node,
* 2) user need to rebind Sound Card everytime
* if he unbinded CPU or Codec.
*/
- ret = snd_soc_of_get_dai_name(node, &dlc->dai_name);
+ ret = snd_soc_get_dlc(&args, dlc);
if (ret < 0)
return ret;
- dlc->of_node = args.np;
-
if (is_single_link)
*is_single_link = !args.args_count;
diff --git a/sound/soc/loongson/loongson_card.c b/sound/soc/loongson/loongson_card.c
index 08df05cb4328..9ded16329747 100644
--- a/sound/soc/loongson/loongson_card.c
+++ b/sound/soc/loongson/loongson_card.c
@@ -114,11 +114,9 @@ static int loongson_card_parse_acpi(struct loongson_card_data *data)
static int loongson_card_parse_of(struct loongson_card_data *data)
{
- const char *cpu_dai_name, *codec_dai_name;
struct device_node *cpu, *codec;
struct snd_soc_card *card = &data->snd_card;
struct device *dev = card->dev;
- struct of_phandle_args args;
int ret, i;
cpu = of_get_child_by_name(dev->of_node, "cpu");
@@ -133,30 +131,20 @@ static int loongson_card_parse_of(struct loongson_card_data *data)
goto err;
}
- ret = of_parse_phandle_with_args(cpu, "sound-dai",
- "#sound-dai-cells", 0, &args);
- if (ret) {
- dev_err(dev, "codec node missing #sound-dai-cells\n");
- goto err;
- }
- for (i = 0; i < card->num_links; i++)
- loongson_dai_links[i].cpus->of_node = args.np;
+ for (i = 0; i < card->num_links; i++) {
+ ret = snd_soc_of_get_dlc(cpu, NULL, loongson_dai_links[i].cpus, 0);
+ if (ret < 0) {
+ dev_err(dev, "getting cpu dlc error (%d)\n", ret);
+ goto err;
+ }
- ret = of_parse_phandle_with_args(codec, "sound-dai",
- "#sound-dai-cells", 0, &args);
- if (ret) {
- dev_err(dev, "codec node missing #sound-dai-cells\n");
- goto err;
+ ret = snd_soc_of_get_dlc(codec, NULL, loongson_dai_links[i].codecs, 0);
+ if (ret < 0) {
+ dev_err(dev, "getting codec dlc error (%d)\n", ret);
+ goto err;
+ }
}
- for (i = 0; i < card->num_links; i++)
- loongson_dai_links[i].codecs->of_node = args.np;
- snd_soc_of_get_dai_name(cpu, &cpu_dai_name);
- snd_soc_of_get_dai_name(codec, &codec_dai_name);
- for (i = 0; i < card->num_links; i++) {
- loongson_dai_links[i].cpus->dai_name = cpu_dai_name;
- loongson_dai_links[i].codecs->dai_name = codec_dai_name;
- }
of_node_put(cpu);
of_node_put(codec);
diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650.c b/sound/soc/mediatek/mt8173/mt8173-rt5650.c
index e05f2b0231fe..3ece4b5eaca2 100644
--- a/sound/soc/mediatek/mt8173/mt8173-rt5650.c
+++ b/sound/soc/mediatek/mt8173/mt8173-rt5650.c
@@ -288,7 +288,7 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
np = of_get_child_by_name(pdev->dev.of_node, "codec-capture");
if (np) {
- ret = snd_soc_of_get_dai_name(np, &codec_capture_dai);
+ ret = snd_soc_of_get_dai_name(np, &codec_capture_dai, 0);
of_node_put(np);
if (ret < 0) {
dev_err(&pdev->dev,
diff --git a/sound/soc/meson/axg-card.c b/sound/soc/meson/axg-card.c
index 74e7cf0ef8d5..f10c0c17863e 100644
--- a/sound/soc/meson/axg-card.c
+++ b/sound/soc/meson/axg-card.c
@@ -319,8 +319,7 @@ static int axg_card_add_link(struct snd_soc_card *card, struct device_node *np,
dai_link->cpus = cpu;
dai_link->num_cpus = 1;
- ret = meson_card_parse_dai(card, np, &dai_link->cpus->of_node,
- &dai_link->cpus->dai_name);
+ ret = meson_card_parse_dai(card, np, dai_link->cpus);
if (ret)
return ret;
diff --git a/sound/soc/meson/gx-card.c b/sound/soc/meson/gx-card.c
index 58c411d3c489..a26b620fc177 100644
--- a/sound/soc/meson/gx-card.c
+++ b/sound/soc/meson/gx-card.c
@@ -90,8 +90,7 @@ static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,
dai_link->cpus = cpu;
dai_link->num_cpus = 1;
- ret = meson_card_parse_dai(card, np, &dai_link->cpus->of_node,
- &dai_link->cpus->dai_name);
+ ret = meson_card_parse_dai(card, np, dai_link->cpus);
if (ret)
return ret;
diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c
index ffc5111f9e3c..f7fd9c013e19 100644
--- a/sound/soc/meson/meson-card-utils.c
+++ b/sound/soc/meson/meson-card-utils.c
@@ -74,23 +74,18 @@ EXPORT_SYMBOL_GPL(meson_card_reallocate_links);
int meson_card_parse_dai(struct snd_soc_card *card,
struct device_node *node,
- struct device_node **dai_of_node,
- const char **dai_name)
+ struct snd_soc_dai_link_component *dlc)
{
- struct of_phandle_args args;
int ret;
- if (!dai_name || !dai_of_node || !node)
+ if (!dlc || !node)
return -EINVAL;
- ret = of_parse_phandle_with_args(node, "sound-dai",
- "#sound-dai-cells", 0, &args);
+ ret = snd_soc_of_get_dlc(node, NULL, dlc, 0);
if (ret)
return dev_err_probe(card->dev, ret, "can't parse dai\n");
- *dai_of_node = args.np;
-
- return snd_soc_get_dai_name(&args, dai_name);
+ return ret;
}
EXPORT_SYMBOL_GPL(meson_card_parse_dai);
@@ -160,8 +155,7 @@ int meson_card_set_be_link(struct snd_soc_card *card,
link->num_codecs = num_codecs;
for_each_child_of_node(node, np) {
- ret = meson_card_parse_dai(card, np, &codec->of_node,
- &codec->dai_name);
+ ret = meson_card_parse_dai(card, np, codec);
if (ret) {
of_node_put(np);
return ret;
diff --git a/sound/soc/meson/meson-card.h b/sound/soc/meson/meson-card.h
index 74314071c80d..a5374324a189 100644
--- a/sound/soc/meson/meson-card.h
+++ b/sound/soc/meson/meson-card.h
@@ -39,8 +39,7 @@ int meson_card_reallocate_links(struct snd_soc_card *card,
unsigned int num_links);
int meson_card_parse_dai(struct snd_soc_card *card,
struct device_node *node,
- struct device_node **dai_of_node,
- const char **dai_name);
+ struct snd_soc_dai_link_component *dlc);
int meson_card_set_be_link(struct snd_soc_card *card,
struct snd_soc_dai_link *link,
struct device_node *node);
diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index cab5a7937a57..43b0a888f1e8 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -96,22 +96,15 @@ int qcom_snd_parse_of(struct snd_soc_card *card)
goto err;
}
- ret = of_parse_phandle_with_args(cpu, "sound-dai",
- "#sound-dai-cells", 0, &args);
- if (ret) {
- dev_err(card->dev, "%s: error getting cpu phandle\n", link->name);
- goto err;
- }
- link->cpus->of_node = args.np;
- link->id = args.args[0];
-
- ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name);
+ ret = snd_soc_of_get_dlc(cpu, &args, link->cpus, 0);
if (ret) {
dev_err_probe(card->dev, ret,
"%s: error getting cpu dai name\n", link->name);
goto err;
}
+ link->id = args.args[0];
+
if (platform) {
link->platforms->of_node = of_parse_phandle(platform,
"sound-dai",
diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c
index fd95a79cc9fa..a5442592bde4 100644
--- a/sound/soc/samsung/odroid.c
+++ b/sound/soc/samsung/odroid.c
@@ -205,7 +205,6 @@ static int odroid_audio_probe(struct platform_device *pdev)
struct snd_soc_card *card;
struct snd_soc_dai_link *link, *codec_link;
int num_pcms, ret, i;
- struct of_phandle_args args = {};
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -260,20 +259,7 @@ static int odroid_audio_probe(struct platform_device *pdev)
}
for (i = 0; i < num_pcms; i++, link += 2) {
- ret = of_parse_phandle_with_args(cpu, "sound-dai",
- "#sound-dai-cells", i, &args);
- if (ret < 0)
- break;
-
- if (!args.np) {
- dev_err(dev, "sound-dai property parse error: %d\n", ret);
- ret = -EINVAL;
- break;
- }
-
- ret = snd_soc_get_dai_name(&args, &link->cpus->dai_name);
- of_node_put(args.np);
-
+ ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name, i);
if (ret < 0)
break;
}
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index e8308926bd98..f06a20773a34 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3257,8 +3257,7 @@ int snd_soc_get_dai_id(struct device_node *ep)
}
EXPORT_SYMBOL_GPL(snd_soc_get_dai_id);
-int snd_soc_get_dai_name(const struct of_phandle_args *args,
- const char **dai_name)
+int snd_soc_get_dlc(const struct of_phandle_args *args, struct snd_soc_dai_link_component *dlc)
{
struct snd_soc_component *pos;
int ret = -EPROBE_DEFER;
@@ -3270,7 +3269,7 @@ int snd_soc_get_dai_name(const struct of_phandle_args *args,
if (component_of_node != args->np || !pos->num_dai)
continue;
- ret = snd_soc_component_of_xlate_dai_name(pos, args, dai_name);
+ ret = snd_soc_component_of_xlate_dai_name(pos, args, &dlc->dai_name);
if (ret == -ENOTSUPP) {
struct snd_soc_dai *dai;
int id = -1;
@@ -3301,9 +3300,10 @@ int snd_soc_get_dai_name(const struct of_phandle_args *args,
id--;
}
- *dai_name = dai->driver->name;
- if (!*dai_name)
- *dai_name = pos->name;
+ dlc->of_node = args->np;
+ dlc->dai_name = dai->driver->name;
+ if (!dlc->dai_name)
+ dlc->dai_name = pos->name;
} else if (ret) {
/*
* if another error than ENOTSUPP is returned go on and
@@ -3319,22 +3319,49 @@ int snd_soc_get_dai_name(const struct of_phandle_args *args,
mutex_unlock(&client_mutex);
return ret;
}
-EXPORT_SYMBOL_GPL(snd_soc_get_dai_name);
+EXPORT_SYMBOL_GPL(snd_soc_get_dlc);
-int snd_soc_of_get_dai_name(struct device_node *of_node,
- const char **dai_name)
+int snd_soc_of_get_dlc(struct device_node *of_node,
+ struct of_phandle_args *args,
+ struct snd_soc_dai_link_component *dlc,
+ int index)
{
- struct of_phandle_args args;
+ struct of_phandle_args __args;
int ret;
+ if (!args)
+ args = &__args;
+
ret = of_parse_phandle_with_args(of_node, "sound-dai",
- "#sound-dai-cells", 0, &args);
+ "#sound-dai-cells", index, args);
if (ret)
return ret;
- ret = snd_soc_get_dai_name(&args, dai_name);
+ return snd_soc_get_dlc(args, dlc);
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_get_dlc);
+
+int snd_soc_get_dai_name(const struct of_phandle_args *args,
+ const char **dai_name)
+{
+ struct snd_soc_dai_link_component dlc;
+ int ret = snd_soc_get_dlc(args, &dlc);
+
+ if (ret == 0)
+ *dai_name = dlc.dai_name;
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_get_dai_name);
+
+int snd_soc_of_get_dai_name(struct device_node *of_node,
+ const char **dai_name, int index)
+{
+ struct snd_soc_dai_link_component dlc;
+ int ret = snd_soc_of_get_dlc(of_node, NULL, &dlc, index);
- of_node_put(args.np);
+ if (ret == 0)
+ *dai_name = dlc.dai_name;
return ret;
}
@@ -3375,26 +3402,6 @@ static int __snd_soc_of_get_dai_link_component_alloc(
return 0;
}
-static int __snd_soc_of_get_dai_link_component_parse(
- struct device_node *of_node,
- struct snd_soc_dai_link_component *component, int index)
-{
- struct of_phandle_args args;
- int ret;
-
- ret = of_parse_phandle_with_args(of_node, "sound-dai", "#sound-dai-cells",
- index, &args);
- if (ret)
- return ret;
-
- ret = snd_soc_get_dai_name(&args, &component->dai_name);
- if (ret < 0)
- return ret;
-
- component->of_node = args.np;
- return 0;
-}
-
/*
* snd_soc_of_put_dai_link_codecs - Dereference device nodes in the codecs array
* @dai_link: DAI link
@@ -3439,7 +3446,7 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev,
/* Parse the list */
for_each_link_codecs(dai_link, index, component) {
- ret = __snd_soc_of_get_dai_link_component_parse(of_node, component, index);
+ ret = snd_soc_of_get_dlc(of_node, NULL, component, index);
if (ret)
goto err;
}
@@ -3494,7 +3501,7 @@ int snd_soc_of_get_dai_link_cpus(struct device *dev,
/* Parse the list */
for_each_link_cpus(dai_link, index, component) {
- ret = __snd_soc_of_get_dai_link_component_parse(of_node, component, index);
+ ret = snd_soc_of_get_dlc(of_node, NULL, component, index);
if (ret)
goto err;
}