[PATCH 1/2] ALSA: hrtimer: Use manual start/stop in callback (v3)

From: Takashi Iwai
Date: Wed Apr 20 2016 - 06:10:10 EST


With the new SNDRV_TIMER_HW_RET_CTRL flag, hrtimer can manage the
callback behavior more correctly. Now it gets a return value from
snd_timer_interrupt() whether to reprogram or stop the timer, and it
can choose the right return value; i.e. we just return
HRTIMER_NORESTART from the handler when the timer is being stopped.

Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
sound/core/hrtimer.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sound/core/hrtimer.c b/sound/core/hrtimer.c
index 656d9a9032dc..79762444bc79 100644
--- a/sound/core/hrtimer.c
+++ b/sound/core/hrtimer.c
@@ -46,12 +46,17 @@ static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt)
struct snd_hrtimer *stime = container_of(hrt, struct snd_hrtimer, hrt);
struct snd_timer *t = stime->timer;
unsigned long oruns;
+ int ret;

if (!atomic_read(&stime->running))
return HRTIMER_NORESTART;

oruns = hrtimer_forward_now(hrt, ns_to_ktime(t->sticks * resolution));
- snd_timer_interrupt(stime->timer, t->sticks * oruns);
+ ret = snd_timer_interrupt(stime->timer, t->sticks * oruns);
+ if (ret == SNDRV_TIMER_RET_STOP) {
+ atomic_set(&stime->running, 0);
+ return HRTIMER_NORESTART;
+ }

if (!atomic_read(&stime->running))
return HRTIMER_NORESTART;
--
2.8.1


--Multipart_Sun_Apr_24_18:16:12_2016-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="0002-ALSA-timer-Introduce-stop_sync-op.patch"
Content-Transfer-Encoding: 7bit