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

ASoC: audio-graph-card2: use snd_soc_ret()

We can use snd_soc_ret() to indicate error message when return.
Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/877c652ql8.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Kuninori Morimoto and committed by
Mark Brown
8d83282e 74a0ca4c

+49 -32
+49 -32
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 { ··· 418 411 419 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 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 ··· 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, ··· 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