diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 7283f0f18813..ddd4da058693 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -100,6 +100,7 @@ struct dummy_timer_ops { int (*prepare)(struct snd_pcm_substream *); int (*start)(struct snd_pcm_substream *); int (*stop)(struct snd_pcm_substream *); + int (*sync_stop)(struct snd_pcm_substream *); snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *); }; @@ -407,9 +408,12 @@ static int dummy_hrtimer_stop(struct snd_pcm_substream *substream) return 0; } -static inline void dummy_hrtimer_sync(struct dummy_hrtimer_pcm *dpcm) +static int dummy_hrtimer_sync_stop(struct snd_pcm_substream *substream) { + struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data; + hrtimer_cancel(&dpcm->timer); + return 0; } static snd_pcm_uframes_t @@ -435,7 +439,6 @@ static int dummy_hrtimer_prepare(struct snd_pcm_substream *substream) long sec; unsigned long nsecs; - dummy_hrtimer_sync(dpcm); period = runtime->period_size; rate = runtime->rate; sec = period / rate; @@ -463,7 +466,7 @@ static int dummy_hrtimer_create(struct snd_pcm_substream *substream) static void dummy_hrtimer_free(struct snd_pcm_substream *substream) { struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data; - dummy_hrtimer_sync(dpcm); + kfree(dpcm); } @@ -473,6 +476,7 @@ static const struct dummy_timer_ops dummy_hrtimer_ops = { .prepare = dummy_hrtimer_prepare, .start = dummy_hrtimer_start, .stop = dummy_hrtimer_stop, + .sync_stop = dummy_hrtimer_sync_stop, .pointer = dummy_hrtimer_pointer, }; @@ -495,6 +499,13 @@ static int dummy_pcm_trigger(struct snd_pcm_substream *substream, int cmd) return -EINVAL; } +static int dummy_pcm_sync_stop(struct snd_pcm_substream *substream) +{ + if (get_dummy_ops(substream)->sync_stop) + return get_dummy_ops(substream)->sync_stop(substream); + return 0; +} + static int dummy_pcm_prepare(struct snd_pcm_substream *substream) { return get_dummy_ops(substream)->prepare(substream); @@ -646,6 +657,7 @@ static const struct snd_pcm_ops dummy_pcm_ops = { .hw_params = dummy_pcm_hw_params, .prepare = dummy_pcm_prepare, .trigger = dummy_pcm_trigger, + .sync_stop = dummy_pcm_sync_stop, .pointer = dummy_pcm_pointer, }; @@ -655,6 +667,7 @@ static const struct snd_pcm_ops dummy_pcm_ops_no_buf = { .hw_params = dummy_pcm_hw_params, .prepare = dummy_pcm_prepare, .trigger = dummy_pcm_trigger, + .sync_stop = dummy_pcm_sync_stop, .pointer = dummy_pcm_pointer, .copy = dummy_pcm_copy, .fill_silence = dummy_pcm_silence,