patch-2.4.0-test7 linux/drivers/sound/emu10k1/timer.c

Next file: linux/drivers/sound/emu10k1/timer.h
Previous file: linux/drivers/sound/emu10k1/recmgr.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test6/linux/drivers/sound/emu10k1/timer.c linux/drivers/sound/emu10k1/timer.c
@@ -29,6 +29,9 @@
 /* 4/3/2000	Implemented timer list using list.h 	     Rui Sousa */
 
 #include "hwaccess.h"
+#include "8010.h"
+#include "irqmgr.h"
+#include "timer.h"
 
 /* Try to schedule only once per fragment */
 
@@ -42,7 +45,7 @@
 	list_for_each(entry, &card->timers) {
 		t = list_entry(entry, struct emu_timer, list);
 
-		if (t->active) {
+		if (t->state & TIMER_STATE_ACTIVE) {
 			t->count++;
 			if (t->count == t->count_max) {
 				t->count = 0;
@@ -56,22 +59,17 @@
 	return;
 }
 
-struct emu_timer *emu10k1_timer_install(struct emu10k1_card *card, void (*func) (unsigned long), unsigned long data, u32 delay)
+void emu10k1_timer_install(struct emu10k1_card *card, struct emu_timer *timer, u32 delay)
 {
-	struct emu_timer *timer;
 	struct emu_timer *t;
 	struct list_head *entry;
 	unsigned long flags;
 
-	if ((timer = (struct emu_timer *) kmalloc(sizeof(struct emu_timer), GFP_KERNEL)) == NULL)
-		return timer;
-
 	if (delay < 5)
 		delay = 5;
 
 	timer->delay = delay;
-	tasklet_init(&timer->tasklet, func, data);
-	timer->active = 0;
+	timer->state = TIMER_STATE_INSTALLED;
 
 	spin_lock_irqsave(&card->timer_lock, flags);
 
@@ -87,7 +85,7 @@
 		card->timer_delay = delay;
 		delay = (delay < 1024 ? delay : 1024);
 
-		WRITE_FN0(card, TIMER_RATE, delay);
+		emu10k1_writefn0(card, TIMER_RATE, delay);
 
 		list_for_each(entry, &card->timers) {
 			t = list_entry(entry, struct emu_timer, list);
@@ -103,7 +101,7 @@
 
 	spin_unlock_irqrestore(&card->timer_lock, flags);
 
-	return timer;
+	return;
 }
 
 void emu10k1_timer_uninstall(struct emu10k1_card *card, struct emu_timer *timer)
@@ -113,6 +111,9 @@
 	u32 delay = TIMER_STOPPED;
 	unsigned long flags;
 
+	if (timer->state == TIMER_STATE_UNINSTALLED)
+		return;
+
 	spin_lock_irqsave(&card->timer_lock, flags);
 
 	list_del(&timer->list);
@@ -132,7 +133,7 @@
 		else {
 			delay = (delay < 1024 ? delay : 1024);
 
-			WRITE_FN0(card, TIMER_RATE, delay);
+			emu10k1_writefn0(card, TIMER_RATE, delay);
 
 			list_for_each(entry, &card->timers) {
 				t = list_entry(entry, struct emu_timer, list);
@@ -147,8 +148,7 @@
 
 	spin_unlock_irqrestore(&card->timer_lock, flags);
 
-	tasklet_unlock_wait(&timer->tasklet);
-	kfree(timer);
+	timer->state = TIMER_STATE_UNINSTALLED;
 
 	return;
 }
@@ -158,7 +158,7 @@
 	unsigned long flags;
 
 	spin_lock_irqsave(&card->timer_lock, flags);
-	timer->active = 1;
+	timer->state |= TIMER_STATE_ACTIVE;
 	spin_unlock_irqrestore(&card->timer_lock, flags);
 
 	return;
@@ -169,7 +169,7 @@
 	unsigned long flags;
 
 	spin_lock_irqsave(&card->timer_lock, flags);
-	timer->active = 0;
+	timer->state &= ~TIMER_STATE_ACTIVE;
 	spin_unlock_irqrestore(&card->timer_lock, flags);
 
 	return;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)