summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2003-06-21 19:02:54 +0000
committermarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2003-06-21 19:02:54 +0000
commiteb9d239a7edfc77870192ebdb7658ce2124d0b7e (patch)
treea2305956550a417b2e9ffbe3896f84d446a05d94
parent88a7e5e14d5a0f851f244c429cd788e7590c39b0 (diff)
Enhance spinlocks on zaptel
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@199 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rwxr-xr-xzaptel.c201
-rwxr-xr-xzaptel.h5
-rwxr-xr-xztcfg.c1
-rwxr-xr-xztd-eth.c1
4 files changed, 118 insertions, 90 deletions
diff --git a/zaptel.c b/zaptel.c
index fdb7be0..c8cbaa7 100755
--- a/zaptel.c
+++ b/zaptel.c
@@ -103,7 +103,8 @@ EXPORT_SYMBOL(zt_lboname);
EXPORT_SYMBOL(zt_transmit);
EXPORT_SYMBOL(zt_receive);
EXPORT_SYMBOL(zt_rbsbits);
-EXPORT_SYMBOL(zt_qevent);
+EXPORT_SYMBOL(zt_qevent_nolock);
+EXPORT_SYMBOL(zt_qevent_lock);
EXPORT_SYMBOL(zt_hooksig);
EXPORT_SYMBOL(zt_alarm_notify);
EXPORT_SYMBOL(zt_set_dynamic_ioctl);
@@ -570,7 +571,7 @@ static void zt_check_conf(int x)
}
/* enqueue an event on a channel */
-static void qevent(struct zt_chan *chan, int event)
+static void __qevent(struct zt_chan *chan, int event)
{
/* if full, ignore */
if ((chan->eventoutidx == 0) && (chan->eventinidx == (ZT_MAX_EVENTSIZE - 1)))
@@ -589,9 +590,17 @@ static void qevent(struct zt_chan *chan, int event)
return;
}
-void zt_qevent(struct zt_chan *chan, int event)
+void zt_qevent_nolock(struct zt_chan *chan, int event)
{
- qevent(chan, event);
+ __qevent(chan, event);
+}
+
+void zt_qevent_lock(struct zt_chan *chan, int event)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&chan->lock, flags);
+ __qevent(chan, event);
+ spin_unlock_irqrestore(&chan->lock, flags);
}
/* sleep in user space until woken up. Equivilant of tsleep() in BSD */
@@ -699,7 +708,7 @@ static void zt_set_law(struct zt_chan *chan, int law);
/* Pull a ZT_CHUNKSIZE piece off the queue. Returns
0 on success or -1 on failure. If failed, provides
silence */
-static int buf_pull(struct confq *q, u_char *data, struct zt_chan *c, char *label)
+static int __buf_pull(struct confq *q, u_char *data, struct zt_chan *c, char *label)
{
int oldoutbuf = q->outbuf;
/* Ain't nuffin to read */
@@ -727,14 +736,14 @@ static int buf_pull(struct confq *q, u_char *data, struct zt_chan *c, char *labe
/* Returns a place to put stuff, or NULL if there is
no room */
-static u_char *buf_pushpeek(struct confq *q)
+static u_char *__buf_pushpeek(struct confq *q)
{
if (q->inbuf < 0)
return NULL;
return q->buf[q->inbuf];
}
-static u_char *buf_peek(struct confq *q)
+static u_char *__buf_peek(struct confq *q)
{
if (q->outbuf < 0)
return NULL;
@@ -742,7 +751,7 @@ static u_char *buf_peek(struct confq *q)
}
#ifdef BUF_MUNGE
-static u_char *buf_cpush(struct confq *q)
+static u_char *__buf_cpush(struct confq *q)
{
int pos;
/* If we have no space, return where the
@@ -755,7 +764,7 @@ static u_char *buf_cpush(struct confq *q)
return q->buf[pos];
}
-static void buf_munge(struct zt_chan *chan, u_char *old, u_char *new)
+static void __buf_munge(struct zt_chan *chan, u_char *old, u_char *new)
{
/* Run a weighted average of the old and new, in order to
mask a missing sample */
@@ -770,7 +779,7 @@ static void buf_munge(struct zt_chan *chan, u_char *old, u_char *new)
#endif
/* Push something onto the queue, or assume what
is there is valid if data is NULL */
-static int buf_push(struct confq *q, u_char *data, char *label)
+static int __buf_push(struct confq *q, u_char *data, char *label)
{
int oldinbuf = q->inbuf;
if (q->inbuf < 0) {
@@ -2222,10 +2231,10 @@ struct zt_tone *zt_dtmf_tone(char digit, int mf)
return NULL;
}
-static inline void do_dtmf(struct zt_chan *chan)
+static void __do_dtmf(struct zt_chan *chan)
{
char c;
-
+ /* Called with chan->lock held */
while (strlen(chan->txdialbuf)) {
c = chan->txdialbuf[0];
/* Skooch */
@@ -2253,7 +2262,7 @@ static inline void do_dtmf(struct zt_chan *chan)
}
/* Notify userspace process if there is nothing left */
chan->dialing = 0;
- qevent(chan, ZT_EVENT_DIALCOMPLETE);
+ __qevent(chan, ZT_EVENT_DIALCOMPLETE);
}
static int zt_release(struct inode *inode, struct file *file)
@@ -2308,7 +2317,7 @@ void zt_alarm_notify(struct zt_span *span)
j = ZT_EVENT_NOALARM;
span->lastalarms = span->alarms;
for (x=0;x < span->channels;x++)
- qevent(&span->chans[x], j);
+ zt_qevent_lock(&span->chans[x], j);
}
}
@@ -2973,7 +2982,7 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign
case ZT_DIAL_OP_REPLACE:
strcpy(chan->txdialbuf, tdo.dialstr);
chan->dialing = 1;
- do_dtmf(chan);
+ __do_dtmf(chan);
break;
case ZT_DIAL_OP_APPEND:
if (strlen(tdo.dialstr) + strlen(chan->txdialbuf) >= ZT_MAX_DTMF_BUF)
@@ -2982,7 +2991,7 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign
if (!chan->dialing)
{
chan->dialing = 1;
- do_dtmf(chan);
+ __do_dtmf(chan);
}
break;
default:
@@ -4050,9 +4059,10 @@ static void __init zt_conv_init(void)
#endif
}
-static inline void zt_process_getaudio_chunk(struct zt_chan *ss, unsigned char *txb)
+static inline void __zt_process_getaudio_chunk(struct zt_chan *ss, unsigned char *txb)
{
/* We transmit data from our master channel */
+ /* Called with ss->lock held */
struct zt_chan *ms = ss->master;
/* Linear representation */
short getlin[ZT_CHUNKSIZE], k[ZT_CHUNKSIZE];
@@ -4203,8 +4213,9 @@ static inline void zt_process_getaudio_chunk(struct zt_chan *ss, unsigned char *
txb[x] = ms->txgain[txb[x]];
}
-static inline void zt_getbuf_chunk(struct zt_chan *ss, unsigned char *txb)
+static inline void __zt_getbuf_chunk(struct zt_chan *ss, unsigned char *txb)
{
+ /* Called with ss->lock held */
/* We transmit data from our master channel */
struct zt_chan *ms = ss->master;
/* Buffer we're using */
@@ -4316,7 +4327,7 @@ out in the later versions, and is put back now. */
if (!ms->curtone) {
/* No more tones... Is this dtmf or mf? If so, go to the next digit */
if (ms->dialing)
- do_dtmf(ms);
+ __do_dtmf(ms);
} else {
if (last != ms->curtone)
zt_init_tone_state(&ms->ts, ms->curtone);
@@ -4346,25 +4357,26 @@ static inline void rbs_itimer_expire(struct zt_chan *chan)
{
/* the only way this could have gotten here, is if a channel
went off hook longer then the wink or flash detect timeout */
-
+ /* Called with chan->lock held */
switch(chan->sig)
{
case ZT_SIG_FXOLS: /* if FXO, its definitely on hook */
case ZT_SIG_FXOGS:
case ZT_SIG_FXOKS:
- qevent(chan,ZT_EVENT_ONHOOK);
+ __qevent(chan,ZT_EVENT_ONHOOK);
chan->gotgs = 0;
break;
default: /* otherwise, its definitely off hook */
- qevent(chan,ZT_EVENT_RINGOFFHOOK);
+ __qevent(chan,ZT_EVENT_RINGOFFHOOK);
break;
}
}
-static inline void rbs_otimer_expire(struct zt_chan *chan)
+static inline void __rbs_otimer_expire(struct zt_chan *chan)
{
int len = 0;
+ /* Called with chan->lock held */
chan->otimer = 0;
/* Move to the next timer state */
@@ -4382,7 +4394,7 @@ static inline void rbs_otimer_expire(struct zt_chan *chan)
}
zt_rbs_sethook(chan, ZT_TXSIG_START, ZT_TXSTATE_RINGON, len);
- qevent(chan, ZT_EVENT_RINGERON);
+ __qevent(chan, ZT_EVENT_RINGERON);
break;
case ZT_TXSTATE_RINGON:
@@ -4398,7 +4410,7 @@ static inline void rbs_otimer_expire(struct zt_chan *chan)
}
zt_rbs_sethook(chan, ZT_TXSIG_OFFHOOK, ZT_TXSTATE_RINGOFF, len);
- qevent(chan, ZT_EVENT_RINGEROFF);
+ __qevent(chan, ZT_EVENT_RINGEROFF);
break;
case ZT_TXSTATE_START:
@@ -4416,7 +4428,7 @@ static inline void rbs_otimer_expire(struct zt_chan *chan)
/* Wink complete, go on hook and stabalize */
zt_rbs_sethook(chan, ZT_TXSIG_ONHOOK, ZT_TXSTATE_ONHOOK, 0);
if (chan->file && (chan->file->f_flags & O_NONBLOCK))
- qevent(chan, ZT_EVENT_HOOKCOMPLETE);
+ __qevent(chan, ZT_EVENT_HOOKCOMPLETE);
wake_up_interruptible(&chan->txstateq);
break;
@@ -4428,7 +4440,7 @@ static inline void rbs_otimer_expire(struct zt_chan *chan)
case ZT_TXSTATE_FLASH:
zt_rbs_sethook(chan, ZT_TXSIG_OFFHOOK, ZT_TXSTATE_OFFHOOK, 0);
if (chan->file && (chan->file->f_flags & O_NONBLOCK))
- qevent(chan, ZT_EVENT_HOOKCOMPLETE);
+ __qevent(chan, ZT_EVENT_HOOKCOMPLETE);
wake_up_interruptible(&chan->txstateq);
break;
@@ -4440,20 +4452,20 @@ static inline void rbs_otimer_expire(struct zt_chan *chan)
case ZT_TXSTATE_AFTERSTART:
zt_rbs_sethook(chan, ZT_TXSIG_OFFHOOK, ZT_TXSTATE_OFFHOOK, 0);
if (chan->file && (chan->file->f_flags & O_NONBLOCK))
- qevent(chan, ZT_EVENT_HOOKCOMPLETE);
+ __qevent(chan, ZT_EVENT_HOOKCOMPLETE);
wake_up_interruptible(&chan->txstateq);
break;
case ZT_TXSTATE_KEWL:
zt_rbs_sethook(chan, ZT_TXSIG_ONHOOK, ZT_TXSTATE_AFTERKEWL, ZT_AFTERKEWLTIME);
if (chan->file && (chan->file->f_flags & O_NONBLOCK))
- qevent(chan, ZT_EVENT_HOOKCOMPLETE);
+ __qevent(chan, ZT_EVENT_HOOKCOMPLETE);
wake_up_interruptible(&chan->txstateq);
break;
case ZT_TXSTATE_AFTERKEWL:
if (chan->kewlonhook) {
- qevent(chan,ZT_EVENT_ONHOOK);
+ __qevent(chan,ZT_EVENT_ONHOOK);
}
chan->txstate = ZT_TXSTATE_ONHOOK;
chan->gotgs = 0;
@@ -4464,10 +4476,11 @@ static inline void rbs_otimer_expire(struct zt_chan *chan)
}
}
-static void zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
+static void __zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
{
- /* State machines for receive hookstate transitions */
+ /* State machines for receive hookstate transitions
+ called with chan->lock held */
if ((chan->rxhooksig) == rxsig) return;
@@ -4484,9 +4497,9 @@ static void zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
/* This interface is now going on hook.
Check for WINK, etc */
if (chan->itimer)
- qevent(chan,ZT_EVENT_WINKFLASH);
+ __qevent(chan,ZT_EVENT_WINKFLASH);
else {
- qevent(chan,ZT_EVENT_ONHOOK);
+ __qevent(chan,ZT_EVENT_ONHOOK);
chan->gotgs = 0;
}
chan->itimerset = chan->itimer = 0;
@@ -4505,7 +4518,7 @@ static void zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
chan->ringtrailer = 0;
if (chan->txstate != ZT_TXSTATE_DEBOUNCE) {
chan->gotgs = 0;
- qevent(chan,ZT_EVENT_ONHOOK);
+ __qevent(chan,ZT_EVENT_ONHOOK);
}
}
break;
@@ -4513,7 +4526,7 @@ static void zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
if (rxsig == ZT_RXSIG_START) {
/* if havent got gs, report it */
if (!chan->gotgs) {
- qevent(chan,ZT_EVENT_RINGOFFHOOK);
+ __qevent(chan,ZT_EVENT_RINGOFFHOOK);
chan->gotgs = 1;
}
}
@@ -4541,14 +4554,14 @@ static void zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
chan->pulsetimer = ZT_PULSETIMEOUT;
chan->itimer = chan->itimerset;
if (chan->pulsecount == 1)
- qevent(chan,ZT_EVENT_PULSE_START);
+ __qevent(chan,ZT_EVENT_PULSE_START);
}
} else
- qevent(chan,ZT_EVENT_WINKFLASH);
+ __qevent(chan,ZT_EVENT_WINKFLASH);
} else {
/* if havent got GS detect */
if (!chan->gotgs) {
- qevent(chan,ZT_EVENT_RINGOFFHOOK);
+ __qevent(chan,ZT_EVENT_RINGOFFHOOK);
chan->gotgs = 1;
chan->itimerset = chan->itimer = 0;
}
@@ -4576,19 +4589,24 @@ static void zt_hooksig_pvt(struct zt_chan *chan, zt_rxsig_t rxsig)
void zt_hooksig(struct zt_chan *chan, zt_rxsig_t rxsig)
{
/* skip if no change */
- zt_hooksig_pvt(chan,rxsig);
+ unsigned long flags;
+ spin_lock_irqsave(&chan->lock, flags);
+ __zt_hooksig_pvt(chan,rxsig);
+ spin_unlock_irqrestore(&chan->lock, flags);
}
void zt_rbsbits(struct zt_chan *chan, int cursig)
{
+ unsigned long flags;
if (cursig == chan->rxsig)
return;
+ spin_lock_irqsave(&chan->lock, flags);
switch(chan->sig) {
case ZT_SIG_FXOGS: /* FXO Groundstart */
/* B-bit only matters for FXO GS */
if (!(cursig & ZT_BBIT)) {
- zt_hooksig_pvt(chan, ZT_RXSIG_START);
+ __zt_hooksig_pvt(chan, ZT_RXSIG_START);
break;
}
/* Fall through */
@@ -4596,9 +4614,9 @@ void zt_rbsbits(struct zt_chan *chan, int cursig)
case ZT_SIG_FXOLS: /* FXO Loopstart */
case ZT_SIG_FXOKS: /* FXO Kewlstart */
if (cursig & ZT_ABIT) /* off hook */
- zt_hooksig_pvt(chan,ZT_RXSIG_OFFHOOK);
+ __zt_hooksig_pvt(chan,ZT_RXSIG_OFFHOOK);
else /* on hook */
- zt_hooksig_pvt(chan,ZT_RXSIG_ONHOOK);
+ __zt_hooksig_pvt(chan,ZT_RXSIG_ONHOOK);
break;
case ZT_SIG_FXSKS: /* FXS Kewlstart */
@@ -4607,19 +4625,19 @@ void zt_rbsbits(struct zt_chan *chan, int cursig)
case ZT_SIG_FXSLS:
if (!(cursig & ZT_BBIT)) {
/* Check for ringing first */
- zt_hooksig_pvt(chan, ZT_RXSIG_RING);
+ __zt_hooksig_pvt(chan, ZT_RXSIG_RING);
break;
}
if ((chan->sig != ZT_SIG_FXSLS) && (cursig & ZT_ABIT)) {
/* if went on hook */
- zt_hooksig_pvt(chan, ZT_RXSIG_ONHOOK);
+ __zt_hooksig_pvt(chan, ZT_RXSIG_ONHOOK);
} else {
- zt_hooksig_pvt(chan, ZT_RXSIG_OFFHOOK);
+ __zt_hooksig_pvt(chan, ZT_RXSIG_OFFHOOK);
}
break;
case ZT_SIG_CAS:
/* send event that something changed */
- qevent(chan, ZT_EVENT_BITSCHANGED);
+ __qevent(chan, ZT_EVENT_BITSCHANGED);
break;
default:
@@ -4627,6 +4645,7 @@ void zt_rbsbits(struct zt_chan *chan, int cursig)
}
/* Keep track of signalling for next time */
chan->rxsig = cursig;
+ spin_unlock_irqrestore(&chan->lock, flags);
}
void zt_ec_chunk(struct zt_chan *ss, unsigned char *rxchunk, const unsigned char *txchunk)
@@ -4701,9 +4720,10 @@ long x,y;
return(rv);
}
-static inline void zt_process_putaudio_chunk(struct zt_chan *ss, unsigned char *rxb)
+static inline void __zt_process_putaudio_chunk(struct zt_chan *ss, unsigned char *rxb)
{
/* We transmit data from our master channel */
+ /* Called with ss->lock held */
struct zt_chan *ms = ss->master;
/* Linear version of received data */
short putlin[ZT_CHUNKSIZE],k[ZT_CHUNKSIZE];
@@ -4747,11 +4767,11 @@ static inline void zt_process_putaudio_chunk(struct zt_chan *ss, unsigned char *
if (((r == 2) && !(ms->toneflags & ZT_REVERSE_RXTONE)) ||
((r == 1) && (ms->toneflags & ZT_REVERSE_RXTONE)))
{
- qevent(ms,ZT_EVENT_RINGOFFHOOK);
+ __qevent(ms,ZT_EVENT_RINGOFFHOOK);
}
else
{
- qevent(ms,ZT_EVENT_ONHOOK);
+ __qevent(ms,ZT_EVENT_ONHOOK);
}
ms->rd.lastdetect = r;
}
@@ -4888,9 +4908,10 @@ static inline void zt_process_putaudio_chunk(struct zt_chan *ss, unsigned char *
}
}
-static inline void zt_putbuf_chunk(struct zt_chan *ss, unsigned char *rxb)
+static inline void __zt_putbuf_chunk(struct zt_chan *ss, unsigned char *rxb)
{
/* We transmit data from our master channel */
+ /* Called with ss->lock held */
struct zt_chan *ms = ss->master;
/* Our receive buffer */
unsigned char *buf;
@@ -5090,7 +5111,7 @@ out in the later versions, and is put back now. */
if ((ms->flags & ZT_FLAG_OPEN) && !ss->span->alarms)
/* Notify the receiver... */
- qevent(ss->master, abort);
+ __qevent(ss->master, abort);
#if 0
printk("torintr_receive: Aborted %d bytes of frame on %d\n", amt, ss->master);
#endif
@@ -5218,42 +5239,44 @@ static unsigned int zt_poll(struct file *file, struct poll_table_struct *wait_ta
return zt_chan_poll(file, wait_table, unit);
}
-static void zt_transmit_chunk(struct zt_chan *chan, unsigned char *buf)
+static void __zt_transmit_chunk(struct zt_chan *chan, unsigned char *buf)
{
unsigned char silly[ZT_CHUNKSIZE];
-
+ /* Called with chan->lock locked */
if (!buf)
buf = silly;
- zt_getbuf_chunk(chan, buf);
+ __zt_getbuf_chunk(chan, buf);
if (chan->flags & ZT_FLAG_AUDIO) {
#ifdef CONFIG_ZAPTEL_MMX
zt_kernel_fpu_begin();
#endif
- zt_process_getaudio_chunk(chan, buf);
+ __zt_process_getaudio_chunk(chan, buf);
#ifdef CONFIG_ZAPTEL_MMX
kernel_fpu_end();
#endif
}
}
-static inline void zt_real_transmit(struct zt_chan *chan)
+static inline void __zt_real_transmit(struct zt_chan *chan)
{
+ /* Called with chan->lock held */
if (chan->confmode) {
/* Pull queued data off the conference */
- buf_pull(&chan->confout, chan->writechunk, chan, "zt_real_transmit");
+ __buf_pull(&chan->confout, chan->writechunk, chan, "zt_real_transmit");
} else {
- zt_transmit_chunk(chan, chan->writechunk);
+ __zt_transmit_chunk(chan, chan->writechunk);
}
}
-static void zt_getempty(struct zt_chan *ms, unsigned char *buf)
+static void __zt_getempty(struct zt_chan *ms, unsigned char *buf)
{
int bytes = ZT_CHUNKSIZE;
int left;
unsigned char *txb = buf;
int x;
short getlin;
+ /* Called with ms->lock held */
while(bytes) {
/* Receive silence, or tone */
@@ -5277,7 +5300,7 @@ static void zt_getempty(struct zt_chan *ms, unsigned char *buf)
if (!ms->curtone) {
/* No more tones... Is this dtmf or mf? If so, go to the next digit */
if (ms->dialing)
- do_dtmf(ms);
+ __do_dtmf(ms);
} else {
if (last != ms->curtone)
zt_init_tone_state(&ms->ts, ms->curtone);
@@ -5292,8 +5315,9 @@ static void zt_getempty(struct zt_chan *ms, unsigned char *buf)
}
-static void zt_receive_chunk(struct zt_chan *chan, unsigned char *buf)
+static void __zt_receive_chunk(struct zt_chan *chan, unsigned char *buf)
{
+ /* Receive chunk of audio -- called with chan->lock held */
char waste[ZT_CHUNKSIZE];
if (!buf) {
@@ -5304,21 +5328,22 @@ static void zt_receive_chunk(struct zt_chan *chan, unsigned char *buf)
#ifdef CONFIG_ZAPTEL_MMX
zt_kernel_fpu_begin();
#endif
- zt_process_putaudio_chunk(chan, buf);
+ __zt_process_putaudio_chunk(chan, buf);
#ifdef CONFIG_ZAPTEL_MMX
kernel_fpu_end();
#endif
}
- zt_putbuf_chunk(chan, buf);
+ __zt_putbuf_chunk(chan, buf);
}
-static inline void zt_real_receive(struct zt_chan *chan)
+static inline void __zt_real_receive(struct zt_chan *chan)
{
+ /* Called with chan->lock held */
if (chan->confmode) {
/* Load into queue if we have space */
- buf_push(&chan->confin, chan->readchunk, "zt_real_receive");
+ __buf_push(&chan->confin, chan->readchunk, "zt_real_receive");
} else {
- zt_receive_chunk(chan, chan->readchunk);
+ __zt_receive_chunk(chan, chan->readchunk);
}
}
@@ -5334,11 +5359,11 @@ int zt_transmit(struct zt_span *span)
if (span->chans[x].otimer) {
span->chans[x].otimer -= ZT_CHUNKSIZE;
if (span->chans[x].otimer <= 0) {
- rbs_otimer_expire(&span->chans[x]);
+ __rbs_otimer_expire(&span->chans[x]);
}
}
if (span->chans[x].flags & ZT_FLAG_AUDIO) {
- zt_real_transmit(&span->chans[x]);
+ __zt_real_transmit(&span->chans[x]);
} else {
if (span->chans[x].nextslave) {
u_char data[ZT_CHUNKSIZE];
@@ -5350,7 +5375,7 @@ int zt_transmit(struct zt_span *span)
do {
if (pos==ZT_CHUNKSIZE) {
/* Get next chunk */
- zt_transmit_chunk(&span->chans[x], data);
+ __zt_transmit_chunk(&span->chans[x], data);
pos = 0;
}
span->chans[z].writechunk[y] = data[pos++];
@@ -5359,7 +5384,7 @@ int zt_transmit(struct zt_span *span)
}
} else {
/* Process independents elsewise */
- zt_real_transmit(&span->chans[x]);
+ __zt_real_transmit(&span->chans[x]);
}
}
}
@@ -5401,7 +5426,7 @@ int zt_receive(struct zt_span *span)
do {
data[pos++] = span->chans[z].readchunk[y];
if (pos == ZT_CHUNKSIZE) {
- zt_receive_chunk(&span->chans[x], data);
+ __zt_receive_chunk(&span->chans[x], data);
pos = 0;
}
z=span->chans[z].nextslave;
@@ -5409,7 +5434,7 @@ int zt_receive(struct zt_span *span)
}
} else {
/* Process a normal channel */
- zt_real_receive(&span->chans[x]);
+ __zt_real_receive(&span->chans[x]);
}
if (span->chans[x].itimer) {
span->chans[x].itimer -= ZT_CHUNKSIZE;
@@ -5426,7 +5451,7 @@ int zt_receive(struct zt_span *span)
span->chans[x].ringtrailer-= ZT_CHUNKSIZE;
/* See if RING trailer is expired */
if (!span->chans[x].ringtrailer && !span->chans[x].ringdebtimer)
- qevent(&span->chans[x],ZT_EVENT_RINGOFFHOOK);
+ __qevent(&span->chans[x],ZT_EVENT_RINGOFFHOOK);
}
}
if (span->chans[x].pulsetimer)
@@ -5442,13 +5467,13 @@ int zt_receive(struct zt_span *span)
span->chans[x].pulsecount,
span->chans[x].name);
} else if (span->chans[x].pulsecount > 11) {
- qevent(&span->chans[x], ZT_EVENT_PULSEDIGIT | '#');
+ __qevent(&span->chans[x], ZT_EVENT_PULSEDIGIT | '#');
} else if (span->chans[x].pulsecount > 10) {
- qevent(&span->chans[x], ZT_EVENT_PULSEDIGIT | '*');
+ __qevent(&span->chans[x], ZT_EVENT_PULSEDIGIT | '*');
} else if (span->chans[x].pulsecount > 9) {
- qevent(&span->chans[x], ZT_EVENT_PULSEDIGIT | '0');
+ __qevent(&span->chans[x], ZT_EVENT_PULSEDIGIT | '0');
} else {
- qevent(&span->chans[x], ZT_EVENT_PULSEDIGIT | ('0' +
+ __qevent(&span->chans[x], ZT_EVENT_PULSEDIGIT | ('0' +
span->chans[x].pulsecount));
}
span->chans[x].pulsecount = 0;
@@ -5470,10 +5495,10 @@ int zt_receive(struct zt_span *span)
if (chans[x] && chans[x]->confmode && !(chans[x]->flags & ZT_FLAG_PSEUDO)) {
u_char *data;
spin_lock_irqsave(&chans[x]->lock, flags);
- data = buf_peek(&chans[x]->confin);
- zt_receive_chunk(chans[x], data);
+ data = __buf_peek(&chans[x]->confin);
+ __zt_receive_chunk(chans[x], data);
if (data)
- buf_pull(&chans[x]->confin, NULL,chans[x], "confreceive");
+ __buf_pull(&chans[x]->confin, NULL,chans[x], "confreceive");
spin_unlock_irqrestore(&chans[x]->lock, flags);
}
}
@@ -5482,7 +5507,9 @@ int zt_receive(struct zt_span *span)
/* do all the pseudo and/or conferenced channel receives (getbuf's) */
for (x=1;x<maxchans;x++) {
if (chans[x] && (chans[x]->flags & ZT_FLAG_PSEUDO)) {
- zt_transmit_chunk(chans[x], NULL);
+ spin_lock_irqsave(&chans[x]->lock, flags);
+ __zt_transmit_chunk(chans[x], NULL);
+ spin_unlock_irqrestore(&chans[x]->lock, flags);
}
}
if (maxlinks) {
@@ -5506,8 +5533,8 @@ int zt_receive(struct zt_span *span)
if (chans[x] && (chans[x]->flags & ZT_FLAG_PSEUDO)) {
unsigned char tmp[ZT_CHUNKSIZE];
spin_lock_irqsave(&chans[x]->lock, flags);
- zt_getempty(chans[x], tmp);
- zt_receive_chunk(chans[x], tmp);
+ __zt_getempty(chans[x], tmp);
+ __zt_receive_chunk(chans[x], tmp);
spin_unlock_irqrestore(&chans[x]->lock, flags);
}
}
@@ -5515,10 +5542,10 @@ int zt_receive(struct zt_span *span)
if (chans[x] && chans[x]->confmode && !(chans[x]->flags & ZT_FLAG_PSEUDO)) {
u_char *data;
spin_lock_irqsave(&chans[x]->lock, flags);
- data = buf_pushpeek(&chans[x]->confout);
- zt_transmit_chunk(chans[x], data);
+ data = __buf_pushpeek(&chans[x]->confout);
+ __zt_transmit_chunk(chans[x], data);
if (data)
- buf_push(&chans[x]->confout, NULL, "conftransmit");
+ __buf_push(&chans[x]->confout, NULL, "conftransmit");
spin_unlock_irqrestore(&chans[x]->lock, flags);
}
}
diff --git a/zaptel.h b/zaptel.h
index 8105c75..f51f743 100755
--- a/zaptel.h
+++ b/zaptel.h
@@ -1240,7 +1240,10 @@ extern void zt_rbsbits(struct zt_chan *chan, int bits);
extern void zt_hooksig(struct zt_chan *chan, zt_rxsig_t rxsig);
/* Queue an event on a channel */
-extern void zt_qevent(struct zt_chan *chan, int event);
+extern void zt_qevent_nolock(struct zt_chan *chan, int event);
+
+/* Queue an event on a channel, locking it first */
+extern void zt_qevent_lock(struct zt_chan *chan, int event);
/* Notify a change possible change in alarm status */
extern void zt_alarm_notify(struct zt_span *span);
diff --git a/ztcfg.c b/ztcfg.c
index ce369bc..b746767 100755
--- a/ztcfg.c
+++ b/ztcfg.c
@@ -645,7 +645,6 @@ int main(int argc, char *argv[])
case 's':
stopmode = 1;
break;
- default:
}
}
cf = fopen(filename, "r");
diff --git a/ztd-eth.c b/ztd-eth.c
index b99b54b..fd602e5 100755
--- a/ztd-eth.c
+++ b/ztd-eth.c
@@ -124,7 +124,6 @@ static int ztdeth_notifier(struct notifier_block *block, unsigned long event, vo
}
spin_unlock_irqrestore(&zlock, flags);
break;
- default:
}
return 0;
}