Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add snd_soc_{of_}get_dlc()

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

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 convert to use it.

+80 -122
+7 -1
include/sound/soc.h
··· 1309 1309 snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix)) 1310 1310 1311 1311 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); 1312 1318 int snd_soc_get_dai_id(struct device_node *ep); 1313 1319 int snd_soc_get_dai_name(const struct of_phandle_args *args, 1314 1320 const char **dai_name); 1315 1321 int snd_soc_of_get_dai_name(struct device_node *of_node, 1316 - const char **dai_name); 1322 + const char **dai_name, int index); 1317 1323 int snd_soc_of_get_dai_link_codecs(struct device *dev, 1318 1324 struct device_node *of_node, 1319 1325 struct snd_soc_dai_link *dai_link);
+3 -11
sound/soc/fsl/imx-card.c
··· 551 551 goto err; 552 552 } 553 553 554 - ret = of_parse_phandle_with_args(cpu, "sound-dai", 555 - "#sound-dai-cells", 0, &args); 554 + ret = snd_soc_of_get_dlc(cpu, &args, link->cpus, 0); 556 555 if (ret) { 557 - dev_err(card->dev, "%s: error getting cpu phandle\n", link->name); 556 + dev_err_probe(card->dev, ret, 557 + "%s: error getting cpu dai info\n", link->name); 558 558 goto err; 559 559 } 560 560 ··· 582 582 } 583 583 } 584 584 585 - link->cpus->of_node = args.np; 586 585 link->platforms->of_node = link->cpus->of_node; 587 586 link->id = args.args[0]; 588 - 589 - ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name); 590 - if (ret) { 591 - dev_err_probe(card->dev, ret, 592 - "%s: error getting cpu dai name\n", link->name); 593 - goto err; 594 - } 595 587 596 588 codec = of_get_child_by_name(np, "codec"); 597 589 if (codec) {
+1 -2
sound/soc/fsl/imx-rpmsg.c
··· 96 96 } else { 97 97 struct clk *clk; 98 98 99 - data->dai.codecs->of_node = args.np; 100 - ret = snd_soc_get_dai_name(&args, &data->dai.codecs->dai_name); 99 + ret = snd_soc_get_dlc(&args, data->dai.codecs); 101 100 if (ret) { 102 101 dev_err(&pdev->dev, "Unable to get codec_dai_name\n"); 103 102 goto fail;
+1 -3
sound/soc/generic/simple-card-utils.c
··· 1103 1103 * 2) user need to rebind Sound Card everytime 1104 1104 * if he unbinded CPU or Codec. 1105 1105 */ 1106 - ret = snd_soc_get_dai_name(&args, &dlc->dai_name); 1106 + ret = snd_soc_get_dlc(&args, dlc); 1107 1107 if (ret < 0) { 1108 1108 of_node_put(node); 1109 1109 return ret; 1110 1110 } 1111 - 1112 - dlc->of_node = node; 1113 1111 1114 1112 if (is_single_link) 1115 1113 *is_single_link = of_graph_get_endpoint_count(node) == 1;
+1 -3
sound/soc/generic/simple-card.c
··· 89 89 * 2) user need to rebind Sound Card everytime 90 90 * if he unbinded CPU or Codec. 91 91 */ 92 - ret = snd_soc_of_get_dai_name(node, &dlc->dai_name); 92 + ret = snd_soc_get_dlc(&args, dlc); 93 93 if (ret < 0) 94 94 return ret; 95 - 96 - dlc->of_node = args.np; 97 95 98 96 if (is_single_link) 99 97 *is_single_link = !args.args_count;
+12 -24
sound/soc/loongson/loongson_card.c
··· 114 114 115 115 static int loongson_card_parse_of(struct loongson_card_data *data) 116 116 { 117 - const char *cpu_dai_name, *codec_dai_name; 118 117 struct device_node *cpu, *codec; 119 118 struct snd_soc_card *card = &data->snd_card; 120 119 struct device *dev = card->dev; 121 - struct of_phandle_args args; 122 120 int ret, i; 123 121 124 122 cpu = of_get_child_by_name(dev->of_node, "cpu"); ··· 131 133 goto err; 132 134 } 133 135 134 - ret = of_parse_phandle_with_args(cpu, "sound-dai", 135 - "#sound-dai-cells", 0, &args); 136 - if (ret) { 137 - dev_err(dev, "codec node missing #sound-dai-cells\n"); 138 - goto err; 139 - } 140 - for (i = 0; i < card->num_links; i++) 141 - loongson_dai_links[i].cpus->of_node = args.np; 142 - 143 - ret = of_parse_phandle_with_args(codec, "sound-dai", 144 - "#sound-dai-cells", 0, &args); 145 - if (ret) { 146 - dev_err(dev, "codec node missing #sound-dai-cells\n"); 147 - goto err; 148 - } 149 - for (i = 0; i < card->num_links; i++) 150 - loongson_dai_links[i].codecs->of_node = args.np; 151 - 152 - snd_soc_of_get_dai_name(cpu, &cpu_dai_name); 153 - snd_soc_of_get_dai_name(codec, &codec_dai_name); 154 136 for (i = 0; i < card->num_links; i++) { 155 - loongson_dai_links[i].cpus->dai_name = cpu_dai_name; 156 - loongson_dai_links[i].codecs->dai_name = codec_dai_name; 137 + ret = snd_soc_of_get_dlc(cpu, NULL, loongson_dai_links[i].cpus, 0); 138 + if (ret < 0) { 139 + dev_err(dev, "getting cpu dlc error (%d)\n", ret); 140 + goto err; 141 + } 142 + 143 + ret = snd_soc_of_get_dlc(codec, NULL, loongson_dai_links[i].codecs, 0); 144 + if (ret < 0) { 145 + dev_err(dev, "getting codec dlc error (%d)\n", ret); 146 + goto err; 147 + } 157 148 } 149 + 158 150 of_node_put(cpu); 159 151 of_node_put(codec); 160 152
+1 -1
sound/soc/mediatek/mt8173/mt8173-rt5650.c
··· 288 288 289 289 np = of_get_child_by_name(pdev->dev.of_node, "codec-capture"); 290 290 if (np) { 291 - ret = snd_soc_of_get_dai_name(np, &codec_capture_dai); 291 + ret = snd_soc_of_get_dai_name(np, &codec_capture_dai, 0); 292 292 of_node_put(np); 293 293 if (ret < 0) { 294 294 dev_err(&pdev->dev,
+1 -2
sound/soc/meson/axg-card.c
··· 319 319 dai_link->cpus = cpu; 320 320 dai_link->num_cpus = 1; 321 321 322 - ret = meson_card_parse_dai(card, np, &dai_link->cpus->of_node, 323 - &dai_link->cpus->dai_name); 322 + ret = meson_card_parse_dai(card, np, dai_link->cpus); 324 323 if (ret) 325 324 return ret; 326 325
+1 -2
sound/soc/meson/gx-card.c
··· 90 90 dai_link->cpus = cpu; 91 91 dai_link->num_cpus = 1; 92 92 93 - ret = meson_card_parse_dai(card, np, &dai_link->cpus->of_node, 94 - &dai_link->cpus->dai_name); 93 + ret = meson_card_parse_dai(card, np, dai_link->cpus); 95 94 if (ret) 96 95 return ret; 97 96
+5 -11
sound/soc/meson/meson-card-utils.c
··· 74 74 75 75 int meson_card_parse_dai(struct snd_soc_card *card, 76 76 struct device_node *node, 77 - struct device_node **dai_of_node, 78 - const char **dai_name) 77 + struct snd_soc_dai_link_component *dlc) 79 78 { 80 - struct of_phandle_args args; 81 79 int ret; 82 80 83 - if (!dai_name || !dai_of_node || !node) 81 + if (!dlc || !node) 84 82 return -EINVAL; 85 83 86 - ret = of_parse_phandle_with_args(node, "sound-dai", 87 - "#sound-dai-cells", 0, &args); 84 + ret = snd_soc_of_get_dlc(node, NULL, dlc, 0); 88 85 if (ret) 89 86 return dev_err_probe(card->dev, ret, "can't parse dai\n"); 90 87 91 - *dai_of_node = args.np; 92 - 93 - return snd_soc_get_dai_name(&args, dai_name); 88 + return ret; 94 89 } 95 90 EXPORT_SYMBOL_GPL(meson_card_parse_dai); 96 91 ··· 155 160 link->num_codecs = num_codecs; 156 161 157 162 for_each_child_of_node(node, np) { 158 - ret = meson_card_parse_dai(card, np, &codec->of_node, 159 - &codec->dai_name); 163 + ret = meson_card_parse_dai(card, np, codec); 160 164 if (ret) { 161 165 of_node_put(np); 162 166 return ret;
+1 -2
sound/soc/meson/meson-card.h
··· 39 39 unsigned int num_links); 40 40 int meson_card_parse_dai(struct snd_soc_card *card, 41 41 struct device_node *node, 42 - struct device_node **dai_of_node, 43 - const char **dai_name); 42 + struct snd_soc_dai_link_component *dlc); 44 43 int meson_card_set_be_link(struct snd_soc_card *card, 45 44 struct snd_soc_dai_link *link, 46 45 struct device_node *node);
+3 -10
sound/soc/qcom/common.c
··· 96 96 goto err; 97 97 } 98 98 99 - ret = of_parse_phandle_with_args(cpu, "sound-dai", 100 - "#sound-dai-cells", 0, &args); 101 - if (ret) { 102 - dev_err(card->dev, "%s: error getting cpu phandle\n", link->name); 103 - goto err; 104 - } 105 - link->cpus->of_node = args.np; 106 - link->id = args.args[0]; 107 - 108 - ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name); 99 + ret = snd_soc_of_get_dlc(cpu, &args, link->cpus, 0); 109 100 if (ret) { 110 101 dev_err_probe(card->dev, ret, 111 102 "%s: error getting cpu dai name\n", link->name); 112 103 goto err; 113 104 } 105 + 106 + link->id = args.args[0]; 114 107 115 108 if (platform) { 116 109 link->platforms->of_node = of_parse_phandle(platform,
+1 -15
sound/soc/samsung/odroid.c
··· 205 205 struct snd_soc_card *card; 206 206 struct snd_soc_dai_link *link, *codec_link; 207 207 int num_pcms, ret, i; 208 - struct of_phandle_args args = {}; 209 208 210 209 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 211 210 if (!priv) ··· 259 260 } 260 261 261 262 for (i = 0; i < num_pcms; i++, link += 2) { 262 - ret = of_parse_phandle_with_args(cpu, "sound-dai", 263 - "#sound-dai-cells", i, &args); 264 - if (ret < 0) 265 - break; 266 - 267 - if (!args.np) { 268 - dev_err(dev, "sound-dai property parse error: %d\n", ret); 269 - ret = -EINVAL; 270 - break; 271 - } 272 - 273 - ret = snd_soc_get_dai_name(&args, &link->cpus->dai_name); 274 - of_node_put(args.np); 275 - 263 + ret = snd_soc_of_get_dai_name(cpu, &link->cpus->dai_name, i); 276 264 if (ret < 0) 277 265 break; 278 266 }
+42 -35
sound/soc/soc-core.c
··· 3257 3257 } 3258 3258 EXPORT_SYMBOL_GPL(snd_soc_get_dai_id); 3259 3259 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) 3262 3261 { 3263 3262 struct snd_soc_component *pos; 3264 3263 int ret = -EPROBE_DEFER; ··· 3269 3270 if (component_of_node != args->np || !pos->num_dai) 3270 3271 continue; 3271 3272 3272 - ret = snd_soc_component_of_xlate_dai_name(pos, args, dai_name); 3273 + ret = snd_soc_component_of_xlate_dai_name(pos, args, &dlc->dai_name); 3273 3274 if (ret == -ENOTSUPP) { 3274 3275 struct snd_soc_dai *dai; 3275 3276 int id = -1; ··· 3300 3301 id--; 3301 3302 } 3302 3303 3303 - *dai_name = dai->driver->name; 3304 - if (!*dai_name) 3305 - *dai_name = pos->name; 3304 + dlc->of_node = args->np; 3305 + dlc->dai_name = dai->driver->name; 3306 + if (!dlc->dai_name) 3307 + dlc->dai_name = pos->name; 3306 3308 } else if (ret) { 3307 3309 /* 3308 3310 * if another error than ENOTSUPP is returned go on and ··· 3319 3319 mutex_unlock(&client_mutex); 3320 3320 return ret; 3321 3321 } 3322 - EXPORT_SYMBOL_GPL(snd_soc_get_dai_name); 3322 + EXPORT_SYMBOL_GPL(snd_soc_get_dlc); 3323 3323 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) 3326 3328 { 3327 - struct of_phandle_args args; 3329 + struct of_phandle_args __args; 3328 3330 int ret; 3329 3331 3332 + if (!args) 3333 + args = &__args; 3334 + 3330 3335 ret = of_parse_phandle_with_args(of_node, "sound-dai", 3331 - "#sound-dai-cells", 0, &args); 3336 + "#sound-dai-cells", index, args); 3332 3337 if (ret) 3333 3338 return ret; 3334 3339 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); 3336 3343 3337 - of_node_put(args.np); 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); 3349 + 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, int index) 3359 + { 3360 + struct snd_soc_dai_link_component dlc; 3361 + int ret = snd_soc_of_get_dlc(of_node, NULL, &dlc, index); 3362 + 3363 + if (ret == 0) 3364 + *dai_name = dlc.dai_name; 3338 3365 3339 3366 return ret; 3340 3367 } ··· 3399 3372 *ret_component = component; 3400 3373 *ret_num = num; 3401 3374 3402 - return 0; 3403 - } 3404 - 3405 - static int __snd_soc_of_get_dai_link_component_parse( 3406 - struct device_node *of_node, 3407 - struct snd_soc_dai_link_component *component, int index) 3408 - { 3409 - struct of_phandle_args args; 3410 - int ret; 3411 - 3412 - ret = of_parse_phandle_with_args(of_node, "sound-dai", "#sound-dai-cells", 3413 - index, &args); 3414 - if (ret) 3415 - return ret; 3416 - 3417 - ret = snd_soc_get_dai_name(&args, &component->dai_name); 3418 - if (ret < 0) 3419 - return ret; 3420 - 3421 - component->of_node = args.np; 3422 3375 return 0; 3423 3376 } 3424 3377 ··· 3446 3439 3447 3440 /* Parse the list */ 3448 3441 for_each_link_codecs(dai_link, index, component) { 3449 - ret = __snd_soc_of_get_dai_link_component_parse(of_node, component, index); 3442 + ret = snd_soc_of_get_dlc(of_node, NULL, component, index); 3450 3443 if (ret) 3451 3444 goto err; 3452 3445 } ··· 3501 3494 3502 3495 /* Parse the list */ 3503 3496 for_each_link_cpus(dai_link, index, component) { 3504 - ret = __snd_soc_of_get_dai_link_component_parse(of_node, component, index); 3497 + ret = snd_soc_of_get_dlc(of_node, NULL, component, index); 3505 3498 if (ret) 3506 3499 goto err; 3507 3500 }