Re: [PATCH 1/2] ASoC: qcom: Add helper for allocating Soundwire stream runtime

From: Pierre-Louis Bossart
Date: Tue Nov 28 2023 - 12:54:05 EST



> +int qcom_snd_sdw_startup(struct snd_pcm_substream *substream)
> +{
> + struct snd_soc_pcm_runtime *rtd = substream->private_data;
> + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
> + struct sdw_stream_runtime *sruntime;
> + struct snd_soc_dai *codec_dai;
> + int ret, i;
> +
> + sruntime = sdw_alloc_stream(cpu_dai->name);
> + if (!sruntime)
> + return -ENOMEM;
> +
> + for_each_rtd_codec_dais(rtd, i, codec_dai) {
> + ret = snd_soc_dai_set_stream(codec_dai, sruntime,
> + substream->stream);
> + if (ret < 0 && ret != -ENOTSUPP) {

I know this is existing code moved into a helper, but out of curiosity
why is -ENOTSUPP ignored? Isn't this problematic?

> + dev_err(rtd->dev, "Failed to set sdw stream on %s\n",
> + codec_dai->name);
> + goto err_set_stream;
> + }
> + }

Also should the CPU DAIs also be used to set the stream information?
it's not clear to me why only the CODEC DAIs are used.

> + return 0;
> +
> +err_set_stream:
> + sdw_release_stream(sruntime);
> +
> + return ret;
> +}