From 491081bb9fd20fe122636025a3f51376fbe0080d Mon Sep 17 00:00:00 2001 From: markster Date: Sat, 24 Jul 2004 16:03:27 +0000 Subject: Heavily reduce stack usage, remove ancient and useless tor.h git-svn-id: http://svn.digium.com/svn/zaptel/trunk@440 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- zaptel.c | 326 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 168 insertions(+), 158 deletions(-) (limited to 'zaptel.c') diff --git a/zaptel.c b/zaptel.c index 14cc238..2d6f948 100755 --- a/zaptel.c +++ b/zaptel.c @@ -1563,14 +1563,14 @@ static ssize_t zt_chan_read(struct file *file, char *usrbuf, size_t count, int u if (amnt) { /* There seems to be a max stack size, so we have to do this in smaller pieces */ - short lindata[512]; + short lindata[128]; int left = amnt >> 1; /* amnt is in bytes */ int pos = 0; int pass; while(left) { pass = left; - if (pass > 512) - pass = 512; + if (pass > 128) + pass = 128; for (x=0;xreadbuf[chan->outreadbuf][x + pos], chan); if (copy_to_user(usrbuf + (pos << 1), lindata, pass << 1)) @@ -1660,14 +1660,14 @@ static ssize_t zt_chan_write(struct file *file, const char *usrbuf, size_t count if (chan->flags & ZT_FLAG_LINEAR) { /* There seems to be a max stack size, so we have to do this in smaller pieces */ - short lindata[512]; + short lindata[128]; int left = amnt >> 1; /* amnt is in bytes */ int pos = 0; int pass; while(left) { pass = left; - if (pass > 512) - pass = 512; + if (pass > 128) + pass = 128; if (copy_from_user(lindata, usrbuf + (pos << 1), pass << 1)) return -EFAULT; left -= pass; @@ -2285,14 +2285,14 @@ static ssize_t zt_write(struct file *file, const char *usrbuf, size_t count, lof /* No bigger than 32k for everything per tone zone */ #define MAX_SIZE 32768 -/* No more than 128 subtones */ -#define MAX_TONES 128 +/* No more than 64 subtones */ +#define MAX_TONES 64 static int ioctl_load_zone(unsigned long data) { struct zt_tone *samples[MAX_TONES]; - int next[MAX_TONES]; + short next[MAX_TONES]; struct zt_tone_def_header th; void *slab, *ptr; long size; @@ -2616,120 +2616,126 @@ static int zt_timer_ioctl(struct inode *node, struct file *file, unsigned int cm } static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int cmd, unsigned long data, int unit) { - struct zt_gains gain; - struct zt_spaninfo span; - struct zt_chan *chan,mychan; - int i,j; - struct zt_params param; + union { + struct zt_gains gain; + struct zt_spaninfo span; + struct zt_params param; + } stack; + struct zt_chan *chan; +#ifdef ALLOW_CHAN_DIAG + /* This structure is huge and will bork a 4k stack */ + struct zt_chan mychan; unsigned long flags; +#endif + int i,j; switch(cmd) { case ZT_GET_PARAMS: /* get channel timing parameters */ - copy_from_user(¶m,(struct zt_params *)data,sizeof(param)); + copy_from_user(&stack.param,(struct zt_params *)data,sizeof(stack.param)); /* Pick the right channo's */ - if (!param.channo || unit) { - param.channo = unit; + if (!stack.param.channo || unit) { + stack.param.channo = unit; } /* Check validity of channel */ - VALID_CHANNEL(param.channo); - chan = chans[param.channo]; + VALID_CHANNEL(stack.param.channo); + chan = chans[stack.param.channo]; /* point to relevant structure */ - param.sigtype = chan->sig; /* get signalling type */ + stack.param.sigtype = chan->sig; /* get signalling type */ /* return non-zero if rx not in idle state */ if (chan->span) { j = zt_q_sig(chan); if (j >= 0) { /* if returned with success */ - param.rxisoffhook = ((chan->rxsig & (j >> 8)) != (j & 0xff)); + stack.param.rxisoffhook = ((chan->rxsig & (j >> 8)) != (j & 0xff)); } else { - param.rxisoffhook = ((chan->rxhooksig != ZT_RXSIG_ONHOOK) && + stack.param.rxisoffhook = ((chan->rxhooksig != ZT_RXSIG_ONHOOK) && (chan->rxhooksig != ZT_RXSIG_INITIAL)); } - } else param.rxisoffhook = 0; + } else stack.param.rxisoffhook = 0; if (chan->span && chan->span->rbsbits && !(chan->sig & ZT_SIG_CLEAR)) { - param.rxbits = chan->rxsig; - param.txbits = chan->txsig; - param.idlebits = chan->idlebits; + stack.param.rxbits = chan->rxsig; + stack.param.txbits = chan->txsig; + stack.param.idlebits = chan->idlebits; } else { - param.rxbits = -1; - param.txbits = -1; - param.idlebits = 0; + stack.param.rxbits = -1; + stack.param.txbits = -1; + stack.param.idlebits = 0; } if (chan->span && (chan->span->rbsbits || chan->span->hooksig) && !(chan->sig & ZT_SIG_CLEAR)) { - param.rxhooksig = chan->rxhooksig; - param.txhooksig = chan->txhooksig; + stack.param.rxhooksig = chan->rxhooksig; + stack.param.txhooksig = chan->txhooksig; } else { - param.rxhooksig = -1; - param.txhooksig = -1; + stack.param.rxhooksig = -1; + stack.param.txhooksig = -1; } - param.prewinktime = chan->prewinktime; - param.preflashtime = chan->preflashtime; - param.winktime = chan->winktime; - param.flashtime = chan->flashtime; - param.starttime = chan->starttime; - param.rxwinktime = chan->rxwinktime; - param.rxflashtime = chan->rxflashtime; - param.debouncetime = chan->debouncetime; - param.channo = chan->channo; - if (chan->span) param.spanno = chan->span->spanno; - else param.spanno = 0; - strncpy(param.name, chan->name, sizeof(param.name) - 1); - param.chanpos = chan->chanpos; + stack.param.prewinktime = chan->prewinktime; + stack.param.preflashtime = chan->preflashtime; + stack.param.winktime = chan->winktime; + stack.param.flashtime = chan->flashtime; + stack.param.starttime = chan->starttime; + stack.param.rxwinktime = chan->rxwinktime; + stack.param.rxflashtime = chan->rxflashtime; + stack.param.debouncetime = chan->debouncetime; + stack.param.channo = chan->channo; + if (chan->span) stack.param.spanno = chan->span->spanno; + else stack.param.spanno = 0; + strncpy(stack.param.name, chan->name, sizeof(stack.param.name) - 1); + stack.param.chanpos = chan->chanpos; /* Return current law */ if (chan->xlaw == __zt_alaw) - param.curlaw = ZT_LAW_ALAW; + stack.param.curlaw = ZT_LAW_ALAW; else - param.curlaw = ZT_LAW_MULAW; - copy_to_user((struct zt_params *)data,¶m,sizeof(param)); + stack.param.curlaw = ZT_LAW_MULAW; + copy_to_user((struct zt_params *)data,&stack.param,sizeof(stack.param)); break; - case ZT_SET_PARAMS: /* set channel timing paramters */ - copy_from_user(¶m,(struct zt_params *)data,sizeof(param)); + case ZT_SET_PARAMS: /* set channel timing stack.paramters */ + copy_from_user(&stack.param,(struct zt_params *)data,sizeof(stack.param)); /* Pick the right channo's */ - if (!param.channo || unit) { - param.channo = unit; + if (!stack.param.channo || unit) { + stack.param.channo = unit; } /* Check validity of channel */ - VALID_CHANNEL(param.channo); - chan = chans[param.channo]; + VALID_CHANNEL(stack.param.channo); + chan = chans[stack.param.channo]; /* point to relevant structure */ /* NOTE: sigtype is *not* included in this */ - /* get timing paramters */ - chan->prewinktime = param.prewinktime; - chan->preflashtime = param.preflashtime; - chan->winktime = param.winktime; - chan->flashtime = param.flashtime; - chan->starttime = param.starttime; + /* get timing stack.paramters */ + chan->prewinktime = stack.param.prewinktime; + chan->preflashtime = stack.param.preflashtime; + chan->winktime = stack.param.winktime; + chan->flashtime = stack.param.flashtime; + chan->starttime = stack.param.starttime; /* Update ringtime if not using a tone zone */ if (!chan->curzone) chan->ringcadence[0] = chan->starttime; - chan->rxwinktime = param.rxwinktime; - chan->rxflashtime = param.rxflashtime; - chan->debouncetime = param.debouncetime; + chan->rxwinktime = stack.param.rxwinktime; + chan->rxflashtime = stack.param.rxflashtime; + chan->debouncetime = stack.param.debouncetime; break; case ZT_GETGAINS: /* get gain stuff */ - if (copy_from_user(&gain,(struct zt_gains *) data,sizeof(gain))) + if (copy_from_user(&stack.gain,(struct zt_gains *) data,sizeof(stack.gain))) return -EIO; - i = gain.chan; /* get channel no */ + i = stack.gain.chan; /* get channel no */ /* if zero, use current channel no */ if (!i) i = unit; /* make sure channel number makes sense */ if ((i < 0) || (i > ZT_MAX_CHANNELS) || !chans[i]) return(-EINVAL); if (!(chans[i]->flags & ZT_FLAG_AUDIO)) return (-EINVAL); - gain.chan = i; /* put the span # in here */ + stack.gain.chan = i; /* put the span # in here */ for (j=0;j<256;j++) { - gain.txgain[j] = chans[i]->txgain[j]; - gain.rxgain[j] = chans[i]->rxgain[j]; + stack.gain.txgain[j] = chans[i]->txgain[j]; + stack.gain.rxgain[j] = chans[i]->rxgain[j]; } - if (copy_to_user((struct zt_gains *) data,&gain,sizeof(gain))) + if (copy_to_user((struct zt_gains *) data,&stack.gain,sizeof(stack.gain))) return -EIO; break; case ZT_SETGAINS: /* set gain stuff */ - if (copy_from_user(&gain,(struct zt_gains *) data,sizeof(gain))) + if (copy_from_user(&stack.gain,(struct zt_gains *) data,sizeof(stack.gain))) return -EIO; - i = gain.chan; /* get channel no */ + i = stack.gain.chan; /* get channel no */ /* if zero, use current channel no */ if (!i) i = unit; /* make sure channel number makes sense */ @@ -2745,10 +2751,10 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c chans[i]->txgain = chans[i]->rxgain + 256; } } - gain.chan = i; /* put the span # in here */ + stack.gain.chan = i; /* put the span # in here */ for (j=0;j<256;j++) { - chans[i]->rxgain[j] = gain.rxgain[j]; - chans[i]->txgain[j] = gain.txgain[j]; + chans[i]->rxgain[j] = stack.gain.rxgain[j]; + chans[i]->txgain[j] = stack.gain.txgain[j]; } if (!memcmp(chans[i]->rxgain, defgain, 256) && !memcmp(chans[i]->txgain, defgain, 256)) { @@ -2760,12 +2766,12 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c chans[i]->txgain = defgain; chans[i]->gainalloc = 0; } - if (copy_to_user((struct zt_gains *) data,&gain,sizeof(gain))) + if (copy_to_user((struct zt_gains *) data,&stack.gain,sizeof(stack.gain))) return -EIO; break; case ZT_SPANSTAT: - copy_from_user(&span,(struct tor_spaninfo *) data,sizeof(span)); - i = span.spanno; /* get specified span number */ + copy_from_user(&stack.span,(struct zt_spaninfo *) data,sizeof(stack.span)); + i = stack.span.spanno; /* get specified span number */ if ((i < 0) || (i >= maxspans)) return(-EINVAL); /* if bad span no */ if (i == 0) /* if to figure it out for this chan */ { @@ -2775,27 +2781,28 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c } if (!spans[i]) return -EINVAL; - span.spanno = i; /* put the span # in here */ - span.totalspans = 0; - if (maxspans) span.totalspans = maxspans - 1; /* put total number of spans here */ - strncpy(span.desc, spans[i]->desc, sizeof(span.desc) - 1); - strncpy(span.name, spans[i]->name, sizeof(span.name) - 1); - span.alarms = spans[i]->alarms; /* get alarm status */ - span.bpvcount = spans[i]->bpvcount; /* get BPV count */ - span.rxlevel = spans[i]->rxlevel; /* get rx level */ - span.txlevel = spans[i]->txlevel; /* get tx level */ - span.crc4count = spans[i]->crc4count; /* get CRC4 error count */ - span.ebitcount = spans[i]->ebitcount; /* get E-bit error count */ - span.fascount = spans[i]->fascount; /* get FAS error count */ - span.irqmisses = spans[i]->irqmisses; /* get IRQ miss count */ - span.syncsrc = spans[i]->syncsrc; /* get active sync source */ - span.totalchans = spans[i]->channels; - span.numchans = 0; + stack.span.spanno = i; /* put the span # in here */ + stack.span.totalspans = 0; + if (maxspans) stack.span.totalspans = maxspans - 1; /* put total number of spans here */ + strncpy(stack.span.desc, spans[i]->desc, sizeof(stack.span.desc) - 1); + strncpy(stack.span.name, spans[i]->name, sizeof(stack.span.name) - 1); + stack.span.alarms = spans[i]->alarms; /* get alarm status */ + stack.span.bpvcount = spans[i]->bpvcount; /* get BPV count */ + stack.span.rxlevel = spans[i]->rxlevel; /* get rx level */ + stack.span.txlevel = spans[i]->txlevel; /* get tx level */ + stack.span.crc4count = spans[i]->crc4count; /* get CRC4 error count */ + stack.span.ebitcount = spans[i]->ebitcount; /* get E-bit error count */ + stack.span.fascount = spans[i]->fascount; /* get FAS error count */ + stack.span.irqmisses = spans[i]->irqmisses; /* get IRQ miss count */ + stack.span.syncsrc = spans[i]->syncsrc; /* get active sync source */ + stack.span.totalchans = spans[i]->channels; + stack.span.numchans = 0; for (j=0; j < spans[i]->channels; j++) if (spans[i]->chans[j].sig) - span.numchans++; - copy_to_user((struct tor_spaninfo *) data,&span,sizeof(span)); + stack.span.numchans++; + copy_to_user((struct zt_spaninfo *) data,&stack.span,sizeof(stack.span)); break; +#ifdef ALLOW_CHAN_DIAG case ZT_CHANDIAG: get_user(j, (int *)data); /* get channel number from user */ /* make sure its a valid channel number */ @@ -2845,6 +2852,7 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c } } #endif +#endif /* ALLOW_CHAN_DIAG */ break; default: return -ENOTTY; @@ -3223,10 +3231,12 @@ static int zt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long data, int unit) { struct zt_chan *chan = chans[unit]; - struct zt_dialoperation tdo; - struct zt_bufferinfo bi; - struct zt_confinfo conf; - struct zt_ring_cadence cad; + union { + struct zt_dialoperation tdo; + struct zt_bufferinfo bi; + struct zt_confinfo conf; + struct zt_ring_cadence cad; + } stack; unsigned long flags, flagso; int i, j, k, rv; int ret, c; @@ -3242,13 +3252,13 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign return -EIO; return 0; case ZT_DIAL: - if (copy_from_user(&tdo, (struct zt_dialoperation *)data, sizeof(tdo))) + if (copy_from_user(&stack.tdo, (struct zt_dialoperation *)data, sizeof(stack.tdo))) return -EIO; rv = 0; /* Force proper NULL termination */ - tdo.dialstr[ZT_MAX_DTMF_BUF - 1] = '\0'; + stack.tdo.dialstr[ZT_MAX_DTMF_BUF - 1] = '\0'; spin_lock_irqsave(&chan->lock, flags); - switch(tdo.op) { + switch(stack.tdo.op) { case ZT_DIAL_OP_CANCEL: chan->curtone = NULL; chan->dialing = 0; @@ -3256,17 +3266,17 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign chan->tonep = 0; break; case ZT_DIAL_OP_REPLACE: - strcpy(chan->txdialbuf, tdo.dialstr); + strcpy(chan->txdialbuf, stack.tdo.dialstr); chan->dialing = 1; __do_dtmf(chan); break; case ZT_DIAL_OP_APPEND: - if (strlen(tdo.dialstr) + strlen(chan->txdialbuf) >= ZT_MAX_DTMF_BUF) + if (strlen(stack.tdo.dialstr) + strlen(chan->txdialbuf) >= ZT_MAX_DTMF_BUF) { rv = -EBUSY; break; } - strncpy(chan->txdialbuf + strlen(chan->txdialbuf), tdo.dialstr, ZT_MAX_DTMF_BUF - strlen(chan->txdialbuf)); + strncpy(chan->txdialbuf + strlen(chan->txdialbuf), stack.tdo.dialstr, ZT_MAX_DTMF_BUF - strlen(chan->txdialbuf)); if (!chan->dialing) { chan->dialing = 1; @@ -3279,28 +3289,28 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign spin_unlock_irqrestore(&chan->lock, flags); return rv; case ZT_GET_BUFINFO: - bi.rxbufpolicy = chan->rxbufpolicy; - bi.txbufpolicy = chan->txbufpolicy; - bi.numbufs = chan->numbufs; - bi.bufsize = chan->blocksize; + stack.bi.rxbufpolicy = chan->rxbufpolicy; + stack.bi.txbufpolicy = chan->txbufpolicy; + stack.bi.numbufs = chan->numbufs; + stack.bi.bufsize = chan->blocksize; /* XXX FIXME! XXX */ - bi.readbufs = -1; - bi.writebufs = -1; - if (copy_to_user((struct zt_bufferinfo *)data, &bi, sizeof(bi))) + stack.bi.readbufs = -1; + stack.bi.writebufs = -1; + if (copy_to_user((struct zt_bufferinfo *)data, &stack.bi, sizeof(stack.bi))) return -EIO; break; case ZT_SET_BUFINFO: - if (copy_from_user(&bi, (struct zt_bufferinfo *)data, sizeof(bi))) + if (copy_from_user(&stack.bi, (struct zt_bufferinfo *)data, sizeof(stack.bi))) return -EIO; - if (bi.bufsize > ZT_MAX_BLOCKSIZE) + if (stack.bi.bufsize > ZT_MAX_BLOCKSIZE) return -EINVAL; - if (bi.bufsize < 16) + if (stack.bi.bufsize < 16) return -EINVAL; - if (bi.bufsize * bi.numbufs > ZT_MAX_BUF_SPACE) + if (stack.bi.bufsize * stack.bi.numbufs > ZT_MAX_BUF_SPACE) return -EINVAL; - chan->rxbufpolicy = bi.rxbufpolicy & 0x1; - chan->txbufpolicy = bi.txbufpolicy & 0x1; - if ((rv = zt_reallocbufs(chan, bi.bufsize, bi.numbufs))) + chan->rxbufpolicy = stack.bi.rxbufpolicy & 0x1; + chan->txbufpolicy = stack.bi.txbufpolicy & 0x1; + if ((rv = zt_reallocbufs(chan, stack.bi.bufsize, stack.bi.numbufs))) return (rv); break; case ZT_GET_BLOCKSIZE: /* get blocksize */ @@ -3470,84 +3480,84 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign spin_unlock_irqrestore(&chan->lock, flags); return rv; case ZT_GETCONF: /* get conf stuff */ - copy_from_user(&conf,(struct zt_confinfo *) data,sizeof(conf)); - i = conf.chan; /* get channel no */ + copy_from_user(&stack.conf,(struct zt_confinfo *) data,sizeof(stack.conf)); + i = stack.conf.chan; /* get channel no */ /* if zero, use current channel no */ if (!i) i = chan->channo; /* make sure channel number makes sense */ if ((i < 0) || (i > ZT_MAX_CONF) || (!chans[i])) return(-EINVAL); if (!(chans[i]->flags & ZT_FLAG_AUDIO)) return (-EINVAL); - conf.chan = i; /* get channel number */ - conf.confno = chans[i]->confna; /* get conference number */ - conf.confmode = chans[i]->confmode; /* get conference mode */ - copy_to_user((struct zt_confinfo *) data,&conf,sizeof(conf)); + stack.conf.chan = i; /* get channel number */ + stack.conf.confno = chans[i]->confna; /* get conference number */ + stack.conf.confmode = chans[i]->confmode; /* get conference mode */ + copy_to_user((struct zt_confinfo *) data,&stack.conf,sizeof(stack.conf)); break; case ZT_SETCONF: /* set conf stuff */ - copy_from_user(&conf,(struct zt_confinfo *) data,sizeof(conf)); - i = conf.chan; /* get channel no */ + copy_from_user(&stack.conf,(struct zt_confinfo *) data,sizeof(stack.conf)); + i = stack.conf.chan; /* get channel no */ /* if zero, use current channel no */ if (!i) i = chan->channo; /* make sure channel number makes sense */ if ((i < 1) || (i > ZT_MAX_CHANNELS) || (!chans[i])) return(-EINVAL); if (!(chans[i]->flags & ZT_FLAG_AUDIO)) return (-EINVAL); - if (conf.confmode && ((conf.confmode & ZT_CONF_MODE_MASK) < 4)) { + if (stack.conf.confmode && ((stack.conf.confmode & ZT_CONF_MODE_MASK) < 4)) { /* Monitor mode -- it's a channel */ - if ((conf.confno < 0) || (conf.confno >= ZT_MAX_CHANNELS) || !chans[conf.confno]) return(-EINVAL); + if ((stack.conf.confno < 0) || (stack.conf.confno >= ZT_MAX_CHANNELS) || !chans[stack.conf.confno]) return(-EINVAL); } else { /* make sure conf number makes sense, too */ - if ((conf.confno < -1) || (conf.confno > ZT_MAX_CONF)) return(-EINVAL); + if ((stack.conf.confno < -1) || (stack.conf.confno > ZT_MAX_CONF)) return(-EINVAL); } /* if taking off of any conf, must have 0 mode */ - if ((!conf.confno) && conf.confmode) return(-EINVAL); + if ((!stack.conf.confno) && stack.conf.confmode) return(-EINVAL); /* likewise if 0 mode must have no conf */ - if ((!conf.confmode) && conf.confno) return (-EINVAL); - conf.chan = i; /* return with real channel # */ + if ((!stack.conf.confmode) && stack.conf.confno) return (-EINVAL); + stack.conf.chan = i; /* return with real channel # */ spin_lock_irqsave(&bigzaplock, flagso); spin_lock_irqsave(&chan->lock, flags); - if (conf.confno == -1) - conf.confno = zt_first_empty_conference(); - if ((conf.confno < 1) && (conf.confmode)) { + if (stack.conf.confno == -1) + stack.conf.confno = zt_first_empty_conference(); + if ((stack.conf.confno < 1) && (stack.conf.confmode)) { /* No more empty conferences */ spin_unlock_irqrestore(&chan->lock, flags); spin_unlock_irqrestore(&bigzaplock, flagso); return -EBUSY; } /* if changing confs, clear last added info */ - if (conf.confno != chans[i]->confna) { + if (stack.conf.confno != chans[i]->confna) { memset(chans[i]->conflast, 0, ZT_MAX_CHUNKSIZE); memset(chans[i]->conflast1, 0, ZT_MAX_CHUNKSIZE); memset(chans[i]->conflast2, 0, ZT_MAX_CHUNKSIZE); } j = chans[i]->confna; /* save old conference number */ - chans[i]->confna = conf.confno; /* set conference number */ - chans[i]->confmode = conf.confmode; /* set conference mode */ + chans[i]->confna = stack.conf.confno; /* set conference number */ + chans[i]->confmode = stack.conf.confmode; /* set conference mode */ chans[i]->_confn = 0; /* Clear confn */ zt_check_conf(j); - zt_check_conf(conf.confno); + zt_check_conf(stack.conf.confno); /* k will be non-zero if in a real conf */ - k = conf.confmode & (ZT_CONF_CONF | ZT_CONF_CONFANN | ZT_CONF_CONFMON | ZT_CONF_CONFANNMON | ZT_CONF_REALANDPSEUDO); + k = stack.conf.confmode & (ZT_CONF_CONF | ZT_CONF_CONFANN | ZT_CONF_CONFMON | ZT_CONF_CONFANNMON | ZT_CONF_REALANDPSEUDO); /* if we are going onto a conf */ - if (conf.confno && k) { + if (stack.conf.confno && k) { /* Get alias */ - chans[i]->_confn = zt_get_conf_alias(conf.confno); + chans[i]->_confn = zt_get_conf_alias(stack.conf.confno); } spin_unlock_irqrestore(&chan->lock, flags); spin_unlock_irqrestore(&bigzaplock, flagso); - copy_to_user((struct zt_confinfo *) data,&conf,sizeof(conf)); + copy_to_user((struct zt_confinfo *) data,&stack.conf,sizeof(stack.conf)); break; case ZT_CONFLINK: /* do conf link stuff */ if (!(chan->flags & ZT_FLAG_AUDIO)) return (-EINVAL); - copy_from_user(&conf,(struct zt_confinfo *) data,sizeof(conf)); + copy_from_user(&stack.conf,(struct zt_confinfo *) data,sizeof(stack.conf)); /* check sanity of arguments */ - if ((conf.chan < 0) || (conf.chan > ZT_MAX_CONF)) return(-EINVAL); - if ((conf.confno < 0) || (conf.confno > ZT_MAX_CONF)) return(-EINVAL); + if ((stack.conf.chan < 0) || (stack.conf.chan > ZT_MAX_CONF)) return(-EINVAL); + if ((stack.conf.confno < 0) || (stack.conf.confno > ZT_MAX_CONF)) return(-EINVAL); /* cant listen to self!! */ - if (conf.chan && (conf.chan == conf.confno)) return(-EINVAL); + if (stack.conf.chan && (stack.conf.chan == stack.conf.confno)) return(-EINVAL); spin_lock_irqsave(&bigzaplock, flagso); spin_lock_irqsave(&chan->lock, flags); /* if to clear all links */ - if ((!conf.chan) && (!conf.confno)) + if ((!stack.conf.chan) && (!stack.conf.confno)) { /* clear all the links */ memset(conf_links,0,sizeof(conf_links)); @@ -3561,12 +3571,12 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign for(i = 1; i <= ZT_MAX_CONF; i++) { /* if found, exit */ - if ((conf_links[i].src == conf.chan) && - (conf_links[i].dst == conf.confno)) break; + if ((conf_links[i].src == stack.conf.chan) && + (conf_links[i].dst == stack.conf.confno)) break; } if (i <= ZT_MAX_CONF) /* if found */ { - if (!conf.confmode) /* if to remove link */ + if (!stack.conf.confmode) /* if to remove link */ { conf_links[i].src = conf_links[i].dst = 0; } @@ -3577,7 +3587,7 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign } else /* if not found */ { - if (conf.confmode) /* if to add link */ + if (stack.conf.confmode) /* if to add link */ { /* look for empty location */ for(i = 1; i <= ZT_MAX_CONF; i++) @@ -3589,8 +3599,8 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign /* if empty spot found */ if (i <= ZT_MAX_CONF) { - conf_links[i].src = conf.chan; - conf_links[i].dst = conf.confno; + conf_links[i].src = stack.conf.chan; + conf_links[i].dst = stack.conf.confno; } else /* if no empties -- error */ { @@ -3662,9 +3672,9 @@ static int zt_chanandpseudo_ioctl(struct inode *inode, struct file *file, unsign case ZT_SETCADENCE: if (data) { /* Use specific ring cadence */ - if (copy_from_user(&cad, (struct zt_ring_cadence *)data, sizeof(cad))) + if (copy_from_user(&stack.cad, (struct zt_ring_cadence *)data, sizeof(stack.cad))) return -EIO; - memcpy(chan->ringcadence, &cad, sizeof(chan->ringcadence)); + memcpy(chan->ringcadence, &stack.cad, sizeof(chan->ringcadence)); } else { /* Reset to default */ if (chan->curzone) { -- cgit v1.2.3