diff options
author | Shaun Ruffell <sruffell@digium.com> | 2010-11-04 16:40:53 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2010-11-04 16:40:53 +0000 |
commit | 8b7ede56279bbf1f47105c0cdc18741659290848 (patch) | |
tree | e8f11075d120a0e77f312cca98a515dab4d6050b /drivers/dahdi/wctdm24xxp | |
parent | d265ee1dbebb904c51c0a7f519b1bfca40e47e9d (diff) |
wctdm24xxp: Replace 'schluffen()' with 'interruptible_sleep_on()'
'schluffen()' essentially duplicates the functionality of the standard
Linux 'interruptible_sleep_on()' function.
There may still be some race conditions that can be closed here, but
most of the command queue processing is sloted for conversion to
something more like in the single span driver in order to reduce the
time in interrupt context spent scanning for commands to the modules.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9469 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/wctdm24xxp')
-rw-r--r-- | drivers/dahdi/wctdm24xxp/base.c | 37 | ||||
-rw-r--r-- | drivers/dahdi/wctdm24xxp/wctdm24xxp.h | 3 | ||||
-rw-r--r-- | drivers/dahdi/wctdm24xxp/xhfc.c | 2 |
3 files changed, 15 insertions, 27 deletions
diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c index 4a287fc..af838cb 100644 --- a/drivers/dahdi/wctdm24xxp/base.c +++ b/drivers/dahdi/wctdm24xxp/base.c @@ -296,19 +296,6 @@ static inline int CMD_BYTE(int card, int bit, int altcs) + ((card) >> 2) + (altcs) + ((altcs) ? -21 : 0)); } -/* sleep in user space until woken up. Equivilant of tsleep() in BSD */ -int schluffen(wait_queue_head_t *q) -{ - DECLARE_WAITQUEUE(wait, current); - add_wait_queue(q, &wait); - current->state = TASK_INTERRUPTIBLE; - if (!signal_pending(current)) schedule(); - current->state = TASK_RUNNING; - remove_wait_queue(q, &wait); - if (signal_pending(current)) return -ERESTARTSYS; - return(0); -} - static inline int empty_slot(struct wctdm *wc, int card) { int x; @@ -1007,7 +994,6 @@ static inline int wctdm_setreg_full(struct wctdm *wc, int card, int addr, int va { unsigned long flags; int hit=0; - int ret; /* QRV and BRI cards are only addressed at their first "port" */ if ((card & 0x03) && ((wc->modtype[card] == MOD_TYPE_QRV) || @@ -1024,8 +1010,9 @@ static inline int wctdm_setreg_full(struct wctdm *wc, int card, int addr, int va if (inisr) break; if (hit < 0) { - if ((ret = schluffen(&wc->regq))) - return ret; + interruptible_sleep_on(&wc->regq); + if (signal_pending(current)) + return -ERESTARTSYS; } } while (hit < 0); return (hit > -1) ? 0 : -1; @@ -1059,8 +1046,9 @@ inline int wctdm_getreg(struct wctdm *wc, int card, int addr) } spin_unlock_irqrestore(&wc->reglock, flags); if (hit < 0) { - if ((ret = schluffen(&wc->regq))) - return ret; + interruptible_sleep_on(&wc->regq); + if (signal_pending(current)) + return -ERESTARTSYS; } } while (hit < 0); do { @@ -1072,8 +1060,9 @@ inline int wctdm_getreg(struct wctdm *wc, int card, int addr) } spin_unlock_irqrestore(&wc->reglock, flags); if (hit > -1) { - if ((ret = schluffen(&wc->regq))) - return ret; + interruptible_sleep_on(&wc->regq); + if (signal_pending(current)) + return -ERESTARTSYS; } } while (hit > -1); return ret; @@ -4004,7 +3993,7 @@ static int wctdm_vpm_init(struct wctdm *wc) } for (i=0;i<30;i++) - schluffen(&wc->regq); + interruptible_sleep_on(&wc->regq); /* Put in bypass mode */ for (i = 0 ; i < MAX_TDM_CHAN ; i++) { @@ -4240,7 +4229,7 @@ static int wctdm_identify_modules(struct wctdm *wc) /* Wait just a bit; this makes sure that cmd_dequeue is emitting SPI commands in the appropriate mode(s). */ for (x = 0; x < 10; x++) - schluffen(&wc->regq); + interruptible_sleep_on(&wc->regq); /* Now that all the cards have been reset, we can stop checking them all if there aren't as many */ spin_lock_irqsave(&wc->reglock, flags); @@ -4306,8 +4295,8 @@ retry: wc->modtype[x] = MOD_TYPE_FXSINIT; spin_unlock_irqrestore(&wc->reglock, flags); - schluffen(&wc->regq); - schluffen(&wc->regq); + interruptible_sleep_on(&wc->regq); + interruptible_sleep_on(&wc->regq); spin_lock_irqsave(&wc->reglock, flags); wc->modtype[x] = MOD_TYPE_FXS; diff --git a/drivers/dahdi/wctdm24xxp/wctdm24xxp.h b/drivers/dahdi/wctdm24xxp/wctdm24xxp.h index ebacff1..e24843f 100644 --- a/drivers/dahdi/wctdm24xxp/wctdm24xxp.h +++ b/drivers/dahdi/wctdm24xxp/wctdm24xxp.h @@ -204,7 +204,7 @@ struct wctdm { signed short txgain[NUM_MODULES]; spinlock_t reglock; /* held when accessing anything affecting the module array */ - wait_queue_head_t regq; /* for schluffen() */ + wait_queue_head_t regq; union { struct fxo { @@ -286,7 +286,6 @@ struct wctdm { /* Atomic flag bits for checkflag field */ #define WCTDM_CHECK_TIMING 0 -int schluffen(wait_queue_head_t *q); void wait_just_a_bit(int foo); int wctdm_getreg(struct wctdm *wc, int card, int addr); int wctdm_setreg(struct wctdm *wc, int card, int addr, int val); diff --git a/drivers/dahdi/wctdm24xxp/xhfc.c b/drivers/dahdi/wctdm24xxp/xhfc.c index ee227e0..65cdfb7 100644 --- a/drivers/dahdi/wctdm24xxp/xhfc.c +++ b/drivers/dahdi/wctdm24xxp/xhfc.c @@ -2641,7 +2641,7 @@ int wctdm_init_b400m(struct wctdm *wc, int card) spin_unlock_irqrestore(&wc->reglock, flags); for (i = 0; i < 10; i++) - schluffen(&wc->regq); + interruptible_sleep_on(&wc->regq); if (b400m_probe(wc, card) != 0) { spin_lock_irqsave(&wc->reglock, flags); |