···142142 card->dev = &pdev->dev;143143 platform_set_drvdata(pdev, card);144144145145- ret = snd_soc_register_card(card);145145+ ret = devm_snd_soc_register_card(&pdev->dev, card);146146 if (ret) {147147 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",148148 ret);···154154155155static int mxs_sgtl5000_remove(struct platform_device *pdev)156156{157157- struct snd_soc_card *card = platform_get_drvdata(pdev);158158-159157 mxs_saif_put_mclk(0);160160-161161- snd_soc_unregister_card(card);162158163159 return 0;164160}
+49
sound/soc/soc-pcm.c
···34343535#define DPCM_MAX_BE_USERS 836363737+/*3838+ * snd_soc_dai_stream_valid() - check if a DAI supports the given stream3939+ *4040+ * Returns true if the DAI supports the indicated stream type.4141+ */4242+static bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream)4343+{4444+ struct snd_soc_pcm_stream *codec_stream;4545+4646+ if (stream == SNDRV_PCM_STREAM_PLAYBACK)4747+ codec_stream = &dai->driver->playback;4848+ else4949+ codec_stream = &dai->driver->capture;5050+5151+ /* If the codec specifies any rate at all, it supports the stream. */5252+ return codec_stream->rates;5353+}5454+3755/**3856 * snd_soc_runtime_activate() - Increment active count for PCM runtime components3957 * @rtd: ASoC PCM runtime that is activated···389371390372 /* first calculate min/max only for CODECs in the DAI link */391373 for (i = 0; i < rtd->num_codecs; i++) {374374+375375+ /*376376+ * Skip CODECs which don't support the current stream type.377377+ * Otherwise, since the rate, channel, and format values will378378+ * zero in that case, we would have no usable settings left,379379+ * causing the resulting setup to fail.380380+ * At least one CODEC should match, otherwise we should have381381+ * bailed out on a higher level, since there would be no382382+ * CODEC to support the transfer direction in that case.383383+ */384384+ if (!snd_soc_dai_stream_valid(rtd->codec_dais[i],385385+ substream->stream))386386+ continue;387387+392388 codec_dai_drv = rtd->codec_dais[i]->driver;393389 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)394390 codec_stream = &codec_dai_drv->playback;···858826 for (i = 0; i < rtd->num_codecs; i++) {859827 struct snd_soc_dai *codec_dai = rtd->codec_dais[i];860828 struct snd_pcm_hw_params codec_params;829829+830830+ /*831831+ * Skip CODECs which don't support the current stream type,832832+ * the idea being that if a CODEC is not used for the currently833833+ * set up transfer direction, it should not need to be834834+ * configured, especially since the configuration used might835835+ * not even be supported by that CODEC. There may be cases836836+ * however where a CODEC needs to be set up although it is837837+ * actually not being used for the transfer, e.g. if a838838+ * capture-only CODEC is acting as an LRCLK and/or BCLK master839839+ * for the DAI link including a playback-only CODEC.840840+ * If this becomes necessary, we will have to augment the841841+ * machine driver setup with information on how to act, so842842+ * we can do the right thing here.843843+ */844844+ if (!snd_soc_dai_stream_valid(codec_dai, substream->stream))845845+ continue;861846862847 /* copy params for each codec */863848 codec_params = *params;