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

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


Author: sruffell
Date: Wed Mar 16 16:40:13 2011
New Revision: 9853

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9853
Log:
wctdm24xxp: Use enumeration for module types.

This change is to primarily to clarify that the types are always mutually
exclusive.

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

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=9853&r1=9852&r2=9853
==============================================================================
--- 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:13 2011
@@ -594,7 +594,7 @@
 	int subaddr = card & 0x3;
 
 	/* QRV only use commands relating to the first channel */
-	if ((card & 0x03) && (mod->type == MOD_TYPE_QRV))
+	if ((card & 0x03) && (mod->type == QRV))
 		return;
 
 	if (mod->altcs)
@@ -617,17 +617,17 @@
 
 	if (!curcmd) {
 		/* If nothing else, use filler */
-		if (mod->type == MOD_TYPE_FXS)
+		if (mod->type == FXS)
 			curcmd = CMD_RD(LINE_STATE);
-		else if (mod->type == MOD_TYPE_FXO)
+		else if (mod->type == FXO)
 			curcmd = CMD_RD(12);
-		else if (mod->type == MOD_TYPE_BRI)
+		else if (mod->type == BRI)
 			curcmd = 0x101010;
-		else if (mod->type == MOD_TYPE_QRV)
+		else if (mod->type == QRV)
 			curcmd = CMD_RD(3);
 	}
 
