Commit 6cadcfe1 authored by Peter Wächtler's avatar Peter Wächtler Committed by Linus Torvalds

[PATCH] oss/sound_timer.c - convert cli to spinlocks

parent 8531bffd
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Thomas Sailer : ioctl code reworked (vmalloc/vfree removed) * Thomas Sailer : ioctl code reworked (vmalloc/vfree removed)
*/ */
#include <linux/string.h> #include <linux/string.h>
#include <linux/spinlock.h>
#include "sound_config.h" #include "sound_config.h"
...@@ -26,6 +26,7 @@ static unsigned long prev_event_time; ...@@ -26,6 +26,7 @@ static unsigned long prev_event_time;
static volatile unsigned long usecs_per_tmr; /* Length of the current interval */ static volatile unsigned long usecs_per_tmr; /* Length of the current interval */
static struct sound_lowlev_timer *tmr; static struct sound_lowlev_timer *tmr;
static spinlock_t lock;
static unsigned long tmr2ticks(int tmr_value) static unsigned long tmr2ticks(int tmr_value)
{ {
...@@ -80,15 +81,14 @@ static void tmr_reset(void) ...@@ -80,15 +81,14 @@ static void tmr_reset(void)
{ {
unsigned long flags; unsigned long flags;
save_flags(flags); spin_lock_irqsave(&lock,flags);
cli();
tmr_offs = 0; tmr_offs = 0;
ticks_offs = 0; ticks_offs = 0;
tmr_ctr = 0; tmr_ctr = 0;
next_event_time = (unsigned long) -1; next_event_time = (unsigned long) -1;
prev_event_time = 0; prev_event_time = 0;
curr_ticks = 0; curr_ticks = 0;
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
} }
static int timer_open(int dev, int mode) static int timer_open(int dev, int mode)
...@@ -278,6 +278,8 @@ static struct sound_timer_operations sound_timer = ...@@ -278,6 +278,8 @@ static struct sound_timer_operations sound_timer =
void sound_timer_interrupt(void) void sound_timer_interrupt(void)
{ {
unsigned long flags;
if (!opened) if (!opened)
return; return;
...@@ -286,6 +288,7 @@ void sound_timer_interrupt(void) ...@@ -286,6 +288,7 @@ void sound_timer_interrupt(void)
if (!tmr_running) if (!tmr_running)
return; return;
spin_lock_irqsave(&lock,flags);
tmr_ctr++; tmr_ctr++;
curr_ticks = ticks_offs + tmr2ticks(tmr_ctr); curr_ticks = ticks_offs + tmr2ticks(tmr_ctr);
...@@ -294,6 +297,7 @@ void sound_timer_interrupt(void) ...@@ -294,6 +297,7 @@ void sound_timer_interrupt(void)
next_event_time = (unsigned long) -1; next_event_time = (unsigned long) -1;
sequencer_timer(0); sequencer_timer(0);
} }
spin_unlock_irqrestore(&lock,flags);
} }
void sound_timer_init(struct sound_lowlev_timer *t, char *name) void sound_timer_init(struct sound_lowlev_timer *t, char *name)
......
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