[svn-commits] russell: linux/trunk r4675 - /linux/trunk/drivers/dahdi/dahdi-base.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Sat Aug 2 17:23:43 CDT 2008
Author: russell
Date: Sat Aug 2 17:23:42 2008
New Revision: 4675
URL: http://svn.digium.com/view/dahdi?view=rev&rev=4675
Log:
Convert dahdi timers to a kernel list instead of an open coded list
Modified:
linux/trunk/drivers/dahdi/dahdi-base.c
Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=4675&r1=4674&r2=4675
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Sat Aug 2 17:23:42 2008
@@ -292,14 +292,16 @@
#define dahdi_kernel_fpu_begin kernel_fpu_begin
#endif
-static struct dahdi_timer {
+struct dahdi_timer {
int ms; /* Countdown */
int pos; /* Position */
int ping; /* Whether we've been ping'd */
int tripped; /* Whether we're tripped */
- struct dahdi_timer *next; /* Linked list */
+ struct list_head list;
wait_queue_head_t sel;
-} *zaptimers = NULL;
+};
+
+LIST_HEAD(zaptimers);
#ifdef DEFINE_SPINLOCK
static DEFINE_SPINLOCK(zaptimerlock);
@@ -2329,7 +2331,8 @@
/* I/O Mask, etc */
chan->iomask = 0;
/* release conference resource if any */
- if (chan->confna) dahdi_check_conf(chan->confna);
+ if (chan->confna)
+ dahdi_check_conf(chan->confna);
if ((chan->sig & __DAHDI_SIG_DACS) != __DAHDI_SIG_DACS) {
chan->confna = 0;
chan->confmode = 0;
@@ -2398,11 +2401,11 @@
return -ENOMEM;
init_waitqueue_head(&t->sel);
+ INIT_LIST_HEAD(&t->list);
file->private_data = t;
spin_lock_irqsave(&zaptimerlock, flags);
- t->next = zaptimers;
- zaptimers = t;
+ list_add(&t->list, &zaptimers);
spin_unlock_irqrestore(&zaptimerlock, flags);
return 0;
@@ -2410,7 +2413,7 @@
static int dahdi_timer_release(struct inode *inode, struct file *file)
{
- struct dahdi_timer *t, *cur, *prev = NULL;
+ struct dahdi_timer *t, *cur, *next;
unsigned long flags;
if (!(t = file->private_data))
@@ -2418,16 +2421,11 @@
spin_lock_irqsave(&zaptimerlock, flags);
- for (cur = zaptimers; cur; prev = cur, cur = cur->next) {
- if (t == cur)
+ list_for_each_entry_safe(cur, next, &zaptimers, list) {
+ if (t == cur) {
+ list_del(&cur->list);
break;
- }
-
- if (cur) {
- if (prev)
- prev->next = cur->next;
- else
- zaptimers = cur->next;
+ }
}
spin_unlock_irqrestore(&zaptimerlock, flags);
@@ -2437,7 +2435,7 @@
return 0;
}
- kfree(t);
+ kfree(cur);
return 0;
}
@@ -7133,9 +7131,10 @@
{
unsigned long flags;
struct dahdi_timer *cur;
+
spin_lock_irqsave(&zaptimerlock, flags);
- cur = zaptimers;
- while(cur) {
+
+ list_for_each_entry(cur, &zaptimers, list) {
if (cur->ms) {
cur->pos -= DAHDI_CHUNKSIZE;
if (cur->pos <= 0) {
@@ -7144,8 +7143,8 @@
wake_up_interruptible(&cur->sel);
}
}
- cur = cur->next;
- }
+ }
+
spin_unlock_irqrestore(&zaptimerlock, flags);
}
More information about the svn-commits
mailing list