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

ASoC: and adn use snd_soc_ret()

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

Each ASoC framwark is using own snd_xxx_ret() function, but we can share
these. This patch-set adds new snd_soc_ret() and use it.

checkpatch indicates that ENOTSUPP is not a SUSV4 error code, prefer to
use EOPNOTSUPP. So this patch-set adds it, but not remove existing ENOTSUPP.

Link: https://lore.kernel.org/r/8734gvsg5i.wl-kuninori.morimoto.gx@renesas.com

+384 -371
+4 -4
include/sound/simple_card_utils.h
··· 142 142 struct device_node *codec, 143 143 char *prefix, 144 144 unsigned int *retfmt); 145 - int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np, 145 + int simple_util_parse_tdm_width_map(struct simple_util_priv *priv, struct device_node *np, 146 146 struct simple_util_dai *dai); 147 147 148 148 __printf(3, 4) 149 - int simple_util_set_dailink_name(struct device *dev, 149 + int simple_util_set_dailink_name(struct simple_util_priv *priv, 150 150 struct snd_soc_dai_link *dai_link, 151 151 const char *fmt, ...); 152 - int simple_util_parse_card_name(struct snd_soc_card *card, 152 + int simple_util_parse_card_name(struct simple_util_priv *priv, 153 153 char *prefix); 154 154 155 155 int simple_util_parse_clk(struct device *dev, ··· 201 201 202 202 int graph_util_card_probe(struct snd_soc_card *card); 203 203 int graph_util_is_ports0(struct device_node *port); 204 - int graph_util_parse_dai(struct device *dev, struct device_node *ep, 204 + int graph_util_parse_dai(struct simple_util_priv *priv, struct device_node *ep, 205 205 struct snd_soc_dai_link_component *dlc, int *is_single_link); 206 206 207 207 void graph_util_parse_link_direction(struct device_node *np,
+1
include/sound/soc.h
··· 539 539 int snd_soc_params_to_bclk(const struct snd_pcm_hw_params *parms); 540 540 int snd_soc_tdm_params_to_bclk(const struct snd_pcm_hw_params *params, 541 541 int tdm_width, int tdm_slots, int slot_multiple); 542 + int snd_soc_ret(const struct device *dev, int ret, const char *fmt, ...); 542 543 543 544 /* set runtime hw params */ 544 545 static inline int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
+2
sound/soc/fsl/fsl_micfil.c
··· 183 183 case QUALITY_VLOW2: 184 184 qsel = MICFIL_QSEL_VLOW2_QUALITY; 185 185 break; 186 + default: 187 + return -EINVAL; 186 188 } 187 189 188 190 return regmap_update_bits(micfil->regmap, REG_MICFIL_CTRL2,
+52 -45
sound/soc/generic/audio-graph-card.c
··· 20 20 21 21 #define DPCM_SELECTABLE 1 22 22 23 + #define graph_ret(priv, ret) _graph_ret(priv, __func__, ret) 24 + static inline int _graph_ret(struct simple_util_priv *priv, 25 + const char *func, int ret) 26 + { 27 + return snd_soc_ret(simple_priv_to_dev(priv), ret, "at %s()\n", func); 28 + } 29 + 23 30 #define ep_to_port(ep) of_get_parent(ep) 24 31 static struct device_node *port_to_ports(struct device_node *port) 25 32 { ··· 118 111 dai = simple_props_to_dai_codec(dai_props, 0); 119 112 } 120 113 121 - ret = graph_util_parse_dai(dev, ep, dlc, cpu); 114 + ret = graph_util_parse_dai(priv, ep, dlc, cpu); 122 115 if (ret < 0) 123 - return ret; 116 + goto end; 124 117 125 118 ret = simple_util_parse_tdm(ep, dai); 126 119 if (ret < 0) 127 - return ret; 120 + goto end; 128 121 129 122 ret = simple_util_parse_clk(dev, ep, dai, dlc); 130 - if (ret < 0) 131 - return ret; 132 - 133 - return 0; 123 + end: 124 + return graph_ret(priv, ret); 134 125 } 135 126 136 127 static int graph_link_init(struct simple_util_priv *priv, ··· 153 148 ret = simple_util_parse_daifmt(dev, ep_cpu, ep_codec, 154 149 NULL, &dai_link->dai_fmt); 155 150 if (ret < 0) 156 - return ret; 151 + goto end; 157 152 158 153 graph_util_parse_link_direction(top, &playback_only, &capture_only); 159 154 graph_util_parse_link_direction(port_cpu, &playback_only, &capture_only); ··· 188 183 if (priv->ops) 189 184 dai_link->ops = priv->ops; 190 185 191 - return simple_util_set_dailink_name(dev, dai_link, name); 186 + ret = simple_util_set_dailink_name(priv, dai_link, name); 187 + end: 188 + return graph_ret(priv, ret); 192 189 } 193 190 194 191 static int graph_dai_link_of_dpcm(struct simple_util_priv *priv, ··· 222 215 223 216 ret = graph_parse_node(priv, cpu_ep, li, &is_single_links); 224 217 if (ret) 225 - return ret; 218 + goto end; 226 219 227 220 snprintf(dai_name, sizeof(dai_name), 228 221 "fe.%pOFP.%s", cpus->of_node, cpus->dai_name); ··· 255 248 256 249 ret = graph_parse_node(priv, codec_ep, li, NULL); 257 250 if (ret < 0) 258 - return ret; 251 + goto end; 259 252 260 253 snprintf(dai_name, sizeof(dai_name), 261 254 "be.%pOFP.%s", codecs->of_node, codecs->dai_name); ··· 274 267 ret = graph_link_init(priv, cpu_ep, codec_ep, li, dai_name); 275 268 276 269 li->link++; 277 - 278 - return ret; 270 + end: 271 + return graph_ret(priv, ret); 279 272 } 280 273 281 274 static int graph_dai_link_of(struct simple_util_priv *priv, ··· 295 288 296 289 ret = graph_parse_node(priv, cpu_ep, li, &is_single_links); 297 290 if (ret < 0) 298 - return ret; 291 + goto end; 299 292 300 293 ret = graph_parse_node(priv, codec_ep, li, NULL); 301 294 if (ret < 0) 302 - return ret; 295 + goto end; 303 296 304 297 snprintf(dai_name, sizeof(dai_name), 305 298 "%s-%s", cpus->dai_name, codecs->dai_name); ··· 309 302 310 303 ret = graph_link_init(priv, cpu_ep, codec_ep, li, dai_name); 311 304 if (ret < 0) 312 - return ret; 305 + goto end; 313 306 314 307 li->link++; 315 - 316 - return 0; 308 + end: 309 + return graph_ret(priv, ret); 317 310 } 318 311 319 312 static inline bool parse_as_dpcm_link(struct simple_util_priv *priv, ··· 390 383 } 391 384 392 385 if (ret < 0) 393 - return ret; 386 + goto end; 394 387 395 388 codec_port_old = codec_port; 396 389 } 397 390 } 398 - 399 - return 0; 391 + end: 392 + return graph_ret(priv, ret); 400 393 } 401 394 402 395 static int graph_for_each_link(struct simple_util_priv *priv, ··· 429 422 break; 430 423 } 431 424 432 - return ret; 425 + return graph_ret(priv, ret); 433 426 } 434 427 435 428 static int graph_count_noml(struct simple_util_priv *priv, ··· 438 431 struct link_info *li) 439 432 { 440 433 struct device *dev = simple_priv_to_dev(priv); 434 + int ret = -EINVAL; 441 435 442 - if (li->link >= SNDRV_MAX_LINKS) { 443 - dev_err(dev, "too many links\n"); 444 - return -EINVAL; 445 - } 436 + if (li->link >= SNDRV_MAX_LINKS) 437 + goto end; 446 438 447 439 /* 448 440 * DON'T REMOVE platforms ··· 456 450 li->link += 1; /* 1xCPU-Codec */ 457 451 458 452 dev_dbg(dev, "Count As Normal\n"); 459 - 460 - return 0; 453 + ret = 0; 454 + end: 455 + return graph_ret(priv, ret); 461 456 } 462 457 463 458 static int graph_count_dpcm(struct simple_util_priv *priv, ··· 467 460 struct link_info *li) 468 461 { 469 462 struct device *dev = simple_priv_to_dev(priv); 463 + int ret = -EINVAL; 470 464 471 - if (li->link >= SNDRV_MAX_LINKS) { 472 - dev_err(dev, "too many links\n"); 473 - return -EINVAL; 474 - } 465 + if (li->link >= SNDRV_MAX_LINKS) 466 + goto end; 475 467 476 468 if (li->cpu) { 477 469 /* ··· 489 483 } 490 484 491 485 dev_dbg(dev, "Count As DPCM\n"); 492 - 493 - return 0; 486 + ret = 0; 487 + end: 488 + return graph_ret(priv, ret); 494 489 } 495 490 496 491 static int graph_get_dais_count(struct simple_util_priv *priv, ··· 551 544 int audio_graph_parse_of(struct simple_util_priv *priv, struct device *dev) 552 545 { 553 546 struct snd_soc_card *card = simple_priv_to_card(priv); 554 - int ret; 547 + int ret = -ENOMEM; 555 548 556 549 struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL); 557 550 if (!li) 558 - return -ENOMEM; 551 + goto end; 559 552 560 553 card->owner = THIS_MODULE; 561 554 card->dev = dev; 562 555 563 556 ret = graph_get_dais_count(priv, li); 564 557 if (ret < 0) 565 - return ret; 558 + goto end; 566 559 560 + ret = -EINVAL; 567 561 if (!li->link) 568 - return -EINVAL; 562 + goto end; 569 563 570 564 ret = simple_util_init_priv(priv, li); 571 565 if (ret < 0) 572 - return ret; 566 + goto end; 573 567 574 568 priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW); 575 569 if (IS_ERR(priv->pa_gpio)) { 576 570 ret = PTR_ERR(priv->pa_gpio); 577 571 dev_err(dev, "failed to get amplifier gpio: %d\n", ret); 578 - return ret; 572 + goto end; 579 573 } 580 574 581 575 ret = simple_util_parse_widgets(card, NULL); 582 576 if (ret < 0) 583 - return ret; 577 + goto end; 584 578 585 579 ret = simple_util_parse_routing(card, NULL); 586 580 if (ret < 0) 587 - return ret; 581 + goto end; 588 582 589 583 memset(li, 0, sizeof(*li)); 590 584 ret = graph_for_each_link(priv, li, ··· 594 586 if (ret < 0) 595 587 goto err; 596 588 597 - ret = simple_util_parse_card_name(card, NULL); 589 + ret = simple_util_parse_card_name(priv, NULL); 598 590 if (ret < 0) 599 591 goto err; 600 592 ··· 607 599 goto err; 608 600 609 601 return 0; 610 - 611 602 err: 612 603 simple_util_clean_reference(card); 613 - 604 + end: 614 605 return dev_err_probe(dev, ret, "parse error\n"); 615 606 } 616 607 EXPORT_SYMBOL_GPL(audio_graph_parse_of);
+56 -39
sound/soc/generic/audio-graph-card2.c
··· 234 234 #define GRAPH_NODENAME_DPCM "dpcm" 235 235 #define GRAPH_NODENAME_C2C "codec2codec" 236 236 237 + #define graph_ret(priv, ret) _graph_ret(priv, __func__, ret) 238 + static inline int _graph_ret(struct simple_util_priv *priv, 239 + const char *func, int ret) 240 + { 241 + return snd_soc_ret(simple_priv_to_dev(priv), ret, "at %s()\n", func); 242 + } 243 + 237 244 #define ep_to_port(ep) of_get_parent(ep) 238 245 static struct device_node *port_to_ports(struct device_node *port) 239 246 { ··· 416 409 dai = simple_props_to_dai_codec(dai_props, idx); 417 410 } 418 411 419 - ret = graph_util_parse_dai(dev, ep, dlc, &is_single_links); 412 + ret = graph_util_parse_dai(priv, ep, dlc, &is_single_links); 420 413 if (ret < 0) 421 - return ret; 414 + goto end; 422 415 423 416 ret = simple_util_parse_tdm(ep, dai); 424 417 if (ret < 0) 425 - return ret; 418 + goto end; 426 419 427 - ret = simple_util_parse_tdm_width_map(dev, ep, dai); 420 + ret = simple_util_parse_tdm_width_map(priv, ep, dai); 428 421 if (ret < 0) 429 - return ret; 422 + goto end; 430 423 431 424 ret = simple_util_parse_clk(dev, ep, dai, dlc); 432 425 if (ret < 0) 433 - return ret; 426 + goto end; 434 427 435 428 /* 436 429 * set DAI Name ··· 450 443 case GRAPH_NORMAL: 451 444 /* run is_cpu only. see audio_graph2_link_normal() */ 452 445 if (is_cpu) 453 - simple_util_set_dailink_name(dev, dai_link, "%s%s-%s%s", 446 + simple_util_set_dailink_name(priv, dai_link, "%s%s-%s%s", 454 447 cpus->dai_name, cpu_multi, 455 448 codecs->dai_name, codec_multi); 456 449 break; 457 450 case GRAPH_DPCM: 458 451 if (is_cpu) 459 - simple_util_set_dailink_name(dev, dai_link, "fe.%pOFP.%s%s", 452 + simple_util_set_dailink_name(priv, dai_link, "fe.%pOFP.%s%s", 460 453 cpus->of_node, cpus->dai_name, cpu_multi); 461 454 else 462 - simple_util_set_dailink_name(dev, dai_link, "be.%pOFP.%s%s", 455 + simple_util_set_dailink_name(priv, dai_link, "be.%pOFP.%s%s", 463 456 codecs->of_node, codecs->dai_name, codec_multi); 464 457 break; 465 458 case GRAPH_C2C: 466 459 /* run is_cpu only. see audio_graph2_link_c2c() */ 467 460 if (is_cpu) 468 - simple_util_set_dailink_name(dev, dai_link, "c2c.%s%s-%s%s", 461 + simple_util_set_dailink_name(priv, dai_link, "c2c.%s%s-%s%s", 469 462 cpus->dai_name, cpu_multi, 470 463 codecs->dai_name, codec_multi); 471 464 break; ··· 495 488 simple_util_canonicalize_cpu(cpus, is_single_links); 496 489 simple_util_canonicalize_platform(platforms, cpus); 497 490 } 498 - 499 - return 0; 491 + end: 492 + return graph_ret(priv, ret); 500 493 } 501 494 502 - static int graph_parse_node_multi_nm(struct snd_soc_dai_link *dai_link, 495 + static int graph_parse_node_multi_nm(struct simple_util_priv *priv, 496 + struct snd_soc_dai_link *dai_link, 503 497 int *nm_idx, int cpu_idx, 504 498 struct device_node *mcpu_port) 505 499 { ··· 542 534 struct device_node *mcodec_port_top __free(device_node) = ep_to_port(mcodec_ep_top); 543 535 struct device_node *mcodec_ports __free(device_node) = port_to_ports(mcodec_port_top); 544 536 int nm_max = max(dai_link->num_cpus, dai_link->num_codecs); 545 - int ret = 0; 537 + int ret = -EINVAL; 546 538 547 539 if (cpu_idx > dai_link->num_cpus) 548 - return -EINVAL; 540 + goto end; 549 541 550 542 for_each_of_graph_port_endpoint(mcpu_port, mcpu_ep_n) { 551 543 int codec_idx = 0; ··· 586 578 if (ret < 0) 587 579 break; 588 580 } 589 - 590 - return ret; 581 + end: 582 + return graph_ret(priv, ret); 591 583 } 592 584 593 585 static int graph_parse_node_multi(struct simple_util_priv *priv, ··· 641 633 642 634 /* CPU:Codec = N:M */ 643 635 if (is_cpu && dai_link->ch_maps) { 644 - ret = graph_parse_node_multi_nm(dai_link, &nm_idx, idx, port); 636 + ret = graph_parse_node_multi_nm(priv, dai_link, &nm_idx, idx, port); 645 637 if (ret < 0) 646 638 goto multi_err; 647 639 } ··· 651 643 ret = -EINVAL; 652 644 653 645 multi_err: 654 - return ret; 646 + return graph_ret(priv, ret); 655 647 } 656 648 657 649 static int graph_parse_node_single(struct simple_util_priv *priv, ··· 659 651 struct device_node *ep, 660 652 struct link_info *li, int is_cpu) 661 653 { 662 - return __graph_parse_node(priv, gtype, ep, li, is_cpu, 0); 654 + return graph_ret(priv, __graph_parse_node(priv, gtype, ep, li, is_cpu, 0)); 663 655 } 664 656 665 657 static int graph_parse_node(struct simple_util_priv *priv, ··· 668 660 struct link_info *li, int is_cpu) 669 661 { 670 662 struct device_node *port __free(device_node) = ep_to_port(ep); 663 + int ret; 671 664 672 665 if (graph_lnk_is_multi(port)) 673 - return graph_parse_node_multi(priv, gtype, port, li, is_cpu); 666 + ret = graph_parse_node_multi(priv, gtype, port, li, is_cpu); 674 667 else 675 - return graph_parse_node_single(priv, gtype, ep, li, is_cpu); 668 + ret = graph_parse_node_single(priv, gtype, ep, li, is_cpu); 669 + 670 + return graph_ret(priv, ret); 676 671 } 677 672 678 673 static void graph_parse_daifmt(struct device_node *node, unsigned int *daifmt) ··· 853 842 */ 854 843 ret = graph_parse_node(priv, GRAPH_NORMAL, codec_ep, li, 0); 855 844 if (ret < 0) 856 - return ret; 845 + goto end; 857 846 858 847 /* 859 848 * call CPU, and set DAI Name 860 849 */ 861 850 ret = graph_parse_node(priv, GRAPH_NORMAL, cpu_ep, li, 1); 862 851 if (ret < 0) 863 - return ret; 852 + goto end; 864 853 865 854 graph_link_init(priv, lnk, cpu_ep, codec_ep, li, 1); 866 855 867 - return ret; 856 + end: 857 + return graph_ret(priv, ret); 868 858 } 869 859 EXPORT_SYMBOL_GPL(audio_graph2_link_normal); 870 860 ··· 958 946 959 947 graph_link_init(priv, lnk, cpu_ep, codec_ep, li, is_cpu); 960 948 961 - return ret; 949 + return graph_ret(priv, ret); 962 950 } 963 951 EXPORT_SYMBOL_GPL(audio_graph2_link_dpcm); 964 952 ··· 1004 992 struct snd_soc_pcm_stream *c2c_conf; 1005 993 1006 994 c2c_conf = devm_kzalloc(dev, sizeof(*c2c_conf), GFP_KERNEL); 1007 - if (!c2c_conf) 1008 - return ret; 995 + if (!c2c_conf) { 996 + /* 997 + * Clang doesn't allow to use "goto end" before calling __free(), 998 + * because it bypasses the initialization. Use graph_ret() directly. 999 + */ 1000 + return graph_ret(priv, -ENOMEM); 1001 + } 1009 1002 1010 1003 c2c_conf->formats = SNDRV_PCM_FMTBIT_S32_LE; /* update ME */ 1011 1004 c2c_conf->rates = SNDRV_PCM_RATE_8000_384000; ··· 1036 1019 */ 1037 1020 ret = graph_parse_node(priv, GRAPH_C2C, codec1_ep, li, 0); 1038 1021 if (ret < 0) 1039 - return ret; 1022 + goto end; 1040 1023 1041 1024 /* 1042 1025 * call CPU, and set DAI Name 1043 1026 */ 1044 1027 ret = graph_parse_node(priv, GRAPH_C2C, codec0_ep, li, 1); 1045 1028 if (ret < 0) 1046 - return ret; 1029 + goto end; 1047 1030 1048 1031 graph_link_init(priv, lnk, codec0_ep, codec1_ep, li, 1); 1049 - 1050 - return ret; 1032 + end: 1033 + return graph_ret(priv, ret); 1051 1034 } 1052 1035 EXPORT_SYMBOL_GPL(audio_graph2_link_c2c); 1053 1036 ··· 1095 1078 1096 1079 li->link++; 1097 1080 err: 1098 - return ret; 1081 + return graph_ret(priv, ret); 1099 1082 } 1100 1083 1101 1084 static int graph_counter(struct device_node *lnk) ··· 1266 1249 1267 1250 li->link++; 1268 1251 err: 1269 - return ret; 1252 + return graph_ret(priv, ret); 1270 1253 } 1271 1254 1272 1255 static int graph_for_each_link(struct simple_util_priv *priv, ··· 1283 1266 struct device_node *node = dev->of_node; 1284 1267 struct device_node *lnk; 1285 1268 enum graph_type gtype; 1286 - int rc, ret; 1269 + int rc, ret = 0; 1287 1270 1288 1271 /* loop for all listed CPU port */ 1289 1272 of_for_each_phandle(&it, rc, node, "links", NULL, 0) { ··· 1293 1276 1294 1277 ret = func(priv, hooks, gtype, lnk, li); 1295 1278 if (ret < 0) 1296 - return ret; 1279 + break; 1297 1280 } 1298 1281 1299 - return 0; 1282 + return graph_ret(priv, ret); 1300 1283 } 1301 1284 1302 1285 int audio_graph2_parse_of(struct simple_util_priv *priv, struct device *dev, ··· 1349 1332 if (ret < 0) 1350 1333 goto err; 1351 1334 1352 - ret = simple_util_parse_card_name(card, NULL); 1335 + ret = simple_util_parse_card_name(priv, NULL); 1353 1336 if (ret < 0) 1354 1337 goto err; 1355 1338 ··· 1372 1355 if (ret < 0) 1373 1356 dev_err_probe(dev, ret, "parse error\n"); 1374 1357 1375 - return ret; 1358 + return graph_ret(priv, ret); 1376 1359 } 1377 1360 EXPORT_SYMBOL_GPL(audio_graph2_parse_of); 1378 1361
+100 -71
sound/soc/generic/simple-card-utils.c
··· 15 15 #include <sound/pcm_params.h> 16 16 #include <sound/simple_card_utils.h> 17 17 18 + #define simple_ret(priv, ret) _simple_ret(priv, __func__, ret) 19 + static inline int _simple_ret(struct simple_util_priv *priv, 20 + const char *func, int ret) 21 + { 22 + return snd_soc_ret(simple_priv_to_dev(priv), ret, "at %s()\n", func); 23 + } 24 + 18 25 int simple_util_get_sample_fmt(struct simple_util_data *data) 19 26 { 20 27 int i; ··· 140 133 } 141 134 EXPORT_SYMBOL_GPL(simple_util_parse_daifmt); 142 135 143 - int simple_util_parse_tdm_width_map(struct device *dev, struct device_node *np, 136 + int simple_util_parse_tdm_width_map(struct simple_util_priv *priv, struct device_node *np, 144 137 struct simple_util_dai *dai) 145 138 { 139 + struct device *dev = simple_priv_to_dev(priv); 146 140 int n, i, ret; 147 141 u32 *p; 142 + 143 + /* 144 + * NOTE 145 + * 146 + * Clang doesn't allow to use "goto end" before calling __free(), 147 + * because it bypasses the initialization. Use simple_ret() directly. 148 + */ 148 149 149 150 n = of_property_count_elems_of_size(np, "dai-tdm-slot-width-map", sizeof(u32)); 150 151 if (n <= 0) 151 152 return 0; 153 + 152 154 if (n % 3) { 153 155 dev_err(dev, "Invalid number of cells for dai-tdm-slot-width-map\n"); 154 - return -EINVAL; 156 + return simple_ret(priv, -EINVAL); /* see NOTE */ 155 157 } 156 158 159 + ret = -ENOMEM; 157 160 dai->tdm_width_map = devm_kcalloc(dev, n, sizeof(*dai->tdm_width_map), GFP_KERNEL); 158 161 if (!dai->tdm_width_map) 159 - return -ENOMEM; 162 + return simple_ret(priv, ret); /* see NOTE */ 160 163 161 - u32 *array_values __free(kfree) = kcalloc(n, sizeof(*array_values), 162 - GFP_KERNEL); 164 + u32 *array_values __free(kfree) = kcalloc(n, sizeof(*array_values), GFP_KERNEL); 163 165 if (!array_values) 164 - return -ENOMEM; 166 + goto end; 165 167 166 168 ret = of_property_read_u32_array(np, "dai-tdm-slot-width-map", array_values, n); 167 169 if (ret < 0) { 168 170 dev_err(dev, "Could not read dai-tdm-slot-width-map: %d\n", ret); 169 - return ret; 171 + goto end; 170 172 } 171 173 172 174 p = array_values; ··· 186 170 } 187 171 188 172 dai->n_tdm_widths = i; 189 - 190 - return 0; 173 + ret = 0; 174 + end: 175 + return simple_ret(priv, ret); 191 176 } 192 177 EXPORT_SYMBOL_GPL(simple_util_parse_tdm_width_map); 193 178 194 - int simple_util_set_dailink_name(struct device *dev, 179 + int simple_util_set_dailink_name(struct simple_util_priv *priv, 195 180 struct snd_soc_dai_link *dai_link, 196 181 const char *fmt, ...) 197 182 { 183 + struct device *dev = simple_priv_to_dev(priv); 198 184 va_list ap; 199 185 char *name = NULL; 200 186 int ret = -ENOMEM; ··· 212 194 dai_link->stream_name = name; 213 195 } 214 196 215 - return ret; 197 + return simple_ret(priv, ret); 216 198 } 217 199 EXPORT_SYMBOL_GPL(simple_util_set_dailink_name); 218 200 219 - int simple_util_parse_card_name(struct snd_soc_card *card, 201 + int simple_util_parse_card_name(struct simple_util_priv *priv, 220 202 char *prefix) 221 203 { 204 + struct snd_soc_card *card = simple_priv_to_card(priv); 222 205 int ret; 223 206 224 207 if (!prefix) ··· 233 214 snprintf(prop, sizeof(prop), "%sname", prefix); 234 215 ret = snd_soc_of_parse_card_name(card, prop); 235 216 if (ret < 0) 236 - return ret; 217 + goto end; 237 218 } 238 219 239 220 if (!card->name && card->dai_link) 240 221 card->name = card->dai_link->name; 241 - 242 - return 0; 222 + end: 223 + return simple_ret(priv, ret); 243 224 } 244 225 EXPORT_SYMBOL_GPL(simple_util_parse_card_name); 245 226 ··· 367 348 break; 368 349 simple_clk_disable(dai); 369 350 } 370 - return ret; 351 + 352 + return simple_ret(priv, ret); 371 353 } 372 354 EXPORT_SYMBOL_GPL(simple_util_startup); 373 355 ··· 399 379 } 400 380 EXPORT_SYMBOL_GPL(simple_util_shutdown); 401 381 402 - static int simple_set_clk_rate(struct device *dev, 403 - struct simple_util_dai *simple_dai, 404 - unsigned long rate) 382 + static int simple_set_clk_rate(struct simple_util_priv *priv, 383 + struct simple_util_dai *simple_dai, 384 + unsigned long rate) 405 385 { 386 + struct device *dev = simple_priv_to_dev(priv); 387 + int ret = -EINVAL; 388 + 406 389 if (!simple_dai) 407 390 return 0; 408 391 409 392 if (simple_dai->clk_fixed && rate != simple_dai->sysclk) { 410 393 dev_err(dev, "dai %s invalid clock rate %lu\n", simple_dai->name, rate); 411 - return -EINVAL; 394 + goto end; 412 395 } 413 396 414 397 if (!simple_dai->clk) ··· 420 397 if (clk_get_rate(simple_dai->clk) == rate) 421 398 return 0; 422 399 423 - return clk_set_rate(simple_dai->clk, rate); 400 + ret = clk_set_rate(simple_dai->clk, rate); 401 + end: 402 + return simple_ret(priv, ret); 424 403 } 425 404 426 - static int simple_set_tdm(struct snd_soc_dai *dai, 427 - struct simple_util_dai *simple_dai, 428 - struct snd_pcm_hw_params *params) 405 + static int simple_set_tdm(struct simple_util_priv *priv, 406 + struct snd_soc_dai *dai, 407 + struct simple_util_dai *simple_dai, 408 + struct snd_pcm_hw_params *params) 429 409 { 430 410 int sample_bits = params_width(params); 431 411 int slot_width, slot_count; ··· 456 430 simple_dai->rx_slot_mask, 457 431 slot_count, 458 432 slot_width); 459 - if (ret && ret != -ENOTSUPP) { 460 - dev_err(dai->dev, "simple-card: set_tdm_slot error: %d\n", ret); 461 - return ret; 462 - } 463 433 464 - return 0; 434 + return simple_ret(priv, ret); 465 435 } 466 436 467 437 int simple_util_hw_params(struct snd_pcm_substream *substream, ··· 479 457 mclk = params_rate(params) * mclk_fs; 480 458 481 459 for_each_prop_dai_codec(props, i, pdai) { 482 - ret = simple_set_clk_rate(rtd->dev, pdai, mclk); 460 + ret = simple_set_clk_rate(priv, pdai, mclk); 483 461 if (ret < 0) 484 - return ret; 462 + goto end; 485 463 } 486 464 487 465 for_each_prop_dai_cpu(props, i, pdai) { 488 - ret = simple_set_clk_rate(rtd->dev, pdai, mclk); 466 + ret = simple_set_clk_rate(priv, pdai, mclk); 489 467 if (ret < 0) 490 - return ret; 468 + goto end; 491 469 } 492 470 493 471 /* Ensure sysclk is set on all components in case any ··· 498 476 ret = snd_soc_component_set_sysclk(component, 0, 0, 499 477 mclk, SND_SOC_CLOCK_IN); 500 478 if (ret && ret != -ENOTSUPP) 501 - return ret; 479 + goto end; 502 480 } 503 481 504 482 for_each_rtd_codec_dais(rtd, i, sdai) { 505 483 pdai = simple_props_to_dai_codec(props, i); 506 484 ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, pdai->clk_direction); 507 485 if (ret && ret != -ENOTSUPP) 508 - return ret; 486 + goto end; 509 487 } 510 488 511 489 for_each_rtd_cpu_dais(rtd, i, sdai) { 512 490 pdai = simple_props_to_dai_cpu(props, i); 513 491 ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, pdai->clk_direction); 514 492 if (ret && ret != -ENOTSUPP) 515 - return ret; 493 + goto end; 516 494 } 517 495 } 518 496 519 497 for_each_prop_dai_codec(props, i, pdai) { 520 498 sdai = snd_soc_rtd_to_codec(rtd, i); 521 - ret = simple_set_tdm(sdai, pdai, params); 499 + ret = simple_set_tdm(priv, sdai, pdai, params); 522 500 if (ret < 0) 523 - return ret; 501 + goto end; 524 502 } 525 503 526 504 for_each_prop_dai_cpu(props, i, pdai) { 527 505 sdai = snd_soc_rtd_to_cpu(rtd, i); 528 - ret = simple_set_tdm(sdai, pdai, params); 506 + ret = simple_set_tdm(priv, sdai, pdai, params); 529 507 if (ret < 0) 530 - return ret; 508 + goto end; 531 509 } 532 - 533 - return 0; 510 + ret = 0; 511 + end: 512 + return simple_ret(priv, ret); 534 513 } 535 514 EXPORT_SYMBOL_GPL(simple_util_hw_params); 536 515 ··· 559 536 } 560 537 EXPORT_SYMBOL_GPL(simple_util_be_hw_params_fixup); 561 538 562 - static int simple_init_dai(struct snd_soc_dai *dai, struct simple_util_dai *simple_dai) 539 + static int simple_init_dai(struct simple_util_priv *priv, 540 + struct snd_soc_dai *dai, struct simple_util_dai *simple_dai) 563 541 { 564 542 int ret; 565 543 ··· 572 548 simple_dai->clk_direction); 573 549 if (ret && ret != -ENOTSUPP) { 574 550 dev_err(dai->dev, "simple-card: set_sysclk error\n"); 575 - return ret; 551 + goto end; 576 552 } 577 553 } 578 554 ··· 584 560 simple_dai->slot_width); 585 561 if (ret && ret != -ENOTSUPP) { 586 562 dev_err(dai->dev, "simple-card: set_tdm_slot error\n"); 587 - return ret; 563 + goto end; 588 564 } 589 565 } 590 - 591 - return 0; 566 + ret = 0; 567 + end: 568 + return simple_ret(priv, ret); 592 569 } 593 570 594 571 static inline int simple_component_is_codec(struct snd_soc_component *component) ··· 597 572 return component->driver->endianness; 598 573 } 599 574 600 - static int simple_init_for_codec2codec(struct snd_soc_pcm_runtime *rtd, 575 + static int simple_init_for_codec2codec(struct simple_util_priv *priv, 576 + struct snd_soc_pcm_runtime *rtd, 601 577 struct simple_dai_props *dai_props) 602 578 { 603 579 struct snd_soc_dai_link *dai_link = rtd->dai_link; ··· 630 604 631 605 if (ret < 0) { 632 606 dev_err(rtd->dev, "simple-card: no valid dai_link params\n"); 633 - return ret; 607 + goto end; 634 608 } 635 609 610 + ret = -ENOMEM; 636 611 c2c_params = devm_kzalloc(rtd->dev, sizeof(*c2c_params), GFP_KERNEL); 637 612 if (!c2c_params) 638 - return -ENOMEM; 613 + goto end; 639 614 640 615 c2c_params->formats = hw.formats; 641 616 c2c_params->rates = hw.rates; ··· 648 621 dai_link->c2c_params = c2c_params; 649 622 dai_link->num_c2c_params = 1; 650 623 651 - return 0; 624 + ret = 0; 625 + end: 626 + return simple_ret(priv, ret); 652 627 } 653 628 654 629 int simple_util_dai_init(struct snd_soc_pcm_runtime *rtd) ··· 661 632 int i, ret; 662 633 663 634 for_each_prop_dai_codec(props, i, dai) { 664 - ret = simple_init_dai(snd_soc_rtd_to_codec(rtd, i), dai); 635 + ret = simple_init_dai(priv, snd_soc_rtd_to_codec(rtd, i), dai); 665 636 if (ret < 0) 666 - return ret; 637 + goto end; 667 638 } 668 639 for_each_prop_dai_cpu(props, i, dai) { 669 - ret = simple_init_dai(snd_soc_rtd_to_cpu(rtd, i), dai); 640 + ret = simple_init_dai(priv, snd_soc_rtd_to_cpu(rtd, i), dai); 670 641 if (ret < 0) 671 - return ret; 642 + goto end; 672 643 } 673 644 674 - ret = simple_init_for_codec2codec(rtd, props); 675 - if (ret < 0) 676 - return ret; 677 - 678 - return 0; 645 + ret = simple_init_for_codec2codec(priv, rtd, props); 646 + end: 647 + return simple_ret(priv, ret); 679 648 } 680 649 EXPORT_SYMBOL_GPL(simple_util_dai_init); 681 650 ··· 858 831 priv->aux_jacks = devm_kcalloc(card->dev, num, 859 832 sizeof(struct snd_soc_jack), GFP_KERNEL); 860 833 if (!priv->aux_jacks) 861 - return -ENOMEM; 834 + return simple_ret(priv, -ENOMEM); 862 835 863 836 for_each_card_auxs(card, component) { 864 837 char id[128]; ··· 1019 992 1020 993 ret = simple_util_init_hp(card, &priv->hp_jack, NULL); 1021 994 if (ret < 0) 1022 - return ret; 995 + goto end; 1023 996 1024 997 ret = simple_util_init_mic(card, &priv->mic_jack, NULL); 1025 - if (ret < 0) 1026 - return ret; 1027 - 1028 - return 0; 998 + end: 999 + return simple_ret(priv, ret); 1029 1000 } 1030 1001 EXPORT_SYMBOL_GPL(graph_util_card_probe); 1031 1002 ··· 1099 1074 return id; 1100 1075 } 1101 1076 1102 - int graph_util_parse_dai(struct device *dev, struct device_node *ep, 1077 + int graph_util_parse_dai(struct simple_util_priv *priv, struct device_node *ep, 1103 1078 struct snd_soc_dai_link_component *dlc, int *is_single_link) 1104 1079 { 1080 + struct device *dev = simple_priv_to_dev(priv); 1105 1081 struct of_phandle_args args = {}; 1106 1082 struct snd_soc_dai *dai; 1107 1083 int ret; ··· 1118 1092 args.np = ep; 1119 1093 dai = snd_soc_get_dai_via_args(&args); 1120 1094 if (dai) { 1095 + ret = -ENOMEM; 1096 + dlc->of_node = node; 1121 1097 dlc->dai_name = snd_soc_dai_name_get(dai); 1122 1098 dlc->dai_args = snd_soc_copy_dai_args(dev, &args); 1123 1099 if (!dlc->dai_args) 1124 - return -ENOMEM; 1100 + goto end; 1125 1101 1126 1102 goto parse_dai_end; 1127 1103 } ··· 1154 1126 */ 1155 1127 ret = snd_soc_get_dlc(&args, dlc); 1156 1128 if (ret < 0) 1157 - return ret; 1129 + goto end; 1158 1130 1159 1131 parse_dai_end: 1160 1132 if (is_single_link) 1161 1133 *is_single_link = of_graph_get_endpoint_count(node) == 1; 1162 - 1163 - return 0; 1134 + ret = 0; 1135 + end: 1136 + return simple_ret(priv, ret); 1164 1137 } 1165 1138 EXPORT_SYMBOL_GPL(graph_util_parse_dai); 1166 1139
+72 -60
sound/soc/generic/simple-card.c
··· 29 29 .hw_params = simple_util_hw_params, 30 30 }; 31 31 32 - static int simple_parse_platform(struct device_node *node, struct snd_soc_dai_link_component *dlc) 32 + #define simple_ret(priv, ret) _simple_ret(priv, __func__, ret) 33 + static inline int _simple_ret(struct simple_util_priv *priv, 34 + const char *func, int ret) 35 + { 36 + return snd_soc_ret(simple_priv_to_dev(priv), ret, "at %s()\n", func); 37 + } 38 + 39 + static int simple_parse_platform(struct simple_util_priv *priv, 40 + struct device_node *node, 41 + struct snd_soc_dai_link_component *dlc) 33 42 { 34 43 struct of_phandle_args args; 35 44 int ret; ··· 52 43 */ 53 44 ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args); 54 45 if (ret) 55 - return ret; 46 + return simple_ret(priv, ret); 56 47 57 48 /* dai_name is not required and may not exist for plat component */ 58 49 ··· 61 52 return 0; 62 53 } 63 54 64 - static int simple_parse_dai(struct device *dev, 55 + static int simple_parse_dai(struct simple_util_priv *priv, 65 56 struct device_node *node, 66 57 struct snd_soc_dai_link_component *dlc, 67 58 int *is_single_link) 68 59 { 60 + struct device *dev = simple_priv_to_dev(priv); 69 61 struct of_phandle_args args; 70 62 struct snd_soc_dai *dai; 71 63 int ret; ··· 80 70 */ 81 71 ret = of_parse_phandle_with_args(node, DAI, CELL, 0, &args); 82 72 if (ret) 83 - return ret; 73 + goto end; 84 74 85 75 /* 86 76 * Try to find from DAI args 87 77 */ 88 78 dai = snd_soc_get_dai_via_args(&args); 89 79 if (dai) { 80 + ret = -ENOMEM; 90 81 dlc->dai_name = snd_soc_dai_name_get(dai); 91 82 dlc->dai_args = snd_soc_copy_dai_args(dev, &args); 92 83 if (!dlc->dai_args) 93 - return -ENOMEM; 84 + goto end; 94 85 95 86 goto parse_dai_end; 96 87 } ··· 117 106 */ 118 107 ret = snd_soc_get_dlc(&args, dlc); 119 108 if (ret < 0) 120 - return ret; 109 + goto end; 121 110 122 111 parse_dai_end: 123 112 if (is_single_link) 124 113 *is_single_link = !args.args_count; 125 - 126 - return 0; 114 + ret = 0; 115 + end: 116 + return simple_ret(priv, ret); 127 117 } 128 118 129 119 static void simple_parse_convert(struct device *dev, ··· 161 149 dai = simple_props_to_dai_codec(dai_props, 0); 162 150 } 163 151 164 - ret = simple_parse_dai(dev, np, dlc, cpu); 152 + ret = simple_parse_dai(priv, np, dlc, cpu); 165 153 if (ret) 166 - return ret; 154 + goto end; 167 155 168 156 ret = simple_util_parse_clk(dev, np, dai, dlc); 169 157 if (ret) 170 - return ret; 158 + goto end; 171 159 172 160 ret = simple_util_parse_tdm(np, dai); 173 - if (ret) 174 - return ret; 175 - 176 - return 0; 161 + end: 162 + return simple_ret(priv, ret); 177 163 } 178 164 179 165 static int simple_link_init(struct simple_util_priv *priv, ··· 193 183 ret = simple_util_parse_daifmt(dev, node, codec, 194 184 prefix, &dai_link->dai_fmt); 195 185 if (ret < 0) 196 - return ret; 186 + goto end; 197 187 198 188 graph_util_parse_link_direction(top, &playback_only, &capture_only); 199 189 graph_util_parse_link_direction(node, &playback_only, &capture_only); ··· 223 213 dai_link->init = simple_util_dai_init; 224 214 dai_link->ops = &simple_ops; 225 215 226 - return simple_util_set_dailink_name(dev, dai_link, name); 216 + ret = simple_util_set_dailink_name(priv, dai_link, name); 217 + end: 218 + return simple_ret(priv, ret); 227 219 } 228 220 229 221 static int simple_dai_link_of_dpcm(struct simple_util_priv *priv, ··· 302 290 out_put_node: 303 291 li->link++; 304 292 305 - return ret; 293 + return simple_ret(priv, ret); 306 294 } 307 295 308 296 static int simple_dai_link_of(struct simple_util_priv *priv, ··· 342 330 if (ret < 0) 343 331 goto dai_link_of_err; 344 332 345 - ret = simple_parse_platform(plat, platforms); 333 + ret = simple_parse_platform(priv, plat, platforms); 346 334 if (ret < 0) 347 335 goto dai_link_of_err; 348 336 ··· 357 345 dai_link_of_err: 358 346 li->link++; 359 347 360 - return ret; 348 + return simple_ret(priv, ret); 361 349 } 362 350 363 351 static int __simple_for_each_link(struct simple_util_priv *priv, ··· 455 443 node = of_get_next_child(top, node); 456 444 } while (!is_top && node); 457 445 458 - error: 446 + error: 459 447 of_node_put(node); 460 448 461 - return ret; 449 + return simple_ret(priv, ret); 462 450 } 463 451 464 452 static int simple_for_each_link(struct simple_util_priv *priv, ··· 491 479 break; 492 480 } 493 481 494 - return ret; 482 + return simple_ret(priv, ret); 495 483 } 496 484 497 485 static void simple_depopulate_aux(void *data) ··· 512 500 513 501 ret = of_platform_populate(node, NULL, NULL, dev); 514 502 if (ret) 515 - return ret; 503 + goto end; 516 504 517 - return devm_add_action_or_reset(dev, simple_depopulate_aux, priv); 505 + ret = devm_add_action_or_reset(dev, simple_depopulate_aux, priv); 506 + end: 507 + return simple_ret(priv, ret); 518 508 } 519 509 520 510 static int simple_parse_of(struct simple_util_priv *priv, struct link_info *li) ··· 526 512 527 513 ret = simple_util_parse_widgets(card, PREFIX); 528 514 if (ret < 0) 529 - return ret; 515 + goto end; 530 516 531 517 ret = simple_util_parse_routing(card, PREFIX); 532 518 if (ret < 0) 533 - return ret; 519 + goto end; 534 520 535 521 ret = simple_util_parse_pin_switches(card, PREFIX); 536 522 if (ret < 0) 537 - return ret; 523 + goto end; 538 524 539 525 /* Single/Muti DAI link(s) & New style of DT node */ 540 526 memset(li, 0, sizeof(*li)); ··· 542 528 simple_dai_link_of, 543 529 simple_dai_link_of_dpcm); 544 530 if (ret < 0) 545 - return ret; 531 + goto end; 546 532 547 - ret = simple_util_parse_card_name(card, PREFIX); 533 + ret = simple_util_parse_card_name(priv, PREFIX); 548 534 if (ret < 0) 549 - return ret; 535 + goto end; 550 536 551 537 ret = simple_populate_aux(priv); 552 538 if (ret < 0) 553 - return ret; 539 + goto end; 554 540 555 541 ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs"); 556 - 557 - return ret; 542 + end: 543 + return simple_ret(priv, ret); 558 544 } 559 545 560 546 static int simple_count_noml(struct simple_util_priv *priv, ··· 562 548 struct device_node *codec, 563 549 struct link_info *li, bool is_top) 564 550 { 565 - if (li->link >= SNDRV_MAX_LINKS) { 566 - struct device *dev = simple_priv_to_dev(priv); 551 + int ret = -EINVAL; 567 552 568 - dev_err(dev, "too many links\n"); 569 - return -EINVAL; 570 - } 553 + if (li->link >= SNDRV_MAX_LINKS) 554 + goto end; 571 555 572 556 /* 573 557 * DON'T REMOVE platforms ··· 587 575 li->num[li->link].codecs = 1; 588 576 589 577 li->link += 1; 590 - 591 - return 0; 578 + ret = 0; 579 + end: 580 + return simple_ret(priv, ret); 592 581 } 593 582 594 583 static int simple_count_dpcm(struct simple_util_priv *priv, ··· 597 584 struct device_node *codec, 598 585 struct link_info *li, bool is_top) 599 586 { 600 - if (li->link >= SNDRV_MAX_LINKS) { 601 - struct device *dev = simple_priv_to_dev(priv); 587 + int ret = -EINVAL; 602 588 603 - dev_err(dev, "too many links\n"); 604 - return -EINVAL; 605 - } 589 + if (li->link >= SNDRV_MAX_LINKS) 590 + goto end; 606 591 607 592 if (li->cpu) { 608 593 /* ··· 617 606 618 607 li->link++; /* dummy-Codec */ 619 608 } 620 - 621 - return 0; 609 + ret = 0; 610 + end: 611 + return simple_ret(priv, ret); 622 612 } 623 613 624 614 static int simple_get_dais_count(struct simple_util_priv *priv, ··· 695 683 696 684 ret = simple_util_init_hp(card, &priv->hp_jack, PREFIX); 697 685 if (ret < 0) 698 - return ret; 686 + goto end; 699 687 700 688 ret = simple_util_init_mic(card, &priv->mic_jack, PREFIX); 701 689 if (ret < 0) 702 - return ret; 690 + goto end; 703 691 704 692 ret = simple_util_init_aux_jacks(priv, PREFIX); 705 - if (ret < 0) 706 - return ret; 707 - 708 - return 0; 693 + end: 694 + return simple_ret(priv, ret); 709 695 } 710 696 711 697 static int simple_probe(struct platform_device *pdev) ··· 725 715 card->probe = simple_soc_probe; 726 716 card->driver_name = "simple-card"; 727 717 718 + ret = -ENOMEM; 728 719 struct link_info *li __free(kfree) = kzalloc(sizeof(*li), GFP_KERNEL); 729 720 if (!li) 730 - return -ENOMEM; 721 + goto end; 731 722 732 723 ret = simple_get_dais_count(priv, li); 733 724 if (ret < 0) 734 - return ret; 725 + goto end; 735 726 727 + ret = -EINVAL; 736 728 if (!li->link) 737 - return -EINVAL; 729 + goto end; 738 730 739 731 ret = simple_util_init_priv(priv, li); 740 732 if (ret < 0) 741 - return ret; 733 + goto end; 742 734 743 735 if (np && of_device_is_available(np)) { 744 736 ··· 807 795 return 0; 808 796 err: 809 797 simple_util_clean_reference(card); 810 - 811 - return ret; 798 + end: 799 + return dev_err_probe(dev, ret, "parse error\n"); 812 800 } 813 801 814 802 static const struct of_device_id simple_of_match[] = {
+1 -1
sound/soc/intel/common/soc-acpi-intel-mtl-match.c
··· 330 330 331 331 static const struct snd_soc_acpi_adr_device rt1318_1_single_adr[] = { 332 332 { 333 - .adr = 0x000130025D131801, 333 + .adr = 0x000130025D131801ull, 334 334 .num_endpoints = 1, 335 335 .endpoints = &single_endpoint, 336 336 .name_prefix = "rt1318-1"
+8 -8
sound/soc/intel/common/soc-acpi-intel-tgl-match.c
··· 658 658 659 659 static const struct snd_soc_acpi_adr_device cs35l56_sdw_eight_1_4_fb_adr[] = { 660 660 { 661 - .adr = 0x00003301fa355601, 661 + .adr = 0x00003301fa355601ull, 662 662 .num_endpoints = ARRAY_SIZE(cs35l56_l_fb_endpoints), 663 663 .endpoints = cs35l56_l_fb_endpoints, 664 664 .name_prefix = "AMP1" 665 665 }, 666 666 { 667 - .adr = 0x00003201fa355601, 667 + .adr = 0x00003201fa355601ull, 668 668 .num_endpoints = ARRAY_SIZE(cs35l56_2_fb_endpoints), 669 669 .endpoints = cs35l56_2_fb_endpoints, 670 670 .name_prefix = "AMP2" 671 671 }, 672 672 { 673 - .adr = 0x00003101fa355601, 673 + .adr = 0x00003101fa355601ull, 674 674 .num_endpoints = ARRAY_SIZE(cs35l56_4_fb_endpoints), 675 675 .endpoints = cs35l56_4_fb_endpoints, 676 676 .name_prefix = "AMP3" 677 677 }, 678 678 { 679 - .adr = 0x00003001fa355601, 679 + .adr = 0x00003001fa355601ull, 680 680 .num_endpoints = ARRAY_SIZE(cs35l56_6_fb_endpoints), 681 681 .endpoints = cs35l56_6_fb_endpoints, 682 682 .name_prefix = "AMP4" ··· 685 685 686 686 static const struct snd_soc_acpi_adr_device cs35l56_sdw_eight_5_8_fb_adr[] = { 687 687 { 688 - .adr = 0x00013701fa355601, 688 + .adr = 0x00013701fa355601ull, 689 689 .num_endpoints = ARRAY_SIZE(cs35l56_r_fb_endpoints), 690 690 .endpoints = cs35l56_r_fb_endpoints, 691 691 .name_prefix = "AMP8" 692 692 }, 693 693 { 694 - .adr = 0x00013601fa355601, 694 + .adr = 0x00013601fa355601ull, 695 695 .num_endpoints = ARRAY_SIZE(cs35l56_3_fb_endpoints), 696 696 .endpoints = cs35l56_3_fb_endpoints, 697 697 .name_prefix = "AMP7" 698 698 }, 699 699 { 700 - .adr = 0x00013501fa355601, 700 + .adr = 0x00013501fa355601ull, 701 701 .num_endpoints = ARRAY_SIZE(cs35l56_5_fb_endpoints), 702 702 .endpoints = cs35l56_5_fb_endpoints, 703 703 .name_prefix = "AMP6" 704 704 }, 705 705 { 706 - .adr = 0x00013401fa355601, 706 + .adr = 0x00013401fa355601ull, 707 707 .num_endpoints = ARRAY_SIZE(cs35l56_7_fb_endpoints), 708 708 .endpoints = cs35l56_7_fb_endpoints, 709 709 .name_prefix = "AMP5"
+2 -2
sound/soc/rockchip/rockchip_i2s_tdm.c
··· 451 451 break; 452 452 case SND_SOC_DAIFMT_DSP_A: 453 453 val = I2S_TXCR_TFS_TDM_PCM; 454 - tdm_val = TDM_SHIFT_CTRL(0); 454 + tdm_val = TDM_SHIFT_CTRL(2); 455 455 break; 456 456 case SND_SOC_DAIFMT_DSP_B: 457 457 val = I2S_TXCR_TFS_TDM_PCM; 458 - tdm_val = TDM_SHIFT_CTRL(2); 458 + tdm_val = TDM_SHIFT_CTRL(4); 459 459 break; 460 460 default: 461 461 ret = -EINVAL;
+2 -12
sound/soc/soc-card.c
··· 15 15 static inline int _soc_card_ret(struct snd_soc_card *card, 16 16 const char *func, int ret) 17 17 { 18 - switch (ret) { 19 - case -EPROBE_DEFER: 20 - case -ENOTSUPP: 21 - case 0: 22 - break; 23 - default: 24 - dev_err(card->dev, 25 - "ASoC: error at %s on %s: %d\n", 26 - func, card->name, ret); 27 - } 28 - 29 - return ret; 18 + return snd_soc_ret(card->dev, ret, 19 + "at %s() on %s\n", func, card->name); 30 20 } 31 21 32 22 struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
+12 -24
sound/soc/soc-component.c
··· 13 13 #include <sound/soc.h> 14 14 #include <linux/bitops.h> 15 15 16 - #define soc_component_ret(dai, ret) _soc_component_ret(dai, __func__, ret, -1) 17 - #define soc_component_ret_reg_rw(dai, ret, reg) _soc_component_ret(dai, __func__, ret, reg) 18 - static inline int _soc_component_ret(struct snd_soc_component *component, 19 - const char *func, int ret, int reg) 16 + #define soc_component_ret(dai, ret) _soc_component_ret(dai, __func__, ret) 17 + static inline int _soc_component_ret(struct snd_soc_component *component, const char *func, int ret) 20 18 { 21 - /* Positive/Zero values are not errors */ 22 - if (ret >= 0) 23 - return ret; 19 + return snd_soc_ret(component->dev, ret, 20 + "at %s() on %s\n", func, component->name); 21 + } 24 22 25 - /* Negative values might be errors */ 26 - switch (ret) { 27 - case -EPROBE_DEFER: 28 - case -ENOTSUPP: 29 - break; 30 - default: 31 - if (reg == -1) 32 - dev_err(component->dev, 33 - "ASoC: error at %s on %s: %d\n", 34 - func, component->name, ret); 35 - else 36 - dev_err(component->dev, 37 - "ASoC: error at %s on %s for register: [0x%08x] %d\n", 38 - func, component->name, reg, ret); 39 - } 40 - 41 - return ret; 23 + #define soc_component_ret_reg_rw(dai, ret, reg) _soc_component_ret_reg_rw(dai, __func__, ret, reg) 24 + static inline int _soc_component_ret_reg_rw(struct snd_soc_component *component, 25 + const char *func, int ret, int reg) 26 + { 27 + return snd_soc_ret(component->dev, ret, 28 + "at %s() on %s for register: [0x%08x]\n", 29 + func, component->name, reg); 42 30 } 43 31 44 32 static inline int soc_component_field_shift(struct snd_soc_component *component,
+2 -16
sound/soc/soc-dai.c
··· 14 14 static inline int _soc_dai_ret(const struct snd_soc_dai *dai, 15 15 const char *func, int ret) 16 16 { 17 - /* Positive, Zero values are not errors */ 18 - if (ret >= 0) 19 - return ret; 20 - 21 - /* Negative values might be errors */ 22 - switch (ret) { 23 - case -EPROBE_DEFER: 24 - case -ENOTSUPP: 25 - break; 26 - default: 27 - dev_err(dai->dev, 28 - "ASoC: error at %s on %s: %d\n", 29 - func, dai->name, ret); 30 - } 31 - 32 - return ret; 17 + return snd_soc_ret(dai->dev, ret, 18 + "at %s() on %s\n", func, dai->name); 33 19 } 34 20 35 21 /*
+2 -16
sound/soc/soc-link.c
··· 12 12 static inline int _soc_link_ret(struct snd_soc_pcm_runtime *rtd, 13 13 const char *func, int ret) 14 14 { 15 - /* Positive, Zero values are not errors */ 16 - if (ret >= 0) 17 - return ret; 18 - 19 - /* Negative values might be errors */ 20 - switch (ret) { 21 - case -EPROBE_DEFER: 22 - case -ENOTSUPP: 23 - break; 24 - default: 25 - dev_err(rtd->dev, 26 - "ASoC: error at %s on %s: %d\n", 27 - func, rtd->dai_link->name, ret); 28 - } 29 - 30 - return ret; 15 + return snd_soc_ret(rtd->dev, ret, 16 + "at %s() on %s\n", func, rtd->dai_link->name); 31 17 } 32 18 33 19 /*
+41 -73
sound/soc/soc-pcm.c
··· 30 30 static inline int _soc_pcm_ret(struct snd_soc_pcm_runtime *rtd, 31 31 const char *func, int ret) 32 32 { 33 - /* Positive, Zero values are not errors */ 34 - if (ret >= 0) 35 - return ret; 36 - 37 - /* Negative values might be errors */ 38 - switch (ret) { 39 - case -EPROBE_DEFER: 40 - case -ENOTSUPP: 41 - break; 42 - default: 43 - dev_err(rtd->dev, 44 - "ASoC: error at %s on %s: %d\n", 45 - func, rtd->dai_link->name, ret); 46 - } 47 - 48 - return ret; 33 + return snd_soc_ret(rtd->dev, ret, 34 + "at %s() on %s\n", func, rtd->dai_link->name); 49 35 } 50 36 51 37 /* is the current PCM operation for this FE ? */ ··· 238 252 int stream; 239 253 char *buf; 240 254 241 - if (fe->dai_link->num_cpus > 1) { 242 - dev_err(fe->dev, 255 + if (fe->dai_link->num_cpus > 1) 256 + return snd_soc_ret(fe->dev, -EINVAL, 243 257 "%s doesn't support Multi CPU yet\n", __func__); 244 - return -EINVAL; 245 - } 246 258 247 259 buf = kmalloc(out_count, GFP_KERNEL); 248 260 if (!buf) ··· 458 474 ret = snd_pcm_hw_constraint_single(substream->runtime, \ 459 475 SNDRV_PCM_HW_PARAM_##NAME,\ 460 476 soc_dai->symmetric_##name); \ 461 - if (ret < 0) { \ 462 - dev_err(soc_dai->dev, \ 463 - "ASoC: Unable to apply %s constraint: %d\n",\ 464 - #name, ret); \ 465 - return ret; \ 466 - } \ 477 + if (ret < 0) \ 478 + return snd_soc_ret(soc_dai->dev, ret, \ 479 + "Unable to apply %s constraint\n", #name); \ 467 480 } 468 481 469 482 __soc_pcm_apply_symmetry(rate, RATE); ··· 491 510 for_each_rtd_cpu_dais(rtd, i, cpu_dai) \ 492 511 if (!snd_soc_dai_is_dummy(cpu_dai) && \ 493 512 cpu_dai->symmetric_##xxx && \ 494 - cpu_dai->symmetric_##xxx != d.symmetric_##xxx) { \ 495 - dev_err(rtd->dev, "ASoC: unmatched %s symmetry: %s:%d - %s:%d\n", \ 496 - #xxx, cpu_dai->name, cpu_dai->symmetric_##xxx, \ 497 - d.name, d.symmetric_##xxx); \ 498 - return -EINVAL; \ 499 - } 513 + cpu_dai->symmetric_##xxx != d.symmetric_##xxx) \ 514 + return snd_soc_ret(rtd->dev, -EINVAL, \ 515 + "unmatched %s symmetry: %s:%d - %s:%d\n", \ 516 + #xxx, cpu_dai->name, cpu_dai->symmetric_##xxx, \ 517 + d.name, d.symmetric_##xxx); 500 518 501 519 /* reject unmatched parameters when applying symmetry */ 502 520 __soc_pcm_params_symmetry(rate); ··· 840 860 return 0; 841 861 842 862 config_err: 843 - dev_err(dev, "ASoC: %s <-> %s No matching %s\n", 844 - name_codec, name_cpu, err_msg); 845 - return -EINVAL; 863 + return snd_soc_ret(dev, -EINVAL, 864 + "%s <-> %s No matching %s\n", name_codec, name_cpu, err_msg); 846 865 } 847 866 848 867 /* ··· 1312 1333 fe_substream = snd_soc_dpcm_get_substream(fe, stream); 1313 1334 be_substream = snd_soc_dpcm_get_substream(be, stream); 1314 1335 1315 - if (!fe_substream->pcm->nonatomic && be_substream->pcm->nonatomic) { 1316 - dev_err(be->dev, "%s: FE is atomic but BE is nonatomic, invalid configuration\n", 1317 - __func__); 1318 - return -EINVAL; 1319 - } 1336 + if (!fe_substream->pcm->nonatomic && be_substream->pcm->nonatomic) 1337 + return snd_soc_ret(be->dev, -EINVAL, 1338 + "%s: %s is atomic but %s is nonatomic, invalid configuration\n", 1339 + __func__, fe->dai_link->name, be->dai_link->name); 1340 + 1320 1341 if (fe_substream->pcm->nonatomic && !be_substream->pcm->nonatomic) { 1321 1342 dev_dbg(be->dev, "FE is nonatomic but BE is not, forcing BE as nonatomic\n"); 1322 1343 be_substream->pcm->nonatomic = 1; ··· 1486 1507 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(fe, 0); 1487 1508 int paths; 1488 1509 1489 - if (fe->dai_link->num_cpus > 1) { 1490 - dev_err(fe->dev, 1510 + if (fe->dai_link->num_cpus > 1) 1511 + return snd_soc_ret(fe->dev, -EINVAL, 1491 1512 "%s doesn't support Multi CPU yet\n", __func__); 1492 - return -EINVAL; 1493 - } 1494 1513 1495 1514 /* get number of valid DAI paths and their widgets */ 1496 1515 paths = snd_soc_dapm_dai_get_connected_widgets(cpu_dai, stream, list, ··· 2379 2402 2380 2403 ret = soc_pcm_trigger(substream, cmd); 2381 2404 if (ret < 0) 2382 - return ret; 2405 + goto end; 2383 2406 2384 2407 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); 2385 - return ret; 2408 + goto end; 2386 2409 } 2387 2410 2388 2411 /* call trigger on the frontend after the backend. */ 2389 2412 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); 2390 2413 if (ret < 0) 2391 - return ret; 2414 + goto end; 2392 2415 2393 2416 dev_dbg(fe->dev, "ASoC: post trigger FE %s cmd %d\n", 2394 2417 fe->dai_link->name, cmd); 2395 2418 2396 2419 ret = soc_pcm_trigger(substream, cmd); 2397 - 2398 - return ret; 2420 + end: 2421 + return snd_soc_ret(fe->dev, ret, "trigger FE cmd: %d failed\n", cmd); 2399 2422 } 2400 2423 2401 2424 static int dpcm_fe_dai_do_trigger(struct snd_pcm_substream *substream, int cmd) ··· 2451 2474 goto out; 2452 2475 } 2453 2476 2454 - if (ret < 0) { 2455 - dev_err(fe->dev, "ASoC: trigger FE cmd: %d failed: %d\n", 2456 - cmd, ret); 2477 + if (ret < 0) 2457 2478 goto out; 2458 - } 2459 2479 2460 2480 switch (cmd) { 2461 2481 case SNDRV_PCM_TRIGGER_START: ··· 2681 2707 if (!fe->dai_link->dynamic) 2682 2708 return 0; 2683 2709 2684 - if (fe->dai_link->num_cpus > 1) { 2685 - dev_err(fe->dev, 2710 + if (fe->dai_link->num_cpus > 1) 2711 + return snd_soc_ret(fe->dev, -EINVAL, 2686 2712 "%s doesn't support Multi CPU yet\n", __func__); 2687 - return -EINVAL; 2688 - } 2689 2713 2690 2714 /* only check active links */ 2691 2715 if (!snd_soc_dai_active(snd_soc_rtd_to_cpu(fe, 0))) ··· 2754 2782 2755 2783 out: 2756 2784 snd_soc_dpcm_mutex_unlock(card); 2757 - return ret; 2785 + 2786 + return snd_soc_ret(card->dev, ret, "%s() failed\n", __func__); 2758 2787 } 2759 2788 EXPORT_SYMBOL_GPL(snd_soc_dpcm_runtime_update); 2760 2789 ··· 2829 2856 int has_capture = 0; 2830 2857 int i; 2831 2858 2832 - if (dai_link->dynamic && dai_link->num_cpus > 1) { 2833 - dev_err(rtd->dev, "DPCM doesn't support Multi CPU for Front-Ends yet\n"); 2834 - return -EINVAL; 2835 - } 2859 + if (dai_link->dynamic && dai_link->num_cpus > 1) 2860 + return snd_soc_ret(rtd->dev, -EINVAL, 2861 + "DPCM doesn't support Multi CPU for Front-Ends yet\n"); 2836 2862 2837 2863 /* Adapt stream for codec2codec links */ 2838 2864 cpu_capture = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_CAPTURE); ··· 2873 2901 if (dai_link->capture_only) 2874 2902 has_playback = 0; 2875 2903 2876 - if (!has_playback && !has_capture) { 2877 - dev_err(rtd->dev, "substream %s has no playback, no capture\n", 2878 - dai_link->stream_name); 2879 - 2880 - return -EINVAL; 2881 - } 2904 + if (!has_playback && !has_capture) 2905 + return snd_soc_ret(rtd->dev, -EINVAL, 2906 + "substream %s has no playback, no capture\n", dai_link->stream_name); 2882 2907 2883 2908 *playback = has_playback; 2884 2909 *capture = has_capture; ··· 2915 2946 ret = snd_pcm_new(rtd->card->snd_card, new_name, rtd->id, playback, 2916 2947 capture, pcm); 2917 2948 } 2918 - if (ret < 0) { 2919 - dev_err(rtd->card->dev, "ASoC: can't create pcm %s for dailink %s: %d\n", 2920 - new_name, rtd->dai_link->name, ret); 2921 - return ret; 2922 - } 2949 + if (ret < 0) 2950 + return snd_soc_ret(rtd->dev, ret, 2951 + "can't create pcm %s for dailink %s\n", new_name, rtd->dai_link->name); 2952 + 2923 2953 dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n", rtd->id, new_name); 2924 2954 2925 2955 return 0;
+27
sound/soc/soc-utils.c
··· 15 15 #include <sound/pcm_params.h> 16 16 #include <sound/soc.h> 17 17 18 + int snd_soc_ret(const struct device *dev, int ret, const char *fmt, ...) 19 + { 20 + struct va_format vaf; 21 + va_list args; 22 + 23 + /* Positive, Zero values are not errors */ 24 + if (ret >= 0) 25 + return ret; 26 + 27 + /* Negative values might be errors */ 28 + switch (ret) { 29 + case -EPROBE_DEFER: 30 + case -ENOTSUPP: 31 + case -EOPNOTSUPP: 32 + break; 33 + default: 34 + va_start(args, fmt); 35 + vaf.fmt = fmt; 36 + vaf.va = &args; 37 + 38 + dev_err(dev, "ASoC error (%d): %pV", ret, &vaf); 39 + } 40 + 41 + return ret; 42 + } 43 + EXPORT_SYMBOL_GPL(snd_soc_ret); 44 + 18 45 int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots) 19 46 { 20 47 return sample_size * channels * tdm_slots;