-	if (mod->type == MOD_TYPE_FXS) {
+	if (mod->type == FXS) {
 		eframe[CMD_BYTE(card, 0, mod->altcs)] = (1 << (subaddr));
 		if (curcmd & __CMD_WR)
 			eframe[CMD_BYTE(card, 1, mod->altcs)] = (curcmd >> 8) & 0x7f;
@@ -635,7 +635,7 @@
 			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) {
+	} else if (mod->type == FXO) {
 		static const int FXO_ADDRS[4] = { 0x00, 0x08, 0x04, 0x0c };
 		int idx = CMD_BYTE(card, 0, mod->altcs);
 		if (curcmd & __CMD_WR)
@@ -645,7 +645,7 @@
 		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) {
+	} else if (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
@@ -657,7 +657,7 @@
 		else
 			eframe[CMD_BYTE(card, 2, mod->altcs)] = 0x00;
 
-	} else if (mod->type == MOD_TYPE_BRI) {
+	} else if (mod->type == BRI) {
 
 		if (unlikely((curcmd != 0x101010) && (curcmd & 0x1010) == 0x1010)) /* b400m CPLD */
 			eframe[CMD_BYTE(card, 0, 0)] = 0x55;
@@ -666,7 +666,7 @@
 		eframe[CMD_BYTE(card, 1, 0)] = (curcmd >> 8) & 0xff;
 		eframe[CMD_BYTE(card, 2, 0)] = curcmd & 0xff;
 
-	} else if (mod->type == MOD_TYPE_QRV) {
+	} else if (mod->type == QRV) {
  
 		eframe[CMD_BYTE(card, 0, mod->altcs)] = 0x00;
 		if (!curcmd) {
@@ -679,7 +679,7 @@
 				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) {
+	} else if (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;
@@ -736,7 +736,7 @@
 	int x;
 
 	/* QRV modules only use commands relating to the first channel */
-	if ((card & 0x03) && (mod->type == MOD_TYPE_QRV))
+	if ((card & 0x03) && (mod->type == QRV))
 		return;
 
 	/* Skip audio */
@@ -776,28 +776,28 @@
 		if (mod->sethook) {
 			mod->cmdq.cmds[USER_COMMANDS + 0] = mod->sethook;
 			mod->sethook = 0;
-		} else if (mod->type == MOD_TYPE_FXS) {
+		} else if (mod->type == FXS) {
 			mod->cmdq.cmds[USER_COMMANDS + 0] = CMD_RD(68);	/* Hook state */
-		} else if (mod->type == MOD_TYPE_FXO) {
+		} else if (mod->type == FXO) {
 			mod->cmdq.cmds[USER_COMMANDS + 0] = CMD_RD(5);	/* Hook/Ring state */
-		} else if (mod->type == MOD_TYPE_QRV) {
+		} else if (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) {
+		} else if (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) {
+		if (mod->type == FXS) {
 #ifdef PAQ_DEBUG
 			mod->cmdq.cmds[USER_COMMANDS + 1] = CMD_RD(19);	/* Transistor interrupts */
 #else
 			mod->cmdq.cmds[USER_COMMANDS + 1] = CMD_RD(LINE_STATE);
 #endif
-		} else if (mod->type == MOD_TYPE_FXO) {
+		} else if (mod->type == FXO) {
 			mod->cmdq.cmds[USER_COMMANDS + 1] = CMD_RD(29);	/* Battery */
-		} else if (mod->type == MOD_TYPE_QRV) {
+		} else if (mod->type == QRV) {
 			wc->mods[card & 0xfc].cmdq.cmds[USER_COMMANDS + 1] = CMD_RD(3);	/* Battery */
-		} else if (mod->type == MOD_TYPE_BRI) {
+		} else if (mod->type == BRI) {
 			mod->cmdq.cmds[USER_COMMANDS + 1] = wctdm_bri_checkisr(wc, card, 1);
 		}
 	}
@@ -933,8 +933,8 @@
 	const unsigned int cmd = CMD_WR(addr, val);
 
 	/* QRV and BRI cards are only addressed at their first "port" */
-	if ((card & 0x03) && ((wc->mods[card].type ==  MOD_TYPE_QRV) ||
-	    (wc->mods[card].type ==  MOD_TYPE_BRI)))
+	if ((card & 0x03) && ((wc->mods[card].type ==  QRV) ||
+	    (wc->mods[card].type ==  BRI)))
 		return 0;
 
 	if (inisr) {
@@ -985,7 +985,7 @@
 	int ret;
 
 	/* if a QRV card, use only its first channel */  
-	if (wc->mods[card].type ==  MOD_TYPE_QRV) {
+	if (wc->mods[card].type ==  QRV) {
 		if (card & 3)
 			return 0;
 	}
@@ -1012,7 +1012,7 @@
 	for (x=0;x<MAX_COMMANDS;x++) {
 		for (y = 0; y < wc->mods_per_board; y++) {
 			struct wctdm_module *const mod = &wc->mods[y];
-			if (mod->type == MOD_TYPE_BRI)
+			if (mod->type == BRI)
 				continue;
 			if (!(mod->cmdq.cmds[x] & __CMD_FIN))
 				mod->cmdq.cmds[x] &= ~(__CMD_TX | (0xff << 24));
@@ -2029,14 +2029,16 @@
 
 	for (x = 0; x < wc->mods_per_board; x++) {
 		switch (wc->mods[x].type) {
-		case MOD_TYPE_FXS:
+		case FXS:
 			wctdm_isr_misc_fxs(wc, x);
 			break;
-		case MOD_TYPE_FXO:
+		case FXO:
 			wctdm_voicedaa_check_hook(wc, x);
 			break;
-		case MOD_TYPE_QRV:
+		case QRV:
 			wctdm_qrvdri_check_hook(wc, x);
+			break;
+		default:
 			break;
 		}
 	}
@@ -2382,7 +2384,7 @@
  *******************************************************************/
 static int wctdm_set_hwgain(struct wctdm *wc, int card, __s32 gain, __u32 tx)
 {
-	if (!(wc->mods[card].type == MOD_TYPE_FXO)) {
+	if (!(wc->mods[card].type == FXO)) {
 		dev_notice(&wc->vb.pdev->dev, "Cannot adjust gain.  Unsupported module type!\n");
 		return -1;
 	}
@@ -2502,17 +2504,17 @@
 	unsigned long flags;
 	long newjiffies;
 
-	if ((wc->mods[card & 0xfc].type == MOD_TYPE_QRV) ||
-	    (wc->mods[card & 0xfc].type == MOD_TYPE_BRI))
+	if ((wc->mods[card & 0xfc].type == QRV) ||
+	    (wc->mods[card & 0xfc].type == BRI))
 		return -2;
 
 	spin_lock_irqsave(&wc->reglock, flags);
-	wc->mods[card].type = MOD_TYPE_NONE;
+	wc->mods[card].type = NONE;
 	spin_unlock_irqrestore(&wc->reglock, flags);
 	msleep(100);
 
 	spin_lock_irqsave(&wc->reglock, flags);
-	wc->mods[card].type = MOD_TYPE_FXO;
+	wc->mods[card].type = FXO;
 	spin_unlock_irqrestore(&wc->reglock, flags);
 	msleep(100);
 
@@ -2613,11 +2615,11 @@
 	int x;
 	int fxsmode=0;
 
-	if (wc->mods[card & 0xfc].type == MOD_TYPE_QRV)
+	if (wc->mods[card & 0xfc].type == QRV)
 		return -2;
 
 	spin_lock_irqsave(&wc->reglock, flags);
-	mod->type = MOD_TYPE_FXS;
+	mod->type = FXS;
 	spin_unlock_irqrestore(&wc->reglock, flags);
 
 	msleep(100);
@@ -2869,11 +2871,11 @@
 {
 	unsigned char x,y;
 
-	if (MOD_TYPE_BRI == wc->mods[card & 0xfc].type)
+	if (BRI == wc->mods[card & 0xfc].type)
 		return -2;
 
 	/* have to set this, at least for now */
-	wc->mods[card].type = MOD_TYPE_QRV;
+	wc->mods[card].type = QRV;
 	if (!(card & 3)) /* if at base of card, reset and write it */
 	{
 		wctdm_setreg(wc,card,0,0x80); 
@@ -2887,11 +2889,12 @@
 		wc->mods[card].mod.qrv.txgain = wc->mods[card + 1].mod.qrv.txgain = 3599;
 		wc->mods[card].mod.qrv.rxgain = wc->mods[card + 1].mod.qrv.rxgain = 1199;
 	} else { /* channel is on same card as base, no need to test */
-		if (wc->mods[card & 0x7c].type == MOD_TYPE_QRV) {
+		if (wc->mods[card & 0x7c].type == QRV) {
 			/* only lower 2 are valid */
-			if (!(card & 2)) return 0;
-		}
-		wc->mods[card].type = MOD_TYPE_NONE;
+			if (!(card & 2))
+				return 0;
+		}
+		wc->mods[card].type = NONE;
 		return 1;
 	}
 	x = wctdm_getreg(wc,card,0);
@@ -2899,7 +2902,7 @@
 	/* if not a QRV card, return as such */
 	if ((x != 0x55) || (y != 0x69))
 	{
-		wc->mods[card].type = MOD_TYPE_NONE;
+		wc->mods[card].type = NONE;
 		return 1;
 	}
 	for (x = 0; x < 0x30; x++)
@@ -3063,7 +3066,7 @@
 
 	switch (cmd) {
 	case DAHDI_ONHOOKTRANSFER:
-		if (mod->type != MOD_TYPE_FXS)
+		if (mod->type != FXS)
 			return -EINVAL;
 		if (get_user(x, (__user int *) data))
 			return -EFAULT;
@@ -3098,7 +3101,7 @@
 		}
 		break;
 	case DAHDI_VMWI_CONFIG:
-		if (mod->type != MOD_TYPE_FXS)
+		if (mod->type != FXS)
 			return -EINVAL;
 		if (copy_from_user(&(fxs->vmwisetting),
 				   (__user void *)data,
@@ -3107,7 +3110,7 @@
 		set_vmwi(wc, chan->chanpos - 1);
 		break;
 	case DAHDI_VMWI:
-		if (mod->type != MOD_TYPE_FXS)
+		if (mod->type != FXS)
 			return -EINVAL;
 		if (get_user(x, (__user int *) data))
 			return -EFAULT;
@@ -3117,11 +3120,11 @@
 		set_vmwi(wc, chan->chanpos - 1);
 		break;
 	case WCTDM_GET_STATS:
-		if (mod->type == MOD_TYPE_FXS) {
+		if (mod->type == FXS) {
 			stats.tipvolt = wctdm_getreg(wc, chan->chanpos - 1, 80) * -376;
 			stats.ringvolt = wctdm_getreg(wc, chan->chanpos - 1, 81) * -376;
 			stats.batvolt = wctdm_getreg(wc, chan->chanpos - 1, 82) * -376;
-		} else if (mod->type == MOD_TYPE_FXO) {
+		} else if (mod->type == FXO) {
 			stats.tipvolt = (signed char)wctdm_getreg(wc, chan->chanpos - 1, 29) * 1000;
 			stats.ringvolt = (signed char)wctdm_getreg(wc, chan->chanpos - 1, 29) * 1000;
 			stats.batvolt = (signed char)wctdm_getreg(wc, chan->chanpos - 1, 29) * 1000;
@@ -3136,9 +3139,9 @@
 		if (!regs)
 			return -ENOMEM;
 
-		if (mod->type == MOD_TYPE_FXS)
+		if (mod->type == FXS)
 			wctdm24xxp_get_fxs_regs(wc, chan, regs);
-		else if (mod->type == MOD_TYPE_QRV)
+		else if (mod->type == QRV)
 			wctdm24xxp_get_qrv_regs(wc, chan, regs);
 		else
 			wctdm24xxp_get_fxo_regs(wc, chan, regs);
@@ -3155,7 +3158,7 @@
 		if (copy_from_user(&regop, (__user void *) data, sizeof(regop)))
 			return -EFAULT;
 		if (regop.indirect) {
-			if (mod->type != MOD_TYPE_FXS)
+			if (mod->type != FXS)
 				return -EINVAL;
 			dev_info(&wc->vb.pdev->dev, "Setting indirect %d to 0x%04x on %d\n", regop.reg, regop.val, chan->chanpos);
 			wctdm_proslic_setreg_indirect(wc, chan->chanpos - 1, regop.reg, regop.val);
@@ -3174,7 +3177,7 @@
 		if (copy_from_user(&echoregs, (__user void *) data, sizeof(echoregs)))
 			return -EFAULT;
 
-		if (mod->type == MOD_TYPE_FXO) {
+		if (mod->type == FXO) {
 			/* Set the ACIM register */
 			wctdm_setreg(wc, chan->chanpos - 1, 30, echoregs.acim);
 
@@ -3214,7 +3217,7 @@
 	case DAHDI_SETPOLARITY:
 		if (get_user(x, (__user int *) data))
 			return -EFAULT;
-		if (mod->type != MOD_TYPE_FXS)
+		if (mod->type != FXS)
 			return -EINVAL;
 		/* Can't change polarity while ringing or when open */
 		if (((fxs->lasttxhook & SLIC_LF_SETMASK) == SLIC_LF_RINGING) ||
@@ -3265,7 +3268,7 @@
 		}
 		break;
 	case DAHDI_RADIO_GETPARAM:
-		if (mod->type != MOD_TYPE_QRV)
+		if (mod->type != QRV)
 			return -ENOTTY;
 		if (copy_from_user(&stack.p, (__user void *) data, sizeof(stack.p)))
 			return -EFAULT;
@@ -3317,7 +3320,7 @@
 		    return -EFAULT;
 		break;
 	case DAHDI_RADIO_SETPARAM:
-		if (mod->type != MOD_TYPE_QRV)
+		if (mod->type != QRV)
 			return -ENOTTY;
 		if (copy_from_user(&stack.p, (__user void *) data, sizeof(stack.p)))
 			return -EFAULT;
@@ -3409,7 +3412,7 @@
 	if (wc->dead)
 		return -ENODEV;
 #endif
-	if (mod->type == MOD_TYPE_FXO) {
+	if (mod->type == FXO) {
 		/* Reset the mwi indicators */
 		spin_lock_irqsave(&wc->reglock, flags);
 		mod->mod.fxo.neonmwi_debounce = 0;
@@ -3443,11 +3446,11 @@
 	wc = chan->pvt;
 	for (x = 0; x < wc->mods_per_board; x++) {
 		struct wctdm_module *const mod = &wc->mods[x];
-		if (MOD_TYPE_FXS == mod->type) {
+		if (FXS == mod->type) {
 			mod->mod.fxs.idletxhookstate =
 				POLARITY_XOR(x) ? SLIC_LF_ACTIVE_REV :
 						  SLIC_LF_ACTIVE_FWD;
-		} else if (MOD_TYPE_QRV == mod->type) {
+		} else if (QRV == mod->type) {
 			int qrvcard = x & 0xfc;
 
 			mod->mod.qrv.hook = 0;
@@ -3476,7 +3479,7 @@
 	int reg = 0;
 	struct wctdm_module *const mod = &wc->mods[chan->chanpos - 1];
 
-	if (mod->type == MOD_TYPE_QRV) {
+	if (mod->type == QRV) {
 		const int qrvcard = (chan->chanpos - 1) & 0xfc;
 
 		switch(txsig) {
@@ -3497,7 +3500,7 @@
 			reg |= 0x10;
 		wc->mods[qrvcard].sethook = CMD_WR(3, reg);
 		/* wctdm_setreg(wc, qrvcard, 3, reg); */
-	} else if (mod->type == MOD_TYPE_FXO) {
+	} else if (mod->type == FXO) {
 		switch(txsig) {
 		case DAHDI_TXSIG_START:
 		case DAHDI_TXSIG_OFFHOOK:
@@ -3513,7 +3516,7 @@
 		default:
 			dev_notice(&wc->vb.pdev->dev, "wctdm24xxp: Can't set tx state to %d\n", txsig);
 		}
-	} else if (mod->type == MOD_TYPE_FXS) {
+	} else if (mod->type == FXS) {
 		wctdm_fxs_hooksig(wc, chan->chanpos - 1, txsig);
 	}
 	return 0;
@@ -3528,14 +3531,14 @@
 		return;
 	}
 	type = wc->mods[srccard].type;
-	if ((type == MOD_TYPE_FXS) || (type == MOD_TYPE_FXO)) {
+	if ((type == FXS) || (type == FXO)) {
 		dev_notice(&wc->vb.pdev->dev,
 			   "wctdm_dacs_connect: Unsupported modtype for "
 			   "card %d\n", srccard);
 		return;
 	}
 	type = wc->mods[dstcard].type;
-	if ((type != MOD_TYPE_FXS) && (type != MOD_TYPE_FXO)) {
+	if ((type != FXS) && (type != FXO)) {
 		dev_notice(&wc->vb.pdev->dev,
 			   "wctdm_dacs_connect: Unsupported modtype "
 			   "for card %d\n", dstcard);
@@ -3546,22 +3549,22 @@
 	wc->mods[dstcard].dacssrc = srccard;
 
 	/* make srccard transmit to srccard+24 on the TDM bus */
-	if (wc->mods[srccard].type == MOD_TYPE_FXS) {
+	if (wc->mods[srccard].type == FXS) {
 		/* proslic */
 		wctdm_setreg(wc, srccard, PCM_XMIT_START_COUNT_LSB, ((srccard+24) * 8) & 0xff); 
 		wctdm_setreg(wc, srccard, PCM_XMIT_START_COUNT_MSB, ((srccard+24) * 8) >> 8);
-	} else if (wc->mods[srccard].type == MOD_TYPE_FXO) {
+	} else if (wc->mods[srccard].type == FXO) {
 		/* daa */
 		wctdm_setreg(wc, srccard, 34, ((srccard+24) * 8) & 0xff); /* TX */
 		wctdm_setreg(wc, srccard, 35, ((srccard+24) * 8) >> 8);   /* TX */
 	}
 
 	/* have dstcard receive from srccard+24 on the TDM bus */
-	if (wc->mods[dstcard].type == MOD_TYPE_FXS) {
+	if (wc->mods[dstcard].type == FXS) {
 		/* proslic */
     	wctdm_setreg(wc, dstcard, PCM_RCV_START_COUNT_LSB,  ((srccard+24) * 8) & 0xff);
 		wctdm_setreg(wc, dstcard, PCM_RCV_START_COUNT_MSB,  ((srccard+24) * 8) >> 8);
-	} else if (wc->mods[dstcard].type == MOD_TYPE_FXO) {
+	} else if (wc->mods[dstcard].type == FXO) {
 		/* daa */
 		wctdm_setreg(wc, dstcard, 36, ((srccard+24) * 8) & 0xff); /* RX */
 		wctdm_setreg(wc, dstcard, 37, ((srccard+24) * 8) >> 8);   /* RX */
@@ -3581,12 +3584,12 @@
 		}
 
 		/* restore TX (source card) */
-		if (wc->mods[mod->dacssrc].type == MOD_TYPE_FXS) {
+		if (wc->mods[mod->dacssrc].type == FXS) {
 			wctdm_setreg(wc, mod->dacssrc, PCM_XMIT_START_COUNT_LSB,
 				     (wc->mods[card].dacssrc * 8) & 0xff);
 			wctdm_setreg(wc, mod->dacssrc, PCM_XMIT_START_COUNT_MSB,
 				     (wc->mods[card].dacssrc * 8) >> 8);
-		} else if (wc->mods[mod->dacssrc].type == MOD_TYPE_FXO) {
+		} else if (wc->mods[mod->dacssrc].type == FXO) {
 			wctdm_setreg(wc, card, 34, (card * 8) & 0xff);
 			wctdm_setreg(wc, card, 35, (card * 8) >> 8);
 		} else {
@@ -3594,10 +3597,10 @@
 		}
 
 		/* restore RX (this card) */
-		if (MOD_TYPE_FXS == mod->type) {
+		if (FXS == mod->type) {
 			wctdm_setreg(wc, card, PCM_RCV_START_COUNT_LSB, (card * 8) & 0xff);
 			wctdm_setreg(wc, card, PCM_RCV_START_COUNT_MSB, (card * 8) >> 8);
-		} else if (MOD_TYPE_FXO == mod->type) {
+		} else if (FXO == mod->type) {
 			wctdm_setreg(wc, card, 36, (card * 8) & 0xff);
 			wctdm_setreg(wc, card, 37, (card * 8) >> 8);
 		} else {
@@ -3825,7 +3828,7 @@
 				 "s->chans[%d]=%p\n", x, y, mod->type,
 				 y, s->chans[y]);
 		}
-		if (mod->type == MOD_TYPE_FXO) {
+		if (mod->type == FXO) {
 			int val;
 			s->chans[y++]->sigcap = DAHDI_SIG_FXSKS | DAHDI_SIG_FXSLS | DAHDI_SIG_SF | DAHDI_SIG_CLEAR;
 			val = should_set_alaw(wc) ? 0x20 : 0x28;
@@ -3833,11 +3836,11 @@
 			val = (digitalloopback) ? 0x30 : val;
 #endif
 			wctdm_setreg(wc, x, 33, val);
-		} else if (mod->type == MOD_TYPE_FXS) {
+		} else if (mod->type == FXS) {
 			s->chans[y++]->sigcap = DAHDI_SIG_FXOKS | DAHDI_SIG_FXOLS | DAHDI_SIG_FXOGS | DAHDI_SIG_SF | DAHDI_SIG_EM | DAHDI_SIG_CLEAR;
 			wctdm_setreg(wc, x, 1,
 				     (should_set_alaw(wc) ? 0x20 : 0x28));
-		} else if (mod->type == MOD_TYPE_QRV) {
+		} else if (mod->type == QRV) {
 			s->chans[y++]->sigcap = DAHDI_SIG_SF | DAHDI_SIG_EM | DAHDI_SIG_CLEAR;
 		} else {
 			s->chans[y++]->sigcap = 0;
@@ -3926,7 +3929,7 @@
  * The FXS modules come out of reset in a two-byte, non-chainable SPI mode.
  * This is currently incompatible with how we do things, so we need to set
  * them to a chained, 3-byte command mode.  This is done by setting the module
- * type to MOD_TYPE_FXSINIT for a little while so that cmd_dequeue will
+ * type to FXSINIT for a little while so that cmd_dequeue will
  * initialize the SLIC into the appropriate mode.
  *
  * This "go to 3-byte chained mode" command, however, wreaks havoc with HybridBRI.
@@ -3934,13 +3937,13 @@
  * The solution:
  * Since HybridBRI is only designed to work in an 8-port card, and since the single-port
  * modules "show up" in SPI slots >= 8 in these cards, we only set SPI slots 8-23 to
- * MOD_TYPE_FXSINIT.  The HybridBRI will never see the command that causes it to freak
+ * FXSINIT.  The HybridBRI will never see the command that causes it to freak
  * out and the single-port FXS cards get what they need so that when we probe with altcs
  * we see them.
  */
 
 	for (x = 0; x < wc->mods_per_board; x++)
-		wc->mods[x].type = MOD_TYPE_FXSINIT;
+		wc->mods[x].type = FXSINIT;
 
 	spin_unlock_irqrestore(&wc->reglock, flags);
 
@@ -4006,13 +4009,13 @@
 						wc->mods[x+2].altcs = 3;
 					}
 
-					mod->type = MOD_TYPE_FXSINIT;
+					mod->type = FXSINIT;
 					spin_unlock_irqrestore(&wc->reglock, flags);
 
 					msleep(20);
 
 					spin_lock_irqsave(&wc->reglock, flags);
-					mod->type = MOD_TYPE_FXS;
+					mod->type = FXS;
 					spin_unlock_irqrestore(&wc->reglock, flags);
 
 					if (debug & DEBUG_CARD)
@@ -4023,7 +4026,7 @@
 					dev_info(&wc->vb.pdev->dev,
 						 "Port %d: Not installed\n",
 						 x + 1);
-					mod->type = MOD_TYPE_NONE;
+					mod->type = NONE;
 				}
 			}
 		}
@@ -4582,7 +4585,7 @@
 	wc->tdm410leds = 0; /* all on by default */
 	for (i = 0; i < wc->desc->ports; ++i) {
 		/* Turn off the LED for any module that isn't installed. */
-		if (MOD_TYPE_NONE == wc->mods[i].type)
+		if (NONE == wc->mods[i].type)
 			wc->tdm410leds |= (1 << i);
 	}
 }
@@ -4748,10 +4751,10 @@
 		struct wctdm_module *const mod = &wc->mods[i];
 		struct b400m *b4;
 
-		if (mod->type == MOD_TYPE_NONE) {
+		if (mod->type == NONE) {
 			++curspan;
 			continue;
-		} else if (mod->type == MOD_TYPE_BRI) {
+		} else if (mod->type == BRI) {
 			if (!is_hx8(wc)) {
 				dev_info(&wc->vb.pdev->dev, "Digital modules "
 					"detected on a non-hybrid card. "
@@ -4811,13 +4814,13 @@
 	for (i = 0; i < wc->mods_per_board; i++) {
 		struct wctdm_module *const mod = &wc->mods[i];
 		switch (mod->type) {
-		case MOD_TYPE_FXS:
+		case FXS:
 			wctdm_proslic_set_ts(wc, i, (digimods * 12) + i);
 			break;
-		case MOD_TYPE_FXO:
+		case FXO:
 			wctdm_voicedaa_set_ts(wc, i, (digimods * 12) + i);
 			break;
-		case MOD_TYPE_QRV:
+		case QRV:
 			wctdm_qrvdri_set_ts(wc, i, (digimods * 12) + i);
 			break;
 		default:
@@ -4937,7 +4940,7 @@
 
 		/* shut down any BRI modules */
 		for (i = 0; i < wc->mods_per_board; i += 4) {
-			if (wc->mods[i].type == MOD_TYPE_BRI)
+			if (wc->mods[i].type == BRI)
 				wctdm_unload_b400m(wc, i);
 		}
 

Modified: linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/wctdm24xxp.h?view=diff&rev=9853&r1=9852&r2=9853
==============================================================================
--- linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/wctdm24xxp.h (original)
+++ linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/wctdm24xxp.h Wed Mar 16 16:40:13 2011
@@ -58,13 +58,6 @@
 #define SFRAME_SIZE ((EFRAME_SIZE * DAHDI_CHUNKSIZE) + (EFRAME_GAP * (DAHDI_CHUNKSIZE - 1)))
 
 #define MAX_ALARMS 10
-
-#define MOD_TYPE_NONE		0
-#define MOD_TYPE_FXS		1
-#define MOD_TYPE_FXO		2
-#define MOD_TYPE_FXSINIT	3
-#define MOD_TYPE_QRV		5
-#define MOD_TYPE_BRI		7
 
 #define MINPEGTIME	10 * 8		/* 30 ms peak to peak gets us no more than 100 Hz */
 #define PEGTIME		50 * 8		/* 50ms peak to peak gets us rings of 10 Hz or more */
@@ -212,6 +205,15 @@
 	signed short txgain;
 };
 
+enum module_type {
+	NONE = 0,
+	FXS,
+	FXO,
+	FXSINIT,
+	QRV,
+	BRI,
+};
+
 struct wctdm_module {
 	union {
 		struct fxo fxo;
@@ -222,7 +224,7 @@
 
 	struct cmdq cmdq;
 
-	int type; /* type of module (FXO/FXS/QRV/etc.) */
+	enum module_type type;
 	int sethook; /* pending hook state command */
 	int dacssrc;
 	int flags;   /* bitmap of board-specific + module-specific flags */

Modified: linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/xhfc.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/xhfc.c?view=diff&rev=9853&r1=9852&r2=9853
==============================================================================
--- linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/xhfc.c (original)
+++ linux/team/sruffell/wctdm24xxp-cmdlist/drivers/dahdi/wctdm24xxp/xhfc.c Wed Mar 16 16:40:13 2011
@@ -2093,7 +2093,7 @@
 
 	spin_lock_irqsave(&wc->reglock, flags);
 	for (i = 0; i < wc->mods_per_board; i += 4) {
-		if (wc->mods[i].type == MOD_TYPE_BRI)
+		if (wc->mods[i].type == BRI)
 			b4s[numb4s++] = wc->mods[i].mod.bri;
 	}
 	spin_unlock_irqrestore(&wc->reglock, flags);
@@ -2113,7 +2113,7 @@
 
 	spin_lock_irqsave(&wc->reglock, flags);
 	for (i = 0; i < wc->mods_per_board; i += 4) {
-		if (wc->mods[i].type == MOD_TYPE_BRI)
+		if (wc->mods[i].type == BRI)
 			b4s[numb4s++] = wc->mods[i].mod.bri;
 	}
 	spin_unlock_irqrestore(&wc->reglock, flags);
@@ -2572,7 +2572,7 @@
 	/* which B400M in the system is this one? count all of them found so
 	 * far */
 	for (x = 0; x < modpos; x += 4) {
-		if (wc->mods[x].type == MOD_TYPE_BRI)
+		if (wc->mods[x].type == BRI)
 			++b4->b400m_no;
 	}
 
@@ -2630,32 +2630,32 @@
 	int ret = 0;
 	unsigned long flags;
 
-	if (wc->mods[card & 0xfc].type == MOD_TYPE_QRV)
+	if (wc->mods[card & 0xfc].type == QRV)
 		return -2;
 
 	if (!(card & 0x03)) { /* only init if at lowest port in module */
 		spin_lock_irqsave(&wc->reglock, flags);
-		wc->mods[card + 0].type = MOD_TYPE_BRI;
-		wc->mods[card + 1].type = MOD_TYPE_BRI;
-		wc->mods[card + 2].type = MOD_TYPE_BRI;
-		wc->mods[card + 3].type = MOD_TYPE_BRI;
+		wc->mods[card + 0].type = BRI;
+		wc->mods[card + 1].type = BRI;
+		wc->mods[card + 2].type = BRI;
+		wc->mods[card + 3].type = BRI;
 		spin_unlock_irqrestore(&wc->reglock, flags);
 
 		msleep(20);
 
 		if (b400m_probe(wc, card) != 0) {
 			spin_lock_irqsave(&wc->reglock, flags);
-			wc->mods[card + 0].type = MOD_TYPE_NONE;
-			wc->mods[card + 1].type = MOD_TYPE_NONE;
-			wc->mods[card + 2].type = MOD_TYPE_NONE;
-			wc->mods[card + 3].type = MOD_TYPE_NONE;
+			wc->mods[card + 0].type = NONE;
+			wc->mods[card + 1].type = NONE;
+			wc->mods[card + 2].type = NONE;
+			wc->mods[card + 3].type = NONE;
 			spin_unlock_irqrestore(&wc->reglock, flags);
 			ret = -2;
 		}
 	} else {	/* for the "sub-cards" */
-		if (wc->mods[card & 0xfc].type == MOD_TYPE_BRI) {
+		if (wc->mods[card & 0xfc].type == BRI) {
 			spin_lock_irqsave(&wc->reglock, flags);
-			wc->mods[card].type = MOD_TYPE_BRI;
+			wc->mods[card].type = BRI;
 			wc->mods[card].mod.bri = wc->mods[card & 0xfc].mod.bri;
 			spin_unlock_irqrestore(&wc->reglock, flags);
 		} else {
@@ -2734,12 +2734,12 @@
 
 		destroy_workqueue(b4->xhfc_ws);
 
-		/* Set these to MOD_TYPE_NONE to ensure that our checkisr
+		/* Set these to NONE to ensure that our checkisr
 		 * routines are not entered */
-		wc->mods[card].type = MOD_TYPE_NONE;
-		wc->mods[card + 1].type = MOD_TYPE_NONE;
-		wc->mods[card + 2].type = MOD_TYPE_NONE;
-		wc->mods[card + 3].type = MOD_TYPE_NONE;
+		wc->mods[card].type = NONE;
+		wc->mods[card + 1].type = NONE;
+		wc->mods[card + 2].type = NONE;
+		wc->mods[card + 3].type = NONE;
 
 		wc->mods[card].mod.bri = NULL;
 		wc->mods[card + 1].mod.bri = NULL;




More information about the svn-commits mailing list