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

ASoC: simple-card: 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/87bjvh2qlk.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Kuninori Morimoto and committed by
Mark Brown
a0ef5b4b be61cd42

+71 -59
+71 -59
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(dev, 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 533 ret = simple_util_parse_card_name(card, 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[] = {