From ae158b038ae61289b0bfcb0b744610e89f80ee2a Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Fri, 26 Feb 2010 18:51:49 +0000 Subject: dahdi_dynamic: Changes to allow to compile against vanilla 2.6.9 kernel. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@8140 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/dahdi_dynamic.c | 9 +++++++-- drivers/dahdi/dahdi_dynamic_ethmf.c | 20 ++++++++++++++++++++ include/dahdi/kernel.h | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c index 8fdf945..f914e21 100644 --- a/drivers/dahdi/dahdi_dynamic.c +++ b/drivers/dahdi/dahdi_dynamic.c @@ -113,10 +113,15 @@ struct dahdi_dynamic { struct list_head list; }; +#ifdef DEFINE_SPINLOCK static DEFINE_SPINLOCK(dspan_lock); -static LIST_HEAD(dspan_list); - static DEFINE_SPINLOCK(driver_lock); +#else +static spinlock_t dspan_lock = SPIN_LOCK_UNLOCKED; +static spinlock_t driver_lock = SPIN_LOCK_UNLOCKED; +#endif + +static LIST_HEAD(dspan_list); static LIST_HEAD(driver_list); static int debug = 0; diff --git a/drivers/dahdi/dahdi_dynamic_ethmf.c b/drivers/dahdi/dahdi_dynamic_ethmf.c index 78068a5..a88fc37 100644 --- a/drivers/dahdi/dahdi_dynamic_ethmf.c +++ b/drivers/dahdi/dahdi_dynamic_ethmf.c @@ -129,7 +129,11 @@ struct ztdeth { /** * Lock for adding and removing items in ethmf_list */ +#ifdef DEFINE_SPINLOCK static DEFINE_SPINLOCK(ethmf_lock); +#else +static spinlock_t ethmf_lock = SPIN_LOCK_UNLOCKED; +#endif /** * The active list of all running spans @@ -396,6 +400,10 @@ static int ztdethmf_transmit(void *pvt, unsigned char *msg, int msglen) struct net_device *dev; unsigned char addr[ETH_ALEN]; int spans_ready = 0, index = 0; +#if LINUX_VERSION < KERNEL_VERSION(2, 6, 18) + static spinlock_t lock = SPIN_LOCK_UNLOCKED; + unsigned long flags; +#endif if (atomic_read(&shutdown)) return 0; @@ -407,12 +415,24 @@ static int ztdethmf_transmit(void *pvt, unsigned char *msg, int msglen) return 0; } +#if LINUX_VERSION < KERNEL_VERSION(2, 6, 18) + if (!atomic_read(&z->ready)) { + spin_lock_irqsave(&lock, flags); + atomic_inc(&z->ready); + if (1 == atomic_read(&z->ready)) { + memcpy(z->msgbuf, msg, msglen); + z->msgbuf_len = msglen; + } + spin_unlock_irqrestore(&lock, flags); + } +#else if (!atomic_read(&z->ready)) { if (atomic_inc_return(&z->ready) == 1) { memcpy(z->msgbuf, msg, msglen); z->msgbuf_len = msglen; } } +#endif spans_ready = ethmf_trx_spans_ready(z->addr_hash, &ready_spans); if (spans_ready) { diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h index 563af82..7d56b42 100644 --- a/include/dahdi/kernel.h +++ b/include/dahdi/kernel.h @@ -1181,6 +1181,7 @@ static inline short dahdi_txtone_nextsample(struct dahdi_chan *ss) (signal_pending((p)) && sigismember(&(p)->pending.signal, SIGKILL)) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18) +#define synchronize_rcu() synchronize_kernel() static inline void list_replace(struct list_head *old, struct list_head *new) { new->next = old->next; -- cgit v1.2.3