Commit 483935fc authored by Takashi Iwai's avatar Takashi Iwai Committed by Ben Hutchings

ALSA: timer: Code cleanup

commit c3b16813 upstream.

This is a minor code cleanup without any functional changes:
- Kill keep_flag argument from _snd_timer_stop(), as all callers pass
  only it false.
- Remove redundant NULL check in _snd_timer_stop().
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
[bwh: Backported to 3.2: adjust to apply after previously backported
 "ALSA: timer: Fix race between stop and interrupt"]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 0a9c9f4c
...@@ -310,8 +310,7 @@ int snd_timer_open(struct snd_timer_instance **ti, ...@@ -310,8 +310,7 @@ int snd_timer_open(struct snd_timer_instance **ti,
return 0; return 0;
} }
static int _snd_timer_stop(struct snd_timer_instance *timeri, static int _snd_timer_stop(struct snd_timer_instance *timeri, int event);
int keep_flag, int event);
/* /*
* close a timer instance * close a timer instance
...@@ -353,7 +352,7 @@ int snd_timer_close(struct snd_timer_instance *timeri) ...@@ -353,7 +352,7 @@ int snd_timer_close(struct snd_timer_instance *timeri)
spin_unlock_irq(&timer->lock); spin_unlock_irq(&timer->lock);
mutex_lock(&register_mutex); mutex_lock(&register_mutex);
list_del(&timeri->open_list); list_del(&timeri->open_list);
if (timer && list_empty(&timer->open_list_head) && if (list_empty(&timer->open_list_head) &&
timer->hw.close) timer->hw.close)
timer->hw.close(timer); timer->hw.close(timer);
/* remove slave links */ /* remove slave links */
...@@ -505,8 +504,7 @@ int snd_timer_start(struct snd_timer_instance *timeri, unsigned int ticks) ...@@ -505,8 +504,7 @@ int snd_timer_start(struct snd_timer_instance *timeri, unsigned int ticks)
return result; return result;
} }
static int _snd_timer_stop(struct snd_timer_instance * timeri, static int _snd_timer_stop(struct snd_timer_instance *timeri, int event)
int keep_flag, int event)
{ {
struct snd_timer *timer; struct snd_timer *timer;
unsigned long flags; unsigned long flags;
...@@ -515,7 +513,6 @@ static int _snd_timer_stop(struct snd_timer_instance * timeri, ...@@ -515,7 +513,6 @@ static int _snd_timer_stop(struct snd_timer_instance * timeri,
return -ENXIO; return -ENXIO;
if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) { if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) {
if (!keep_flag) {
spin_lock_irqsave(&slave_active_lock, flags); spin_lock_irqsave(&slave_active_lock, flags);
if (!(timeri->flags & SNDRV_TIMER_IFLG_RUNNING)) { if (!(timeri->flags & SNDRV_TIMER_IFLG_RUNNING)) {
spin_unlock_irqrestore(&slave_active_lock, flags); spin_unlock_irqrestore(&slave_active_lock, flags);
...@@ -529,7 +526,6 @@ static int _snd_timer_stop(struct snd_timer_instance * timeri, ...@@ -529,7 +526,6 @@ static int _snd_timer_stop(struct snd_timer_instance * timeri,
if (timeri->timer) if (timeri->timer)
spin_unlock(&timeri->timer->lock); spin_unlock(&timeri->timer->lock);
spin_unlock_irqrestore(&slave_active_lock, flags); spin_unlock_irqrestore(&slave_active_lock, flags);
}
goto __end; goto __end;
} }
timer = timeri->timer; timer = timeri->timer;
...@@ -555,9 +551,7 @@ static int _snd_timer_stop(struct snd_timer_instance * timeri, ...@@ -555,9 +551,7 @@ static int _snd_timer_stop(struct snd_timer_instance * timeri,
} }
} }
} }
if (!keep_flag) timeri->flags &= ~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START);
timeri->flags &=
~(SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START);
spin_unlock_irqrestore(&timer->lock, flags); spin_unlock_irqrestore(&timer->lock, flags);
__end: __end:
if (event != SNDRV_TIMER_EVENT_RESOLUTION) if (event != SNDRV_TIMER_EVENT_RESOLUTION)
...@@ -576,7 +570,7 @@ int snd_timer_stop(struct snd_timer_instance *timeri) ...@@ -576,7 +570,7 @@ int snd_timer_stop(struct snd_timer_instance *timeri)
unsigned long flags; unsigned long flags;
int err; int err;
err = _snd_timer_stop(timeri, 0, SNDRV_TIMER_EVENT_STOP); err = _snd_timer_stop(timeri, SNDRV_TIMER_EVENT_STOP);
if (err < 0) if (err < 0)
return err; return err;
timer = timeri->timer; timer = timeri->timer;
...@@ -625,7 +619,7 @@ int snd_timer_continue(struct snd_timer_instance *timeri) ...@@ -625,7 +619,7 @@ int snd_timer_continue(struct snd_timer_instance *timeri)
*/ */
int snd_timer_pause(struct snd_timer_instance * timeri) int snd_timer_pause(struct snd_timer_instance * timeri)
{ {
return _snd_timer_stop(timeri, 0, SNDRV_TIMER_EVENT_PAUSE); return _snd_timer_stop(timeri, SNDRV_TIMER_EVENT_PAUSE);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment