Skip to content

Commit ecc7478

Browse files
povikjannau
authored andcommitted
ASoC: apple: mca: Factor out mca_be_get_fe
This is a function that we also want to use from within mca_be_shutdown, so factor it out. Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
1 parent 9906f57 commit ecc7478

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

sound/soc/apple/mca.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -696,30 +696,35 @@ static bool mca_be_clk_started(struct mca_cluster *cl)
696696
return false;
697697
}
698698

699-
static int mca_be_startup(struct snd_pcm_substream *substream,
700-
struct snd_soc_dai *dai)
699+
static struct snd_soc_pcm_runtime *mca_be_get_fe(struct snd_soc_pcm_runtime *be,
700+
int stream)
701701
{
702-
struct snd_soc_pcm_runtime *be = snd_soc_substream_to_rtd(substream);
703-
struct snd_soc_pcm_runtime *fe;
704-
struct mca_cluster *cl = mca_dai_to_cluster(dai);
705-
struct mca_cluster *fe_cl;
706-
struct mca_data *mca = cl->host;
702+
struct snd_soc_pcm_runtime *fe = NULL;
707703
struct snd_soc_dpcm *dpcm;
708704

709-
fe = NULL;
710-
711-
for_each_dpcm_fe(be, substream->stream, dpcm) {
705+
for_each_dpcm_fe(be, stream, dpcm) {
712706
if (fe && dpcm->fe != fe) {
713-
dev_err(mca->dev, "many FE per one BE unsupported\n");
714-
return -EINVAL;
707+
dev_err(be->dev, "many FE per one BE unsupported\n");
708+
return NULL;
715709
}
716710

717711
fe = dpcm->fe;
718712
}
719713

714+
return fe;
715+
}
716+
717+
static int mca_be_startup(struct snd_pcm_substream *substream,
718+
struct snd_soc_dai *dai)
719+
{
720+
struct snd_soc_pcm_runtime *be = snd_soc_substream_to_rtd(substream);
721+
struct snd_soc_pcm_runtime *fe = mca_be_get_fe(be, substream->stream);
722+
struct mca_cluster *cl = mca_dai_to_cluster(dai);
723+
struct mca_cluster *fe_cl;
724+
struct mca_data *mca = cl->host;
725+
720726
if (!fe)
721727
return -EINVAL;
722-
723728
fe_cl = mca_dai_to_cluster(snd_soc_rtd_to_cpu(fe, 0));
724729

725730
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {

0 commit comments

Comments
 (0)