[svn-commits] sruffell: branch linux/sruffell/wctdm24xxp-cmdlist r9855 - /linux/team/sruffe...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 16 16:40:26 CDT 2011


Author: sruffell
Date: Wed Mar 16 16:40:22 2011
New Revision: 9855

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9855
Log:
wctdm24xxp: Pass the pointer to struct wctdm_module directly instead of index.

This change gets all the easy places and saves on array dereferences
when we already have the address of the module that we are interested
in.

Signed-off-by: Shaun Ruffell <sruffell at digium.com>

Modified:
    linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c
    linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
    linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/xhfc.c
    linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/xhfc.h

Modified: linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=9855&r1=9854&r2=9855
==============================================================================
--- linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/base.c Wed Mar 16 16:40:22 2011
@@ -107,10 +107,9 @@
  * 	polarity reversal for the port,
  * 	and the state of the line reversal MWI indicator
  */
-#define POLARITY_XOR(card) \
-	((reversepolarity != 0) ^ \
-	(wc->mods[(card)].mod.fxs.reversepolarity != 0) ^ \
-	(wc->mods[(card)].mod.fxs.vmwi_linereverse != 0))
+#define POLARITY_XOR(fxs) \
+	((reversepolarity != 0) ^ ((fxs)->reversepolarity != 0) ^ \
+	((fxs)->vmwi_linereverse != 0))
 
 static int reversepolarity = 0;
 
@@ -259,7 +258,9 @@
 	.echocan_free = echocan_free,
 };
 
-static int wctdm_init_proslic(struct wctdm *wc, int card, int fast , int manual, int sane);
+static int
+wctdm_init_proslic(struct wctdm *wc, struct wctdm_module *const mod, int fast,
+		   int manual, int sane);
 
 static inline int CMD_BYTE(int card, int bit, int altcs)
 {
@@ -278,11 +279,11 @@
 			+ ((card) >> 2) + (altcs) + ((altcs) ? -21 : 0));
 }
 
