diff options
author | sruffell <sruffell@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2008-03-27 21:17:46 +0000 |
---|---|---|
committer | sruffell <sruffell@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2008-03-27 21:17:46 +0000 |
commit | cd81703764c4d2884c60f3632f15d5bfc44dc31d (patch) | |
tree | 93046f7721e2be48425642d4902bafe1ffee47f6 /kernel/zaptel-base.c | |
parent | a15be82083adbbc27fe2c5b8ce648f14b6eb93d3 (diff) |
- Updated wctdm24xxp and wcte12xp driver which are now more tolerant of
systems which do not exhibit good real-time characteristics.
- Bringing in improvements to battery alarm generation that was on kpflemings
battery_alarms branch. (Issue #12099)
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4096 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'kernel/zaptel-base.c')
-rw-r--r-- | kernel/zaptel-base.c | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/kernel/zaptel-base.c b/kernel/zaptel-base.c index c4b4ccf..da503eb 100644 --- a/kernel/zaptel-base.c +++ b/kernel/zaptel-base.c @@ -1157,16 +1157,23 @@ static int start_tone(struct zt_chan *chan, int tone) if (tone == -1) { /* Just stop the current tone */ res = 0; + } else if (!chan->curzone) { + static int __warnonce = 1; + if (__warnonce) { + __warnonce = 0; + /* The tonezones are loaded by ztcfg based on /etc/zaptel.conf. */ + printk(KERN_WARNING "zaptel: Cannot start tones until tone zone is loaded.\n"); + } + /* Note that no tone zone exists at the moment */ + res = -ENODATA; } else if ((tone >= 0 && tone <= ZT_TONE_MAX)) { - if (chan->curzone) { - /* Have a tone zone */ - if (chan->curzone->tones[tone]) { - chan->curtone = chan->curzone->tones[tone]; - res = 0; - } else /* Indicate that zone is loaded but no such tone exists */ - res = -ENOSYS; - } else /* Note that no tone zone exists at the moment */ - res = -ENODATA; + /* Have a tone zone */ + if (chan->curzone->tones[tone]) { + chan->curtone = chan->curzone->tones[tone]; + res = 0; + } else { /* Indicate that zone is loaded but no such tone exists */ + res = -ENOSYS; + } } else if (chan->digitmode == DIGIT_MODE_DTMF) { if ((tone >= ZT_TONE_DTMF_BASE) && (tone <= ZT_TONE_DTMF_MAX)) { chan->dialing = 1; @@ -1187,8 +1194,9 @@ static int start_tone(struct zt_chan *chan, int tone) } } else { res = -EINVAL; - }; + } } else { + chan->dialing = 0; res = -EINVAL; } @@ -2827,6 +2835,16 @@ struct zt_tone *zt_mf_tone(const struct zt_chan *chan, char digit, int digitmode { unsigned int tone_index; + if (!chan->curzone) { + static int __warnonce = 1; + if (__warnonce) { + __warnonce = 0; + /* The tonezones are loaded by ztcfg based on /etc/zaptel.conf. */ + printk(KERN_WARNING "zaptel: Cannot get dtmf tone until tone zone is loaded.\n"); + } + return NULL; + } + switch (digitmode) { case DIGIT_MODE_DTMF: switch (digit) { @@ -3981,6 +3999,12 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign for (s = stack.tdo.dialstr; *s; s++) *s = toupper(*s); spin_lock_irqsave(&chan->lock, flags); + if (!chan->curzone) { + spin_unlock_irqrestore(&chan->lock, flags); + /* The tone zones are loaded by ztcfg from /etc/zaptel.conf */ + printk(KERN_WARNING "zaptel: Cannot dial until a tone zone is loaded.\n"); + return -ENODATA; + } switch (stack.tdo.op) { case ZT_DIAL_OP_CANCEL: chan->curtone = NULL; @@ -4853,6 +4877,11 @@ static int zt_chan_ioctl(struct inode *inode, struct file *file, unsigned int cm case ZT_RING: case ZT_START: spin_lock_irqsave(&chan->lock, flags); + if (!chan->curzone) { + spin_unlock_irqrestore(&chan->lock, flags); + printk(KERN_WARNING "zaptel: Cannot start tone until a tone zone is loaded.\n"); + return -ENODATA; + } if (chan->txstate != ZT_TXSTATE_ONHOOK) { spin_unlock_irqrestore(&chan->lock, flags); return -EBUSY; |