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

ASoC: minor cleanup for soc_get_playback_capture()

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

This is minor cleanup patches for soc_get_playback_capture().

+33 -25
+33 -25
sound/soc/soc-pcm.c
··· 2730 2730 static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, 2731 2731 int *playback, int *capture) 2732 2732 { 2733 + struct snd_soc_dai_link *dai_link = rtd->dai_link; 2733 2734 struct snd_soc_dai *cpu_dai; 2735 + int has_playback = 0; 2736 + int has_capture = 0; 2734 2737 int i; 2735 2738 2736 - if (rtd->dai_link->dynamic && rtd->dai_link->num_cpus > 1) { 2737 - dev_err(rtd->dev, 2738 - "DPCM doesn't support Multi CPU for Front-Ends yet\n"); 2739 + if (dai_link->dynamic && dai_link->num_cpus > 1) { 2740 + dev_err(rtd->dev, "DPCM doesn't support Multi CPU for Front-Ends yet\n"); 2739 2741 return -EINVAL; 2740 2742 } 2741 2743 2742 - if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) { 2744 + if (dai_link->dynamic || dai_link->no_pcm) { 2743 2745 int stream; 2744 2746 2745 - if (rtd->dai_link->dpcm_playback) { 2747 + if (dai_link->dpcm_playback) { 2746 2748 stream = SNDRV_PCM_STREAM_PLAYBACK; 2747 2749 2748 2750 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { 2749 2751 if (snd_soc_dai_stream_valid(cpu_dai, stream)) { 2750 - *playback = 1; 2752 + has_playback = 1; 2751 2753 break; 2752 2754 } 2753 2755 } 2754 - if (!*playback) { 2756 + if (!has_playback) { 2755 2757 dev_err(rtd->card->dev, 2756 2758 "No CPU DAIs support playback for stream %s\n", 2757 - rtd->dai_link->stream_name); 2759 + dai_link->stream_name); 2758 2760 return -EINVAL; 2759 2761 } 2760 2762 } 2761 - if (rtd->dai_link->dpcm_capture) { 2763 + if (dai_link->dpcm_capture) { 2762 2764 stream = SNDRV_PCM_STREAM_CAPTURE; 2763 2765 2764 2766 for_each_rtd_cpu_dais(rtd, i, cpu_dai) { 2765 2767 if (snd_soc_dai_stream_valid(cpu_dai, stream)) { 2766 - *capture = 1; 2768 + has_capture = 1; 2767 2769 break; 2768 2770 } 2769 2771 } 2770 2772 2771 - if (!*capture) { 2773 + if (!has_capture) { 2772 2774 dev_err(rtd->card->dev, 2773 2775 "No CPU DAIs support capture for stream %s\n", 2774 - rtd->dai_link->stream_name); 2776 + dai_link->stream_name); 2775 2777 return -EINVAL; 2776 2778 } 2777 2779 } ··· 2781 2779 struct snd_soc_dai *codec_dai; 2782 2780 2783 2781 /* Adapt stream for codec2codec links */ 2784 - int cpu_capture = rtd->dai_link->c2c_params ? 2782 + int cpu_capture = dai_link->c2c_params ? 2785 2783 SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE; 2786 - int cpu_playback = rtd->dai_link->c2c_params ? 2784 + int cpu_playback = dai_link->c2c_params ? 2787 2785 SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; 2788 2786 2789 2787 for_each_rtd_codec_dais(rtd, i, codec_dai) { 2790 - if (rtd->dai_link->num_cpus == 1) { 2788 + if (dai_link->num_cpus == 1) { 2791 2789 cpu_dai = asoc_rtd_to_cpu(rtd, 0); 2792 - } else if (rtd->dai_link->num_cpus == rtd->dai_link->num_codecs) { 2790 + } else if (dai_link->num_cpus == dai_link->num_codecs) { 2793 2791 cpu_dai = asoc_rtd_to_cpu(rtd, i); 2794 2792 } else { 2795 2793 dev_err(rtd->card->dev, ··· 2799 2797 2800 2798 if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) && 2801 2799 snd_soc_dai_stream_valid(cpu_dai, cpu_playback)) 2802 - *playback = 1; 2800 + has_playback = 1; 2803 2801 if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) && 2804 2802 snd_soc_dai_stream_valid(cpu_dai, cpu_capture)) 2805 - *capture = 1; 2803 + has_capture = 1; 2806 2804 } 2807 2805 } 2808 2806 2809 - if (rtd->dai_link->playback_only) { 2810 - *playback = 1; 2811 - *capture = 0; 2807 + if (dai_link->playback_only) 2808 + has_capture = 0; 2809 + 2810 + if (dai_link->capture_only) 2811 + has_playback = 0; 2812 + 2813 + if (!has_playback && !has_capture) { 2814 + dev_err(rtd->dev, "substream %s has no playback, no capture\n", 2815 + dai_link->stream_name); 2816 + 2817 + return -EINVAL; 2812 2818 } 2813 2819 2814 - if (rtd->dai_link->capture_only) { 2815 - *playback = 0; 2816 - *capture = 1; 2817 - } 2820 + *playback = has_playback; 2821 + *capture = has_capture; 2818 2822 2819 2823 return 0; 2820 2824 }