-static inline int empty_slot(struct wctdm *wc, int card)
+static inline int empty_slot(struct wctdm_module *const mod)
 {
 	int x;
 	for (x = 0; x < USER_COMMANDS; x++) {
-		if (!wc->mods[card].cmdq.cmds[x])
+		if (!mod->cmdq.cmds[x])
 			return x;
 	}
 	return -1;
@@ -424,11 +425,12 @@
 	}
 
 	for (i = 0; i < vpm->options.channels; ++i) {
+		struct dahdi_chan *const chan = &wc->mods[i].chan->chan;
 		vpm->curecstate[i].tap_length = 0;
 		vpm->curecstate[i].nlp_type = vpm->options.vpmnlptype;
 		vpm->curecstate[i].nlp_threshold = vpm->options.vpmnlpthresh;
 		vpm->curecstate[i].nlp_max_suppress = vpm->options.vpmnlpmaxsupp;
-		vpm->curecstate[i].companding = (wc->chans[i]->chan.span->deflaw == DAHDI_LAW_ALAW) ? ADT_COMP_ALAW : ADT_COMP_ULAW;
+		vpm->curecstate[i].companding = (chan->span->deflaw == DAHDI_LAW_ALAW) ? ADT_COMP_ALAW : ADT_COMP_ULAW;
 		/* set_vpmadt032_chanconfig_from_state(&vpm->curecstate[i], &vpm->options, i, &chanconfig); !!! */
 		vpm->setchanconfig_from_state(vpm, i, &chanconfig);
 		if ((res = gpakConfigureChannel(vpm->dspid, i, tdmToTdm, &chanconfig, &cstatus))) {
@@ -768,10 +770,8 @@
 	spin_unlock_irqrestore(&wc->reglock, flags);
 }
 
-static inline void cmd_checkisr(struct wctdm *wc, int card)
-{
-	struct wctdm_module *const mod = &wc->mods[card];
-
+static void cmd_checkisr(struct wctdm *wc, struct wctdm_module *const mod)
+{
 	if (!mod->cmdq.cmds[USER_COMMANDS + 0]) {
 		if (mod->sethook) {
 			mod->cmdq.cmds[USER_COMMANDS + 0] = mod->sethook;
@@ -781,9 +781,9 @@
 		} else if (mod->type == FXO) {
 			mod->cmdq.cmds[USER_COMMANDS + 0] = CMD_RD(5);	/* Hook/Ring state */
 		} else if (mod->type == QRV) {
-			wc->mods[card & 0xfc].cmdq.cmds[USER_COMMANDS + 0] = CMD_RD(3);	/* COR/CTCSS state */
+			wc->mods[mod->card & 0xfc].cmdq.cmds[USER_COMMANDS + 0] = CMD_RD(3);	/* COR/CTCSS state */
 		} else if (mod->type == BRI) {
-			mod->cmdq.cmds[USER_COMMANDS + 0] = wctdm_bri_checkisr(wc, card, 0);
+			wctdm_bri_checkisr(wc, mod, 0);
 		}
 	}
 	if (!mod->cmdq.cmds[USER_COMMANDS + 1]) {
@@ -796,9 +796,9 @@
 		} else if (mod->type == FXO) {
 			mod->cmdq.cmds[USER_COMMANDS + 1] = CMD_RD(29);	/* Battery */
 		} else if (mod->type == QRV) {
-			wc->mods[card & 0xfc].cmdq.cmds[USER_COMMANDS + 1] = CMD_RD(3);	/* Battery */
+			wc->mods[mod->card & 0xfc].cmdq.cmds[USER_COMMANDS + 1] = CMD_RD(3);	/* Battery */
 		} else if (mod->type == BRI) {
-			mod->cmdq.cmds[USER_COMMANDS + 1] = wctdm_bri_checkisr(wc, card, 1);
+			wctdm_bri_checkisr(wc, mod, 1);
 		}
 	}
 }
@@ -813,7 +813,7 @@
 	register u8 *chanchunk;
 
 	for (i = 0; i < wc->avchannels; i += 4) {
-		chanchunk = &wc->chans[0 + i]->chan.writechunk[0];
+		chanchunk = &wc->mods[0 + i].chan->chan.writechunk[0];
 		sframe[0 + i + (EFRAME_SIZE + EFRAME_GAP)*0] = chanchunk[0];
 		sframe[0 + i + (EFRAME_SIZE + EFRAME_GAP)*1] = chanchunk[1];
 		sframe[0 + i + (EFRAME_SIZE + EFRAME_GAP)*2] = chanchunk[2];
@@ -823,7 +823,7 @@
 		sframe[0 + i + (EFRAME_SIZE + EFRAME_GAP)*6] = chanchunk[6];
 		sframe[0 + i + (EFRAME_SIZE + EFRAME_GAP)*7] = chanchunk[7];
 
-		chanchunk = &wc->chans[1 + i]->chan.writechunk[0];
+		chanchunk = &wc->mods[1 + i].chan->chan.writechunk[0];
 		sframe[1 + i + (EFRAME_SIZE + EFRAME_GAP)*0] = chanchunk[0];
 		sframe[1 + i + (EFRAME_SIZE + EFRAME_GAP)*1] = chanchunk[1];
 		sframe[1 + i + (EFRAME_SIZE + EFRAME_GAP)*2] = chanchunk[2];
@@ -833,7 +833,7 @@
 		sframe[1 + i + (EFRAME_SIZE + EFRAME_GAP)*6] = chanchunk[6];
 		sframe[1 + i + (EFRAME_SIZE + EFRAME_GAP)*7] = chanchunk[7];
 
-		chanchunk = &wc->chans[2 + i]->chan.writechunk[0];
+		chanchunk = &wc->mods[2 + i].chan->chan.writechunk[0];
 		sframe[2 + i + (EFRAME_SIZE + EFRAME_GAP)*0] = chanchunk[0];
 		sframe[2 + i + (EFRAME_SIZE + EFRAME_GAP)*1] = chanchunk[1];
 		sframe[2 + i + (EFRAME_SIZE + EFRAME_GAP)*2] = chanchunk[2];
@@ -843,7 +843,7 @@
 		sframe[2 + i + (EFRAME_SIZE + EFRAME_GAP)*6] = chanchunk[6];
 		sframe[2 + i + (EFRAME_SIZE + EFRAME_GAP)*7] = chanchunk[7];
 
-		chanchunk = &wc->chans[3 + i]->chan.writechunk[0];
+		chanchunk = &wc->mods[3 + i].chan->chan.writechunk[0];
 		sframe[3 + i + (EFRAME_SIZE + EFRAME_GAP)*0] = chanchunk[0];
 		sframe[3 + i + (EFRAME_SIZE + EFRAME_GAP)*1] = chanchunk[1];
 		sframe[3 + i + (EFRAME_SIZE + EFRAME_GAP)*2] = chanchunk[2];
@@ -888,7 +888,7 @@
 		 * installed modules. */
 		for (y = 0; y < wc->avchannels; y++) {
 			if (!x && y < wc->mods_per_board) {
-				cmd_checkisr(wc, y);
+				cmd_checkisr(wc, &wc->mods[y]);
 			}
 
 			if (y < wc->mods_per_board)
@@ -912,55 +912,59 @@
 }
 
 static bool
-stuff_command(struct wctdm *wc, int card, unsigned int cmd, int *hit)
+stuff_command(struct wctdm *wc, struct wctdm_module *const mod,
+	      unsigned int cmd, int *hit)
 {
 	unsigned long flags;
 
 	spin_lock_irqsave(&wc->reglock, flags);
-	*hit = empty_slot(wc, card);
+	*hit = empty_slot(mod);
 	if (*hit > -1)
-		wc->mods[card].cmdq.cmds[*hit] = cmd;
+		mod->cmdq.cmds[*hit] = cmd;
 	spin_unlock_irqrestore(&wc->reglock, flags);
 
 	return (*hit > -1);
 }
 
 static int
-wctdm_setreg_full(struct wctdm *wc, int card, int addr, int val, int inisr)
-{
+wctdm_setreg_full(struct wctdm *wc, struct wctdm_module *mod,
+		  int addr, int val, int inisr)
+{
+	const unsigned int cmd = CMD_WR(addr, val);
 	int ret;
 	int hit;
-	const unsigned int cmd = CMD_WR(addr, val);
-
+
+#if 0 /* TODO */
 	/* QRV and BRI cards are only addressed at their first "port" */
 	if ((card & 0x03) && ((wc->mods[card].type ==  QRV) ||
 	    (wc->mods[card].type ==  BRI)))
 		return 0;
+#endif
 
 	if (inisr) {
-		stuff_command(wc, card, cmd, &hit);
+		stuff_command(wc, mod, cmd, &hit);
 		return 0;
 	}
 
 	ret = wait_event_interruptible(wc->regq,
-			stuff_command(wc, card, cmd, &hit));
+			stuff_command(wc, mod, cmd, &hit));
 	return ret;
 }
 
 static inline void
-wctdm_setreg_intr(struct wctdm *wc, int card, int addr, int val)
-{
-	wctdm_setreg_full(wc, card, addr, val, 1);
-}
-
-int wctdm_setreg(struct wctdm *wc, int card, int addr, int val)
-{
-	return wctdm_setreg_full(wc, card, addr, val, 0);
-}
-
-static bool cmd_finished(struct wctdm *wc, int card, int hit, u8 *val)
-{
-	struct wctdm_module *const mod = &wc->mods[card];
+wctdm_setreg_intr(struct wctdm *wc, struct wctdm_module *mod, int addr, int val)
+{
+	wctdm_setreg_full(wc, mod, addr, val, 1);
+}
+
+int wctdm_setreg(struct wctdm *wc, struct wctdm_module *mod, int addr, int val)
+{
+	return wctdm_setreg_full(wc, mod, addr, val, 0);
+}
+
+static bool
+cmd_finished(struct wctdm *wc, struct wctdm_module *const mod, int hit, u8 *val)
+{
 	bool ret;
 	unsigned long flags;
 
@@ -977,26 +981,28 @@
 	return ret;
 }
 
-int wctdm_getreg(struct wctdm *wc, int card, int addr)
+int wctdm_getreg(struct wctdm *wc, struct wctdm_module *const mod, int addr)
 {
 	const unsigned int cmd = CMD_RD(addr);
 	u8 val = 0;
 	int hit;
 	int ret;
 
+#if 0 /* TODO */
 	/* if a QRV card, use only its first channel */  
 	if (wc->mods[card].type ==  QRV) {
 		if (card & 3)
 			return 0;
 	}
+#endif
 
 	ret = wait_event_interruptible(wc->regq,
-			stuff_command(wc, card, cmd, &hit));
+			stuff_command(wc, mod, cmd, &hit));
 	if (ret)
 		return ret;
 
 	ret = wait_event_interruptible(wc->regq,
-			cmd_finished(wc, card, hit, &val));
+			cmd_finished(wc, mod, hit, &val));
 	if (ret)
 		return ret;
 
@@ -1035,7 +1041,7 @@
 	register u8 *chanchunk;
 
 	for (i = 0; i < wc->avchannels; i += 4) {
-		chanchunk = &wc->chans[0 + i]->chan.readchunk[0];
+		chanchunk = &wc->mods[0 + i].chan->chan.readchunk[0];
 		chanchunk[0] = sframe[0 + i + (EFRAME_SIZE + EFRAME_GAP)*0];
 		chanchunk[1] = sframe[0 + i + (EFRAME_SIZE + EFRAME_GAP)*1];
 		chanchunk[2] = sframe[0 + i + (EFRAME_SIZE + EFRAME_GAP)*2];
@@ -1045,7 +1051,7 @@
 		chanchunk[6] = sframe[0 + i + (EFRAME_SIZE + EFRAME_GAP)*6];
 		chanchunk[7] = sframe[0 + i + (EFRAME_SIZE + EFRAME_GAP)*7];
 
-		chanchunk = &wc->chans[1 + i]->chan.readchunk[0];
+		chanchunk = &wc->mods[1 + i].chan->chan.readchunk[0];
 		chanchunk[0] = sframe[1 + i + (EFRAME_SIZE + EFRAME_GAP)*0];
 		chanchunk[1] = sframe[1 + i + (EFRAME_SIZE + EFRAME_GAP)*1];
 		chanchunk[2] = sframe[1 + i + (EFRAME_SIZE + EFRAME_GAP)*2];
@@ -1055,7 +1061,7 @@
 		chanchunk[6] = sframe[1 + i + (EFRAME_SIZE + EFRAME_GAP)*6];
 		chanchunk[7] = sframe[1 + i + (EFRAME_SIZE + EFRAME_GAP)*7];
 
-		chanchunk = &wc->chans[2 + i]->chan.readchunk[0];
+		chanchunk = &wc->mods[2 + i].chan->chan.readchunk[0];
 		chanchunk[0] = sframe[2 + i + (EFRAME_SIZE + EFRAME_GAP)*0];
 		chanchunk[1] = sframe[2 + i + (EFRAME_SIZE + EFRAME_GAP)*1];
 		chanchunk[2] = sframe[2 + i + (EFRAME_SIZE + EFRAME_GAP)*2];
@@ -1065,7 +1071,7 @@
 		chanchunk[6] = sframe[2 + i + (EFRAME_SIZE + EFRAME_GAP)*6];
 		chanchunk[7] = sframe[2 + i + (EFRAME_SIZE + EFRAME_GAP)*7];
 
-		chanchunk = &wc->chans[3 + i]->chan.readchunk[0];
+		chanchunk = &wc->mods[3 + i].chan->chan.readchunk[0];
 		chanchunk[0] = sframe[3 + i + (EFRAME_SIZE + EFRAME_GAP)*0];
 		chanchunk[1] = sframe[3 + i + (EFRAME_SIZE + EFRAME_GAP)*1];
 		chanchunk[2] = sframe[3 + i + (EFRAME_SIZE + EFRAME_GAP)*2];
@@ -1115,7 +1121,7 @@
 	/* XXX We're wasting 8 taps.  We should get closer :( */
 	if (likely(wc->initialized)) {
 		for (x = 0; x < wc->avchannels; x++) {
-			struct dahdi_chan *c = &wc->chans[x]->chan;
+			struct dahdi_chan *c = &wc->mods[x].chan->chan;
 #ifdef CONFIG_VOICEBUS_ECREFERENCE
 			unsigned char buffer[DAHDI_CHUNKSIZE];
 			__dahdi_fifo_get(wc->ec_reference[x], buffer,
@@ -1149,26 +1155,24 @@
 	wake_up_interruptible_all(&wc->regq);
 }
 
-static int wait_access(struct wctdm *wc, int card)
-{
-    unsigned char data=0;
-    int count = 0;
-
-    #define MAX 10 /* attempts */
-
-
-    /* Wait for indirect access */
-    while (count++ < MAX)
-	 {
-		data = wctdm_getreg(wc, card, I_STATUS);
-
+static int wait_access(struct wctdm *wc, struct wctdm_module *const mod)
+{
+	unsigned char data = 0;
+	int count = 0;
+
+	#define MAX 10 /* attempts */
+
+	/* Wait for indirect access */
+	while (count++ < MAX) {
+		data = wctdm_getreg(wc, mod, I_STATUS);
 		if (!data)
 			return 0;
-
-	 }
-
-    if (count > (MAX-1))
-	    dev_notice(&wc->vb.pdev->dev, " ##### Loop error (%02x) #####\n", data);
+	}
+
+	if (count > (MAX-1)) {
+		dev_notice(&wc->vb.pdev->dev,
+			   " ##### Loop error (%02x) #####\n", data);
+	}
 
 	return 0;
 }
@@ -1185,40 +1189,44 @@
 	return address;
 }
 
-static int wctdm_proslic_setreg_indirect(struct wctdm *wc, int card, unsigned char address, unsigned short data)
+static int
+wctdm_proslic_setreg_indirect(struct wctdm *wc, struct wctdm_module *const mod,
+			      unsigned char address, unsigned short data)
 {
 	int res = -1;
 	/* Translate 3215 addresses */
-	if (wc->mods[card].flags & FLAG_3215) {
+	if (mod->flags & FLAG_3215) {
 		address = translate_3215(address);
 		if (address == 255)
 			return 0;
 	}
-	if (!wait_access(wc, card)) {
-		wctdm_setreg(wc, card, IDA_LO,(unsigned char)(data & 0xFF));
-		wctdm_setreg(wc, card, IDA_HI,(unsigned char)((data & 0xFF00)>>8));
-		wctdm_setreg(wc, card, IAA,address);
+	if (!wait_access(wc, mod)) {
+		wctdm_setreg(wc, mod, IDA_LO, (u8)(data & 0xFF));
+		wctdm_setreg(wc, mod, IDA_HI, (u8)((data & 0xFF00)>>8));
+		wctdm_setreg(wc, mod, IAA, address);
 		res = 0;
 	};
 	return res;
 }
 
-static int wctdm_proslic_getreg_indirect(struct wctdm *wc, int card, unsigned char address)
+static int
+wctdm_proslic_getreg_indirect(struct wctdm *wc, struct wctdm_module *const mod,
+			      unsigned char address)
 { 
 	int res = -1;
 	char *p=NULL;
 	/* Translate 3215 addresses */
-	if (wc->mods[card].flags & FLAG_3215) {
+	if (mod->flags & FLAG_3215) {
 		address = translate_3215(address);
 		if (address == 255)
 			return 0;
 	}
-	if (!wait_access(wc, card)) {
-		wctdm_setreg(wc, card, IAA, address);
-		if (!wait_access(wc, card)) {
+	if (!wait_access(wc, mod)) {
+		wctdm_setreg(wc, mod, IAA, address);
+		if (!wait_access(wc, mod)) {
 			unsigned char data1, data2;
-			data1 = wctdm_getreg(wc, card, IDA_LO);
-			data2 = wctdm_getreg(wc, card, IDA_HI);
+			data1 = wctdm_getreg(wc, mod, IDA_LO);
+			data2 = wctdm_getreg(wc, mod, IDA_HI);
 			res = data1 | (data2 << 8);
 		} else
 			p = "Failed to wait inside\n";
@@ -1229,12 +1237,13 @@
 	return res;
 }
 
-static int wctdm_proslic_init_indirect_regs(struct wctdm *wc, int card)
+static int
+wctdm_proslic_init_indirect_regs(struct wctdm *wc, struct wctdm_module *mod)
 {
 	unsigned char i;
 
 	for (i = 0; i < ARRAY_SIZE(indirect_regs); i++) {
-		if (wctdm_proslic_setreg_indirect(wc, card,
+		if (wctdm_proslic_setreg_indirect(wc, mod,
 				indirect_regs[i].address,
 				indirect_regs[i].initial))
 			return -1;
@@ -1243,22 +1252,23 @@
 	return 0;
 }
 
-static int wctdm_proslic_verify_indirect_regs(struct wctdm *wc, int card)
+static int
+wctdm_proslic_verify_indirect_regs(struct wctdm *wc, struct wctdm_module *mod)
 { 
 	int passed = 1;
 	unsigned short i, initial;
 	int j;
 
-	for (i = 0; i < ARRAY_SIZE(indirect_regs); i++) 
-	{
-		j = wctdm_proslic_getreg_indirect(wc, card, (unsigned char) indirect_regs[i].address);
+	for (i = 0; i < ARRAY_SIZE(indirect_regs); i++) {
+		j = wctdm_proslic_getreg_indirect(wc, mod,
+						(u8)indirect_regs[i].address);
 		if (j < 0) {
 			dev_notice(&wc->vb.pdev->dev, "Failed to read indirect register %d\n", i);
 			return -1;
 		}
-		initial= indirect_regs[i].initial;
-
-		if ((j != initial) && (!(wc->mods[card].flags & FLAG_3215) ||
+		initial = indirect_regs[i].initial;
+
+		if ((j != initial) && (!(mod->flags & FLAG_3215) ||
 		    (indirect_regs[i].altaddr != 255))) {
 			dev_notice(&wc->vb.pdev->dev,
 				   "!!!!!!! %s  iREG %X = %X  should be %X\n",
@@ -1268,20 +1278,23 @@
 		}	
 	}
 
-    if (passed) {
-		if (debug & DEBUG_CARD)
-			dev_info(&wc->vb.pdev->dev, "Init Indirect Registers completed successfully.\n");
-    } else {
-		dev_notice(&wc->vb.pdev->dev, " !!!!! Init Indirect Registers UNSUCCESSFULLY.\n");
+	if (passed) {
+		if (debug & DEBUG_CARD) {
+			dev_info(&wc->vb.pdev->dev,
+			 "Init Indirect Registers completed successfully.\n");
+		}
+	} else {
+		dev_notice(&wc->vb.pdev->dev,
+			" !!!!! Init Indirect Registers UNSUCCESSFULLY.\n");
 		return -1;
-    }
-    return 0;
+	}
+	return 0;
 }
 
 /* 1ms interrupt */
-static inline void wctdm_proslic_check_oppending(struct wctdm *wc, int card)
-{
-	struct wctdm_module *const mod = &wc->mods[card];
+static void
+wctdm_proslic_check_oppending(struct wctdm *wc, struct wctdm_module *const mod)
+{
 	struct fxs *const fxs = &mod->mod.fxs;
 	int res;
 
@@ -1303,7 +1316,7 @@
 		if (debug & DEBUG_CARD) {
 			dev_info(&wc->vb.pdev->dev,
 				 "SLIC_LF OK: card=%d shadow=%02x "
-				 "lasttxhook=%02x intcount=%d\n", card,
+				 "lasttxhook=%02x intcount=%d\n", mod->card,
 				 res, fxs->lasttxhook, wc->intcount);
 		}
 	} else if (fxs->oppending_ms && (--fxs->oppending_ms == 0)) {
@@ -1312,7 +1325,7 @@
 		if (debug & DEBUG_CARD) {
 			dev_info(&wc->vb.pdev->dev,
 				 "SLIC_LF RETRY: card=%d shadow=%02x "
-				 "lasttxhook=%02x intcount=%d\n", card,
+				 "lasttxhook=%02x intcount=%d\n", mod->card,
 				 res, fxs->lasttxhook, wc->intcount);
 		}
 	} else { /* Start 100ms Timeout */
@@ -1322,9 +1335,9 @@
 }
 
 /* 256ms interrupt */
-static inline void wctdm_proslic_recheck_sanity(struct wctdm *wc, int card)
-{
-	struct wctdm_module *const mod = &wc->mods[card];
+static void
+wctdm_proslic_recheck_sanity(struct wctdm *wc, struct wctdm_module *const mod)
+{
 	struct fxs *const fxs = &mod->mod.fxs;
 	int res;
 	unsigned long flags;
@@ -1378,10 +1391,12 @@
 	if (res) {
 		fxs->palarms++;
 		if (fxs->palarms < MAX_ALARMS) {
-			dev_notice(&wc->vb.pdev->dev, "Power alarm on module %d, resetting!\n", card + 1);
+			dev_notice(&wc->vb.pdev->dev,
+				   "Power alarm on module %d, resetting!\n",
+				   mod->card + 1);
 			spin_lock_irqsave(&fxs->lasttxhooklock, flags);
 			if (fxs->lasttxhook == SLIC_LF_RINGING) {
-				fxs->lasttxhook = POLARITY_XOR(card) ?
+				fxs->lasttxhook = POLARITY_XOR(fxs) ?
 							SLIC_LF_ACTIVE_REV :
 							SLIC_LF_ACTIVE_FWD;;
 			}
@@ -1392,14 +1407,17 @@
 			/* Update shadow register to avoid extra power alarms until next read */
 			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);
+			if (fxs->palarms == MAX_ALARMS) {
+				dev_notice(&wc->vb.pdev->dev,
+					   "Too many power alarms on card %d, "
+					   "NOT resetting!\n", mod->card + 1);
+			}
 		}
 	}
 #endif
 }
 
-static inline void wctdm_qrvdri_check_hook(struct wctdm *wc, int card)
+static void wctdm_qrvdri_check_hook(struct wctdm *wc, int card)
 {
 	signed char b,b1;
 	int qrvcard = card & 0xfc;
@@ -1467,14 +1485,14 @@
 	return;
 }
 
-static inline void wctdm_voicedaa_check_hook(struct wctdm *wc, int card)
+static void
+wctdm_voicedaa_check_hook(struct wctdm *wc, struct wctdm_module *const mod)
 {
 #define MS_PER_CHECK_HOOK 1
 
 	unsigned char res;
 	signed char b;
 	unsigned int abs_voltage;
-	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 */
@@ -1482,10 +1500,10 @@
 	b &= 0x9b;
 	if (fxo->offhook) {
 		if (b != 0x9)
-			wctdm_setreg_intr(wc, card, 5, 0x9);
+			wctdm_setreg_intr(wc, mod, 5, 0x9);
 	} else {
 		if (b != 0x8)
-			wctdm_setreg_intr(wc, card, 5, 0x8);
+			wctdm_setreg_intr(wc, mod, 5, 0x8);
 	}
 	if (!fxo->offhook) {
 		if (fwringdetect || neonmwi_monitor) {
@@ -1514,8 +1532,8 @@
 					if (++fxo->lastrdtx_count >= 2) {
 						fxo->wasringing = 1;
 						if (debug)
-							dev_info(&wc->vb.pdev->dev, "FW RING on %d/%d!\n", wc->aspan->span.spanno, card + 1);
-						dahdi_hooksig(wc->aspan->span.chans[card], DAHDI_RXSIG_RING);
+							dev_info(&wc->vb.pdev->dev, "FW RING on %d/%d!\n", wc->aspan->span.spanno, mod->card + 1);
+						dahdi_hooksig(&mod->chan->chan, DAHDI_RXSIG_RING);
 						fxo->ringdebounce = ringdebounce / 16;
 					} else {
 						fxo->lastrdtx = res;
@@ -1531,8 +1549,8 @@
 				} else if (--fxo->ringdebounce == 0) {
 					fxo->wasringing = 0;
 					if (debug)
-						dev_info(&wc->vb.pdev->dev, "FW NO RING on %d/%d!\n", wc->aspan->span.spanno, card + 1);
-					dahdi_hooksig(wc->aspan->span.chans[card], DAHDI_RXSIG_OFFHOOK);
+						dev_info(&wc->vb.pdev->dev, "FW NO RING on %d/%d!\n", wc->aspan->span.spanno, mod->card + 1);
+					dahdi_hooksig(&mod->chan->chan, DAHDI_RXSIG_OFFHOOK);
 				}
 			}
 		} else {
@@ -1542,9 +1560,9 @@
 				if (fxo->ringdebounce >= DAHDI_CHUNKSIZE * ringdebounce) {
 					if (!fxo->wasringing) {
 						fxo->wasringing = 1;
-						dahdi_hooksig(wc->aspan->span.chans[card], DAHDI_RXSIG_RING);
+						dahdi_hooksig(&mod->chan->chan, DAHDI_RXSIG_RING);
 						if (debug)
-							dev_info(&wc->vb.pdev->dev, "RING on %d/%d!\n", wc->aspan->span.spanno, card + 1);
+							dev_info(&wc->vb.pdev->dev, "RING on %d/%d!\n", wc->aspan->span.spanno, mod->card + 1);
 					}
 					fxo->ringdebounce = DAHDI_CHUNKSIZE * ringdebounce;
 				}
@@ -1553,9 +1571,9 @@
 				if (fxo->ringdebounce <= 0) {
 					if (fxo->wasringing) {
 						fxo->wasringing = 0;
-						dahdi_hooksig(wc->aspan->span.chans[card], DAHDI_RXSIG_OFFHOOK);
+						dahdi_hooksig(&mod->chan->chan, DAHDI_RXSIG_OFFHOOK);
 						if (debug)
-							dev_info(&wc->vb.pdev->dev, "NO RING on %d/%d!\n", wc->aspan->span.spanno, card + 1);
+							dev_info(&wc->vb.pdev->dev, "NO RING on %d/%d!\n", wc->aspan->span.spanno, mod->card + 1);
 					}
 					fxo->ringdebounce = 0;
 				}
@@ -1569,11 +1587,11 @@
 
 	if (fxovoltage) {
 		if (!(wc->intcount % 100)) {
-			dev_info(&wc->vb.pdev->dev, "Port %d: Voltage: %d  Debounce %d\n", card + 1, b, fxo->battdebounce);
-		}
-	}
-
-	if (unlikely(DAHDI_RXSIG_INITIAL == wc->aspan->span.chans[card]->rxhooksig)) {
+			dev_info(&wc->vb.pdev->dev, "Port %d: Voltage: %d  Debounce %d\n", mod->card + 1, b, fxo->battdebounce);
+		}
+	}
+
+	if (unlikely(DAHDI_RXSIG_INITIAL == mod->chan->chan.rxhooksig)) {
 		/*
 		 * dahdi-base will set DAHDI_RXSIG_INITIAL after a
 		 * DAHDI_STARTUP or DAHDI_CHANCONFIG ioctl so that new events
@@ -1608,7 +1626,7 @@
 				if (--fxo->battdebounce == 0) {
 					fxo->battery = BATTERY_LOST;
 					if (debug)
-						dev_info(&wc->vb.pdev->dev, "NO BATTERY on %d/%d!\n", wc->aspan->span.spanno, card + 1);
+						dev_info(&wc->vb.pdev->dev, "NO BATTERY on %d/%d!\n", wc->aspan->span.spanno, mod->card + 1);
 #ifdef	JAPAN
 					if (!wc->ohdebounce && wc->offhook) {
 						dahdi_hooksig(wc->aspan->chans[card], DAHDI_RXSIG_ONHOOK);
@@ -1619,7 +1637,7 @@
 #endif
 					}
 #else
-					dahdi_hooksig(wc->aspan->span.chans[card], DAHDI_RXSIG_ONHOOK);
+					dahdi_hooksig(&mod->chan->chan, DAHDI_RXSIG_ONHOOK);
 					/* set the alarm timer, taking into account that part of its time
 					   period has already passed while debouncing occurred */
 					fxo->battalarm = (battalarm - battdebounce) / MS_PER_CHECK_HOOK;
@@ -1653,7 +1671,7 @@
 						dev_info(&wc->vb.pdev->dev,
 							 "BATTERY on %d/%d (%s)!\n",
 							 wc->aspan->span.spanno,
-							 card + 1,
+							 mod->card + 1,
 							 (b < 0) ? "-" : "+");
 					}
 #ifdef	ZERO_BATT_RING
@@ -1664,7 +1682,7 @@
 							dev_info(&wc->vb.pdev->dev, "Signalled Off Hook\n");
 					}
 #else
-					dahdi_hooksig(wc->aspan->span.chans[card], DAHDI_RXSIG_OFFHOOK);
+					dahdi_hooksig(&mod->chan->chan, DAHDI_RXSIG_OFFHOOK);
 #endif
 					/* set the alarm timer, taking into account that part of its time
 					   period has already passed while debouncing occurred */
@@ -1694,7 +1712,10 @@
 		if (--fxo->battalarm == 0) {
 			/* the alarm timer has expired, so update the battery alarm state
 			   for this channel */
-			dahdi_alarm_channel(wc->aspan->span.chans[card], fxo->battery == BATTERY_LOST ? DAHDI_ALARM_RED : DAHDI_ALARM_NONE);
+			dahdi_alarm_channel(&mod->chan->chan,
+					    (fxo->battery == BATTERY_LOST) ?
+						DAHDI_ALARM_RED :
+						DAHDI_ALARM_NONE);
 		}
 	}
 
@@ -1707,7 +1728,7 @@
 				       fxo->polarity, 
 				       fxo->lastpol);
 			if (fxo->polarity)
-				dahdi_qevent_lock(wc->aspan->span.chans[card], DAHDI_EVENT_POLARITY);
+				dahdi_qevent_lock(&mod->chan->chan, DAHDI_EVENT_POLARITY);
 			fxo->polarity = fxo->lastpol;
 		    }
 		}
@@ -1727,10 +1748,10 @@
 			if (NEONMWI_ON_DEBOUNCE == fxo->neonmwi_debounce) {
 				fxo->neonmwi_offcounter = neonmwi_offlimit_cycles;
 				if (0 == fxo->neonmwi_state) {
-					dahdi_qevent_lock(wc->aspan->span.chans[card], DAHDI_EVENT_NEONMWI_ACTIVE);
+					dahdi_qevent_lock(&mod->chan->chan, DAHDI_EVENT_NEONMWI_ACTIVE);
 					fxo->neonmwi_state = 1;
 					if (debug)
-						dev_info(&wc->vb.pdev->dev, "NEON MWI active for card %d\n", card+1);
+						dev_info(&wc->vb.pdev->dev, "NEON MWI active for card %d\n", mod->card+1);
 				}
 				fxo->neonmwi_debounce++;  /* terminate the processing */
 			} else if (NEONMWI_ON_DEBOUNCE > fxo->neonmwi_debounce) {
@@ -1746,41 +1767,44 @@
 		if (fxo->neonmwi_state && 0 < fxo->neonmwi_offcounter ) {
 			fxo->neonmwi_offcounter--;
 			if (0 == fxo->neonmwi_offcounter) {
-				dahdi_qevent_lock(wc->aspan->span.chans[card], DAHDI_EVENT_NEONMWI_INACTIVE);
+				dahdi_qevent_lock(&mod->chan->chan, DAHDI_EVENT_NEONMWI_INACTIVE);
 				fxo->neonmwi_state = 0;
 				if (debug)
-					dev_info(&wc->vb.pdev->dev, "NEON MWI cleared for card %d\n", card+1);
+					dev_info(&wc->vb.pdev->dev, "NEON MWI cleared for card %d\n", mod->card+1);
 			}
 		}
 	}
 #undef MS_PER_CHECK_HOOK
 }
 
-static void wctdm_fxs_hooksig(struct wctdm *wc, const int card, enum dahdi_txsig txsig)
+static void
+wctdm_fxs_hooksig(struct wctdm *wc, struct wctdm_module *const mod,
+		  enum dahdi_txsig txsig)
 {
 	int x = 0;
 	unsigned long flags;
-	struct fxs *const fxs = &wc->mods[card].mod.fxs;
+	struct fxs *const fxs = &mod->mod.fxs;
+
 	spin_lock_irqsave(&fxs->lasttxhooklock, flags);
 	switch (txsig) {
 	case DAHDI_TXSIG_ONHOOK:
-		switch (wc->aspan->span.chans[card]->sig) {
+		switch (mod->chan->chan.sig) {
 		case DAHDI_SIG_EM:
 		case DAHDI_SIG_FXOKS:
 		case DAHDI_SIG_FXOLS:
 			x = fxs->idletxhookstate;
 			break;
 		case DAHDI_SIG_FXOGS:
-			x = (POLARITY_XOR(card)) ?
+			x = (POLARITY_XOR(fxs)) ?
 					SLIC_LF_RING_OPEN :
 					SLIC_LF_TIP_OPEN;
 			break;
 		}
 		break;
 	case DAHDI_TXSIG_OFFHOOK:
-		switch (wc->aspan->span.chans[card]->sig) {
+		switch (mod->chan->chan.sig) {
 		case DAHDI_SIG_EM:
-			x = (POLARITY_XOR(card)) ?
+			x = (POLARITY_XOR(fxs)) ?
 					SLIC_LF_ACTIVE_FWD :
 					SLIC_LF_ACTIVE_REV;
 			break;
@@ -1804,7 +1828,7 @@
 
 	if (x != fxs->lasttxhook) {
 		fxs->lasttxhook = x | SLIC_LF_OPPENDING;
-		wc->mods[card].sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
+		mod->sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
 		spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
 
 		if (debug & DEBUG_CARD) {
@@ -1817,25 +1841,25 @@
 	}
 }
 
-static void wctdm_fxs_off_hook(struct wctdm *wc, const int card)
-{
-	struct fxs *const fxs = &wc->mods[card].mod.fxs;
+static void wctdm_fxs_off_hook(struct wctdm *wc, struct wctdm_module *const mod)
+{
+	struct fxs *const fxs = &mod->mod.fxs;
 
 	if (debug & DEBUG_CARD)
 		dev_info(&wc->vb.pdev->dev,
-			"fxs_off_hook: Card %d Going off hook\n", card);
+			"fxs_off_hook: Card %d Going off hook\n", mod->card);
 	switch (fxs->lasttxhook) {
 	case SLIC_LF_RINGING:		/* Ringing */
 	case SLIC_LF_OHTRAN_FWD:	/* Forward On Hook Transfer */
 	case SLIC_LF_OHTRAN_REV:	/* Reverse On Hook Transfer */
 		/* just detected OffHook, during Ringing or OnHookTransfer */
-		fxs->idletxhookstate = POLARITY_XOR(card) ?
+		fxs->idletxhookstate = POLARITY_XOR(fxs) ?
 						SLIC_LF_ACTIVE_REV :
 						SLIC_LF_ACTIVE_FWD;
 		break;
 	}
-	wctdm_fxs_hooksig(wc, card, DAHDI_TXSIG_OFFHOOK);
-	dahdi_hooksig(wc->aspan->span.chans[card], DAHDI_RXSIG_OFFHOOK);
+	wctdm_fxs_hooksig(wc, mod, DAHDI_TXSIG_OFFHOOK);
+	dahdi_hooksig(&mod->chan->chan, DAHDI_RXSIG_OFFHOOK);
 
 #ifdef DEBUG
 	if (robust)
@@ -1844,27 +1868,29 @@
 	fxs->oldrxhook = 1;
 }
 
-static void wctdm_fxs_on_hook(struct wctdm *wc, const int card)
-{
-	struct fxs *const fxs = &wc->mods[card].mod.fxs;
-	if (debug & DEBUG_CARD)
+static void wctdm_fxs_on_hook(struct wctdm *wc, struct wctdm_module *const mod)
+{
+	struct fxs *const fxs = &mod->mod.fxs;
+	if (debug & DEBUG_CARD) {
 		dev_info(&wc->vb.pdev->dev,
-			"fxs_on_hook: Card %d Going on hook\n", card);
-	wctdm_fxs_hooksig(wc, card, DAHDI_TXSIG_ONHOOK);
-	dahdi_hooksig(wc->aspan->span.chans[card], DAHDI_RXSIG_ONHOOK);
+			"fxs_on_hook: Card %d Going on hook\n", mod->card);
+	}
+	wctdm_fxs_hooksig(wc, mod, DAHDI_TXSIG_ONHOOK);
+	dahdi_hooksig(&mod->chan->chan, DAHDI_RXSIG_ONHOOK);
 	fxs->oldrxhook = 0;
 }
 
-static inline void wctdm_proslic_check_hook(struct wctdm *wc, const int card)
-{
-	struct fxs *const fxs = &wc->mods[card].mod.fxs;
+static void
+wctdm_proslic_check_hook(struct wctdm *wc, struct wctdm_module *const mod)
+{
+	struct fxs *const fxs = &mod->mod.fxs;
 	char res;
 	int hook;
 
 	/* For some reason we have to debounce the
 	   hook detector.  */
 
-	res = wc->mods[card].cmdq.isrshadow[0];	/* Hook state */
+	res = mod->cmdq.isrshadow[0];	/* Hook state */
 	hook = (res & 1);
 	
 	if (hook != fxs->lastrxhook) {
@@ -1889,9 +1915,9 @@
 			}
 
 			if (!fxs->oldrxhook && fxs->debouncehook)
-				wctdm_fxs_off_hook(wc, card);
+				wctdm_fxs_off_hook(wc, mod);
 			else if (fxs->oldrxhook && !fxs->debouncehook)
-				wctdm_fxs_on_hook(wc, card);
+				wctdm_fxs_on_hook(wc, mod);
 		}
 	}
 	fxs->lastrxhook = hook;
@@ -1950,9 +1976,9 @@
 }
 
 /* 1ms interrupt */
-static void wctdm_isr_misc_fxs(struct wctdm *wc, int card)
-{
-	struct fxs *const fxs = &wc->mods[card].mod.fxs;
+static void wctdm_isr_misc_fxs(struct wctdm *wc, struct wctdm_module *const mod)
+{
+	struct fxs *const fxs = &mod->mod.fxs;
 	unsigned long flags;
 
 	if (!(wc->intcount % 10000)) {
@@ -1960,17 +1986,17 @@
 		if (fxs->palarms)
 			fxs->palarms--;
 	}
-	wctdm_proslic_check_hook(wc, card);
-
-	wctdm_proslic_check_oppending(wc, card);
+	wctdm_proslic_check_hook(wc, mod);
+
+	wctdm_proslic_check_oppending(wc, mod);
 
 	if (!(wc->intcount & 0xfc))	/* every 256ms */
-		wctdm_proslic_recheck_sanity(wc, card);
+		wctdm_proslic_recheck_sanity(wc, mod);
 	if (SLIC_LF_RINGING == fxs->lasttxhook) {
 		/* RINGing, prepare for OHT */
 		fxs->ohttimer = OHT_TIMER << 3;
 		/* OHT mode when idle */
-		fxs->idletxhookstate = POLARITY_XOR(card) ? SLIC_LF_OHTRAN_REV :
+		fxs->idletxhookstate = POLARITY_XOR(fxs) ? SLIC_LF_OHTRAN_REV :
 							    SLIC_LF_OHTRAN_FWD;
 	} else if (fxs->ohttimer) {
 		 /* check if still OnHook */
@@ -1980,39 +2006,39 @@
 				return;
 
 			/* Switch to active */
-			fxs->idletxhookstate = POLARITY_XOR(card) ? SLIC_LF_ACTIVE_REV :
+			fxs->idletxhookstate = POLARITY_XOR(fxs) ? SLIC_LF_ACTIVE_REV :
 								    SLIC_LF_ACTIVE_FWD;
 			spin_lock_irqsave(&fxs->lasttxhooklock, flags);
 			if (SLIC_LF_OHTRAN_FWD == fxs->lasttxhook) {
 				/* Apply the change if appropriate */
 				fxs->lasttxhook = SLIC_LF_OPPENDING | SLIC_LF_ACTIVE_FWD;
 				/* Data enqueued here */
-				wc->mods[card].sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
+				mod->sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
 				if (debug & DEBUG_CARD) {
 					dev_info(&wc->vb.pdev->dev,
 						 "Channel %d OnHookTransfer "
-						 "stop\n", card);
+						 "stop\n", mod->card);
 				}
 			} else if (SLIC_LF_OHTRAN_REV == fxs->lasttxhook) {
 				/* Apply the change if appropriate */
 				fxs->lasttxhook = SLIC_LF_OPPENDING | SLIC_LF_ACTIVE_REV;
 				/* Data enqueued here */
-				wc->mods[card].sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
+				mod->sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
 				if (debug & DEBUG_CARD) {
 					dev_info(&wc->vb.pdev->dev,
 						 "Channel %d OnHookTransfer "
-						 "stop\n", card);
+						 "stop\n", mod->card);
 				}
 			}
 			spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
 		} else {
 			fxs->ohttimer = 0;
 			/* Switch to active */
-			fxs->idletxhookstate = POLARITY_XOR(card) ? SLIC_LF_ACTIVE_REV : SLIC_LF_ACTIVE_FWD;
+			fxs->idletxhookstate = POLARITY_XOR(fxs) ? SLIC_LF_ACTIVE_REV : SLIC_LF_ACTIVE_FWD;
 			if (debug & DEBUG_CARD) {
 				dev_info(&wc->vb.pdev->dev,
 					 "Channel %d OnHookTransfer abort\n",
-					 card);
+					 mod->card);
 			}
 		}
 
@@ -2029,12 +2055,13 @@
 	}
 
 	for (x = 0; x < wc->mods_per_board; x++) {
-		switch (wc->mods[x].type) {
+		struct wctdm_module *const mod = &wc->mods[x];
+		switch (mod->type) {
 		case FXS:
-			wctdm_isr_misc_fxs(wc, x);
+			wctdm_isr_misc_fxs(wc, mod);
 			break;
 		case FXO:
-			wctdm_voicedaa_check_hook(wc, x);
+			wctdm_voicedaa_check_hook(wc, mod);
 			break;
 		case QRV:
 			wctdm_qrvdri_check_hook(wc, x);
@@ -2115,30 +2142,36 @@
 	}
 }
 
-static int wctdm_voicedaa_insane(struct wctdm *wc, int card)
+static int wctdm_voicedaa_insane(struct wctdm *wc, struct wctdm_module *mod)
 {
 	int blah;
-	blah = wctdm_getreg(wc, card, 2);
+	blah = wctdm_getreg(wc, mod, 2);
 	if (blah != 0x3)
 		return -2;
-	blah = wctdm_getreg(wc, card, 11);
+	blah = wctdm_getreg(wc, mod, 11);
 	if (debug & DEBUG_CARD)
 		dev_info(&wc->vb.pdev->dev, "VoiceDAA System: %02x\n", blah & 0xf);
 	return 0;
 }
 
-static int wctdm_proslic_insane(struct wctdm *wc, int card)
+static int
+wctdm_proslic_insane(struct wctdm *wc, struct wctdm_module *const mod)
 {
 	int blah, reg1, insane_report;
 	insane_report=0;
 
-	blah = wctdm_getreg(wc, card, 0);
-	if (blah != 0xff && (debug & DEBUG_CARD))
-		dev_info(&wc->vb.pdev->dev, "ProSLIC on module %d, product %d, version %d\n", card, (blah & 0x30) >> 4, (blah & 0xf));
+	blah = wctdm_getreg(wc, mod, 0);
+	if (blah != 0xff && (debug & DEBUG_CARD)) {
+		dev_info(&wc->vb.pdev->dev,
+			 "ProSLIC on module %d, product %d, "
+			 "version %d\n", mod->card, (blah & 0x30) >> 4,
+			 (blah & 0xf));
+	}
 
 #if 0
 	if ((blah & 0x30) >> 4) {
-		dev_info(&wc->vb.pdev->dev, "ProSLIC on module %d is not a 3210.\n", card);
+		dev_info(&wc->vb.pdev->dev,
+			 "ProSLIC on module %d is not a 3210.\n", mod->card);
 		return -1;
 	}
 #endif
@@ -2148,99 +2181,126 @@
 	}
 
 	/* let's be really sure this is an FXS before we continue */
-	reg1 = wctdm_getreg(wc, card, 1);
+	reg1 = wctdm_getreg(wc, mod, 1);
 	if ((0x80 != (blah & 0xf0)) || (0x88 != reg1)) {
-		if (debug & DEBUG_CARD)
-			dev_info(&wc->vb.pdev->dev, "DEBUG: not FXS b/c reg0=%x or reg1 != 0x88 (%x).\n", blah, reg1);
+		if (debug & DEBUG_CARD) {
+			dev_info(&wc->vb.pdev->dev,
+				 "DEBUG: not FXS b/c reg0=%x or "
+				 "reg1 != 0x88 (%x).\n", blah, reg1);
+		}
 		return -1;
 	}
 
 	if ((blah & 0xf) < 2) {
-		dev_info(&wc->vb.pdev->dev, "ProSLIC 3210 version %d is too old\n", blah & 0xf);
+		dev_info(&wc->vb.pdev->dev,
+			 "ProSLIC 3210 version %d is too old\n", blah & 0xf);
 		return -1;
 	}
-	if (wctdm_getreg(wc, card, 1) & 0x80)
+
+	if (wctdm_getreg(wc, mod, 1) & 0x80)
 		/* ProSLIC 3215, not a 3210 */
-		wc->mods[card].flags |= FLAG_3215;
-
-	blah = wctdm_getreg(wc, card, 8);
+		mod->flags |= FLAG_3215;
+
+	blah = wctdm_getreg(wc, mod, 8);
 	if (blah != 0x2) {
-		dev_notice(&wc->vb.pdev->dev, "ProSLIC on module %d insane (1) %d should be 2\n", card, blah);
+		dev_notice(&wc->vb.pdev->dev,
+			   "ProSLIC on module %d insane (1) %d should be 2\n",
+			   mod->card, blah);
 		return -1;
-	} else if ( insane_report)
-		dev_notice(&wc->vb.pdev->dev, "ProSLIC on module %d Reg 8 Reads %d Expected is 0x2\n",card,blah);
-
-	blah = wctdm_getreg(wc, card, 64);
+	} else if (insane_report) {
+		dev_notice(&wc->vb.pdev->dev,
+			   "ProSLIC on module %d Reg 8 Reads %d Expected "
+			   "is 0x2\n", mod->card, blah);
+	}
+
+	blah = wctdm_getreg(wc, mod, 64);
 	if (blah != 0x0) {
-		dev_notice(&wc->vb.pdev->dev, "ProSLIC on module %d insane (2)\n", card);
+		dev_notice(&wc->vb.pdev->dev,
+			   "ProSLIC on module %d insane (2)\n",
+			   mod->card);
 		return -1;
-	} else if ( insane_report)
-		dev_notice(&wc->vb.pdev->dev, "ProSLIC on module %d Reg 64 Reads %d Expected is 0x0\n",card,blah);
-
-	blah = wctdm_getreg(wc, card, 11);
+	} else if (insane_report) {
+		dev_notice(&wc->vb.pdev->dev,
+			   "ProSLIC on module %d Reg 64 Reads %d Expected "
+			   "is 0x0\n", mod->card, blah);
+	}
+
+	blah = wctdm_getreg(wc, mod, 11);
 	if (blah != 0x33) {
-		dev_notice(&wc->vb.pdev->dev, "ProSLIC on module %d insane (3)\n", card);
+		dev_notice(&wc->vb.pdev->dev,
+			   "ProSLIC on module %d insane (3)\n", mod->card);
 		return -1;
-	} else if ( insane_report)
-		dev_notice(&wc->vb.pdev->dev, "ProSLIC on module %d Reg 11 Reads %d Expected is 0x33\n",card,blah);
+	} else if (insane_report) {
+		dev_notice(&wc->vb.pdev->dev,
+			   "ProSLIC on module %d Reg 11 Reads %d "
+			   "Expected is 0x33\n", mod->card, blah);
+	}
 
 	/* Just be sure it's setup right. */
-	wctdm_setreg(wc, card, 30, 0);
-
-	if (debug & DEBUG_CARD) 
-		dev_info(&wc->vb.pdev->dev, "ProSLIC on module %d seems sane.\n", card);
+	wctdm_setreg(wc, mod, 30, 0);
+
+	if (debug & DEBUG_CARD) {
+		dev_info(&wc->vb.pdev->dev,
+			 "ProSLIC on module %d seems sane.\n", mod->card);
+	}
 	return 0;
 }
 
-static int wctdm_proslic_powerleak_test(struct wctdm *wc, int card)
+static int
+wctdm_proslic_powerleak_test(struct wctdm *wc, struct wctdm_module *const mod)
 {
 	unsigned long origjiffies;
 	unsigned char vbat;
 
 	/* Turn off linefeed */
-	wctdm_setreg(wc, card, LINE_STATE, 0);
+	wctdm_setreg(wc, mod, LINE_STATE, 0);
 
 	/* Power down */
-	wctdm_setreg(wc, card, 14, 0x10);
+	wctdm_setreg(wc, mod, 14, 0x10);
 
 	/* Wait for one second */
 	origjiffies = jiffies;
 
-	while ((vbat = wctdm_getreg(wc, card, 82)) > 0x6) {
+	while ((vbat = wctdm_getreg(wc, mod, 82)) > 0x6) {
 		if ((jiffies - origjiffies) >= (HZ/2))
 			break;;
 	}
 
 	if (vbat < 0x06) {
-		dev_notice(&wc->vb.pdev->dev, "Excessive leakage detected on module %d: %d volts (%02x) after %d ms\n", card,
-		       376 * vbat / 1000, vbat, (int)((jiffies - origjiffies) * 1000 / HZ));
+		dev_notice(&wc->vb.pdev->dev,
+			   "Excessive leakage detected on module %d: %d "
+			   "volts (%02x) after %d ms\n", mod->card,
+			   376 * vbat / 1000, vbat,
+			   (int)((jiffies - origjiffies) * 1000 / HZ));
 		return -1;
 	} else if (debug & DEBUG_CARD) {
-		dev_info(&wc->vb.pdev->dev, "Post-leakage voltage: %d volts\n", 376 * vbat / 1000);
+		dev_info(&wc->vb.pdev->dev,
+			 "Post-leakage voltage: %d volts\n", 376 * vbat / 1000);
 	}
 	return 0;
 }
 
-static int wctdm_powerup_proslic(struct wctdm *wc, int card, int fast)
+static int wctdm_powerup_proslic(struct wctdm *wc,
+				 struct wctdm_module *mod, int fast)
 {
 	unsigned char vbat;
 	unsigned long origjiffies;
 	int lim;
 
 	/* Set period of DC-DC converter to 1/64 khz */
-	wctdm_setreg(wc, card, 92, 0xc0 /* was 0xff */);
+	wctdm_setreg(wc, mod, 92, 0xc0 /* was 0xff */);
 
 	/* Wait for VBat to powerup */
 	origjiffies = jiffies;
 
 	/* Disable powerdown */
-	wctdm_setreg(wc, card, 14, 0);
+	wctdm_setreg(wc, mod, 14, 0);
 
 	/* If fast, don't bother checking anymore */
 	if (fast)
 		return 0;
 
-	while ((vbat = wctdm_getreg(wc, card, 82)) < 0xc0) {
+	while ((vbat = wctdm_getreg(wc, mod, 82)) < 0xc0) {
 		/* Wait no more than 500ms */
 		if ((jiffies - origjiffies) > HZ/2) {
 			break;
@@ -2249,12 +2309,14 @@
 
 	if (vbat < 0xc0) {
 		dev_notice(&wc->vb.pdev->dev, "ProSLIC on module %d failed to powerup within %d ms (%d mV only)\n\n -- DID YOU REMEMBER TO PLUG IN THE HD POWER CABLE TO THE TDM CARD??\n",
-		       card, (int)(((jiffies - origjiffies) * 1000 / HZ)),
+		       mod->card, (int)(((jiffies - origjiffies) * 1000 / HZ)),
 			vbat * 375);
 		return -1;
 	} else if (debug & DEBUG_CARD) {
-		dev_info(&wc->vb.pdev->dev, "ProSLIC on module %d powered up to -%d volts (%02x) in %d ms\n",
-		       card, vbat * 376 / 1000, vbat, (int)(((jiffies - origjiffies) * 1000 / HZ)));
+		dev_info(&wc->vb.pdev->dev,
+			 "ProSLIC on module %d powered up to -%d volts (%02x) "
+			 "in %d ms\n", mod->card, vbat * 376 / 1000, vbat,

[... 1728 lines stripped ...]



More information about the svn-commits mailing list