From: Kuninori Morimoto Date: Tue, 20 Jun 2023 02:14:06 +0000 (+0000) Subject: ASoC: soc-core.c: add snd_soc_{of_}get_dlc() X-Git-Tag: v6.6.7~1940^2~32^2~52^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=05722a0ce6fbd1c603ec0f0ecb5ed839dd561ac7;p=platform%2Fkernel%2Flinux-starfive.git ASoC: soc-core.c: add snd_soc_{of_}get_dlc() Current soc-core.c has snd_soc_{of_}get_dai_name() to get DAI name for dlc (snd_soc_dai_link_component). It gets .dai_name, but we need .of_node too. Therefor user need to arrange. It will be more useful if it gets both .dai_name and .of_node. This patch adds snd_soc_{of_}get_dlc() for it, and existing functions uses it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87r0q6dgnm.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- diff --git a/include/sound/soc.h b/include/sound/soc.h index a7ae8b2..943f0a1b 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1309,6 +1309,12 @@ unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np, snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix)) int snd_soc_get_stream_cpu(struct snd_soc_dai_link *dai_link, int stream); +int snd_soc_get_dlc(const struct of_phandle_args *args, + struct snd_soc_dai_link_component *dlc); +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); int snd_soc_get_dai_id(struct device_node *ep); int snd_soc_get_dai_name(const struct of_phandle_args *args, const char **dai_name); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index e830892..8dba5bb 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); - of_node_put(args.np); + 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) +{ + struct snd_soc_dai_link_component dlc; + int ret = snd_soc_of_get_dlc(of_node, NULL, &dlc, 0); + + if (ret == 0) + *dai_name = dlc.dai_name; return ret; }