[PORT FROM R2] [AUDIO] Worker thread cancelled late on close function call
authorhe bo <bo.he@intel.com>
Sat, 31 Mar 2012 01:58:39 +0000 (09:58 +0800)
committerbuildbot <buildbot@intel.com>
Fri, 6 Apr 2012 23:04:01 +0000 (16:04 -0700)
BZ: 29782

Cancel the workqueue first and then close it to avoid close
and the workqueue is still running.

Change-Id: I943e68a5430a250d47acf2d3106a5a810b9a13c6
Signed-off-by: he, bo <bo.he@intel.com>
Signed-off-by: zhang, yanmin <yanmin.zhang@intel.com>
Reviewed-on: http://android.intel.com:8080/41935
Reviewed-by: Mendi, EduardoX <eduardox.mendi@intel.com>
Tested-by: Mendi, EduardoX <eduardox.mendi@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
sound/pci/intel_mid_i2s/intel_alsa_ifx_snd_card.c
sound/pci/intel_mid_i2s/intel_alsa_ssp_snd_card.c

index 92c536a..195c88c 100644 (file)
@@ -162,9 +162,13 @@ int snd_i2s_alsa_ifx_close(struct snd_pcm_substream *substream)
        WARN(!substream->runtime, "ALSA_IFX: ERROR NULL substream->runtime\n");
        if (!substream->runtime)
                return -EINVAL;
+
        str_info = substream->runtime->private_data;
 
        if (str_info) {
+               /* Cancel pending work */
+               cancel_work_sync(&str_info->ssp_ws);
+
                /* SST API to actually stop/free the stream */
                ret_val = intel_alsa_ifx_control(INTEL_ALSA_SSP_CTRL_SND_CLOSE,
                                str_info);
@@ -184,9 +188,6 @@ int snd_i2s_alsa_ifx_close(struct snd_pcm_substream *substream)
                        p_alsa_ifx_snd_card->playback_cnt,
                        p_alsa_ifx_snd_card->capture_cnt);
 
-       /* Cancel pending work */
-       cancel_work_sync(&str_info->ssp_ws);
-
        kfree(substream->runtime->private_data);
 
        return ret_val;
index 9954006..c2d9747 100644 (file)
@@ -161,9 +161,13 @@ int snd_i2s_alsa_close(struct snd_pcm_substream *substream)
        WARN(!substream->runtime, "ALSA_SSP: ERROR NULL substream->runtime\n");
        if (!substream->runtime)
                return -EINVAL;
+
        str_info = substream->runtime->private_data;
 
        if (str_info) {
+               /* Cancel pending work */
+               cancel_work_sync(&str_info->ssp_ws);
+
                /* SST API to actually stop/free the stream */
                ret_val = intel_alsa_ssp_control(INTEL_ALSA_SSP_CTRL_SND_CLOSE,
                                str_info);
@@ -183,9 +187,6 @@ int snd_i2s_alsa_close(struct snd_pcm_substream *substream)
                        p_alsa_ssp_snd_card->playback_cnt,
                        p_alsa_ssp_snd_card->capture_cnt);
 
-       /* Cancel pending work */
-       cancel_work_sync(&str_info->ssp_ws);
-
        kfree(substream->runtime->private_data);
 
        return ret_val;