From b7aa56683a7bd657063cf88021542c94bc842d05 Mon Sep 17 00:00:00 2001 From: markster Date: Fri, 9 Apr 2004 17:08:35 +0000 Subject: Make wcfxs more compatible with old compilers git-svn-id: http://svn.digium.com/svn/zaptel/trunk@352 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- wcfxs.c | 184 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 92 insertions(+), 92 deletions(-) (limited to 'wcfxs.c') diff --git a/wcfxs.c b/wcfxs.c index c67c55e..e7f5c40 100755 --- a/wcfxs.c +++ b/wcfxs.c @@ -194,7 +194,7 @@ struct wcfxs { int lasttxhook[NUM_CARDS]; int palarms[NUM_CARDS]; } fxs; - }; + } mod; /* Receive hook state and debouncing */ int modtype[NUM_CARDS]; @@ -263,41 +263,41 @@ static inline void ring_check(struct wcfxs *wc, int card) for (x=0;xchans[card].readchunk[x], (&(wc->chans[card]))); - if ((sample > 32000) && (wc->fxo.peg[card] != 1)) { + if ((sample > 32000) && (wc->mod.fxo.peg[card] != 1)) { printk("High peg!\n"); - if ((wc->fxo.pegtimer[card] < PEGTIME) && (wc->fxo.pegtimer[card] > MINPEGTIME)) - wc->fxo.pegcount[card]++; - wc->fxo.pegtimer[card] = 0; - wc->fxo.peg[card] = 1; - } else if ((sample < -32000) && (wc->fxo.peg[card] != -1)) { + if ((wc->mod.fxo.pegtimer[card] < PEGTIME) && (wc->mod.fxo.pegtimer[card] > MINPEGTIME)) + wc->mod.fxo.pegcount[card]++; + wc->mod.fxo.pegtimer[card] = 0; + wc->mod.fxo.peg[card] = 1; + } else if ((sample < -32000) && (wc->mod.fxo.peg[card] != -1)) { printk("Low peg!\n"); - if ((wc->fxo.pegtimer[card] < PEGTIME) && (wc->fxo.pegtimer[card] > MINPEGTIME)) - wc->fxo.pegcount[card]++; - wc->fxo.pegtimer[card] = 0; - wc->fxo.peg[card] = -1; + if ((wc->mod.fxo.pegtimer[card] < PEGTIME) && (wc->mod.fxo.pegtimer[card] > MINPEGTIME)) + wc->mod.fxo.pegcount[card]++; + wc->mod.fxo.pegtimer[card] = 0; + wc->mod.fxo.peg[card] = -1; } } - if (wc->fxo.pegtimer[card] > PEGTIME) { + if (wc->mod.fxo.pegtimer[card] > PEGTIME) { /* Reset pegcount if our timer expires */ - wc->fxo.pegcount[card] = 0; + wc->mod.fxo.pegcount[card] = 0; } /* Decrement debouncer if appropriate */ - if (wc->fxo.ringdebounce[card]) - wc->fxo.ringdebounce[card]--; - if (!wc->fxo.offhook[card] && !wc->fxo.ringdebounce[card]) { - if (!wc->fxo.ring[card] && (wc->fxo.pegcount[card] > PEGCOUNT)) { + if (wc->mod.fxo.ringdebounce[card]) + wc->mod.fxo.ringdebounce[card]--; + if (!wc->mod.fxo.offhook[card] && !wc->mod.fxo.ringdebounce[card]) { + if (!wc->mod.fxo.ring[card] && (wc->mod.fxo.pegcount[card] > PEGCOUNT)) { /* It's ringing */ if (debug) printk("RING!\n"); zt_hooksig(&wc->chans[card], ZT_RXSIG_RING); - wc->fxo.ring[card] = 1; + wc->mod.fxo.ring[card] = 1; } - if (wc->fxo.ring[card] && !wc->fxo.pegcount[card]) { + if (wc->mod.fxo.ring[card] && !wc->mod.fxo.pegcount[card]) { /* No more ring */ if (debug) printk("NO RING!\n"); zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK); - wc->fxo.ring[card] = 0; + wc->mod.fxo.ring[card] = 0; } } } @@ -647,19 +647,19 @@ static void wcfxs_interrupt(int irq, void *dev_id, struct pt_regs *regs) for (x=0;x<4;x++) { if ((x < wc->cards) && (wc->cardflag & (1 << x)) && (wc->modtype[x] == MOD_TYPE_FXS)) { - if (wc->fxs.lasttxhook[x] == 0x4) { + if (wc->mod.fxs.lasttxhook[x] == 0x4) { /* RINGing, prepare for OHT */ - wc->fxs.ohttimer[x] = OHT_TIMER << 3; - wc->fxs.idletxhookstate[x] = 0x2; /* OHT mode when idle */ + wc->mod.fxs.ohttimer[x] = OHT_TIMER << 3; + wc->mod.fxs.idletxhookstate[x] = 0x2; /* OHT mode when idle */ } else { - if (wc->fxs.ohttimer[x]) { - wc->fxs.ohttimer[x]-= ZT_CHUNKSIZE; - if (!wc->fxs.ohttimer[x]) { - wc->fxs.idletxhookstate[x] = 0x1; /* Switch to active */ - if (wc->fxs.lasttxhook[x] == 0x2) { + if (wc->mod.fxs.ohttimer[x]) { + wc->mod.fxs.ohttimer[x]-= ZT_CHUNKSIZE; + if (!wc->mod.fxs.ohttimer[x]) { + wc->mod.fxs.idletxhookstate[x] = 0x1; /* Switch to active */ + if (wc->mod.fxs.lasttxhook[x] == 0x2) { /* Apply the change if appropriate */ - wc->fxs.lasttxhook[x] = 0x1; - wcfxs_setreg(wc, x, 64, wc->fxs.lasttxhook[x]); + wc->mod.fxs.lasttxhook[x] = 0x1; + wcfxs_setreg(wc, x, 64, wc->mod.fxs.lasttxhook[x]); } } } @@ -683,8 +683,8 @@ static void wcfxs_interrupt(int irq, void *dev_id, struct pt_regs *regs) /* Accept an alarm once per 10 seconds */ for (x=0;x<4;x++) if (wc->modtype[x] == MOD_TYPE_FXS) { - if (wc->fxs.palarms[x]) - wc->fxs.palarms[x]--; + if (wc->mod.fxs.palarms[x]) + wc->mod.fxs.palarms[x]--; } } wcfxs_receiveprep(wc, ints); @@ -1021,7 +1021,7 @@ static int wcfxs_init_proslic(struct wcfxs *wc, int card, int fast, int manual, int x; /* By default, don't send on hook */ - wc->fxs.idletxhookstate [card] = 1; + wc->mod.fxs.idletxhookstate [card] = 1; /* Sanity check the ProSLIC */ if (!sane && wcfxs_proslic_insane(wc, card)) @@ -1170,14 +1170,14 @@ static inline void wcfxs_proslic_recheck_sanity(struct wcfxs *wc, int card) wcfxs_init_proslic(wc, card, 1, 0, 1); } else { res = wcfxs_getreg(wc, card, 64); - if (!res && (res != wc->fxs.lasttxhook[card])) { - if (wc->fxs.palarms[card]++ < MAX_ALARMS) { + if (!res && (res != wc->mod.fxs.lasttxhook[card])) { + if (wc->mod.fxs.palarms[card]++ < MAX_ALARMS) { printk("Power alarm on module %d, resetting!\n", card + 1); - if (wc->fxs.lasttxhook[card] == 4) - wc->fxs.lasttxhook[card] = 1; - wcfxs_setreg(wc, card, 64, wc->fxs.lasttxhook[card]); + if (wc->mod.fxs.lasttxhook[card] == 4) + wc->mod.fxs.lasttxhook[card] = 1; + wcfxs_setreg(wc, card, 64, wc->mod.fxs.lasttxhook[card]); } else { - if (wc->fxs.palarms[card] == MAX_ALARMS) + if (wc->mod.fxs.palarms[card] == MAX_ALARMS) printk("Too many power alarms on card %d, NOT resetting!\n", card + 1); } } @@ -1189,29 +1189,29 @@ static inline void wcfxs_voicedaa_check_hook(struct wcfxs *wc, int card) unsigned char res; signed char b; #ifndef AUDIO_RINGCHECK - if (!wc->fxo.offhook[card]) { + if (!wc->mod.fxo.offhook[card]) { res = wcfxs_getreg(wc, card, 5); if (res & 0x60) { - wc->fxo.ringdebounce[card] += (ZT_CHUNKSIZE * 4); - if (wc->fxo.ringdebounce[card] >= ZT_CHUNKSIZE * 32) { - if (!wc->fxo.wasringing[card]) { - wc->fxo.wasringing[card] = 1; + wc->mod.fxo.ringdebounce[card] += (ZT_CHUNKSIZE * 4); + if (wc->mod.fxo.ringdebounce[card] >= ZT_CHUNKSIZE * 32) { + if (!wc->mod.fxo.wasringing[card]) { + wc->mod.fxo.wasringing[card] = 1; zt_hooksig(&wc->chans[card], ZT_RXSIG_RING); if (debug) printk("RING!\n"); } - wc->fxo.ringdebounce[card] = ZT_CHUNKSIZE * 32; + wc->mod.fxo.ringdebounce[card] = ZT_CHUNKSIZE * 32; } } else { - wc->fxo.ringdebounce[card] -= ZT_CHUNKSIZE; - if (wc->fxo.ringdebounce[card] <= 0) { - if (wc->fxo.wasringing[card]) { - wc->fxo.wasringing[card] =0; + wc->mod.fxo.ringdebounce[card] -= ZT_CHUNKSIZE; + if (wc->mod.fxo.ringdebounce[card] <= 0) { + if (wc->mod.fxo.wasringing[card]) { + wc->mod.fxo.wasringing[card] =0; zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK); if (debug) printk("NO RING!\n"); } - wc->fxo.ringdebounce[card] = 0; + wc->mod.fxo.ringdebounce[card] = 0; } } @@ -1227,15 +1227,15 @@ static inline void wcfxs_voicedaa_check_hook(struct wcfxs *wc, int card) } #endif if (abs(b) < 2) { - wc->fxo.nobatttimer[card]++; + wc->mod.fxo.nobatttimer[card]++; #if 0 - if (wc->fxo.battery[card]) - printk("Battery loss: %d (%d debounce)\n", b, wc->fxo.battdebounce[card]); + if (wc->mod.fxo.battery[card]) + printk("Battery loss: %d (%d debounce)\n", b, wc->mod.fxo.battdebounce[card]); #endif - if (wc->fxo.battery[card] && !wc->fxo.battdebounce[card]) { + if (wc->mod.fxo.battery[card] && !wc->mod.fxo.battdebounce[card]) { if (debug) printk("NO BATTERY!\n"); - wc->fxo.battery[card] = 0; + wc->mod.fxo.battery[card] = 0; #ifdef JAPAN if ((!wc->ohdebounce) && wc->offhook) { zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK); @@ -1248,11 +1248,11 @@ static inline void wcfxs_voicedaa_check_hook(struct wcfxs *wc, int card) #else zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK); #endif - wc->fxo.battdebounce[card] = BATT_DEBOUNCE; - } else if (!wc->fxo.battery[card]) - wc->fxo.battdebounce[card] = BATT_DEBOUNCE; + wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE; + } else if (!wc->mod.fxo.battery[card]) + wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE; } else if (abs(b) > 1) { - if (!wc->fxo.battery[card] && !wc->fxo.battdebounce[card]) { + if (!wc->mod.fxo.battery[card] && !wc->mod.fxo.battdebounce[card]) { if (debug) printk("BATTERY!\n"); #ifdef ZERO_BATT_RING @@ -1265,14 +1265,14 @@ static inline void wcfxs_voicedaa_check_hook(struct wcfxs *wc, int card) #else zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK); #endif - wc->fxo.battery[card] = 1; - wc->fxo.nobatttimer[card] = 0; - wc->fxo.battdebounce[card] = BATT_DEBOUNCE; - } else if (wc->fxo.battery[card]) - wc->fxo.battdebounce[card] = BATT_DEBOUNCE; + wc->mod.fxo.battery[card] = 1; + wc->mod.fxo.nobatttimer[card] = 0; + wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE; + } else if (wc->mod.fxo.battery[card]) + wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE; } else { /* It's something else... */ - wc->fxo.battdebounce[card] = BATT_DEBOUNCE; + wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE; } } @@ -1287,25 +1287,25 @@ static inline void wcfxs_proslic_check_hook(struct wcfxs *wc, int card) res = wcfxs_getreg(wc, card, 68); hook = (res & 1); - if (hook != wc->fxs.lastrxhook[card]) { + if (hook != wc->mod.fxs.lastrxhook[card]) { /* Reset the debounce (must be multiple of 4ms) */ - wc->fxs.debounce[card] = 3 * 4 * 8; + wc->mod.fxs.debounce[card] = 3 * 4 * 8; #if 0 - printk("Resetting debounce card %d hook %d, %d\n", card, hook, wc->fxs.debounce[card]); + printk("Resetting debounce card %d hook %d, %d\n", card, hook, wc->mod.fxs.debounce[card]); #endif } else { - if (wc->fxs.debounce[card] > 0) { - wc->fxs.debounce[card]-= 4 * ZT_CHUNKSIZE; + if (wc->mod.fxs.debounce[card] > 0) { + wc->mod.fxs.debounce[card]-= 4 * ZT_CHUNKSIZE; #if 0 - printk("Sustaining hook %d, %d\n", hook, wc->fxs.debounce[card]); + printk("Sustaining hook %d, %d\n", hook, wc->mod.fxs.debounce[card]); #endif - if (!wc->fxs.debounce[card]) { + if (!wc->mod.fxs.debounce[card]) { #if 0 printk("Counted down debounce, newhook: %d...\n", hook); #endif - wc->fxs.debouncehook[card] = hook; + wc->mod.fxs.debouncehook[card] = hook; } - if (!wc->fxs.oldrxhook[card] && wc->fxs.debouncehook[card]) { + if (!wc->mod.fxs.oldrxhook[card] && wc->mod.fxs.debouncehook[card]) { /* Off hook */ #if 1 if (debug) @@ -1314,20 +1314,20 @@ static inline void wcfxs_proslic_check_hook(struct wcfxs *wc, int card) zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK); if (robust) wcfxs_init_proslic(wc, card, 1, 0, 1); - wc->fxs.oldrxhook[card] = 1; + wc->mod.fxs.oldrxhook[card] = 1; - } else if (wc->fxs.oldrxhook[card] && !wc->fxs.debouncehook[card]) { + } else if (wc->mod.fxs.oldrxhook[card] && !wc->mod.fxs.debouncehook[card]) { /* On hook */ #if 1 if (debug) #endif printk("wcfxs: Card %d Going on hook\n", card); zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK); - wc->fxs.oldrxhook[card] = 0; + wc->mod.fxs.oldrxhook[card] = 0; } } } - wc->fxs.lastrxhook[card] = hook; + wc->mod.fxs.lastrxhook[card] = hook; } @@ -1345,12 +1345,12 @@ static int wcfxs_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long dat return -EINVAL; if (get_user(x, (int *)data)) return -EFAULT; - wc->fxs.ohttimer[chan->chanpos - 1] = x << 3; - wc->fxs.idletxhookstate[chan->chanpos - 1] = 0x2; /* OHT mode when idle */ - if (wc->fxs.lasttxhook[chan->chanpos - 1] == 0x1) { + wc->mod.fxs.ohttimer[chan->chanpos - 1] = x << 3; + wc->mod.fxs.idletxhookstate[chan->chanpos - 1] = 0x2; /* OHT mode when idle */ + if (wc->mod.fxs.lasttxhook[chan->chanpos - 1] == 0x1) { /* Apply the change if appropriate */ - wc->fxs.lasttxhook[chan->chanpos - 1] = 0x2; - wcfxs_setreg(wc, chan->chanpos - 1, 64, wc->fxs.lasttxhook[chan->chanpos - 1]); + wc->mod.fxs.lasttxhook[chan->chanpos - 1] = 0x2; + wcfxs_setreg(wc, chan->chanpos - 1, 64, wc->mod.fxs.lasttxhook[chan->chanpos - 1]); } break; case WCFXS_GET_STATS: @@ -1424,7 +1424,7 @@ static int wcfxs_close(struct zt_chan *chan) wc->usecount--; MOD_DEC_USE_COUNT; for (x=0;xcards;x++) - wc->fxs.idletxhookstate[x] = 1; + wc->mod.fxs.idletxhookstate[x] = 1; /* If we're dead, release us now */ if (!wc->usecount && wc->dead) wcfxs_release(wc); @@ -1440,11 +1440,11 @@ static int wcfxs_hooksig(struct zt_chan *chan, zt_txsig_t txsig) switch(txsig) { case ZT_TXSIG_START: case ZT_TXSIG_OFFHOOK: - wc->fxo.offhook[chan->chanpos - 1] = 1; + wc->mod.fxo.offhook[chan->chanpos - 1] = 1; wcfxs_setreg(wc, chan->chanpos - 1, 5, 0x9); break; case ZT_TXSIG_ONHOOK: - wc->fxo.offhook[chan->chanpos - 1] = 0; + wc->mod.fxo.offhook[chan->chanpos - 1] = 0; wcfxs_setreg(wc, chan->chanpos - 1, 5, 0x8); break; default: @@ -1456,21 +1456,21 @@ static int wcfxs_hooksig(struct zt_chan *chan, zt_txsig_t txsig) switch(chan->sig) { case ZT_SIG_FXOKS: case ZT_SIG_FXOLS: - wc->fxs.lasttxhook[chan->chanpos-1] = wc->fxs.idletxhookstate[chan->chanpos-1]; + wc->mod.fxs.lasttxhook[chan->chanpos-1] = wc->mod.fxs.idletxhookstate[chan->chanpos-1]; break; case ZT_SIG_FXOGS: - wc->fxs.lasttxhook[chan->chanpos-1] = 3; + wc->mod.fxs.lasttxhook[chan->chanpos-1] = 3; break; } break; case ZT_TXSIG_OFFHOOK: - wc->fxs.lasttxhook[chan->chanpos-1] = wc->fxs.idletxhookstate[chan->chanpos-1]; + wc->mod.fxs.lasttxhook[chan->chanpos-1] = wc->mod.fxs.idletxhookstate[chan->chanpos-1]; break; case ZT_TXSIG_START: - wc->fxs.lasttxhook[chan->chanpos-1] = 4; + wc->mod.fxs.lasttxhook[chan->chanpos-1] = 4; break; case ZT_TXSIG_KEWL: - wc->fxs.lasttxhook[chan->chanpos-1] = 0; + wc->mod.fxs.lasttxhook[chan->chanpos-1] = 0; break; default: printk("wcfxs: Can't set tx state to %d\n", txsig); @@ -1479,7 +1479,7 @@ static int wcfxs_hooksig(struct zt_chan *chan, zt_txsig_t txsig) printk("Setting FXS hook state to %d (%02x)\n", txsig, reg); #if 1 - wcfxs_setreg(wc, chan->chanpos - 1, 64, wc->fxs.lasttxhook[chan->chanpos-1]); + wcfxs_setreg(wc, chan->chanpos - 1, 64, wc->mod.fxs.lasttxhook[chan->chanpos-1]); #endif } return 0; -- cgit v1.2.3