Merge branch 'topic/component' of git://git.kernel.org/pub/scm/linux/kernel/git/broon...
authorMark Brown <broonie@kernel.org>
Mon, 25 Sep 2017 16:33:31 +0000 (17:33 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 25 Sep 2017 16:33:31 +0000 (17:33 +0100)
sound/soc/soc-core.c
sound/soc/soc-dapm.c
sound/soc/soc-pcm.c

index fee4b0ef5566cf9e8de0bf5c568706da9cab2ea2..e16220600e51e746020ce4009be4ebb127698592 100644 (file)
@@ -639,8 +639,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
 
 static void soc_free_pcm_runtime(struct snd_soc_pcm_runtime *rtd)
 {
-       if (rtd && rtd->codec_dais)
-               kfree(rtd->codec_dais);
+       kfree(rtd->codec_dais);
        snd_soc_rtdcom_del_all(rtd);
        kfree(rtd);
 }
@@ -2632,7 +2631,7 @@ EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls);
 int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
        unsigned int freq, int dir)
 {
-       if (dai->driver && dai->driver->ops->set_sysclk)
+       if (dai->driver->ops->set_sysclk)
                return dai->driver->ops->set_sysclk(dai, clk_id, freq, dir);
 
        return snd_soc_component_set_sysclk(dai->component, clk_id, 0,
@@ -2700,7 +2699,7 @@ EXPORT_SYMBOL_GPL(snd_soc_component_set_sysclk);
 int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
        int div_id, int div)
 {
-       if (dai->driver && dai->driver->ops->set_clkdiv)
+       if (dai->driver->ops->set_clkdiv)
                return dai->driver->ops->set_clkdiv(dai, div_id, div);
        else
                return -EINVAL;
@@ -2720,7 +2719,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv);
 int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
        unsigned int freq_in, unsigned int freq_out)
 {
-       if (dai->driver && dai->driver->ops->set_pll)
+       if (dai->driver->ops->set_pll)
                return dai->driver->ops->set_pll(dai, pll_id, source,
                                         freq_in, freq_out);
 
@@ -2786,7 +2785,7 @@ EXPORT_SYMBOL_GPL(snd_soc_component_set_pll);
  */
 int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
 {
-       if (dai->driver && dai->driver->ops->set_bclk_ratio)
+       if (dai->driver->ops->set_bclk_ratio)
                return dai->driver->ops->set_bclk_ratio(dai, ratio);
        else
                return -EINVAL;
@@ -2860,7 +2859,7 @@ static int snd_soc_xlate_tdm_slot_mask(unsigned int slots,
 int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
        unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
 {
-       if (dai->driver && dai->driver->ops->xlate_tdm_slot_mask)
+       if (dai->driver->ops->xlate_tdm_slot_mask)
                dai->driver->ops->xlate_tdm_slot_mask(slots,
                                                &tx_mask, &rx_mask);
        else
@@ -2869,7 +2868,7 @@ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
        dai->tx_mask = tx_mask;
        dai->rx_mask = rx_mask;
 
-       if (dai->driver && dai->driver->ops->set_tdm_slot)
+       if (dai->driver->ops->set_tdm_slot)
                return dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask,
                                slots, slot_width);
        else
@@ -2893,7 +2892,7 @@ int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
        unsigned int tx_num, unsigned int *tx_slot,
        unsigned int rx_num, unsigned int *rx_slot)
 {
-       if (dai->driver && dai->driver->ops->set_channel_map)
+       if (dai->driver->ops->set_channel_map)
                return dai->driver->ops->set_channel_map(dai, tx_num, tx_slot,
                        rx_num, rx_slot);
        else
@@ -2910,7 +2909,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_channel_map);
  */
 int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate)
 {
-       if (dai->driver && dai->driver->ops->set_tristate)
+       if (dai->driver->ops->set_tristate)
                return dai->driver->ops->set_tristate(dai, tristate);
        else
                return -EINVAL;
index dcef67a9bd4854a29c79ad8355343c5f16ae76a2..9d4748e2b67aa87def4cbba8f75459a3a695f8bf 100644 (file)
@@ -3681,7 +3681,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
        switch (event) {
        case SND_SOC_DAPM_PRE_PMU:
                substream.stream = SNDRV_PCM_STREAM_CAPTURE;
-               if (source->driver->ops && source->driver->ops->startup) {
+               if (source->driver->ops->startup) {
                        ret = source->driver->ops->startup(&substream, source);
                        if (ret < 0) {
                                dev_err(source->dev,
@@ -3695,7 +3695,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
                        goto out;
 
                substream.stream = SNDRV_PCM_STREAM_PLAYBACK;
-               if (sink->driver->ops && sink->driver->ops->startup) {
+               if (sink->driver->ops->startup) {
                        ret = sink->driver->ops->startup(&substream, sink);
                        if (ret < 0) {
                                dev_err(sink->dev,
@@ -3725,13 +3725,13 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
                ret = 0;
 
                source->active--;
-               if (source->driver->ops && source->driver->ops->shutdown) {
+               if (source->driver->ops->shutdown) {
                        substream.stream = SNDRV_PCM_STREAM_CAPTURE;
                        source->driver->ops->shutdown(&substream, source);
                }
 
                sink->active--;
-               if (sink->driver->ops && sink->driver->ops->shutdown) {
+               if (sink->driver->ops->shutdown) {
                        substream.stream = SNDRV_PCM_STREAM_PLAYBACK;
                        sink->driver->ops->shutdown(&substream, sink);
                }
index 94b88b897c3bb1acd0d8b18922a8286f5cadd081..983edd0e6e8f69d5584dec1029c679b198d450e9 100644 (file)
@@ -474,7 +474,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
        mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
        /* startup the audio subsystem */
-       if (cpu_dai->driver->ops && cpu_dai->driver->ops->startup) {
+       if (cpu_dai->driver->ops->startup) {
                ret = cpu_dai->driver->ops->startup(substream, cpu_dai);
                if (ret < 0) {
                        dev_err(cpu_dai->dev, "ASoC: can't open interface"
@@ -494,7 +494,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 
        for (i = 0; i < rtd->num_codecs; i++) {
                codec_dai = rtd->codec_dais[i];
-               if (codec_dai->driver->ops && codec_dai->driver->ops->startup) {
+               if (codec_dai->driver->ops->startup) {
                        ret = codec_dai->driver->ops->startup(substream,
                                                              codec_dai);
                        if (ret < 0) {
@@ -771,7 +771,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 
        for (i = 0; i < rtd->num_codecs; i++) {
                codec_dai = rtd->codec_dais[i];
-               if (codec_dai->driver->ops && codec_dai->driver->ops->prepare) {
+               if (codec_dai->driver->ops->prepare) {
                        ret = codec_dai->driver->ops->prepare(substream,
                                                              codec_dai);
                        if (ret < 0) {
@@ -783,7 +783,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
                }
        }
 
-       if (cpu_dai->driver->ops && cpu_dai->driver->ops->prepare) {
+       if (cpu_dai->driver->ops->prepare) {
                ret = cpu_dai->driver->ops->prepare(substream, cpu_dai);
                if (ret < 0) {
                        dev_err(cpu_dai->dev,
@@ -829,7 +829,7 @@ int soc_dai_hw_params(struct snd_pcm_substream *substream,
 {
        int ret;
 
-       if (dai->driver->ops && dai->driver->ops->hw_params) {
+       if (dai->driver->ops->hw_params) {
                ret = dai->driver->ops->hw_params(substream, params, dai);
                if (ret < 0) {
                        dev_err(dai->dev, "ASoC: can't set %s hw params: %d\n",
@@ -855,11 +855,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
        int i, ret = 0;
 
        mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
-
-       ret = soc_pcm_params_symmetry(substream, params);
-       if (ret)
-               goto out;
-
        if (rtd->dai_link->ops && rtd->dai_link->ops->hw_params) {
                ret = rtd->dai_link->ops->hw_params(substream, params);
                if (ret < 0) {
@@ -930,12 +925,16 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
        cpu_dai->sample_bits =
                snd_pcm_format_physical_width(params_format(params));
 
+
+       ret = soc_pcm_params_symmetry(substream, params);
+        if (ret)
+                goto platform_err;
 out:
        mutex_unlock(&rtd->pcm_mutex);
        return ret;
 
 platform_err:
-       if (cpu_dai->driver->ops && cpu_dai->driver->ops->hw_free)
+       if (cpu_dai->driver->ops->hw_free)
                cpu_dai->driver->ops->hw_free(substream, cpu_dai);
 
 interface_err:
@@ -944,7 +943,7 @@ interface_err:
 codec_err:
        while (--i >= 0) {
                struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
-               if (codec_dai->driver->ops && codec_dai->driver->ops->hw_free)
+               if (codec_dai->driver->ops->hw_free)
                        codec_dai->driver->ops->hw_free(substream, codec_dai);
                codec_dai->rate = 0;
        }
@@ -1005,11 +1004,11 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
        /* now free hw params for the DAIs  */
        for (i = 0; i < rtd->num_codecs; i++) {
                codec_dai = rtd->codec_dais[i];
-               if (codec_dai->driver->ops && codec_dai->driver->ops->hw_free)
+               if (codec_dai->driver->ops->hw_free)
                        codec_dai->driver->ops->hw_free(substream, codec_dai);
        }
 
-       if (cpu_dai->driver->ops && cpu_dai->driver->ops->hw_free)
+       if (cpu_dai->driver->ops->hw_free)
                cpu_dai->driver->ops->hw_free(substream, cpu_dai);
 
        mutex_unlock(&rtd->pcm_mutex);
@@ -1026,7 +1025,7 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 
        for (i = 0; i < rtd->num_codecs; i++) {
                codec_dai = rtd->codec_dais[i];
-               if (codec_dai->driver->ops && codec_dai->driver->ops->trigger) {
+               if (codec_dai->driver->ops->trigger) {
                        ret = codec_dai->driver->ops->trigger(substream,
                                                              cmd, codec_dai);
                        if (ret < 0)
@@ -1040,7 +1039,7 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
                        return ret;
        }
 
-       if (cpu_dai->driver->ops && cpu_dai->driver->ops->trigger) {
+       if (cpu_dai->driver->ops->trigger) {
                ret = cpu_dai->driver->ops->trigger(substream, cmd, cpu_dai);
                if (ret < 0)
                        return ret;
@@ -1065,8 +1064,7 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream,
 
        for (i = 0; i < rtd->num_codecs; i++) {
                codec_dai = rtd->codec_dais[i];
-               if (codec_dai->driver->ops &&
-                   codec_dai->driver->ops->bespoke_trigger) {
+               if (codec_dai->driver->ops->bespoke_trigger) {
                        ret = codec_dai->driver->ops->bespoke_trigger(substream,
                                                                cmd, codec_dai);
                        if (ret < 0)
@@ -1074,7 +1072,7 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream,
                }
        }
 
-       if (cpu_dai->driver->ops && cpu_dai->driver->ops->bespoke_trigger) {
+       if (cpu_dai->driver->ops->bespoke_trigger) {
                ret = cpu_dai->driver->ops->bespoke_trigger(substream, cmd, cpu_dai);
                if (ret < 0)
                        return ret;
@@ -1101,12 +1099,12 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
        if (platform->driver->ops && platform->driver->ops->pointer)
                offset = platform->driver->ops->pointer(substream);
 
-       if (cpu_dai->driver->ops && cpu_dai->driver->ops->delay)
+       if (cpu_dai->driver->ops->delay)
                delay += cpu_dai->driver->ops->delay(substream, cpu_dai);
 
        for (i = 0; i < rtd->num_codecs; i++) {
                codec_dai = rtd->codec_dais[i];
-               if (codec_dai->driver->ops && codec_dai->driver->ops->delay)
+               if (codec_dai->driver->ops->delay)
                        codec_delay = max(codec_delay,
                                        codec_dai->driver->ops->delay(substream,
                                                                    codec_dai));