[svn-commits] sruffell: linux/trunk r9956 - /linux/trunk/drivers/dahdi/wctdm24xxp/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Jun 2 15:02:55 CDT 2011
Author: sruffell
Date: Thu Jun 2 15:02:51 2011
New Revision: 9956
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9956
Log:
wctdm24xxp: Group the per-module information together
Signed-off-by: Shaun Ruffell <sruffell at digium.com>
Modified:
linux/trunk/drivers/dahdi/wctdm24xxp/base.c
linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
linux/trunk/drivers/dahdi/wctdm24xxp/xhfc.c
Modified: linux/trunk/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=9956&r1=9955&r2=9956
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/base.c Thu Jun 2 15:02:51 2011
@@ -107,7 +107,11 @@
* polarity reversal for the port,
* and the state of the line reversal MWI indicator
*/
-#define POLARITY_XOR(card) ( (reversepolarity != 0) ^ (wc->mods[(card)].fxs.reversepolarity != 0) ^ (wc->mods[(card)].fxs.vmwi_linereverse != 0) )
+#define POLARITY_XOR(card) \
+ ((reversepolarity != 0) ^ \
+ (wc->mods[(card)].mod.fxs.reversepolarity != 0) ^ \
+ (wc->mods[(card)].mod.fxs.vmwi_linereverse != 0))
+
static int reversepolarity = 0;
static alpha indirect_regs[] =
@@ -277,7 +281,7 @@
{
int x;
for (x = 0; x < USER_COMMANDS; x++) {
- if (!wc->cmdq[card].cmds[x])
+ if (!wc->mods[card].cmdq.cmds[x])
return x;
}
return -1;
@@ -579,17 +583,17 @@
static inline void cmd_dequeue(struct wctdm *wc, unsigned char *eframe, int card, int pos)
{
+ struct wctdm_module *const mod = &wc->mods[card];
unsigned long flags;
unsigned int curcmd=0;
int x;
int subaddr = card & 0x3;
- /* QRV and BRI modules only use commands relating to the first channel */
- if ((card & 0x03) && (wc->modtype[card] == MOD_TYPE_QRV)) {
+ /* QRV only use commands relating to the first channel */
+ if ((card & 0x03) && (mod->type == MOD_TYPE_QRV))
return;
- }
-
- if (wc->altcs[card])
+
+ if (mod->altcs)
subaddr = 0;
/* Skip audio */
@@ -598,10 +602,10 @@
/* Search for something waiting to transmit */
if (pos) {
for (x = 0; x < MAX_COMMANDS; x++) {
- if ((wc->cmdq[card].cmds[x] & (__CMD_RD | __CMD_WR)) &&
- !(wc->cmdq[card].cmds[x] & (__CMD_TX | __CMD_FIN))) {
- curcmd = wc->cmdq[card].cmds[x];
- wc->cmdq[card].cmds[x] |= (wc->txident << 24) | __CMD_TX;
+ if ((mod->cmdq.cmds[x] & (__CMD_RD | __CMD_WR)) &&
+ !(mod->cmdq.cmds[x] & (__CMD_TX | __CMD_FIN))) {
+ curcmd = mod->cmdq.cmds[x];
+ mod->cmdq.cmds[x] |= (wc->txident << 24) | __CMD_TX;
break;
}
}
@@ -609,47 +613,47 @@
if (!curcmd) {
/* If nothing else, use filler */
- if (wc->modtype[card] == MOD_TYPE_FXS)
+ if (mod->type == MOD_TYPE_FXS)
curcmd = CMD_RD(LINE_STATE);
- else if (wc->modtype[card] == MOD_TYPE_FXO)
+ else if (mod->type == MOD_TYPE_FXO)
curcmd = CMD_RD(12);
- else if (wc->modtype[card] == MOD_TYPE_BRI)
+ else if (mod->type == MOD_TYPE_BRI)
curcmd = 0x101010;
- else if (wc->modtype[card] == MOD_TYPE_QRV)
+ else if (mod->type == MOD_TYPE_QRV)
curcmd = CMD_RD(3);
}
- if (wc->modtype[card] == MOD_TYPE_FXS) {
- eframe[CMD_BYTE(card, 0, wc->altcs[card])] = (1 << (subaddr));
+ if (mod->type == MOD_TYPE_FXS) {
+ eframe[CMD_BYTE(card, 0, mod->altcs)] = (1 << (subaddr));
if (curcmd & __CMD_WR)
- eframe[CMD_BYTE(card, 1, wc->altcs[card])] = (curcmd >> 8) & 0x7f;
+ eframe[CMD_BYTE(card, 1, mod->altcs)] = (curcmd >> 8) & 0x7f;
else
- eframe[CMD_BYTE(card, 1, wc->altcs[card])] = 0x80 | ((curcmd >> 8) & 0x7f);
- eframe[CMD_BYTE(card, 2, wc->altcs[card])] = curcmd & 0xff;
-
- } else if (wc->modtype[card] == MOD_TYPE_FXO) {
+ eframe[CMD_BYTE(card, 1, mod->altcs)] = 0x80 | ((curcmd >> 8) & 0x7f);
+ eframe[CMD_BYTE(card, 2, mod->altcs)] = curcmd & 0xff;
+
+ } else if (mod->type == MOD_TYPE_FXO) {
static const int FXO_ADDRS[4] = { 0x00, 0x08, 0x04, 0x0c };
- int idx = CMD_BYTE(card, 0, wc->altcs[card]);
+ int idx = CMD_BYTE(card, 0, mod->altcs);
if (curcmd & __CMD_WR)
eframe[idx] = 0x20 | FXO_ADDRS[subaddr];
else
eframe[idx] = 0x60 | FXO_ADDRS[subaddr];
- eframe[CMD_BYTE(card, 1, wc->altcs[card])] = (curcmd >> 8) & 0xff;
- eframe[CMD_BYTE(card, 2, wc->altcs[card])] = curcmd & 0xff;
-
- } else if (wc->modtype[card] == MOD_TYPE_FXSINIT) {
+ eframe[CMD_BYTE(card, 1, mod->altcs)] = (curcmd >> 8) & 0xff;
+ eframe[CMD_BYTE(card, 2, mod->altcs)] = curcmd & 0xff;
+
+ } else if (mod->type == MOD_TYPE_FXSINIT) {
/* Special case, we initialize the FXS's into the three-byte command mode then
switch to the regular mode. To send it into thee byte mode, treat the path as
6 two-byte commands and in the last one we initialize register 0 to 0x80. All modules
read this as the command to switch to daisy chain mode and we're done. */
- eframe[CMD_BYTE(card, 0, wc->altcs[card])] = 0x00;
- eframe[CMD_BYTE(card, 1, wc->altcs[card])] = 0x00;
+ eframe[CMD_BYTE(card, 0, mod->altcs)] = 0x00;
+ eframe[CMD_BYTE(card, 1, mod->altcs)] = 0x00;
if ((card & 0x1) == 0x1)
- eframe[CMD_BYTE(card, 2, wc->altcs[card])] = 0x80;
+ eframe[CMD_BYTE(card, 2, mod->altcs)] = 0x80;
else
- eframe[CMD_BYTE(card, 2, wc->altcs[card])] = 0x00;
-
- } else if (wc->modtype[card] == MOD_TYPE_BRI) {
+ eframe[CMD_BYTE(card, 2, mod->altcs)] = 0x00;
+
+ } else if (mod->type == MOD_TYPE_BRI) {
if (unlikely((curcmd != 0x101010) && (curcmd & 0x1010) == 0x1010)) /* b400m CPLD */
eframe[CMD_BYTE(card, 0, 0)] = 0x55;
@@ -657,23 +661,24 @@
eframe[CMD_BYTE(card, 0, 0)] = 0x10;
eframe[CMD_BYTE(card, 1, 0)] = (curcmd >> 8) & 0xff;
eframe[CMD_BYTE(card, 2, 0)] = curcmd & 0xff;
- } else if (wc->modtype[card] == MOD_TYPE_QRV) {
+
+ } else if (mod->type == MOD_TYPE_QRV) {
- eframe[CMD_BYTE(card, 0, wc->altcs[card])] = 0x00;
+ eframe[CMD_BYTE(card, 0, mod->altcs)] = 0x00;
if (!curcmd) {
- eframe[CMD_BYTE(card, 1, wc->altcs[card])] = 0x00;
- eframe[CMD_BYTE(card, 2, wc->altcs[card])] = 0x00;
+ eframe[CMD_BYTE(card, 1, mod->altcs)] = 0x00;
+ eframe[CMD_BYTE(card, 2, mod->altcs)] = 0x00;
} else {
if (curcmd & __CMD_WR)
- eframe[CMD_BYTE(card, 1, wc->altcs[card])] = 0x40 | ((curcmd >> 8) & 0x3f);
+ eframe[CMD_BYTE(card, 1, mod->altcs)] = 0x40 | ((curcmd >> 8) & 0x3f);
else
- eframe[CMD_BYTE(card, 1, wc->altcs[card])] = 0xc0 | ((curcmd >> 8) & 0x3f);
- eframe[CMD_BYTE(card, 2, wc->altcs[card])] = curcmd & 0xff;
- }
- } else if (wc->modtype[card] == MOD_TYPE_NONE) {
- eframe[CMD_BYTE(card, 0, wc->altcs[card])] = 0x10;
- eframe[CMD_BYTE(card, 1, wc->altcs[card])] = 0x10;
- eframe[CMD_BYTE(card, 2, wc->altcs[card])] = 0x10;
+ eframe[CMD_BYTE(card, 1, mod->altcs)] = 0xc0 | ((curcmd >> 8) & 0x3f);
+ eframe[CMD_BYTE(card, 2, mod->altcs)] = curcmd & 0xff;
+ }
+ } else if (mod->type == MOD_TYPE_NONE) {
+ eframe[CMD_BYTE(card, 0, mod->altcs)] = 0x10;
+ eframe[CMD_BYTE(card, 1, mod->altcs)] = 0x10;
+ eframe[CMD_BYTE(card, 2, mod->altcs)] = 0x10;
}
spin_unlock_irqrestore(&wc->reglock, flags);
}
@@ -721,14 +726,14 @@
static inline void cmd_decipher(struct wctdm *wc, const u8 *eframe, int card)
{
+ struct wctdm_module *const mod = &wc->mods[card];
unsigned long flags;
unsigned char ident;
int x;
- /* QRV and BRI modules only use commands relating to the first channel */
- if ((card & 0x03) && (wc->modtype[card] == MOD_TYPE_QRV)) { /* || (wc->modtype[card] == MOD_TYPE_BRI))) { */
+ /* QRV modules only use commands relating to the first channel */
+ if ((card & 0x03) && (mod->type == MOD_TYPE_QRV))
return;
- }
/* Skip audio */
eframe += 24;
@@ -736,22 +741,21 @@
/* Search for any pending results */
for (x=0;x<MAX_COMMANDS;x++) {
- if ((wc->cmdq[card].cmds[x] & (__CMD_RD | __CMD_WR)) &&
- (wc->cmdq[card].cmds[x] & (__CMD_TX)) &&
- !(wc->cmdq[card].cmds[x] & (__CMD_FIN))) {
- ident = (wc->cmdq[card].cmds[x] >> 24) & 0xff;
+ if ((mod->cmdq.cmds[x] & (__CMD_RD | __CMD_WR)) &&
+ (mod->cmdq.cmds[x] & (__CMD_TX)) &&
+ !(mod->cmdq.cmds[x] & (__CMD_FIN))) {
+ ident = (mod->cmdq.cmds[x] >> 24) & 0xff;
if (ident == wc->rxident) {
/* Store result */
- wc->cmdq[card].cmds[x] |= eframe[CMD_BYTE(card, 2, wc->altcs[card])];
- wc->cmdq[card].cmds[x] |= __CMD_FIN;
-
- if (wc->cmdq[card].cmds[x] & __CMD_WR) {
+ mod->cmdq.cmds[x] |= eframe[CMD_BYTE(card, 2, mod->altcs)];
+ mod->cmdq.cmds[x] |= __CMD_FIN;
+ if (mod->cmdq.cmds[x] & __CMD_WR) {
/* Go ahead and clear out writes since they need no acknowledgement */
- wc->cmdq[card].cmds[x] = 0x00000000;
+ mod->cmdq.cmds[x] = 0x00000000;
} else if (x >= USER_COMMANDS) {
/* Clear out ISR reads */
- wc->cmdq[card].isrshadow[x - USER_COMMANDS] = wc->cmdq[card].cmds[x] & 0xff;
- wc->cmdq[card].cmds[x] = 0x00000000;
+ mod->cmdq.isrshadow[x - USER_COMMANDS] = mod->cmdq.cmds[x] & 0xff;
+ mod->cmdq.cmds[x] = 0x00000000;
}
break;
}
@@ -762,33 +766,35 @@
static inline void cmd_checkisr(struct wctdm *wc, int card)
{
- if (!wc->cmdq[card].cmds[USER_COMMANDS + 0]) {
- if (wc->sethook[card]) {
- wc->cmdq[card].cmds[USER_COMMANDS + 0] = wc->sethook[card];
- wc->sethook[card] = 0;
- } else if (wc->modtype[card] == MOD_TYPE_FXS) {
- wc->cmdq[card].cmds[USER_COMMANDS + 0] = CMD_RD(68); /* Hook state */
- } else if (wc->modtype[card] == MOD_TYPE_FXO) {
- wc->cmdq[card].cmds[USER_COMMANDS + 0] = CMD_RD(5); /* Hook/Ring state */
- } else if (wc->modtype[card] == MOD_TYPE_QRV) {
- wc->cmdq[card & 0xfc].cmds[USER_COMMANDS + 0] = CMD_RD(3); /* COR/CTCSS state */
- } else if (wc->modtype[card] == MOD_TYPE_BRI) {
- wc->cmdq[card].cmds[USER_COMMANDS + 0] = wctdm_bri_checkisr(wc, card, 0);
- }
- }
- if (!wc->cmdq[card].cmds[USER_COMMANDS + 1]) {
- if (wc->modtype[card] == MOD_TYPE_FXS) {
+ struct wctdm_module *const mod = &wc->mods[card];
+
+ if (!mod->cmdq.cmds[USER_COMMANDS + 0]) {
+ if (mod->sethook) {
+ mod->cmdq.cmds[USER_COMMANDS + 0] = mod->sethook;
+ mod->sethook = 0;
+ } else if (mod->type == MOD_TYPE_FXS) {
+ mod->cmdq.cmds[USER_COMMANDS + 0] = CMD_RD(68); /* Hook state */
+ } else if (mod->type == MOD_TYPE_FXO) {
+ mod->cmdq.cmds[USER_COMMANDS + 0] = CMD_RD(5); /* Hook/Ring state */
+ } else if (mod->type == MOD_TYPE_QRV) {
+ wc->mods[card & 0xfc].cmdq.cmds[USER_COMMANDS + 0] = CMD_RD(3); /* COR/CTCSS state */
+ } else if (mod->type == MOD_TYPE_BRI) {
+ mod->cmdq.cmds[USER_COMMANDS + 0] = wctdm_bri_checkisr(wc, card, 0);
+ }
+ }
+ if (!mod->cmdq.cmds[USER_COMMANDS + 1]) {
+ if (mod->type == MOD_TYPE_FXS) {
#ifdef PAQ_DEBUG
- wc->cmdq[card].cmds[USER_COMMANDS + 1] = CMD_RD(19); /* Transistor interrupts */
+ mod->cmdq.cmds[USER_COMMANDS + 1] = CMD_RD(19); /* Transistor interrupts */
#else
- wc->cmdq[card].cmds[USER_COMMANDS + 1] = CMD_RD(LINE_STATE);
+ mod->cmdq.cmds[USER_COMMANDS + 1] = CMD_RD(LINE_STATE);
#endif
- } else if (wc->modtype[card] == MOD_TYPE_FXO) {
- wc->cmdq[card].cmds[USER_COMMANDS + 1] = CMD_RD(29); /* Battery */
- } else if (wc->modtype[card] == MOD_TYPE_QRV) {
- wc->cmdq[card & 0xfc].cmds[USER_COMMANDS + 1] = CMD_RD(3); /* Battery */
- } else if (wc->modtype[card] == MOD_TYPE_BRI) {
- wc->cmdq[card].cmds[USER_COMMANDS + 1] = wctdm_bri_checkisr(wc, card, 1);
+ } else if (mod->type == MOD_TYPE_FXO) {
+ mod->cmdq.cmds[USER_COMMANDS + 1] = CMD_RD(29); /* Battery */
+ } else if (mod->type == MOD_TYPE_QRV) {
+ wc->mods[card & 0xfc].cmdq.cmds[USER_COMMANDS + 1] = CMD_RD(3); /* Battery */
+ } else if (mod->type == MOD_TYPE_BRI) {
+ mod->cmdq.cmds[USER_COMMANDS + 1] = wctdm_bri_checkisr(wc, card, 1);
}
}
}
@@ -905,7 +911,7 @@
spin_lock_irqsave(&wc->reglock, flags);
*hit = empty_slot(wc, card);
if (*hit > -1)
- wc->cmdq[card].cmds[*hit] = cmd;
+ wc->mods[card].cmdq.cmds[*hit] = cmd;
spin_unlock_irqrestore(&wc->reglock, flags);
return (*hit > -1);
@@ -919,8 +925,8 @@
const unsigned int cmd = CMD_WR(addr, val);
/* QRV and BRI cards are only addressed at their first "port" */
- if ((card & 0x03) && ((wc->modtype[card] == MOD_TYPE_QRV) ||
- (wc->modtype[card] == MOD_TYPE_BRI)))
+ if ((card & 0x03) && ((wc->mods[card].type == MOD_TYPE_QRV) ||
+ (wc->mods[card].type == MOD_TYPE_BRI)))
return 0;
if (inisr) {
@@ -946,13 +952,14 @@
static bool cmd_finished(struct wctdm *wc, int card, int hit, u8 *val)
{
+ struct wctdm_module *const mod = &wc->mods[card];
bool ret;
unsigned long flags;
spin_lock_irqsave(&wc->reglock, flags);
- if (wc->cmdq[card].cmds[hit] & __CMD_FIN) {
- *val = wc->cmdq[card].cmds[hit] & 0xff;
- wc->cmdq[card].cmds[hit] = 0x00000000;
+ if (mod->cmdq.cmds[hit] & __CMD_FIN) {
+ *val = mod->cmdq.cmds[hit] & 0xff;
+ mod->cmdq.cmds[hit] = 0x00000000;
ret = true;
} else {
ret = false;
@@ -970,7 +977,7 @@
int ret;
/* if a QRV card, use only its first channel */
- if (wc->modtype[card] == MOD_TYPE_QRV) {
+ if (wc->mods[card].type == MOD_TYPE_QRV) {
if (card & 3)
return 0;
}
@@ -996,10 +1003,11 @@
spin_lock_irqsave(&wc->reglock, flags);
for (x=0;x<MAX_COMMANDS;x++) {
for (y = 0; y < wc->mods_per_board; y++) {
- if (wc->modtype[y] != MOD_TYPE_BRI) {
- if (!(wc->cmdq[y].cmds[x] & __CMD_FIN))
- wc->cmdq[y].cmds[x] &= ~(__CMD_TX | (0xff << 24));
- }
+ struct wctdm_module *const mod = &wc->mods[y];
+ if (mod->type == MOD_TYPE_BRI)
+ continue;
+ if (!(mod->cmdq.cmds[x] & __CMD_FIN))
+ mod->cmdq.cmds[x] &= ~(__CMD_TX | (0xff << 24));
}
}
spin_unlock_irqrestore(&wc->reglock, flags);
@@ -1173,7 +1181,7 @@
{
int res = -1;
/* Translate 3215 addresses */
- if (wc->flags[card] & FLAG_3215) {
+ if (wc->mods[card].flags & FLAG_3215) {
address = translate_3215(address);
if (address == 255)
return 0;
@@ -1192,7 +1200,7 @@
int res = -1;
char *p=NULL;
/* Translate 3215 addresses */
- if (wc->flags[card] & FLAG_3215) {
+ if (wc->mods[card].flags & FLAG_3215) {
address = translate_3215(address);
if (address == 255)
return 0;
@@ -1242,10 +1250,12 @@
}
initial= indirect_regs[i].initial;
- if ( j != initial && (!(wc->flags[card] & FLAG_3215) || (indirect_regs[i].altaddr != 255)))
- {
- dev_notice(&wc->vb.pdev->dev, "!!!!!!! %s iREG %X = %X should be %X\n",
- indirect_regs[i].name,indirect_regs[i].address,j,initial );
+ if ((j != initial) && (!(wc->mods[card].flags & FLAG_3215) ||
+ (indirect_regs[i].altaddr != 255))) {
+ dev_notice(&wc->vb.pdev->dev,
+ "!!!!!!! %s iREG %X = %X should be %X\n",
+ indirect_regs[i].name,
+ indirect_regs[i].address, j, initial);
passed = 0;
}
}
@@ -1263,7 +1273,8 @@
/* 1ms interrupt */
static inline void wctdm_proslic_check_oppending(struct wctdm *wc, int card)
{
- struct fxs *const fxs = &wc->mods[card].fxs;
+ struct wctdm_module *const mod = &wc->mods[card];
+ struct fxs *const fxs = &mod->mod.fxs;
int res;
/* Monitor the Pending LF state change, for the next 100ms */
@@ -1275,20 +1286,24 @@
return;
}
- res = wc->cmdq[card].isrshadow[1];
+ res = mod->cmdq.isrshadow[1];
if ((res & SLIC_LF_SETMASK) == (fxs->lasttxhook & SLIC_LF_SETMASK)) {
fxs->lasttxhook &= SLIC_LF_SETMASK;
fxs->oppending_ms = 0;
if (debug & DEBUG_CARD) {
- dev_info(&wc->vb.pdev->dev, "SLIC_LF OK: card=%d shadow=%02x lasttxhook=%02x intcount=%d \n", card, res, fxs->lasttxhook, wc->intcount);
+ dev_info(&wc->vb.pdev->dev,
+ "SLIC_LF OK: card=%d shadow=%02x "
+ "lasttxhook=%02x intcount=%d\n", card,
+ res, fxs->lasttxhook, wc->intcount);
}
- } else if (fxs->oppending_ms) { /* if timing out */
- if (--fxs->oppending_ms == 0) {
- /* Timed out, resend the linestate */
- wc->sethook[card] = CMD_WR(LINE_STATE, fxs->lasttxhook);
- if (debug & DEBUG_CARD) {
- dev_info(&wc->vb.pdev->dev, "SLIC_LF RETRY: card=%d shadow=%02x lasttxhook=%02x intcount=%d \n", card, res, fxs->lasttxhook, wc->intcount);
- }
+ } else if (fxs->oppending_ms && (--fxs->oppending_ms == 0)) {
+ /* Timed out, resend the linestate */
+ mod->sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
+ if (debug & DEBUG_CARD) {
+ dev_info(&wc->vb.pdev->dev,
+ "SLIC_LF RETRY: card=%d shadow=%02x "
+ "lasttxhook=%02x intcount=%d\n", card,
+ res, fxs->lasttxhook, wc->intcount);
}
} else { /* Start 100ms Timeout */
fxs->oppending_ms = 100;
@@ -1300,20 +1315,21 @@
/* 256ms interrupt */
static inline void wctdm_proslic_recheck_sanity(struct wctdm *wc, int card)
{
- struct fxs *const fxs = &wc->mods[card].fxs;
+ struct wctdm_module *const mod = &wc->mods[card];
+ struct fxs *const fxs = &mod->mod.fxs;
int res;
unsigned long flags;
#ifdef PAQ_DEBUG
- res = wc->cmdq[card].isrshadow[1];
+ res = mod->cmdq.isrshadow[1];
res &= ~0x3;
if (res) {
- wc->cmdq[card].isrshadow[1]=0;
+ mod->cmdq.isrshadow[1] = 0;
fxs->palarms++;
if (fxs->palarms < MAX_ALARMS) {
dev_notice(&wc->vb.pdev->dev, "Power alarm (%02x) on module %d, resetting!\n", res, card + 1);
- wc->sethook[card] = CMD_WR(19, res);
+ mod->sethook = CMD_WR(19, res);
/* Update shadow register to avoid extra power alarms until next read */
- wc->cmdq[card].isrshadow[1] = 0;
+ mod->cmdq.isrshadow[1] = 0;
} else {
if (fxs->palarms == MAX_ALARMS)
dev_notice(&wc->vb.pdev->dev, "Too many power alarms on card %d, NOT resetting!\n", card + 1);
@@ -1321,7 +1337,7 @@
}
#else
spin_lock_irqsave(&fxs->lasttxhooklock, flags);
- res = wc->cmdq[card].isrshadow[1];
+ res = mod->cmdq.isrshadow[1];
#if 0
/* This makes sure the lasthook was put in reg 64 the linefeed reg */
@@ -1332,7 +1348,7 @@
dev_info(&wc->vb.pdev->dev, "SLIC_LF OK: intcount=%d channel=%d shadow=%02x lasttxhook=%02x\n", wc->intcount, card, res, fxs->lasttxhook);
}
} else if (!(wc->intcount & 0x03)) {
- wc->sethook[card] = CMD_WR(LINE_STATE, fxs->lasttxhook);
+ mod->sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
if (debug & DEBUG_CARD) {
dev_info(&wc->vb.pdev->dev, "SLIC_LF RETRY: intcount=%d channel=%d shadow=%02x lasttxhook=%02x\n", wc->intcount, card, res, fxs->lasttxhook);
}
@@ -1361,11 +1377,11 @@
SLIC_LF_ACTIVE_FWD;;
}
fxs->lasttxhook |= SLIC_LF_OPPENDING;
- wc->sethook[card] = CMD_WR(LINE_STATE, fxs->lasttxhook);
+ mod->sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
/* Update shadow register to avoid extra power alarms until next read */
- wc->cmdq[card].isrshadow[1] = fxs->lasttxhook;
+ mod->cmdq.isrshadow[1] = fxs->lasttxhook;
} else {
if (fxs->palarms == MAX_ALARMS)
dev_notice(&wc->vb.pdev->dev, "Too many power alarms on card %d, NOT resetting!\n", card + 1);
@@ -1379,51 +1395,65 @@
signed char b,b1;
int qrvcard = card & 0xfc;
-
- if (wc->qrvdebtime[card] >= 2) wc->qrvdebtime[card]--;
- b = wc->cmdq[qrvcard].isrshadow[0]; /* Hook/Ring state */
+ if (wc->mods[card].qrvdebtime >= 2)
+ wc->mods[card].qrvdebtime--;
+ b = wc->mods[qrvcard].cmdq.isrshadow[0]; /* Hook/Ring state */
b &= 0xcc; /* use bits 3-4 and 6-7 only */
- if (wc->radmode[qrvcard] & RADMODE_IGNORECOR) b &= ~4;
- else if (!(wc->radmode[qrvcard] & RADMODE_INVERTCOR)) b ^= 4;
- if (wc->radmode[qrvcard + 1] | RADMODE_IGNORECOR) b &= ~0x40;
- else if (!(wc->radmode[qrvcard + 1] | RADMODE_INVERTCOR)) b ^= 0x40;
-
- if ((wc->radmode[qrvcard] & RADMODE_IGNORECT) ||
- (!(wc->radmode[qrvcard] & RADMODE_EXTTONE))) b &= ~8;
- else if (!(wc->radmode[qrvcard] & RADMODE_EXTINVERT)) b ^= 8;
- if ((wc->radmode[qrvcard + 1] & RADMODE_IGNORECT) ||
- (!(wc->radmode[qrvcard + 1] & RADMODE_EXTTONE))) b &= ~0x80;
- else if (!(wc->radmode[qrvcard + 1] & RADMODE_EXTINVERT)) b ^= 0x80;
+ if (wc->mods[qrvcard].radmode & RADMODE_IGNORECOR)
+ b &= ~4;
+ else if (!(wc->mods[qrvcard].radmode & RADMODE_INVERTCOR))
+ b ^= 4;
+ if (wc->mods[qrvcard + 1].radmode | RADMODE_IGNORECOR)
+ b &= ~0x40;
+ else if (!(wc->mods[qrvcard + 1].radmode | RADMODE_INVERTCOR))
+ b ^= 0x40;
+
+ if ((wc->mods[qrvcard].radmode & RADMODE_IGNORECT) ||
+ (!(wc->mods[qrvcard].radmode & RADMODE_EXTTONE)))
+ b &= ~8;
+ else if (!(wc->mods[qrvcard].radmode & RADMODE_EXTINVERT))
+ b ^= 8;
+ if ((wc->mods[qrvcard + 1].radmode & RADMODE_IGNORECT) ||
+ (!(wc->mods[qrvcard + 1].radmode & RADMODE_EXTTONE)))
+ b &= ~0x80;
+ else if (!(wc->mods[qrvcard + 1].radmode & RADMODE_EXTINVERT))
+ b ^= 0x80;
/* now b & MASK should be zero, if its active */
/* check for change in chan 0 */
- if ((!(b & 0xc)) != wc->qrvhook[qrvcard + 2])
+ if ((!(b & 0xc)) != wc->mods[qrvcard + 2].qrvhook)
{
- wc->qrvdebtime[qrvcard] = wc->debouncetime[qrvcard];
- wc->qrvhook[qrvcard + 2] = !(b & 0xc);
+ wc->mods[qrvcard].qrvdebtime = wc->mods[qrvcard].debouncetime;
+ wc->mods[qrvcard + 2].qrvhook = !(b & 0xc);
}
/* if timed-out and ready */
- if (wc->qrvdebtime[qrvcard] == 1)
- {
- b1 = wc->qrvhook[qrvcard + 2];
-if (debug) dev_info(&wc->vb.pdev->dev, "QRV channel %d rx state changed to %d\n",qrvcard,wc->qrvhook[qrvcard + 2]);
+ if (wc->mods[qrvcard].qrvdebtime == 1) {
+ b1 = wc->mods[qrvcard + 2].qrvhook;
+ if (debug) {
+ dev_info(&wc->vb.pdev->dev,
+ "QRV channel %d rx state changed to %d\n",
+ qrvcard, wc->mods[qrvcard + 2].qrvhook);
+ }
dahdi_hooksig(wc->aspan->span.chans[qrvcard],
(b1) ? DAHDI_RXSIG_OFFHOOK : DAHDI_RXSIG_ONHOOK);
- wc->qrvdebtime[card] = 0;
+ wc->mods[card].qrvdebtime = 0;
}
/* check for change in chan 1 */
- if ((!(b & 0xc0)) != wc->qrvhook[qrvcard + 3])
+ if ((!(b & 0xc0)) != wc->mods[qrvcard + 3].qrvhook)
{
- wc->qrvdebtime[qrvcard + 1] = QRV_DEBOUNCETIME;
- wc->qrvhook[qrvcard + 3] = !(b & 0xc0);
- }
- if (wc->qrvdebtime[qrvcard + 1] == 1)
- {
- b1 = wc->qrvhook[qrvcard + 3];
-if (debug) dev_info(&wc->vb.pdev->dev, "QRV channel %d rx state changed to %d\n",qrvcard + 1,wc->qrvhook[qrvcard + 3]);
+ wc->mods[qrvcard + 1].qrvdebtime = QRV_DEBOUNCETIME;
+ wc->mods[qrvcard + 3].qrvhook = !(b & 0xc0);
+ }
+ if (wc->mods[qrvcard + 1].qrvdebtime == 1) {
+ b1 = wc->mods[qrvcard + 3].qrvhook;
+ if (debug) {
+ dev_info(&wc->vb.pdev->dev,
+ "QRV channel %d rx state changed to %d\n",
+ qrvcard + 1, wc->mods[qrvcard + 3].qrvhook);
+ }
dahdi_hooksig(wc->aspan->span.chans[qrvcard + 1],
(b1) ? DAHDI_RXSIG_OFFHOOK : DAHDI_RXSIG_ONHOOK);
- wc->qrvdebtime[card] = 0;
+ wc->mods[card].qrvdebtime = 0;
}
return;
}
@@ -1435,10 +1465,11 @@
unsigned char res;
signed char b;
unsigned int abs_voltage;
- struct fxo *fxo = &wc->mods[card].fxo;
+ struct wctdm_module *const mod = &wc->mods[card];
+ struct fxo *const fxo = &mod->mod.fxo;
/* Try to track issues that plague slot one FXO's */
- b = wc->cmdq[card].isrshadow[0]; /* Hook/Ring state */
+ b = mod->cmdq.isrshadow[0]; /* Hook/Ring state */
b &= 0x9b;
if (fxo->offhook) {
if (b != 0x9)
@@ -1458,8 +1489,8 @@
* but not to have transitions between the two bits (i.e. no negative
* to positive or positive to negative transversals )
*/
- res = wc->cmdq[card].isrshadow[0] & 0x60;
- if (0 == wc->mods[card].fxo.wasringing) {
+ res = mod->cmdq.isrshadow[0] & 0x60;
+ if (0 == fxo->wasringing) {
if (res) {
/* Look for positive/negative crossings in ring status reg */
fxo->wasringing = 2;
@@ -1496,7 +1527,7 @@
}
}
} else {
- res = wc->cmdq[card].isrshadow[0];
+ res = mod->cmdq.isrshadow[0];
if ((res & 0x60) && (fxo->battery == BATTERY_PRESENT)) {
fxo->ringdebounce += (DAHDI_CHUNKSIZE * 16);
if (fxo->ringdebounce >= DAHDI_CHUNKSIZE * ringdebounce) {
@@ -1524,7 +1555,7 @@
}
}
- b = wc->cmdq[card].isrshadow[1]; /* Voltage */
+ b = mod->cmdq.isrshadow[1]; /* Voltage */
abs_voltage = abs(b);
if (fxovoltage) {
@@ -1673,7 +1704,7 @@
}
}
/* Look for neon mwi pulse */
- if (neonmwi_monitor && !wc->mods[card].fxo.offhook) {
+ if (neonmwi_monitor && !fxo->offhook) {
/* Look for 4 consecutive voltage readings
* where the voltage is over the neon limit but
* does not vary greatly from the last reading
@@ -1720,7 +1751,7 @@
{
int x = 0;
unsigned long flags;
- struct fxs *const fxs = &wc->mods[card].fxs;
+ struct fxs *const fxs = &wc->mods[card].mod.fxs;
spin_lock_irqsave(&fxs->lasttxhooklock, flags);
switch (txsig) {
case DAHDI_TXSIG_ONHOOK:
@@ -1769,7 +1800,7 @@
if (x != fxs->lasttxhook) {
fxs->lasttxhook = x | SLIC_LF_OPPENDING;
- wc->sethook[card] = CMD_WR(LINE_STATE, fxs->lasttxhook);
+ wc->mods[card].sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
if (debug & DEBUG_CARD) {
@@ -1784,7 +1815,7 @@
static void wctdm_fxs_off_hook(struct wctdm *wc, const int card)
{
- struct fxs *const fxs = &wc->mods[card].fxs;
+ struct fxs *const fxs = &wc->mods[card].mod.fxs;
if (debug & DEBUG_CARD)
dev_info(&wc->vb.pdev->dev,
@@ -1811,7 +1842,7 @@
static void wctdm_fxs_on_hook(struct wctdm *wc, const int card)
{
- struct fxs *const fxs = &wc->mods[card].fxs;
+ struct fxs *const fxs = &wc->mods[card].mod.fxs;
if (debug & DEBUG_CARD)
dev_info(&wc->vb.pdev->dev,
"fxs_on_hook: Card %d Going on hook\n", card);
@@ -1822,14 +1853,14 @@
static inline void wctdm_proslic_check_hook(struct wctdm *wc, const int card)
{
- struct fxs *const fxs = &wc->mods[card].fxs;
+ struct fxs *const fxs = &wc->mods[card].mod.fxs;
char res;
int hook;
/* For some reason we have to debounce the
hook detector. */
- res = wc->cmdq[card].isrshadow[0]; /* Hook state */
+ res = wc->mods[card].cmdq.isrshadow[0]; /* Hook state */
hook = (res & 1);
if (hook != fxs->lastrxhook) {
@@ -1917,7 +1948,7 @@
/* 1ms interrupt */
static void wctdm_isr_misc_fxs(struct wctdm *wc, int card)
{
- struct fxs *const fxs = &wc->mods[card].fxs;
+ struct fxs *const fxs = &wc->mods[card].mod.fxs;
unsigned long flags;
if (!(wc->intcount % 10000)) {
@@ -1952,7 +1983,7 @@
/* Apply the change if appropriate */
fxs->lasttxhook = SLIC_LF_OPPENDING | SLIC_LF_ACTIVE_FWD;
/* Data enqueued here */
- wc->sethook[card] = CMD_WR(LINE_STATE, fxs->lasttxhook);
+ wc->mods[card].sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
if (debug & DEBUG_CARD) {
dev_info(&wc->vb.pdev->dev,
"Channel %d OnHookTransfer "
@@ -1962,7 +1993,7 @@
/* Apply the change if appropriate */
fxs->lasttxhook = SLIC_LF_OPPENDING | SLIC_LF_ACTIVE_REV;
/* Data enqueued here */
- wc->sethook[card] = CMD_WR(LINE_STATE, fxs->lasttxhook);
+ wc->mods[card].sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
if (debug & DEBUG_CARD) {
dev_info(&wc->vb.pdev->dev,
"Channel %d OnHookTransfer "
@@ -1993,11 +2024,12 @@
return;
for (x = 0; x < wc->mods_per_board; x++) {
+
spin_lock(&wc->reglock);
cmd_checkisr(wc, x);
spin_unlock(&wc->reglock);
- switch (wc->modtype[x]) {
+ switch (wc->mods[x].type) {
case MOD_TYPE_FXS:
wctdm_isr_misc_fxs(wc, x);
break;
@@ -2127,7 +2159,7 @@
}
if (wctdm_getreg(wc, card, 1) & 0x80)
/* ProSLIC 3215, not a 3210 */
- wc->flags[card] |= FLAG_3215;
+ wc->mods[card].flags |= FLAG_3215;
blah = wctdm_getreg(wc, card, 8);
if (blah != 0x2) {
@@ -2351,7 +2383,7 @@
*******************************************************************/
static int wctdm_set_hwgain(struct wctdm *wc, int card, __s32 gain, __u32 tx)
{
- if (!(wc->modtype[card] == MOD_TYPE_FXO)) {
+ if (!(wc->mods[card].type == MOD_TYPE_FXO)) {
dev_notice(&wc->vb.pdev->dev, "Cannot adjust gain. Unsupported module type!\n");
return -1;
}
@@ -2414,7 +2446,7 @@
static int set_vmwi(struct wctdm *wc, int chan_idx)
{
int x;
- struct fxs *const fxs = &wc->mods[chan_idx].fxs;
+ struct fxs *const fxs = &wc->mods[chan_idx].mod.fxs;
/* Presently only supports line reversal MWI */
if ((fxs->vmwi_active_messages) &&
@@ -2431,7 +2463,8 @@
((fxs->lasttxhook & SLIC_LF_SETMASK) != SLIC_LF_OPEN)) {
x = fxs->lasttxhook;
x |= SLIC_LF_REVMASK;
- set_lasttxhook_interruptible(fxs, x, &wc->sethook[chan_idx]);
+ set_lasttxhook_interruptible(fxs, x,
+ &wc->mods[chan_idx].sethook);
}
} else {
fxs->idletxhookstate &= ~SLIC_LF_REVMASK;
@@ -2440,7 +2473,8 @@
((fxs->lasttxhook & SLIC_LF_SETMASK) != SLIC_LF_OPEN)) {
x = fxs->lasttxhook;
x &= ~SLIC_LF_REVMASK;
- set_lasttxhook_interruptible(fxs, x, &wc->sethook[chan_idx]);
+ set_lasttxhook_interruptible(fxs, x,
+ &wc->mods[chan_idx].sethook);
}
}
if (debug) {
@@ -2469,17 +2503,17 @@
unsigned long flags;
long newjiffies;
- if ((wc->modtype[card & 0xfc] == MOD_TYPE_QRV) ||
- (wc->modtype[card & 0xfc] == MOD_TYPE_BRI))
+ if ((wc->mods[card & 0xfc].type == MOD_TYPE_QRV) ||
+ (wc->mods[card & 0xfc].type == MOD_TYPE_BRI))
return -2;
spin_lock_irqsave(&wc->reglock, flags);
- wc->modtype[card] = MOD_TYPE_NONE;
+ wc->mods[card].type = MOD_TYPE_NONE;
spin_unlock_irqrestore(&wc->reglock, flags);
msleep(100);
spin_lock_irqsave(&wc->reglock, flags);
- wc->modtype[card] = MOD_TYPE_FXO;
+ wc->mods[card].type = MOD_TYPE_FXO;
spin_unlock_irqrestore(&wc->reglock, flags);
msleep(100);
@@ -2572,16 +2606,19 @@
static int wctdm_init_proslic(struct wctdm *wc, int card, int fast, int manual, int sane)
{
+ struct wctdm_module *const mod = &wc->mods[card];
+ struct fxs *const fxs = &mod->mod.fxs;
unsigned short tmp[5];
unsigned long flags;
unsigned char r19,r9;
int x;
int fxsmode=0;
- if (wc->modtype[card & 0xfc] == MOD_TYPE_QRV) return -2;
+ if (wc->mods[card & 0xfc].type == MOD_TYPE_QRV)
+ return -2;
spin_lock_irqsave(&wc->reglock, flags);
- wc->modtype[card] = MOD_TYPE_FXS;
+ mod->type = MOD_TYPE_FXS;
spin_unlock_irqrestore(&wc->reglock, flags);
msleep(100);
@@ -2591,15 +2628,14 @@
return -2;
/* Initialize VMWI settings */
- memset(&(wc->mods[card].fxs.vmwisetting), 0, sizeof(wc->mods[card].fxs.vmwisetting));
- wc->mods[card].fxs.vmwi_linereverse = 0;
+ memset(&(fxs->vmwisetting), 0, sizeof(fxs->vmwisetting));
+ fxs->vmwi_linereverse = 0;
/* By default, don't send on hook */
- if (!reversepolarity != !wc->mods[card].fxs.reversepolarity) {
- wc->mods[card].fxs.idletxhookstate = SLIC_LF_ACTIVE_REV;
- } else {
- wc->mods[card].fxs.idletxhookstate = SLIC_LF_ACTIVE_FWD;
- }
+ if (!reversepolarity != !fxs->reversepolarity)
+ fxs->idletxhookstate = SLIC_LF_ACTIVE_REV;
+ else
+ fxs->idletxhookstate = SLIC_LF_ACTIVE_FWD;
if (sane) {
/* Make sure we turn off the DC->DC converter to prevent anything from blowing up */
@@ -2642,7 +2678,7 @@
}
if (!fast) {
- spin_lock_init(&wc->mods[card].fxs.lasttxhooklock);
+ spin_lock_init(&fxs->lasttxhooklock);
/* Check for power leaks */
if (wctdm_proslic_powerleak_test(wc, card)) {
@@ -2684,14 +2720,14 @@
}
/* Save calibration vectors */
- for (x=0;x<NUM_CAL_REGS;x++)
- wc->mods[card].fxs.calregs.vals[x] = wctdm_getreg(wc, card, 96 + x);
+ for (x = 0; x < NUM_CAL_REGS; x++)
+ fxs->calregs.vals[x] = wctdm_getreg(wc, card, 96 + x);
#endif
} else {
/* Restore calibration registers */
- for (x=0;x<NUM_CAL_REGS;x++)
- wctdm_setreg(wc, card, 96 + x, wc->mods[card].fxs.calregs.vals[x]);
+ for (x = 0; x < NUM_CAL_REGS; x++)
+ wctdm_setreg(wc, card, 96 + x, fxs->calregs.vals[x]);
}
/* Calibration complete, restore original values */
for (x=0;x<5;x++) {
@@ -2814,13 +2850,13 @@
if (debug)
dev_info(&wc->vb.pdev->dev, "DEBUG: fxstxgain:%s fxsrxgain:%s\n",((wctdm_getreg(wc, card, 9)/8) == 1)?"3.5":(((wctdm_getreg(wc,card,9)/4) == 1)?"-3.5":"0.0"),((wctdm_getreg(wc, card, 9)/2) == 1)?"3.5":((wctdm_getreg(wc,card,9)%2)?"-3.5":"0.0"));
- wc->mods[card].fxs.lasttxhook = wc->mods[card].fxs.idletxhookstate;
- wctdm_setreg(wc, card, LINE_STATE, wc->mods[card].fxs.lasttxhook);
+ fxs->lasttxhook = wc->mods[card].mod.fxs.idletxhookstate;
+ wctdm_setreg(wc, card, LINE_STATE, fxs->lasttxhook);
/* Preset the isrshadow register so that we won't get a power alarm
* when we finish initialization, otherwise the line state register
* may not have been read yet. */
- wc->cmdq[card].isrshadow[1] = wc->mods[card].fxs.lasttxhook;
+ mod->cmdq.isrshadow[1] = fxs->lasttxhook;
return 0;
}
@@ -2839,30 +2875,29 @@
{
unsigned char x,y;
- if (MOD_TYPE_BRI == wc->modtype[card & 0xfc])
+ if (MOD_TYPE_BRI == wc->mods[card & 0xfc].type)
return -2;
/* have to set this, at least for now */
- wc->modtype[card] = MOD_TYPE_QRV;
+ wc->mods[card].type = MOD_TYPE_QRV;
if (!(card & 3)) /* if at base of card, reset and write it */
{
wctdm_setreg(wc,card,0,0x80);
wctdm_setreg(wc,card,0,0x55);
wctdm_setreg(wc,card,1,0x69);
- wc->qrvhook[card] = wc->qrvhook[card + 1] = 0;
- wc->qrvhook[card + 2] = wc->qrvhook[card + 3] = 0xff;
- wc->debouncetime[card] = wc->debouncetime[card + 1] = QRV_DEBOUNCETIME;
- wc->qrvdebtime[card] = wc->qrvdebtime[card + 1] = 0;
- wc->radmode[card] = wc->radmode[card + 1] = 0;
- wc->txgain[card] = wc->txgain[card + 1] = 3599;
- wc->rxgain[card] = wc->rxgain[card + 1] = 1199;
+ wc->mods[card].qrvhook = wc->mods[card + 1].qrvhook = 0;
+ wc->mods[card + 2].qrvhook = wc->mods[card + 3].qrvhook = 0xff;
+ wc->mods[card].debouncetime = wc->mods[card + 1].debouncetime = QRV_DEBOUNCETIME;
+ wc->mods[card].qrvdebtime = wc->mods[card + 1].qrvdebtime = 0;
+ wc->mods[card].radmode = wc->mods[card + 1].radmode = 0;
+ wc->mods[card].txgain = wc->mods[card + 1].txgain = 3599;
+ wc->mods[card].rxgain = wc->mods[card + 1].rxgain = 1199;
} else { /* channel is on same card as base, no need to test */
- if (wc->modtype[card & 0x7c] == MOD_TYPE_QRV)
- {
+ if (wc->mods[card & 0x7c].type == MOD_TYPE_QRV) {
/* only lower 2 are valid */
if (!(card & 2)) return 0;
}
- wc->modtype[card] = MOD_TYPE_NONE;
+ wc->mods[card].type = MOD_TYPE_NONE;
return 1;
}
x = wctdm_getreg(wc,card,0);
@@ -2870,7 +2905,7 @@
/* if not a QRV card, return as such */
if ((x != 0x55) || (y != 0x69))
{
- wc->modtype[card] = MOD_TYPE_NONE;
+ wc->mods[card].type = MOD_TYPE_NONE;
return 1;
}
for (x = 0; x < 0x30; x++)
@@ -2914,51 +2949,76 @@
/* actually do something with the values */
qrvcard = (chan->chanpos - 1) & 0xfc;
- if (debug) dev_info(&wc->vb.pdev->dev, "@@@@@ radmodes: %d,%d rxgains: %d,%d txgains: %d,%d\n",
- wc->radmode[qrvcard],wc->radmode[qrvcard + 1],
- wc->rxgain[qrvcard],wc->rxgain[qrvcard + 1],
- wc->txgain[qrvcard],wc->txgain[qrvcard + 1]);
+ if (debug) {
+ dev_info(&wc->vb.pdev->dev,
+ "@@@@@ radmodes: %d,%d rxgains: %d,%d "
+ "txgains: %d,%d\n", wc->mods[qrvcard].radmode,
+ wc->mods[qrvcard + 1].radmode,
+ wc->mods[qrvcard].rxgain, wc->mods[qrvcard + 1].rxgain,
+ wc->mods[qrvcard].txgain,
+ wc->mods[qrvcard + 1].txgain);
+ }
r = 0;
- if (wc->radmode[qrvcard] & RADMODE_DEEMP) r |= 4;
- if (wc->radmode[qrvcard + 1] & RADMODE_DEEMP) r |= 8;
- if (wc->rxgain[qrvcard] < 1200) r |= 1;
- if (wc->rxgain[qrvcard + 1] < 1200) r |= 2;
+ if (wc->mods[qrvcard].radmode & RADMODE_DEEMP)
+ r |= 4;
+ if (wc->mods[qrvcard + 1].radmode & RADMODE_DEEMP)
+ r |= 8;
+ if (wc->mods[qrvcard].rxgain < 1200)
+ r |= 1;
+ if (wc->mods[qrvcard + 1].rxgain < 1200)
+ r |= 2;
wctdm_setreg(wc, qrvcard, 7, r);
if (debug) dev_info(&wc->vb.pdev->dev, "@@@@@ setting reg 7 to %02x hex\n",r);
r = 0;
- if (wc->radmode[qrvcard] & RADMODE_PREEMP) r |= 3;
- else if (wc->txgain[qrvcard] >= 3600) r |= 1;
- else if (wc->txgain[qrvcard] >= 1200) r |= 2;
- if (wc->radmode[qrvcard + 1] & RADMODE_PREEMP) r |= 0xc;
- else if (wc->txgain[qrvcard + 1] >= 3600) r |= 4;
- else if (wc->txgain[qrvcard + 1] >= 1200) r |= 8;
+ if (wc->mods[qrvcard].radmode & RADMODE_PREEMP)
+ r |= 3;
+ else if (wc->mods[qrvcard].txgain >= 3600)
+ r |= 1;
+ else if (wc->mods[qrvcard].txgain >= 1200)
+ r |= 2;
+ if (wc->mods[qrvcard + 1].radmode & RADMODE_PREEMP)
+ r |= 0xc;
+ else if (wc->mods[qrvcard + 1].txgain >= 3600)
+ r |= 4;
+ else if (wc->mods[qrvcard + 1].txgain >= 1200)
+ r |= 8;
wctdm_setreg(wc, qrvcard, 4, r);
if (debug) dev_info(&wc->vb.pdev->dev, "@@@@@ setting reg 4 to %02x hex\n",r);
r = 0;
- if (wc->rxgain[qrvcard] >= 2400) r |= 1;
- if (wc->rxgain[qrvcard + 1] >= 2400) r |= 2;
+ if (wc->mods[qrvcard].rxgain >= 2400)
+ r |= 1;
+ if (wc->mods[qrvcard + 1].rxgain >= 2400)
+ r |= 2;
wctdm_setreg(wc, qrvcard, 0x25, r);
if (debug) dev_info(&wc->vb.pdev->dev, "@@@@@ setting reg 0x25 to %02x hex\n",r);
r = 0;
- if (wc->txgain[qrvcard] < 2400) r |= 1; else r |= 4;
- if (wc->txgain[qrvcard + 1] < 2400) r |= 8; else r |= 0x20;
+ if (wc->mods[qrvcard].txgain < 2400)
+ r |= 1;
+ else
+ r |= 4;
+ if (wc->mods[qrvcard + 1].txgain < 2400)
+ r |= 8;
+ else
+ r |= 0x20;
wctdm_setreg(wc, qrvcard, 0x26, r);
if (debug) dev_info(&wc->vb.pdev->dev, "@@@@@ setting reg 0x26 to %02x hex\n",r);
- l = ((long)(wc->rxgain[qrvcard] % 1200) * 10000) / 46875;
+ l = ((long)(wc->mods[qrvcard].rxgain % 1200) * 10000) / 46875;
if (l == 0) l = 1;
- if (wc->rxgain[qrvcard] >= 2400) l += 181;
+ if (wc->mods[qrvcard].rxgain >= 2400)
+ l += 181;
wctdm_setreg(wc, qrvcard, 0x0b, (unsigned char)l);
if (debug) dev_info(&wc->vb.pdev->dev, "@@@@@ setting reg 0x0b to %02x hex\n",(unsigned char)l);
- l = ((long)(wc->rxgain[qrvcard + 1] % 1200) * 10000) / 46875;
+ l = ((long)(wc->mods[qrvcard + 1].rxgain % 1200) * 10000) / 46875;
if (l == 0) l = 1;
- if (wc->rxgain[qrvcard + 1] >= 2400) l += 181;
+ if (wc->mods[qrvcard + 1].rxgain >= 2400)
+ l += 181;
wctdm_setreg(wc, qrvcard, 0x0c, (unsigned char)l);
if (debug) dev_info(&wc->vb.pdev->dev, "@@@@@ setting reg 0x0c to %02x hex\n",(unsigned char)l);
- l = ((long)(wc->txgain[qrvcard] % 1200) * 10000) / 46875;
+ l = ((long)(wc->mods[qrvcard].txgain % 1200) * 10000) / 46875;
if (l == 0) l = 1;
wctdm_setreg(wc, qrvcard, 0x0f, (unsigned char)l);
if (debug) dev_info(&wc->vb.pdev->dev, "@@@@@ setting reg 0x0f to %02x hex\n", (unsigned char)l);
- l = ((long)(wc->txgain[qrvcard + 1] % 1200) * 10000) / 46875;
+ l = ((long)(wc->mods[qrvcard + 1].txgain % 1200) * 10000) / 46875;
if (l == 0) l = 1;
wctdm_setreg(wc, qrvcard, 0x10,(unsigned char)l);
if (debug) dev_info(&wc->vb.pdev->dev, "@@@@@ setting reg 0x10 to %02x hex\n",(unsigned char)l);
@@ -3004,11 +3064,12 @@
struct dahdi_radio_stat s;
struct dahdi_radio_param p;
} stack;
- struct fxs *const fxs = &wc->mods[chan->chanpos - 1].fxs;
+ struct wctdm_module *const mod = &wc->mods[chan->chanpos - 1];
+ struct fxs *const fxs = &mod->mod.fxs;
switch (cmd) {
case DAHDI_ONHOOKTRANSFER:
- if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
+ if (mod->type != MOD_TYPE_FXS)
return -EINVAL;
if (get_user(x, (__user int *) data))
return -EFAULT;
@@ -3025,7 +3086,7 @@
x = set_lasttxhook_interruptible(fxs,
(POLARITY_XOR(chan->chanpos - 1) ?
SLIC_LF_OHTRAN_REV : SLIC_LF_OHTRAN_FWD),
- &wc->sethook[chan->chanpos - 1]);
+ &mod->sethook);
if (debug & DEBUG_CARD) {
if (x) {
@@ -3043,7 +3104,7 @@
}
break;
case DAHDI_VMWI_CONFIG:
- if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
+ if (mod->type != MOD_TYPE_FXS)
return -EINVAL;
if (copy_from_user(&(fxs->vmwisetting),
(__user void *)data,
@@ -3052,7 +3113,7 @@
set_vmwi(wc, chan->chanpos - 1);
break;
case DAHDI_VMWI:
- if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
+ if (mod->type != MOD_TYPE_FXS)
return -EINVAL;
if (get_user(x, (__user int *) data))
return -EFAULT;
@@ -3062,11 +3123,11 @@
set_vmwi(wc, chan->chanpos - 1);
break;
case WCTDM_GET_STATS:
- if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXS) {
+ if (mod->type == MOD_TYPE_FXS) {
stats.tipvolt = wctdm_getreg(wc, chan->chanpos - 1, 80) * -376;
stats.ringvolt = wctdm_getreg(wc, chan->chanpos - 1, 81) * -376;
[... 998 lines stripped ...]
More information about the svn-commits
mailing list