Skip to content

Commit 05722a0

Browse files
morimotobroonie
authored andcommitted
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 <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87r0q6dgnm.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 0247488 commit 05722a0

2 files changed

Lines changed: 46 additions & 13 deletions

File tree

include/sound/soc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,12 @@ unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
13091309
snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix))
13101310

13111311
int snd_soc_get_stream_cpu(struct snd_soc_dai_link *dai_link, int stream);
1312+
int snd_soc_get_dlc(const struct of_phandle_args *args,
1313+
struct snd_soc_dai_link_component *dlc);
1314+
int snd_soc_of_get_dlc(struct device_node *of_node,
1315+
struct of_phandle_args *args,
1316+
struct snd_soc_dai_link_component *dlc,
1317+
int index);
13121318
int snd_soc_get_dai_id(struct device_node *ep);
13131319
int snd_soc_get_dai_name(const struct of_phandle_args *args,
13141320
const char **dai_name);

sound/soc/soc-core.c

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,8 +3257,7 @@ int snd_soc_get_dai_id(struct device_node *ep)
32573257
}
32583258
EXPORT_SYMBOL_GPL(snd_soc_get_dai_id);
32593259

3260-
int snd_soc_get_dai_name(const struct of_phandle_args *args,
3261-
const char **dai_name)
3260+
int snd_soc_get_dlc(const struct of_phandle_args *args, struct snd_soc_dai_link_component *dlc)
32623261
{
32633262
struct snd_soc_component *pos;
32643263
int ret = -EPROBE_DEFER;
@@ -3270,7 +3269,7 @@ int snd_soc_get_dai_name(const struct of_phandle_args *args,
32703269
if (component_of_node != args->np || !pos->num_dai)
32713270
continue;
32723271

3273-
ret = snd_soc_component_of_xlate_dai_name(pos, args, dai_name);
3272+
ret = snd_soc_component_of_xlate_dai_name(pos, args, &dlc->dai_name);
32743273
if (ret == -ENOTSUPP) {
32753274
struct snd_soc_dai *dai;
32763275
int id = -1;
@@ -3301,9 +3300,10 @@ int snd_soc_get_dai_name(const struct of_phandle_args *args,
33013300
id--;
33023301
}
33033302

3304-
*dai_name = dai->driver->name;
3305-
if (!*dai_name)
3306-
*dai_name = pos->name;
3303+
dlc->of_node = args->np;
3304+
dlc->dai_name = dai->driver->name;
3305+
if (!dlc->dai_name)
3306+
dlc->dai_name = pos->name;
33073307
} else if (ret) {
33083308
/*
33093309
* 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,
33193319
mutex_unlock(&client_mutex);
33203320
return ret;
33213321
}
3322-
EXPORT_SYMBOL_GPL(snd_soc_get_dai_name);
3322+
EXPORT_SYMBOL_GPL(snd_soc_get_dlc);
33233323

3324-
int snd_soc_of_get_dai_name(struct device_node *of_node,
3325-
const char **dai_name)
3324+
int snd_soc_of_get_dlc(struct device_node *of_node,
3325+
struct of_phandle_args *args,
3326+
struct snd_soc_dai_link_component *dlc,
3327+
int index)
33263328
{
3327-
struct of_phandle_args args;
3329+
struct of_phandle_args __args;
33283330
int ret;
33293331

3332+
if (!args)
3333+
args = &__args;
3334+
33303335
ret = of_parse_phandle_with_args(of_node, "sound-dai",
3331-
"#sound-dai-cells", 0, &args);
3336+
"#sound-dai-cells", index, args);
33323337
if (ret)
33333338
return ret;
33343339

3335-
ret = snd_soc_get_dai_name(&args, dai_name);
3340+
return snd_soc_get_dlc(args, dlc);
3341+
}
3342+
EXPORT_SYMBOL_GPL(snd_soc_of_get_dlc);
3343+
3344+
int snd_soc_get_dai_name(const struct of_phandle_args *args,
3345+
const char **dai_name)
3346+
{
3347+
struct snd_soc_dai_link_component dlc;
3348+
int ret = snd_soc_get_dlc(args, &dlc);
33363349

3337-
of_node_put(args.np);
3350+
if (ret == 0)
3351+
*dai_name = dlc.dai_name;
3352+
3353+
return ret;
3354+
}
3355+
EXPORT_SYMBOL_GPL(snd_soc_get_dai_name);
3356+
3357+
int snd_soc_of_get_dai_name(struct device_node *of_node,
3358+
const char **dai_name)
3359+
{
3360+
struct snd_soc_dai_link_component dlc;
3361+
int ret = snd_soc_of_get_dlc(of_node, NULL, &dlc, 0);
3362+
3363+
if (ret == 0)
3364+
*dai_name = dlc.dai_name;
33383365

33393366
return ret;
33403367
}

0 commit comments

Comments
 (0)