diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2017-09-26 00:40:42 +0000 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-09-26 09:19:33 -0700 |
commit | 75ab9eb6f15bad78b3ce274c699c27dc98ab13ce (patch) | |
tree | 22a53174bcd06a07710e8c17f521017f21a03994 /sound/soc/soc-core.c | |
parent | 74b33b8481e7c8a66149093f691b9082b50e24fc (diff) | |
download | blackbird-obmc-linux-75ab9eb6f15bad78b3ce274c699c27dc98ab13ce.tar.gz blackbird-obmc-linux-75ab9eb6f15bad78b3ce274c699c27dc98ab13ce.zip |
ASoC: add null_snd_soc_ops and reduce NULL ops check
Double NULL pointer check for ops and ops->func is difficult to read
and might be forget to check it if new func was add.
This patch adds new null_snd_soc_ops and use it if rtd->dai_link didn't
have it to avoid NULL ops, and reduces ops NULL check.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index e16220600e51..1b5b51952718 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -614,6 +614,8 @@ struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(snd_soc_get_dai_substream); +static const struct snd_soc_ops null_snd_soc_ops; + static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { @@ -626,6 +628,9 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( INIT_LIST_HEAD(&rtd->component_list); rtd->card = card; rtd->dai_link = dai_link; + if (!rtd->dai_link->ops) + rtd->dai_link->ops = &null_snd_soc_ops; + rtd->codec_dais = kzalloc(sizeof(struct snd_soc_dai *) * dai_link->num_codecs, GFP_KERNEL); |