[asterisk-scf-commits] team/sruffell/dahdi-linux.git branch "master" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Feb 2 15:01:04 CST 2011


branch "master" has been created
        at  ca160497906a8443c11d6c7075fb59436ab5acb5 (commit)

- Log -----------------------------------------------------------------
commit ca160497906a8443c11d6c7075fb59436ab5acb5
Author: Shaun Ruffell <sruffell at digium.com>
Date:   Wed Feb 2 19:28:40 2011 +0000

    dahdi: Analog spans do not have to be marked RUNNING to become master.
    
    Fixes a regression introduced in r9611. Analog spans would never become
    the master since the SPANSTART ioctl is not typically called on them,
    and therefore they were never marked RUNNING.  The result could be audio
    problems.
    
    I'm marking this as related to issue 13205 since it's generally all
    related to how should the drivers select which span is the master.  I
    also mark as related to issue 16165 because the problems experienced are
    a result of the same fundamental issue.
    
    (issue #13205)(issue #16165)
    
    Reported-and-Tested-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    Signed-off-by: Shaun Ruffell <sruffell at digium.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9729 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index 60d690b..01bee57 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -3595,6 +3595,11 @@ void dahdi_alarm_channel(struct dahdi_chan *chan, int alarms)
 	spin_unlock_irqrestore(&chan->lock, flags);
 }
 
+static inline bool is_analog_span(const struct dahdi_span *s)
+{
+	return (s->linecompat == 0);
+}
+
 static void __dahdi_find_master_span(void)
 {
 	struct dahdi_span *s;
@@ -3606,7 +3611,8 @@ static void __dahdi_find_master_span(void)
 	list_for_each_entry(s, &span_list, node) {
 		if (s->alarms)
 			continue;
-		if (!test_bit(DAHDI_FLAGBIT_RUNNING, &s->flags))
+		if (!is_analog_span(s) &&
+		    !test_bit(DAHDI_FLAGBIT_RUNNING, &s->flags))
 			continue;
 		if (!can_provide_timing(s))
 			continue;

commit 4e314aee570302d2eda2461e39e8e60e4a921f39
Author: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Date:   Mon Jan 31 20:16:33 2011 +0000

    xpp: Missing lock release in xpp_dahdi_unregister
    
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9727 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/xpp/xpp_dahdi.c b/drivers/dahdi/xpp/xpp_dahdi.c
index cc4edef..5a27f45 100644
--- a/drivers/dahdi/xpp/xpp_dahdi.c
+++ b/drivers/dahdi/xpp/xpp_dahdi.c
@@ -1065,6 +1065,7 @@ int dahdi_unregister_xpd(xpd_t *xpd)
 
 	if (!IS_PHONEDEV(xpd)) {
 		XPD_ERR(xpd, "Not a telephony device\n");
+		spin_unlock_irqrestore(&xpd->lock, flags);
 		return -EBADF;
 	}
 	if(!SPAN_REGISTERED(xpd)) {

commit b37d14966739e43fcd0a872658726de28f2089ea
Author: Shaun Ruffell <sruffell at digium.com>
Date:   Mon Jan 31 15:53:31 2011 +0000

    dahdi: Experimentally remove dependency on the Big Kernel Lock.
    
    With the release of Linux 2.6.37, the Big Kernel Lock is now a compile
    time option.  This change adds a mutex around the one place in the code
    that we already knew was dependent on the lock_kernel/unlock_kernel
    calls for serialization and drops the other calls to
    lock_kernel/unlock_kernel if CONFIG_BKL is not defined.
    
    This is *mostly* the dahdi-no-bkl.patch with a few minor whitespace
    changes, the global_dialparmslock made static, and a warning added to
    let people know they are running an experimental configuration.
    
    (issue #18604)
    Reported by: jkroon
    Patches:
          dahdi-no-bkl.patch uploaded by jkroon (license 714)
    
    Signed-off-by: Jaco Kroon <jaco at uls.co.za>
    Signed-off-by: Shaun Ruffell <sruffell at digium.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9721 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index ed95510..60d690b 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -48,8 +48,9 @@
 #include <linux/sched.h>
 #include <linux/list.h>
 #include <linux/delay.h>
+#include <linux/mutex.h>
 
-#ifdef HAVE_UNLOCKED_IOCTL
+#if defined(HAVE_UNLOCKED_IOCTL) && defined(CONFIG_BKL)
 #include <linux/smp_lock.h>
 #endif
 
@@ -87,7 +88,7 @@
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
 #ifndef CONFIG_BKL
-#error You must have CONFIG_BKL lock defined to build DAHDI
+#warning "No CONFIG_BKL is an experimental configuration."
 #endif
 #endif
 
@@ -235,6 +236,8 @@ static struct dahdi_dialparams global_dialparams = {
 	.mfr2_tonelen = DAHDI_MS_TO_SAMPLES(DAHDI_CONFIG_DEFAULT_MFR2_LENGTH),
 };
 
+static DEFINE_MUTEX(global_dialparamslock);
+
 static int dahdi_chan_ioctl(struct file *file, unsigned int cmd, unsigned long data);
 
 #if defined(CONFIG_DAHDI_MMX) || defined(ECHO_CAN_FP)
@@ -3151,14 +3154,14 @@ static int dahdi_ioctl_loadzone(unsigned long data)
 
 	z->name = kasprintf(GFP_KERNEL, work->th.name);
 	if (!z->name) {
-		kfree(z);
-		kfree(work);
-		return -ENOMEM;
+		res = -ENOMEM;
+		goto error_exit;
 	}
 
 	for (x = 0; x < DAHDI_MAX_CADENCE; x++)
 		z->ringcadence[x] = work->th.ringcadence[x];
 
+	mutex_lock(&global_dialparamslock);
 	for (x = 0; x < work->th.count; x++) {
 		enum {
 			REGULAR_TONE,
@@ -3171,14 +3174,14 @@ static int dahdi_ioctl_loadzone(unsigned long data)
 		if (space < sizeof(*t)) {
 			module_printk(KERN_NOTICE, "Insufficient tone zone space\n");
 			res = -EINVAL;
-			goto error_exit;
+			goto unlock_error_exit;
 		}
 
 		res = copy_from_user(&work->td, user_data,
 				     sizeof(work->td));
 		if (res) {
 			res = -EFAULT;
-			goto error_exit;
+			goto unlock_error_exit;
 		}
 
 		user_data += sizeof(work->td);
@@ -3201,7 +3204,7 @@ static int dahdi_ioctl_loadzone(unsigned long data)
 					      "Invalid 'next' pointer: %d\n",
 					      work->next[x]);
 				res = -EINVAL;
-				goto error_exit;
+				goto unlock_error_exit;
 			}
 		} else if ((work->td.tone >= DAHDI_TONE_DTMF_BASE) &&
 			   (work->td.tone <= DAHDI_TONE_DTMF_MAX)) {
@@ -3228,7 +3231,7 @@ static int dahdi_ioctl_loadzone(unsigned long data)
 				      "Invalid tone (%d) defined\n",
 				      work->td.tone);
 			res = -EINVAL;
-			goto error_exit;
+			goto unlock_error_exit;
 		}
 
 		t->fac1 = work->td.fac1;
@@ -3284,6 +3287,7 @@ static int dahdi_ioctl_loadzone(unsigned long data)
 			break;
 		}
 	}
+	mutex_unlock(&global_dialparamslock);
 
 	for (x = 0; x < work->th.count; x++) {
 		if (work->samples[x])
@@ -3301,6 +3305,8 @@ static int dahdi_ioctl_loadzone(unsigned long data)
 	kfree(work);
 	return res;
 
+unlock_error_exit:
+	mutex_unlock(&global_dialparamslock);
 error_exit:
 	if (z)
 		kfree(z->name);
@@ -4532,10 +4538,6 @@ static int dahdi_ioctl_chanconfig(unsigned long data)
 /**
  * dahdi_ioctl_set_dialparms - Set the global dial parameters.
  * @data:	Pointer to user space that contains dahdi_dialparams.
- *
- * NOTE: The global_dialparms is currently protected from concurrent updates
- * by the lock_kernel/unlock_kernel calls.
- *
  */
 static int dahdi_ioctl_set_dialparams(unsigned long data)
 {
@@ -4547,6 +4549,8 @@ static int dahdi_ioctl_set_dialparams(unsigned long data)
 	if (copy_from_user(&tdp, (void __user *)data, sizeof(tdp)))
 		return -EFAULT;
 
+	mutex_lock(&global_dialparamslock);
+
 	if ((tdp.dtmf_tonelen >= 10) && (tdp.dtmf_tonelen <= 4000))
 		gdp->dtmf_tonelen = tdp.dtmf_tonelen;
 
@@ -4587,6 +4591,8 @@ static int dahdi_ioctl_set_dialparams(unsigned long data)
 	mfr1_silence.tonesamples = gdp->mfv1_tonelen * DAHDI_CHUNKSIZE;
 	mfr2_silence.tonesamples = gdp->mfr2_tonelen * DAHDI_CHUNKSIZE;
 
+	mutex_unlock(&global_dialparamslock);
+
 	return 0;
 }
 
@@ -4594,7 +4600,9 @@ static int dahdi_ioctl_get_dialparams(unsigned long data)
 {
 	struct dahdi_dialparams tdp;
 
+	mutex_lock(&global_dialparamslock);
 	tdp = global_dialparams;
+	mutex_unlock(&global_dialparamslock);
 	if (copy_to_user((void __user *)data, &tdp, sizeof(tdp)))
 		return -EFAULT;
 	return 0;
@@ -6268,18 +6276,14 @@ static int dahdi_prechan_ioctl(struct file *file, unsigned int cmd, unsigned lon
 	return 0;
 }
 
-#ifdef HAVE_UNLOCKED_IOCTL
-static long dahdi_ioctl(struct file *file, unsigned int cmd, unsigned long data)
-#else
-static int dahdi_ioctl(struct inode *inode, struct file *file,
-		unsigned int cmd, unsigned long data)
-#endif
+static long
+dahdi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long data)
 {
 	int unit = UNIT(file);
 	struct dahdi_timer *timer;
 	int ret;
 
-#ifdef HAVE_UNLOCKED_IOCTL
+#if defined(HAVE_UNLOCKED_IOCTL) && defined(CONFIG_BKL)
 	lock_kernel();
 #endif
 
@@ -6329,12 +6333,20 @@ static int dahdi_ioctl(struct inode *inode, struct file *file,
 	ret = dahdi_chan_ioctl(file, cmd, data);
 
 unlock_exit:
-#ifdef HAVE_UNLOCKED_IOCTL
+#if defined(HAVE_UNLOCKED_IOCTL) && defined(CONFIG_BKL)
 	unlock_kernel();
 #endif
 	return ret;
 }
 
+#ifndef HAVE_UNLOCKED_IOCTL
+static int dahdi_ioctl(struct inode *inode, struct file *file,
+		unsigned int cmd, unsigned long data)
+{
+	return dahdi_unlocked_ioctl(file, cmd, data);
+}
+#endif
+
 #ifdef HAVE_COMPAT_IOCTL
 static long dahdi_ioctl_compat(struct file *file, unsigned int cmd,
 		unsigned long data)
@@ -6342,7 +6354,7 @@ static long dahdi_ioctl_compat(struct file *file, unsigned int cmd,
 	if (cmd == DAHDI_SFCONFIG)
 		return -ENOTTY; /* Not supported yet */
 
-	return dahdi_ioctl(file, cmd, data);
+	return dahdi_unlocked_ioctl(file, cmd, data);
 }
 #endif
 
@@ -9171,7 +9183,7 @@ static const struct file_operations dahdi_fops = {
 	.open    = dahdi_open,
 	.release = dahdi_release,
 #ifdef HAVE_UNLOCKED_IOCTL
-	.unlocked_ioctl  = dahdi_ioctl,
+	.unlocked_ioctl  = dahdi_unlocked_ioctl,
 #ifdef HAVE_COMPAT_IOCTL
 	.compat_ioctl = dahdi_ioctl_compat,
 #endif
@@ -9186,7 +9198,7 @@ static const struct file_operations dahdi_chan_fops = {
 	.open    = dahdi_open,
 	.release = dahdi_release,
 #ifdef HAVE_UNLOCKED_IOCTL
-	.unlocked_ioctl  = dahdi_ioctl,
+	.unlocked_ioctl  = dahdi_unlocked_ioctl,
 #ifdef HAVE_COMPAT_IOCTL
 	.compat_ioctl = dahdi_ioctl_compat,
 #endif

commit 621579c3cd0a068235dc9d09f4277130c2b465be
Author: Shaun Ruffell <sruffell at digium.com>
Date:   Mon Jan 31 15:53:26 2011 +0000

    wctdm24xxp: Remove code for unsupported modules.
    
    The VPM100 and S100M modules are no longer supported. Analog cards supported
    by the wctdm24xxp are still compatible with the S110 and VPMADT032 modules.
    DAHDI-302
    
    Signed-off-by: Shaun Ruffell <sruffell at digium.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9720 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c
index 22854cb..3794b55 100644
--- a/drivers/dahdi/wctdm24xxp/base.c
+++ b/drivers/dahdi/wctdm24xxp/base.c
@@ -160,21 +160,7 @@ static alpha  indirect_regs[] =
 {43,66,"LOOP_CLOSE_TRES_LOW",0x1000},
 };
 
-#ifdef FANCY_ECHOCAN
-static char ectab[] = {
-0, 0, 0, 1, 2, 3, 4, 6, 8, 9, 11, 13, 16, 18, 20, 22, 24, 25, 27, 28, 29, 30, 31, 31, 32, 
-32, 32, 32, 32, 32, 32, 32, 32, 32, 32 ,32 ,32, 32,
-32, 32, 32, 32, 32, 32, 32, 32, 32, 32 ,32 ,32, 32,
-32, 32, 32, 32, 32, 32, 32, 32, 32, 32 ,32 ,32, 32,
-31, 31, 30, 29, 28, 27, 25, 23, 22, 20, 18, 16, 13, 11, 9, 8, 6, 4, 3, 2, 1, 0, 0, 
-};
-static int ectrans[4] = { 0, 1, 3, 2 };
-#define EC_SIZE (sizeof(ectab))
-#define EC_SIZE_Q (sizeof(ectab) / 4)
-#endif
-
 /* names of HWEC modules */
-static const char *vpm100m_name = "VPM100M";
 static const char *vpmadt032_name = "VPMADT032";
 static const char *noec_name = "NONE";
 
@@ -598,12 +584,6 @@ static inline void cmd_dequeue(struct wctdm *wc, unsigned char *writechunk, int
 	unsigned int curcmd=0;
 	int x;
 	int subaddr = card & 0x3;
-#ifdef FANCY_ECHOCAN
-	int ecval;
-	ecval = wc->echocanpos;
-	ecval += EC_SIZE_Q * ectrans[(card & 0x3)];
-	ecval = ecval % EC_SIZE;
-#endif
 
 	/* QRV and BRI modules only use commands relating to the first channel */
 	if ((card & 0x03) && (wc->modtype[card] ==  MOD_TYPE_QRV)) {
@@ -638,16 +618,6 @@ static inline void cmd_dequeue(struct wctdm *wc, unsigned char *writechunk, int
 			curcmd = 0x101010;
 		else if (wc->modtype[card] == MOD_TYPE_QRV)
 			curcmd = CMD_RD(3);
-		else if (wc->modtype[card] == MOD_TYPE_VPM) {
-#ifdef FANCY_ECHOCAN
-			if (wc->blinktimer >= 0xf) {
-				curcmd = CMD_WR(0x1ab, 0x0f);
-			} else if (wc->blinktimer == (ectab[ecval] >> 1)) {
-				curcmd = CMD_WR(0x1ab, 0x00);
-			} else
-#endif
-			curcmd = CMD_RD(0x1a0);
-		}
 	}
 
 	if (wc->modtype[card] == MOD_TYPE_FXS) {
@@ -688,13 +658,7 @@ static inline void cmd_dequeue(struct wctdm *wc, unsigned char *writechunk, int
 			writechunk[CMD_BYTE(card, 0, 0)] = 0x10;
 		writechunk[CMD_BYTE(card, 1, 0)] = (curcmd >> 8) & 0xff;
 		writechunk[CMD_BYTE(card, 2, 0)] = curcmd & 0xff;
-	} else if (wc->modtype[card] == MOD_TYPE_VPM) {
-		if (curcmd & __CMD_WR)
-			writechunk[CMD_BYTE(card, 0, wc->altcs[card])] = ((card & 0x3) << 4) | 0xc | ((curcmd >> 16) & 0x1);
-		else
-			writechunk[CMD_BYTE(card, 0, wc->altcs[card])] = ((card & 0x3) << 4) | 0xa | ((curcmd >> 16) & 0x1);
-		writechunk[CMD_BYTE(card, 1, wc->altcs[card])] = (curcmd >> 8) & 0xff;
-		writechunk[CMD_BYTE(card, 2, wc->altcs[card])] = curcmd & 0xff;
+
 	} else if (wc->modtype[card] == MOD_TYPE_QRV) {
  
 		writechunk[CMD_BYTE(card, 0, wc->altcs[card])] = 0x00;
@@ -830,10 +794,6 @@ static inline void cmd_checkisr(struct wctdm *wc, int card)
 			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);
-#ifdef VPM_SUPPORT
-		} else if (wc->modtype[card] == MOD_TYPE_VPM) {
-			wc->cmdq[card].cmds[USER_COMMANDS + 0] = CMD_RD(0xb9); /* DTMF interrupt */
-#endif
 		}
 	}
 	if (!wc->cmdq[card].cmds[USER_COMMANDS + 1]) {
@@ -849,10 +809,6 @@ static inline void cmd_checkisr(struct wctdm *wc, int card)
 			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);
-#ifdef VPM_SUPPORT
-		} else if (wc->modtype[card] == MOD_TYPE_VPM) {
-			wc->cmdq[card].cmds[USER_COMMANDS + 1] = CMD_RD(0xbd); /* DTMF interrupt */
-#endif
 		}
 	}
 }
@@ -947,36 +903,19 @@ static inline void wctdm_transmitprep(struct wctdm *wc, unsigned char *writechun
 			if (y < wc->mods_per_board)
 				cmd_dequeue(wc, writechunk, y, x);
 		}
-		if (!x)
-			wc->blinktimer++;
-		if (wc->vpm100) {
-			for (y = NUM_MODULES; y < NUM_MODULES + NUM_EC; y++) {
-				if (!x)
-					cmd_checkisr(wc, y);
-				cmd_dequeue(wc, writechunk, y, x);
-			}
-#ifdef FANCY_ECHOCAN
-			if (wc->vpm100 && wc->blinktimer >= 0xf) {
-				wc->blinktimer = -1;
-				wc->echocanpos++;
-			}
-#endif			
-		} else if (wc->vpmadt032) {
+
+		if (wc->vpmadt032)
 			cmd_dequeue_vpmadt032(wc, writechunk);
-		}
 
 		if (x < DAHDI_CHUNKSIZE - 1) {
 			writechunk[EFRAME_SIZE] = wc->ctlreg;
 			writechunk[EFRAME_SIZE + 1] = wc->txident++;
 
-			if ((wc->desc->ports == 4) && ((wc->ctlreg & 0x10) || (wc->modtype[NUM_MODULES] == MOD_TYPE_NONE))) {
+			if ((wc->desc->ports == 4) && ((wc->ctlreg & 0x10))) {
 				writechunk[EFRAME_SIZE + 2] = 0;
-				for (y = 0; y < 4; y++) {
-					if (wc->modtype[y] == MOD_TYPE_NONE)
-						writechunk[EFRAME_SIZE + 2] |= (1 << y);
-				}
-			} else
-				writechunk[EFRAME_SIZE + 2] = 0xf;
+				for (y = 0; y < 4; y++)
+					writechunk[EFRAME_SIZE + 2] |= (1 << y);
+			}
 		}
 		writechunk += (EFRAME_SIZE + EFRAME_GAP);
 	}
@@ -1181,10 +1120,8 @@ static inline void wctdm_receiveprep(struct wctdm *wc, const u8 *readchunk)
 		for (y = 0; y < wc->avchannels; y++) {
 			cmd_decipher(wc, readchunk, y);
 		}
-		if (wc->vpm100) {
-			for (y = NUM_MODULES; y < NUM_MODULES + NUM_EC; y++)
-				cmd_decipher(wc, readchunk, y);
-		} else if (wc->vpmadt032)
+
+		if (wc->vpmadt032)
 			cmd_decipher_vpmadt032(wc, readchunk);
 
 		readchunk += (EFRAME_SIZE + EFRAME_GAP);
@@ -1973,9 +1910,7 @@ static inline void wctdm_vpm_check(struct wctdm *wc, int x)
 static const char *wctdm_echocan_name(const struct dahdi_chan *chan)
 {
 	struct wctdm *wc = chan->pvt;
-	if (wc->vpm100)
-		return vpm100m_name;
-	else if (wc->vpmadt032)
+	if (wc->vpmadt032)
 		return vpmadt032_name;
 	return noec_name;
 }
@@ -1989,53 +1924,28 @@ static int wctdm_echocan_create(struct dahdi_chan *chan,
 	struct wctdm_chan *wchan = container_of(chan, struct wctdm_chan, chan);
 	const struct dahdi_echocan_ops *ops;
 	const struct dahdi_echocan_features *features;
+	enum adt_companding comp;
+
 
 #ifdef VPM_SUPPORT
 	if (!vpmsupport)
 		return -ENODEV;
 #endif
-	if (!wc->vpm100 && !wc->vpmadt032)
+	if (!wc->vpmadt032)
 		return -ENODEV;
 
 	ops = &vpm_ec_ops;
 	features = &vpm_ec_features;
 
-	if (wc->vpm100 && (ecp->param_count > 0)) {
-		dev_warn(&wc->vb.pdev->dev, "%s echo canceller does not "
-			 "support parameters; failing request\n",
-			 chan->ec_factory->get_name(chan));
-		return -EINVAL;
-	}
-
 	*ec = &wchan->ec;
 	(*ec)->ops = ops;
 	(*ec)->features = *features;
 
-	if (wc->vpm100) {
-		int channel;
-		int unit;
+	comp = (DAHDI_LAW_ALAW == chan->span->deflaw) ?
+				ADT_COMP_ALAW : ADT_COMP_ULAW;
 
-		channel = wchan->timeslot;
-		unit = wchan->timeslot & 0x3;
-		if (wc->vpm100 < 2)
-			channel >>= 2;
-	
-		if (debug & DEBUG_ECHOCAN)
-			dev_info(&wc->vb.pdev->dev, "echocan: Unit is %d, Channel is %d length %d\n", unit, channel, ecp->tap_length);
-
-		wctdm_vpm_out(wc, unit, channel, 0x3e);
-		return 0;
-	} else if (wc->vpmadt032) {
-		enum adt_companding comp;
-
-		comp = (DAHDI_LAW_ALAW == chan->span->deflaw) ?
-					ADT_COMP_ALAW : ADT_COMP_ULAW;
-
-		return vpmadt032_echocan_create(wc->vpmadt032,
-						wchan->timeslot, comp, ecp, p);
-	} else {
-		return -ENODEV;
-	}
+	return vpmadt032_echocan_create(wc->vpmadt032, wchan->timeslot,
+					comp, ecp, p);
 }
 
 static void echocan_free(struct dahdi_chan *chan, struct dahdi_echocan_state *ec)
@@ -2043,21 +1953,8 @@ static void echocan_free(struct dahdi_chan *chan, struct dahdi_echocan_state *ec
 	struct wctdm *wc = chan->pvt;
 	struct wctdm_chan *wchan = container_of(chan, struct wctdm_chan, chan);
 
-	memset(ec, 0, sizeof(*ec));
-	if (wc->vpm100) {
-		int channel;
-		int unit;
-
-		channel = wchan->timeslot;
-		unit = wchan->timeslot & 0x3;
-		if (wc->vpm100 < 2)
-			channel >>= 2;
-
-		if (debug & DEBUG_ECHOCAN)
-			dev_info(&wc->vb.pdev->dev, "echocan: Unit is %d, Channel is %d length 0\n",
-			       unit, channel);
-		wctdm_vpm_out(wc, unit, channel, 0x01);
-	} else if (wc->vpmadt032) {
+	if (wc->vpmadt032) {
+		memset(ec, 0, sizeof(*ec));
 		vpmadt032_echocan_free(wc->vpmadt032, wchan->timeslot, ec);
 	}
 }
@@ -2152,10 +2049,6 @@ static inline void wctdm_isr_misc(struct wctdm *wc)
 			}
 		}
 	}
-	if (wc->vpm100 > 0) {
-		for (x = NUM_MODULES; x < NUM_MODULES+NUM_EC; x++)
-			wctdm_vpm_check(wc, x);
-	}
 }
 
 static void handle_receive(struct voicebus *vb, struct list_head *buffers)
@@ -2262,7 +2155,7 @@ static int wctdm_proslic_insane(struct wctdm *wc, int card)
 
 	/* let's be really sure this is an FXS before we continue */
 	reg1 = wctdm_getreg(wc, card, 1);
-	if ((0x80 != (blah & 0xf0)) || ((0x88 != reg1) && (0x08 != reg1))) {
+	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);
 		return -1;
@@ -3900,151 +3793,11 @@ static void wctdm_fixup_analog_span(struct wctdm *wc, int spanno)
 	for (x = 0; x < MAX_SPANS; x++) {
 		if (!wc->spans[x])
 			continue;
-		if (wc->vpm100)
-			strncat(wc->spans[x]->span.devicetype, " (VPM100M)", sizeof(wc->spans[x]->span.devicetype) - 1);
-		else if (wc->vpmadt032)
+		if (wc->vpmadt032)
 			strncat(wc->spans[x]->span.devicetype, " (VPMADT032)", sizeof(wc->spans[x]->span.devicetype) - 1);
 	}
 }
 
-static int wctdm_vpm_init(struct wctdm *wc)
-{
-	unsigned char reg;
-	unsigned int mask;
-	unsigned int ver;
-	unsigned char vpmver=0;
-	unsigned int i, x, y;
-
-	for (x=0;x<NUM_EC;x++) {
-		ver = wctdm_vpm_in(wc, x, 0x1a0); /* revision */
-		if (debug & DEBUG_ECHOCAN)
-			dev_info(&wc->vb.pdev->dev, "VPM100: Chip %d: ver %02x\n", x, ver);
-		if (ver != 0x33) {
-			if (x)
-				dev_info(&wc->vb.pdev->dev,
-						"VPM100: Inoperable\n");
-			wc->vpm100 = 0;
-			return -ENODEV;
-		}	
-
-		if (!x) {
-			vpmver = wctdm_vpm_in(wc, x, 0x1a6) & 0xf;
-			dev_info(&wc->vb.pdev->dev, "VPM Revision: %02x\n", vpmver);
-		}
-
-
-		/* Setup GPIO's */
-		for (y=0;y<4;y++) {
-			wctdm_vpm_out(wc, x, 0x1a8 + y, 0x00); /* GPIO out */
-			if (y == 3)
-				wctdm_vpm_out(wc, x, 0x1ac + y, 0x00); /* GPIO dir */
-			else
-				wctdm_vpm_out(wc, x, 0x1ac + y, 0xff); /* GPIO dir */
-			wctdm_vpm_out(wc, x, 0x1b0 + y, 0x00); /* GPIO sel */
-		}
-
-		/* Setup TDM path - sets fsync and tdm_clk as inputs */
-		reg = wctdm_vpm_in(wc, x, 0x1a3); /* misc_con */
-		wctdm_vpm_out(wc, x, 0x1a3, reg & ~2);
-
-		/* Setup Echo length (256 taps) */
-		wctdm_vpm_out(wc, x, 0x022, 0);
-
-		/* Setup timeslots */
-		if (vpmver == 0x01) {
-			wctdm_vpm_out(wc, x, 0x02f, 0x00); 
-			wctdm_vpm_out(wc, x, 0x023, 0xff);
-			mask = 0x11111111 << x;
-		} else {
-			wctdm_vpm_out(wc, x, 0x02f, 0x20  | (x << 3)); 
-			wctdm_vpm_out(wc, x, 0x023, 0x3f);
-			mask = 0x0000003f;
-		}
-
-		/* Setup the tdm channel masks for all chips*/
-		for (i = 0; i < 4; i++)
-			wctdm_vpm_out(wc, x, 0x33 - i, (mask >> (i << 3)) & 0xff);
-
-		/* Setup convergence rate */
-		reg = wctdm_vpm_in(wc,x,0x20);
-		reg &= 0xE0;
-
-		if (wc->companding == DAHDI_LAW_DEFAULT) {
-			if (wc->digi_mods)
-				/* If we have a BRI module, Auto set to alaw */
-				reg |= 0x01;
-			else
-				/* Auto set to ulaw */
-				reg &= ~0x01;
-		} else if (wc->companding == DAHDI_LAW_ALAW) {
-			/* Force everything to alaw */
-			reg |= 0x01;
-		} else {
-			/* Auto set to ulaw */
-			reg &= ~0x01;
-		}
-
-		wctdm_vpm_out(wc,x,0x20,(reg | 0x20));
-
-		/* Initialize echo cans */
-		for (i = 0 ; i < MAX_TDM_CHAN; i++) {
-			if (mask & (0x00000001 << i))
-				wctdm_vpm_out(wc,x,i,0x00);
-		}
-
-		msleep(30);
-
-		/* Put in bypass mode */
-		for (i = 0 ; i < MAX_TDM_CHAN ; i++) {
-			if (mask & (0x00000001 << i)) {
-				wctdm_vpm_out(wc,x,i,0x01);
-			}
-		}
-
-		/* Enable bypass */
-		for (i = 0 ; i < MAX_TDM_CHAN ; i++) {
-			if (mask & (0x00000001 << i))
-				wctdm_vpm_out(wc,x,0x78 + i,0x01);
-		}
-      
-		/* Enable DTMF detectors (always DTMF detect all spans) */
-		for (i = 0; i < 6; i++) {
-			if (vpmver == 0x01) 
-				wctdm_vpm_out(wc, x, 0x98 + i, 0x40 | (i << 2) | x);
-			else
-				wctdm_vpm_out(wc, x, 0x98 + i, 0x40 | i);
-		}
-
-		for (i = 0xB8; i < 0xC0; i++)
-			wctdm_vpm_out(wc, x, i, 0xFF);
-		for (i = 0xC0; i < 0xC4; i++)
-			wctdm_vpm_out(wc, x, i, 0xff);
-
-	} 
-	
-	/* TODO: What do the different values for vpm100 mean? */
-	if (vpmver == 0x01) {
-		wc->vpm100 = 2;
-	} else {
-		wc->vpm100 = 1;
-	}
-
-	dev_info(&wc->vb.pdev->dev, "Enabling VPM100 gain adjustments on any FXO ports found\n");
-	for (i = 0; i < wc->desc->ports; i++) {
-		if (wc->modtype[i] == MOD_TYPE_FXO) {
-			/* Apply negative Tx gain of 4.5db to DAA */
-			wctdm_setreg(wc, i, 38, 0x14);	/* 4db */
-			wctdm_setreg(wc, i, 40, 0x15);	/* 0.5db */
-
-			/* Apply negative Rx gain of 4.5db to DAA */
-			wctdm_setreg(wc, i, 39, 0x14);	/* 4db */
-			wctdm_setreg(wc, i, 41, 0x15);	/* 0.5db */
-		}
-	}
-
-	return 0;
-}
-
 static void get_default_portconfig(GpakPortConfig_t *portconfig)
 {
 	memset(portconfig, 0, sizeof(GpakPortConfig_t));
@@ -4118,18 +3871,11 @@ static void get_default_portconfig(GpakPortConfig_t *portconfig)
 
 static int wctdm_initialize_vpmadt032(struct wctdm *wc)
 {
-	int x;
 	int res;
-	unsigned long flags;
 	struct vpmadt032_options options;
 
 	GpakPortConfig_t portconfig;
 
-	spin_lock_irqsave(&wc->reglock, flags);
-	for (x = NUM_MODULES; x < NUM_MODULES + NUM_EC; x++)
-		wc->modtype[x] = MOD_TYPE_NONE;
-	spin_unlock_irqrestore(&wc->reglock, flags);
-
 	options.debug = debug;
 	options.vpmnlptype = vpmnlptype;
 	options.vpmnlpthresh = vpmnlpthresh;
@@ -4164,22 +3910,18 @@ static int wctdm_initialize_vpmadt032(struct wctdm *wc)
 	return 0;
 }
 
-static int wctdm_initialize_vpm(struct wctdm *wc)
+static void wctdm_initialize_vpm(struct wctdm *wc)
 {
 	int res = 0;
 
 	if (!vpmsupport) {
 		dev_notice(&wc->vb.pdev->dev, "VPM: Support Disabled\n");
-	} else if (!wctdm_vpm_init(wc)) {
-		dev_info(&wc->vb.pdev->dev, "VPM: Present and operational (Rev %c)\n",
-		       'A' + wc->vpm100 - 1);
-		wc->ctlreg |= 0x10;
-	} else {
-		res = wctdm_initialize_vpmadt032(wc);
-		if (!res)
-			wc->ctlreg |= 0x10;
+		return;
 	}
-	return res;
+
+	res = wctdm_initialize_vpmadt032(wc);
+	if (!res)
+		wc->ctlreg |= 0x10;
 }
 
 static int wctdm_identify_modules(struct wctdm *wc)
@@ -4220,10 +3962,6 @@ static int wctdm_identify_modules(struct wctdm *wc)
 	for (x = 0; x < wc->mods_per_board; x++)
 		wc->modtype[x] = MOD_TYPE_FXSINIT;
 
-	wc->vpm100 = -1;
-	for (x = wc->mods_per_board; x < wc->mods_per_board+NUM_EC; x++)
-		wc->modtype[x] = MOD_TYPE_VPM;
-
 	spin_unlock_irqrestore(&wc->reglock, flags);
 
 /* Wait just a bit; this makes sure that cmd_dequeue is emitting SPI commands in the appropriate mode(s). */
diff --git a/drivers/dahdi/wctdm24xxp/wctdm24xxp.h b/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
index 562761b..90c4aaa 100644
--- a/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
+++ b/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
@@ -63,9 +63,7 @@
 #define MOD_TYPE_FXS		1
 #define MOD_TYPE_FXO		2
 #define MOD_TYPE_FXSINIT	3
-#define MOD_TYPE_VPM		4
 #define MOD_TYPE_QRV		5
-#define MOD_TYPE_VPM150M	6
 #define MOD_TYPE_BRI		7
 
 #define MINPEGTIME	10 * 8		/* 30 ms peak to peak gets us no more than 100 Hz */
@@ -90,9 +88,7 @@
 			+ ((card) >> 2) + (altcs) + ((altcs) ? -21 : 0))
 #endif
 #define NUM_MODULES		24
-#define NUM_EC			4
 #define NUM_SLOTS		6
-#define MAX_TDM_CHAN		31
 #define MAX_SPANS		9
 
 #define NUM_CAL_REGS		12
@@ -108,17 +104,7 @@
 #define VPM150M_HPI_DATA	0x03
 
 #define VPM_SUPPORT
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 #define VPM150M_SUPPORT
-#endif
-
-#ifdef VPM_SUPPORT
-
-/* Define to get more attention-grabbing but slightly more CPU using echocan status */
-#define FANCY_ECHOCAN
-
-#endif
 
 #ifdef VPM150M_SUPPORT
 #include "voicebus/GpakCust.h"
@@ -185,7 +171,7 @@ struct wctdm {
 	int avchannels;				/* active "voice" (voice, B and D) channels */
 	int modmap;				/* Bit-map of present cards (1=present) */
 
-	int altcs[NUM_MODULES + NUM_EC];
+	int altcs[NUM_MODULES];
 
 /* FIXME: why are all of these QRV-only members part of the main card structure? */
 	char qrvhook[NUM_MODULES];
@@ -252,18 +238,13 @@ struct wctdm {
 		struct b400m *bri;
 	} mods[NUM_MODULES];
 
-	struct cmdq cmdq[NUM_MODULES + NUM_EC];
-	int modtype[NUM_MODULES + NUM_EC];		/* type of module (FXO/FXS/QRV/VPM/etc.) in this position */
-	int sethook[NUM_MODULES + NUM_EC];		/* pending hook state command for each module */
+	struct cmdq cmdq[NUM_MODULES];
+	int modtype[NUM_MODULES]; /* type of module (FXO/FXS/QRV/etc.) */
+	int sethook[NUM_MODULES]; /* pending hook state command */
 	int dacssrc[NUM_MODULES];
 
-	int vpm100;
-
 	struct vpmadt032 *vpmadt032;
-#ifdef FANCY_ECHOCAN
-	int echocanpos;
-	int blinktimer;
-#endif
+
 	struct voicebus vb;
 	struct wctdm_span *aspan;			/* pointer to the spans[] holding the analog span */
 	struct wctdm_span *spans[MAX_SPANS];

commit bfb586396580a2a07650aedd095f01a48e332994
Author: Oron Peled <oron at actcom.co.il>
Date:   Sun Jan 30 18:33:37 2011 +0000

    xpd_pri: Explicit initialization of span.alarms
    
    Signed-off-by: Oron Peled <oron at actcom.co.il>
    Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9718 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c
index 3ada1fd..c283cbe 100644
--- a/drivers/dahdi/xpp/card_pri.c
+++ b/drivers/dahdi/xpp/card_pri.c
@@ -1319,6 +1319,7 @@ static int PRI_card_dahdi_preregistration(xpd_t *xpd, bool on)
 	PHONEDEV(xpd).span.spantype = pri_protocol_name(priv->pri_protocol);
 	PHONEDEV(xpd).span.linecompat = pri_linecompat(priv->pri_protocol);
 	PHONEDEV(xpd).span.deflaw = priv->deflaw;
+	PHONEDEV(xpd).span.alarms = DAHDI_ALARM_NONE;
 	for_each_line(xpd, i) {
 		struct dahdi_chan	*cur_chan = XPD_CHAN(xpd, i);
 		bool		is_dchan = i == PRI_DCHAN_IDX(priv);

commit ed34941d2d4ea90ef48af0db55e8d09988eb41da
Author: Oron Peled <oron at actcom.co.il>
Date:   Sun Jan 30 18:32:53 2011 +0000

    xpd_pri: Reduce indentation
    
    Signed-off-by: Oron Peled <oron at actcom.co.il>
    Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9717 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c
index e2833f7..3ada1fd 100644
--- a/drivers/dahdi/xpp/card_pri.c
+++ b/drivers/dahdi/xpp/card_pri.c
@@ -1140,16 +1140,16 @@ static int pri_chanconfig(struct dahdi_chan *chan, int sigtype)
 	 *        and prevent DChan definitions with CAS.
 	 */
 	if(is_sigtype_dchan(sigtype)) {
-		if(VALID_DCHAN(priv) && DCHAN(priv) != chan->channo) {
+		if (VALID_DCHAN(priv) && DCHAN(priv) != chan->channo) {
 			ERR("channel %d (%s) marked DChan but also channel %d.\n",
 				chan->channo, chan->name, DCHAN(priv));
 			return -EINVAL;
-		} else {
-			XPD_DBG(GENERAL, xpd, "channel %d (%s) marked as DChan\n", chan->channo, chan->name);
-			SET_DCHAN(priv, chan->channo);
-			/* In T1, we don't know before-hand */
-			if(priv->pri_protocol != PRI_PROTO_E1 && priv->is_cas != 0)
-				set_mode_cas(xpd, 0);
+		}
+		XPD_DBG(GENERAL, xpd, "channel %d (%s) marked as DChan\n", chan->channo, chan->name);
+		SET_DCHAN(priv, chan->channo);
+		/* In T1, we don't know before-hand */
+		if(priv->pri_protocol != PRI_PROTO_E1 && priv->is_cas != 0) {
+			set_mode_cas(xpd, 0);
 		}
 	} else {
 		if(chan->channo == 1) {

commit 0c1f1e8e69143901411d9ad22a3d0435c50c072f
Author: Oron Peled <oron at actcom.co.il>
Date:   Sun Jan 30 18:32:16 2011 +0000

    xpd_pri: reorder debug messages
    
    Move priv->layer1_up debug message after priv->is_cas debug message.
    Otherwise, we get extra meaningless debug message.
    
    Signed-off-by: Oron Peled <oron at actcom.co.il>
    Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9716 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c
index 9950c64..e2833f7 100644
--- a/drivers/dahdi/xpp/card_pri.c
+++ b/drivers/dahdi/xpp/card_pri.c
@@ -1690,9 +1690,6 @@ static int pri_rbsbits(struct dahdi_chan *chan, int bits)
 	pos = chan->chanpos - 1;
 	priv = xpd->priv;
 	BUG_ON(!priv);
-	if(!priv->layer1_up) {
-		XPD_DBG(SIGNAL, xpd, "RBS: TX: No layer1 yet. Keep going.\n");
-	}
 	if(!priv->is_cas) {
 		XPD_DBG(SIGNAL, xpd, "RBS: TX: not in CAS mode. Ignore.\n");
 		return 0;
@@ -1703,6 +1700,9 @@ static int pri_rbsbits(struct dahdi_chan *chan, int bits)
 				sig2str(chan->sig), bits);
 		return 0;
 	}
+	if(!priv->layer1_up) {
+		XPD_DBG(SIGNAL, xpd, "RBS: TX: No layer1 yet. Keep going.\n");
+	}
 	if(priv->pri_protocol == PRI_PROTO_E1) {
 		if(encode_rbsbits_e1(xpd, pos, bits) < 0)
 			return -EINVAL;

commit 086e0d31c13fefbbf76e4859c2c9ef86b68c9c9f
Author: Oron Peled <oron at actcom.co.il>
Date:   Sun Jan 30 18:31:35 2011 +0000

    xpp: remove unused XPD_STATE() "protocol method"
    
    Folded XPD_STATE() "protocol method" into the card_state() method.
    It was only called from these (otherwise empty) methods.
    
    Also it is not a "protocol method" for a very very very long time.
    
    Signed-off-by: Oron Peled <oron at actcom.co.il>
    Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9715 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/xpp/card_bri.c b/drivers/dahdi/xpp/card_bri.c
index 13bb054..ede9d9a 100644
--- a/drivers/dahdi/xpp/card_bri.c
+++ b/drivers/dahdi/xpp/card_bri.c
@@ -1443,26 +1443,9 @@ static void BRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
 	}
 }
 
-/*---------------- BRI: HOST COMMANDS -------------------------------------*/
 
-static /* 0x0F */ HOSTCMD(BRI, XPD_STATE, bool on)
-{
-	struct BRI_priv_data	*priv;
 
-	BUG_ON(!xpd);
-	priv = xpd->priv;
-	XPD_DBG(GENERAL, xpd, "%s\n", (on)?"ON":"OFF");
-	if(on) {
-		if(!test_bit(HFC_L1_ACTIVATED, &priv->l1_flags)) {
-			if( ! IS_NT(xpd))
-				te_activation(xpd, 1);
-			else
-				nt_activation(xpd, 1);
-		}
-	} else if(IS_NT(xpd))
-		nt_activation(xpd, 0);
-	return 0;
-}
+/*---------------- BRI: HOST COMMANDS -------------------------------------*/
 
 static /* 0x33 */ HOSTCMD(BRI, SET_LED, enum bri_led_names which_led, enum led_state to_led_state)
 {
@@ -1671,7 +1654,21 @@ end:
 
 static int BRI_card_state(xpd_t *xpd, bool on)
 {
-	return CALL_PROTO(BRI, XPD_STATE, xpd->xbus, xpd, on);
+	struct BRI_priv_data	*priv;
+
+	BUG_ON(!xpd);
+	priv = xpd->priv;
+	XPD_DBG(GENERAL, xpd, "%s\n", (on)?"ON":"OFF");
+	if(on) {
+		if(!test_bit(HFC_L1_ACTIVATED, &priv->l1_flags)) {
+			if( ! IS_NT(xpd))
+				te_activation(xpd, 1);
+			else
+				nt_activation(xpd, 1);
+		}
+	} else if(IS_NT(xpd))
+		nt_activation(xpd, 0);
+	return 0;
 }
 
 static const struct xops	bri_xops = {
diff --git a/drivers/dahdi/xpp/card_fxo.c b/drivers/dahdi/xpp/card_fxo.c
index 00c9320..2da9584 100644
--- a/drivers/dahdi/xpp/card_fxo.c
+++ b/drivers/dahdi/xpp/card_fxo.c
@@ -83,8 +83,6 @@ enum fxo_leds {
 
 /*---------------- FXO Protocol Commands ----------------------------------*/
 
-static /* 0x0F */ DECLARE_CMD(FXO, XPD_STATE, bool on);
-
 static bool fxo_packet_is_valid(xpacket_t *pack);
 static void fxo_packet_dump(const char *msg, xpacket_t *pack);
 #ifdef CONFIG_PROC_FS
@@ -511,7 +509,7 @@ static int FXO_card_dahdi_preregistration(xpd_t *xpd, bool on)
 	BUG_ON(!priv);
 	timer_count = xpd->timer_count;
 	XPD_DBG(GENERAL, xpd, "%s\n", (on)?"ON":"OFF");
- 	PHONEDEV(xpd).span.spantype = "FXO";
+	PHONEDEV(xpd).span.spantype = "FXO";
 	for_each_line(xpd, i) {
 		struct dahdi_chan	*cur_chan = XPD_CHAN(xpd, i);
 
@@ -832,19 +830,6 @@ static int FXO_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a
 
 /*---------------- FXO: HOST COMMANDS -------------------------------------*/
 
-static /* 0x0F */ HOSTCMD(FXO, XPD_STATE, bool on)
-{
-	int			ret = 0;
-	struct FXO_priv_data	*priv;
-
-	BUG_ON(!xbus);
-	BUG_ON(!xpd);
-	priv = xpd->priv;
-	BUG_ON(!priv);
-	XPD_DBG(GENERAL, xpd, "%s\n", (on) ? "on" : "off");
-	return ret;
-}
-
 /*---------------- FXO: Astribank Reply Handlers --------------------------*/
 
 HANDLER_DEF(FXO, SIG_CHANGED)
@@ -1113,7 +1098,14 @@ static int FXO_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
 
 static int FXO_card_state(xpd_t *xpd, bool on)
 {
-	return CALL_PROTO(FXO, XPD_STATE, xpd->xbus, xpd, on);
+	int			ret = 0;
+	struct FXO_priv_data	*priv;
+
+	BUG_ON(!xpd);
+	priv = xpd->priv;
+	BUG_ON(!priv);
+	XPD_DBG(GENERAL, xpd, "%s\n", (on) ? "on" : "off");
+	return ret;
 }
 
 static const struct xops	fxo_xops = {
diff --git a/drivers/dahdi/xpp/card_fxs.c b/drivers/dahdi/xpp/card_fxs.c
index ebd0eeb..50814a1 100644
--- a/drivers/dahdi/xpp/card_fxs.c
+++ b/drivers/dahdi/xpp/card_fxs.c
@@ -104,8 +104,6 @@ enum fxs_state {
 
 /*---------------- FXS Protocol Commands ----------------------------------*/
 
-static /* 0x0F */ DECLARE_CMD(FXS, XPD_STATE, bool on);
-
 static bool fxs_packet_is_valid(xpacket_t *pack);
 static void fxs_packet_dump(const char *msg, xpacket_t *pack);
 #ifdef CONFIG_PROC_FS
@@ -1159,14 +1157,6 @@ static int FXS_card_tick(xbus_t *xbus, xpd_t *xpd)
 
 /*---------------- FXS: HOST COMMANDS -------------------------------------*/
 
-static /* 0x0F */ HOSTCMD(FXS, XPD_STATE, bool on)
-{
-	BUG_ON(!xbus);
-	BUG_ON(!xpd);
-	XPD_DBG(GENERAL, xpd, "%s\n", (on)?"on":"off");
-	return 0;
-}
-
 /*---------------- FXS: Astribank Reply Handlers --------------------------*/
 
 /*
@@ -1396,7 +1386,9 @@ static int FXS_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
 
 static int FXS_card_state(xpd_t *xpd, bool on)
 {
-	return CALL_PROTO(FXS, XPD_STATE, xpd->xbus, xpd, on);
+	BUG_ON(!xpd);
+	XPD_DBG(GENERAL, xpd, "%s\n", (on)?"on":"off");
+	return 0;
 }
 
 static const struct xops	fxs_xops = {
diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c
index 3d152c7..9950c64 100644
--- a/drivers/dahdi/xpp/card_pri.c
+++ b/drivers/dahdi/xpp/card_pri.c
@@ -1866,14 +1866,9 @@ int PRI_timing_priority(xpd_t *xpd)
 	return -ENOENT;
 }
 
-/*---------------- PRI: HOST COMMANDS -------------------------------------*/
 
-static /* 0x0F */ HOSTCMD(PRI, XPD_STATE, bool on)
-{
-	BUG_ON(!xpd);
-	XPD_DBG(GENERAL, xpd, "%s\n", (on)?"on":"off");
-	return 0;
-}
+
+/*---------------- PRI: HOST COMMANDS -------------------------------------*/
 
 static /* 0x33 */ HOSTCMD(PRI, SET_LED, enum pri_led_selectors led_sel, enum pri_led_state to_led_state)
 {
@@ -2170,7 +2165,9 @@ end:
 
 static int PRI_card_state(xpd_t *xpd, bool on)
 {
-	return CALL_PROTO(PRI, XPD_STATE, xpd->xbus, xpd, on);
+	BUG_ON(!xpd);
+	XPD_DBG(GENERAL, xpd, "%s\n", (on)?"on":"off");
+	return 0;
 }
 
 static const struct xops	pri_xops = {
@@ -2629,7 +2626,6 @@ static DEVICE_ATTR_READER(pri_clocking_show, dev, buf)
 
 static	DEVICE_ATTR(pri_clocking, S_IRUGO, pri_clocking_show, NULL);
 
-
 static int pri_xpd_probe(struct device *dev)
 {
 	xpd_t	*xpd;

commit 3af1adebba3b9a80237b34f89887cec9338d5eac
Author: Oron Peled <oron at actcom.co.il>
Date:   Sun Jan 30 18:16:35 2011 +0000

    xpp: Remove few extra leading spaces
    
    Signed-off-by: Oron Peled <oron at actcom.co.il>
    Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9713 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/xpp/xpp_dahdi.c b/drivers/dahdi/xpp/xpp_dahdi.c
index 397ab91..cc4edef 100644
--- a/drivers/dahdi/xpp/xpp_dahdi.c
+++ b/drivers/dahdi/xpp/xpp_dahdi.c
@@ -1127,21 +1127,21 @@ int dahdi_register_xpd(xpd_t *xpd)
 		XPD_ERR(xpd, "Already registered\n");
 		return -EEXIST;
 	}
- 	cn = PHONEDEV(xpd).channels;
+	cn = PHONEDEV(xpd).channels;
 	XPD_DBG(DEVICES, xpd, "Initializing span: %d channels.\n", cn);
- 	memset(&PHONEDEV(xpd).span, 0, sizeof(struct dahdi_span));
+	memset(&PHONEDEV(xpd).span, 0, sizeof(struct dahdi_span));
 	for(i = 0; i < cn; i++) {
 		memset(XPD_CHAN(xpd, i), 0, sizeof(struct dahdi_chan));
 	}
 
- 	span = &PHONEDEV(xpd).span;
+	span = &PHONEDEV(xpd).span;
 	snprintf(span->name, MAX_SPANNAME, "%s/%s", xbus->busname, xpd->xpdname);
 	span->deflaw = DAHDI_LAW_MULAW;	/* default, may be overriden by card_* drivers */
 	span->channels = cn;
- 	span->chans = PHONEDEV(xpd).chans;
+	span->chans = PHONEDEV(xpd).chans;
 
 	span->flags = DAHDI_FLAG_RBS;
- 	if(PHONEDEV(xpd).phoneops->card_hooksig)
+	if(PHONEDEV(xpd).phoneops->card_hooksig)
 		span->ops = &xpp_rbs_span_ops;	/* Only with RBS bits */
 	else
 		span->ops = &xpp_span_ops;

commit 840c1664c68f27081240feec8aaed0fe1beafe68
Author: Oron Peled <oron at actcom.co.il>
Date:   Sun Jan 30 18:14:49 2011 +0000

    xpp: Use our KZALLOC/KZFREE
    
    Signed-off-by: Oron Peled <oron at actcom.co.il>
    Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9712 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/xpp/xpp_dahdi.c b/drivers/dahdi/xpp/xpp_dahdi.c
index ba36c80..397ab91 100644
--- a/drivers/dahdi/xpp/xpp_dahdi.c
+++ b/drivers/dahdi/xpp/xpp_dahdi.c
@@ -510,7 +510,7 @@ static void phonedev_cleanup(xpd_t *xpd)
 
 	for (x = 0; x < phonedev->channels; x++) {
 		if (phonedev->chans[x]) {
-			kfree(phonedev->chans[x]);
+			KZFREE(phonedev->chans[x]);
 		}
 	}
 }
@@ -531,7 +531,7 @@ __must_check static int phonedev_init(xpd_t *xpd, const xproto_table_t *proto_ta
 	atomic_set(&phonedev->dahdi_registered, 0);
 	atomic_set(&phonedev->open_counter, 0);
 	for (x = 0; x < phonedev->channels; x++) {
-		if (!(phonedev->chans[x] = kmalloc(sizeof(*(phonedev->chans[x])), GFP_KERNEL))) {
+		if (!(phonedev->chans[x] = KZALLOC(sizeof(*(phonedev->chans[x])), GFP_KERNEL))) {
 			ERR("%s: Unable to allocate channel %d\n", __FUNCTION__, x);
 			goto err;
 		}

commit a1f7cf3f3292c0e6fc4133092e5a5728e10dff96
Author: Oron Peled <oron at actcom.co.il>
Date:   Sun Jan 30 18:13:39 2011 +0000

    xpp: use phonedev_cleanup() instead of inline code
    
    Signed-off-by: Oron Peled <oron at actcom.co.il>
    Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9711 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/xpp/xpp_dahdi.c b/drivers/dahdi/xpp/xpp_dahdi.c
index c587219..ba36c80 100644
--- a/drivers/dahdi/xpp/xpp_dahdi.c
+++ b/drivers/dahdi/xpp/xpp_dahdi.c
@@ -67,6 +67,8 @@ static DEF_PARM_BOOL(prefmaster, 0, 0644, "Do we want to be dahdi preferred sync
 
 #include "dahdi_debug.h"
 
+static void phonedev_cleanup(xpd_t *xpd);
+
 #ifdef	DEBUG_SYNC_PARPORT
 /*
  * Use parallel port to sample our PCM sync and diagnose quality and
@@ -238,7 +240,6 @@ err:
 void xpd_free(xpd_t *xpd)
 {
 	xbus_t		*xbus = NULL;
-	unsigned int	x;
 
 	if(!xpd)
 		return;
@@ -251,10 +252,7 @@ void xpd_free(xpd_t *xpd)
 	XPD_DBG(DEVICES, xpd, "\n");
 	xpd_proc_remove(xbus, xpd);
 	xbus_xpd_unbind(xbus, xpd);
-	for (x = 0; x < PHONEDEV(xpd).channels; x++) {
-		if (PHONEDEV(xpd).chans[x])
-			KZFREE(PHONEDEV(xpd).chans[x]);
-	}
+	phonedev_cleanup(xpd);
 	KZFREE(xpd);
 	DBG(DEVICES, "refcount_xbus=%d\n", refcount_xbus(xbus));
 	/*

commit 7f6f338b8ab432a7ad36fbf6f2b7cf3b95f24bf8
Author: Oron Peled <oron at actcom.co.il>
Date:   Sun Jan 30 18:12:02 2011 +0000

    xpp: Add fixed runtime checks for the PHONEDEV code
    
    Signed-off-by: Oron Peled <oron at actcom.co.il>
    Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9710 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/xpp/xproto.c b/drivers/dahdi/xpp/xproto.c
index afc6be5..570fd85 100644
--- a/drivers/dahdi/xpp/xproto.c
+++ b/drivers/dahdi/xpp/xproto.c
@@ -420,11 +420,18 @@ const char *xproto_name(xpd_type_t xpd_type)
 			return -EINVAL;	\
 		}
 
+#define	CHECK_PHONEOP(phoneops, f)	\
+		if(!(phoneops)->f) { \
+			ERR("%s: missing phone method %s [%s (%d)]\n", __FUNCTION__, #f, name, type);	\
+			return -EINVAL;	\
+		}
+
 int xproto_register(const xproto_table_t *proto_table)
 {
 	int			type;
 	const char		*name;
 	const struct xops	*xops;
+	const struct phoneops	*phoneops;
 	
 	BUG_ON(!proto_table);
 	type = proto_table->type;
@@ -441,17 +448,18 @@ int xproto_register(const xproto_table_t *proto_table)
 	CHECK_XOP(xops, card_init);
 	CHECK_XOP(xops, card_remove);
 	CHECK_XOP(xops, card_tick);
-#if 0
-	/* FIXME: check PHONE_METHOD() */
-	CHECK_XOP(card_pcm_recompute);
-	CHECK_XOP(card_pcm_fromspan);
-	CHECK_XOP(card_pcm_tospan);
-	CHECK_XOP(card_dahdi_preregistration);
-	CHECK_XOP(card_dahdi_postregistration);
-	// CHECK_XOP(card_ioctl);	// optional method -- call after testing
-	CHECK_XOP(card_register_reply);
-	CHECK_XOP(XPD_STATE);
-#endif
+	CHECK_XOP(xops, card_register_reply);
+
+	phoneops = proto_table->phoneops;
+	if (phoneops) {
+		CHECK_PHONEOP(phoneops, card_pcm_recompute);
+		CHECK_PHONEOP(phoneops, card_pcm_fromspan);
+		CHECK_PHONEOP(phoneops, card_pcm_tospan);
+		CHECK_PHONEOP(phoneops, card_dahdi_preregistration);
+		CHECK_PHONEOP(phoneops, card_dahdi_postregistration);
+		/* optional method -- call after testing: */
+		/*CHECK_PHONEOP(phoneops, card_ioctl);*/
+	}
 
 	xprotocol_tables[type] = proto_table;
 	return 0;

commit aaca5292c564c95d527a97e4ff61763d8b3965dc
Author: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Date:   Sun Jan 30 18:10:33 2011 +0000

    xpp: init_card_4_30: add comment
    
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9709 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/xpp/init_card_4_30 b/drivers/dahdi/xpp/init_card_4_30
index 2f0a79d..d70cfdc 100755
--- a/drivers/dahdi/xpp/init_card_4_30
+++ b/drivers/dahdi/xpp/init_card_4_30
@@ -348,6 +348,11 @@ sub port_setup($) {
 	} else {
 		my $file = sprintf "/sys/bus/xpds/devices/%02d:%1d:%1d/pri_protocol",
 				$ENV{XBUS_NUMBER}, $ENV{UNIT_NUMBER}, $portno;
+		# The 'open' will fail if the port does not exist.
+		# (or rather: the XPD for it does not exist). While
+		# we only read this file to get the default E1/T1 value,
+		# if it does not exist, it also implies the commands sent would
+		# get nowhere. So we might as well quit now.
 		open(F, $file) || return;
 		$sysfs_pri_protocol = <F>;
 		close F;

commit 5ff59ba3efd52e01be86d15b3bc84983c6764d20
Author: Oron Peled <oron at actcom.co.il>
Date:   Sun Jan 30 18:06:16 2011 +0000

    xpp: Kbuild: always update version string
    
    * Keep the xpp version number up-to-date
    * Non-verbose build output.
    
    Signed-off-by: Oron Peled <oron at actcom.co.il>
    Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9708 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/xpp/Kbuild b/drivers/dahdi/xpp/Kbuild
index 3b87bf6..2abeaf3 100644
--- a/drivers/dahdi/xpp/Kbuild
+++ b/drivers/dahdi/xpp/Kbuild
@@ -41,6 +41,7 @@ clean-files	+= xpp_version.h
 $(obj)/card_fxs.o $(obj)/card_fxo.o $(obj)/card_bri.o $(obj)/card_pri.o $(obj)/xpp_usb.o $(obj)/xpp.o: $(obj)/xpp_version.h
 
 $(obj)/xpp_version.h: FORCE
+	@echo '  VERSION $@'
 	$(Q)echo '#define	XPP_VERSION	$(XPP_VERSION_STR)' > $@.tmp
 	$(Q)if cmp -s $@.tmp $@ ; then echo; else \
 		mv $@.tmp $@ ; \
@@ -66,7 +67,7 @@ FXO_MODES  = $(src)/../fxo_modes.h
 FXO_VERIFY = $(obj)/init_card_2_$(XPP_PROTOCOL_VERSION) -v $(obj)/init_fxo_modes
 
 hostprogs-y			:= print_fxo_modes
-always				:= $(xpp_verified)
+always				:= $(xpp_verified) xpp_version.h
 print_fxo_modes-objs		:= print_fxo_modes.o
 HOSTCFLAGS_print_fxo_modes.o	+= -include $(FXO_MODES)
 
@@ -79,7 +80,7 @@ $(obj)/init_fxo_modes: $(obj)/print_fxo_modes
 $(obj)/init_fxo_modes.verified: $(obj)/init_card_2_$(XPP_PROTOCOL_VERSION) $(obj)/init_fxo_modes
 	@echo '  CHECK   $(obj)/init_card_2_$(XPP_PROTOCOL_VERSION)'
 	$(Q)$(FXO_VERIFY) || (rm -f $@; exit 1)
-	touch $@
+	$(Q)touch $@
 
 $(obj)/init_card_%_$(XPP_PROTOCOL_VERSION).verified: $(src)/init_card_%_$(XPP_PROTOCOL_VERSION)
 	@echo '  VERIFY  $<'

commit a752d38ad145a55079f5451b6aca199f2da94b15
Author: Oron Peled <oron at actcom.co.il>
Date:   Sun Jan 30 14:14:14 2011 +0000

    xpp: phonedev: Cleanup method macros
    
    * Caller to CALL_XMETHOD() no longer need to explicitly pass xbus
      (calculate xpd->xbus)
    * Create CALL_PHONE_METHOD() similar to CALL_XMETHOD() -- inlining
      the extra parameters (more readable)
    * Reverse parameter order in PHONE_METHOD() and CALL_PHONE_METHOD()
      to be consistent with XMETHOD() and CALL_XMETHOD()
    * Rename XPD_STATE phonedev method to card_state:
      - Consistency with other phonedev methods.
      - These calls now Wrap internal calls to XPD_STATE protocol HOSTCMD
        in PRI, BRI, FXS, FXO
    
    Signed-off-by: Oron Peled <oron at actcom.co.il>
    Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    
    git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9706 a0bf4364-ded3-4de4-8d8a-66a801d63aff

diff --git a/drivers/dahdi/xpp/card_bri.c b/drivers/dahdi/xpp/card_bri.c
index 556d175..13bb054 100644
--- a/drivers/dahdi/xpp/card_bri.c
+++ b/drivers/dahdi/xpp/card_bri.c
@@ -932,7 +932,7 @@ static int BRI_card_dahdi_preregistration(xpd_t *xpd, bool on)
 			cur_chan->sigcap = BRI_BCHAN_SIGCAP;
 		}
 	}
-	PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	PHONEDEV(xpd).span.ops = &BRI_span_ops;
 	return 0;
 }
@@ -950,7 +950,7 @@ static int BRI_card_dahdi_postregistration(xpd_t *xpd, bool on)
 	return(0);
 }
 
-static int BRI_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig txsig)
+static int BRI_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
 {
 	LINE_DBG(SIGNAL, xpd, pos, "%s\n", txsig2str(txsig));
 	return 0;
@@ -1154,7 +1154,7 @@ static int BRI_card_open(xpd_t *xpd, lineno_t pos)
 		BIT_SET(PHONEDEV(xpd).offhook_state, 0);
 		BIT_SET(PHONEDEV(xpd).offhook_state, 1);
 		BIT_SET(PHONEDEV(xpd).offhook_state, 2);
-		PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);
+		CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	}
 	return 0;
 }
@@ -1176,7 +1176,7 @@ static int BRI_card_close(xpd_t *xpd, lineno_t pos)
 		BIT_CLR(PHONEDEV(xpd).offhook_state, 0);
 		BIT_CLR(PHONEDEV(xpd).offhook_state, 1);
 		BIT_CLR(PHONEDEV(xpd).offhook_state, 2);
-		PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);
+		CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	}
 	return 0;
 }
@@ -1257,7 +1257,7 @@ static int bri_startup(struct dahdi_span *span)
 	}
 	XPD_DBG(GENERAL, xpd, "STARTUP\n");
 	// Turn on all channels
-	PHONE_METHOD(xpd, XPD_STATE)(xpd->xbus, xpd, 1);
+	CALL_PHONE_METHOD(card_state, xpd, 1);
 	if(SPAN_REGISTERED(xpd)) {
 		dchan = XPD_CHAN(xpd, 2);
 		span->flags |= DAHDI_FLAG_RUNNING;
@@ -1293,11 +1293,11 @@ static int bri_shutdown(struct dahdi_span *span)
 	}
 	XPD_DBG(GENERAL, xpd, "SHUTDOWN\n");
 	// Turn off all channels
-	PHONE_METHOD(xpd, XPD_STATE)(xpd->xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_state, xpd, 0);
 	return 0;
 }
 
-static void BRI_card_pcm_recompute(xbus_t *xbus, xpd_t *xpd,
+static void BRI_card_pcm_recompute(xpd_t *xpd,
 		xpp_line_t dont_care)
 {
 	int		i;
@@ -1308,7 +1308,7 @@ static void BRI_card_pcm_recompute(xbus_t *xbus, xpd_t *xpd,
 	unsigned long	flags;
 
 	BUG_ON(!xpd);
-	main_xpd = xpd_byaddr(xbus, xpd->addr.unit, 0);
+	main_xpd = xpd_byaddr(xpd->xbus, xpd->addr.unit, 0);
 	if(!main_xpd) {
 		XPD_DBG(DEVICES, xpd, "Unit 0 is already gone. Ignore request\n");
 		return;
@@ -1321,7 +1321,7 @@ static void BRI_card_pcm_recompute(xbus_t *xbus, xpd_t *xpd,
 	line_count = 0;
 	pcm_mask = 0;
 	for(i = 0; i < MAX_SUBUNIT; i++) {
-		xpd_t		*sub_xpd = xpd_byaddr(xbus, main_xpd->addr.unit, i);
+		xpd_t		*sub_xpd = xpd_byaddr(xpd->xbus, main_xpd->addr.unit, i);
 
 		if(sub_xpd) {
 			xpp_line_t	lines =
@@ -1355,7 +1355,7 @@ static void BRI_card_pcm_recompute(xbus_t *xbus, xpd_t *xpd,
 	spin_unlock_irqrestore(&PHONEDEV(main_xpd).lock_recompute_pcm, flags);
 }
 
-static void BRI_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
+static void BRI_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack)
 {
 	byte		*pcm;
 	unsigned long	flags;
@@ -1365,14 +1365,13 @@ static void BRI_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
 	xpp_line_t	wanted_lines;
 
 
-	BUG_ON(!xbus);
 	BUG_ON(!xpd);
 	BUG_ON(!pack);
 	pcm = RPACKET_FIELD(pack, GLOBAL, PCM_WRITE, pcm);
 	for(subunit = 0; subunit < MAX_SUBUNIT; subunit++) {
 		xpd_t		*tmp_xpd;
 
-		tmp_xpd = xpd_byaddr(xbus, xpd->addr.unit, subunit);
+		tmp_xpd = xpd_byaddr(xpd->xbus, xpd->addr.unit, subunit);
 		if(!tmp_xpd || !tmp_xpd->card_present)
 			continue;
 		spin_lock_irqsave(&tmp_xpd->lock, flags);
@@ -1402,7 +1401,7 @@ static void BRI_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
 	RPACKET_FIELD(pack, GLOBAL, PCM_WRITE, lines) = pcm_mask;
 }
 
-static void BRI_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
+static void BRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
 {
 	byte		*pcm;
 	xpp_line_t	pcm_mask;
@@ -1424,7 +1423,7 @@ static void BRI_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
 
 		if(!pcm_mask)
 			break;	/* optimize */
-		tmp_xpd = xpd_byaddr(xbus, xpd->addr.unit, subunit);
+		tmp_xpd = xpd_byaddr(xpd->xbus, xpd->addr.unit, subunit);
 		if(!tmp_xpd || !tmp_xpd->card_present || !SPAN_REGISTERED(tmp_xpd))
 			continue;
 		spin_lock_irqsave(&tmp_xpd->lock, flags);
@@ -1670,6 +1669,11 @@ end:
 	return 0;
 }
 
+static int BRI_card_state(xpd_t *xpd, bool on)
+{
+	return CALL_PROTO(BRI, XPD_STATE, xpd->xbus, xpd, on);
+}
+
 static const struct xops	bri_xops = {
 	.card_new	= BRI_card_new,
 	.card_init	= BRI_card_init,
@@ -1689,8 +1693,7 @@ static const struct phoneops	bri_phoneops = {
 	.card_ioctl	= BRI_card_ioctl,
 	.card_open	= BRI_card_open,
 	.card_close	= BRI_card_close,
-
-	.XPD_STATE	= XPROTO_CALLER(BRI, XPD_STATE),
+	.card_state	= BRI_card_state,
 };
 
 static xproto_table_t PROTO_TABLE(BRI) = {
diff --git a/drivers/dahdi/xpp/card_fxo.c b/drivers/dahdi/xpp/card_fxo.c
index 5ee41c5..00c9320 100644
--- a/drivers/dahdi/xpp/card_fxo.c
+++ b/drivers/dahdi/xpp/card_fxo.c
@@ -482,7 +482,7 @@ static int FXO_card_init(xbus_t *xbus, xpd_t *xpd)
 		do_led(xpd, i, LED_GREEN, 0);
 		msleep(50);
 	}
-	PHONE_METHOD(xpd, card_pcm_recompute)(xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	return 0;
 }
 
@@ -555,7 +555,7 @@ static int FXO_card_dahdi_postregistration(xpd_t *xpd, bool on)
 	return 0;
 }
 
-static int FXO_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig txsig)
+static int FXO_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
 {
 	struct FXO_priv_data	*priv;
 	int			ret = 0;
@@ -1111,6 +1111,11 @@ static int FXO_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
 	return 0;
 }
 
+static int FXO_card_state(xpd_t *xpd, bool on)
+{
+	return CALL_PROTO(FXO, XPD_STATE, xpd->xbus, xpd, on);
+}
+
 static const struct xops	fxo_xops = {
 	.card_new	= FXO_card_new,
 	.card_init	= FXO_card_init,
@@ -1129,8 +1134,7 @@ static const struct phoneops	fxo_phoneops = {
 	.card_timing_priority	= generic_timing_priority,
 	.card_ioctl	= FXO_card_ioctl,
 	.card_open	= FXO_card_open,
-
-	.XPD_STATE	= XPROTO_CALLER(FXO, XPD_STATE),
+	.card_state	= FXO_card_state,
 };
 
 static xproto_table_t PROTO_TABLE(FXO) = {
diff --git a/drivers/dahdi/xpp/card_fxs.c b/drivers/dahdi/xpp/card_fxs.c
index e3606b5..ebd0eeb 100644
--- a/drivers/dahdi/xpp/card_fxs.c
+++ b/drivers/dahdi/xpp/card_fxs.c
@@ -455,7 +455,7 @@ static int FXS_card_init(xbus_t *xbus, xpd_t *xpd)
 		msleep(50);
 	}
 	restore_leds(xpd);
-	PHONE_METHOD(xpd, card_pcm_recompute)(xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	/*
 	 * We should query our offhook state long enough time after we
 	 * set the linefeed_control()
@@ -559,7 +559,7 @@ static void __do_mute_dtmf(xpd_t *xpd, int pos, bool muteit)
 		BIT_SET(PHONEDEV(xpd).mute_dtmf, pos);
 	else
 		BIT_CLR(PHONEDEV(xpd).mute_dtmf, pos);
-	PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);	/* already spinlocked */
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);	/* already spinlocked */
 }
 
 static int set_vm_led_mode(xbus_t *xbus, xpd_t *xpd, int pos,
@@ -661,7 +661,7 @@ static int send_ring(xpd_t *xpd, lineno_t chan, bool on)
 	return ret;
 }
 
-static int FXS_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig txsig)
+static int FXS_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
 {
 	struct FXS_priv_data	*priv;
 	int			ret = 0;
@@ -698,13 +698,13 @@ static int FXS_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig
 				 * Restore state after KEWL hangup.
 				 */
 				LINE_DBG(SIGNAL, xpd, pos, "KEWL STOP\n");
-				linefeed_control(xbus, xpd, pos, FXS_LINE_POL_ACTIVE);
+				linefeed_control(xpd->xbus, xpd, pos, FXS_LINE_POL_ACTIVE);
 				if(IS_OFFHOOK(xpd, pos))
 					MARK_ON(priv, pos, LED_GREEN);
 			}
 			ret = send_ring(xpd, pos, 0);			// RING off
 			if (!IS_OFFHOOK(xpd, pos))
-				start_stop_vm_led(xbus, xpd, pos);
+				start_stop_vm_led(xpd->xbus, xpd, pos);
 			txhook = priv->lasttxhook[pos];
 			if(chan) {
 				switch(chan->sig) {
@@ -718,7 +718,7 @@ static int FXS_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig
 						break;
 				}
 			}
-			ret = linefeed_control(xbus, xpd, pos, txhook);
+			ret = linefeed_control(xpd->xbus, xpd, pos, txhook);
 			break;
 		case DAHDI_TXSIG_OFFHOOK:
 			if(IS_SET(PHONEDEV(xpd).digital_outputs, pos)) {
@@ -741,7 +741,7 @@ static int FXS_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig
 						break;
 				}
 			}
-			ret = linefeed_control(xbus, xpd, pos, txhook);
+			ret = linefeed_control(xpd->xbus, xpd, pos, txhook);
 			break;
 		case DAHDI_TXSIG_START:
 			PHONEDEV(xpd).ringing[pos] = 1;
@@ -759,7 +759,7 @@ static int FXS_card_hooksig(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig
 				LINE_DBG(SIGNAL, xpd, pos, "%s -> Is digital output. Ignored\n", txsig2str(txsig));
 				return -EINVAL;
 			}
-			linefeed_control(xbus, xpd, pos, FXS_LINE_OPEN);
+			linefeed_control(xpd->xbus, xpd, pos, FXS_LINE_OPEN);
 			MARK_OFF(priv, pos, LED_GREEN);
 			break;
 		default:
@@ -847,7 +847,7 @@ static int FXS_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a
 				priv->ohttimer[pos] = val;
 				priv->idletxhookstate[pos] = FXS_LINE_POL_OHTRANS;
 				vmwi_search(xpd, pos, 1);
-				PHONE_METHOD(xpd, card_pcm_recompute)(xbus, xpd, priv->search_fsk_pattern);
+				CALL_PHONE_METHOD(card_pcm_recompute, xpd, priv->search_fsk_pattern);
 				LINE_DBG(SIGNAL, xpd, pos, "Start OHT_TIMER. wanted_pcm_mask=0x%X\n", PHONEDEV(xpd).wanted_pcm_mask);
 			}
 			if (VMWI_NEON(priv, pos) && !IS_OFFHOOK(xpd, pos))
@@ -1394,6 +1394,11 @@ static int FXS_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info)
 	return 0;
 }
 
+static int FXS_card_state(xpd_t *xpd, bool on)
+{
+	return CALL_PROTO(FXS, XPD_STATE, xpd->xbus, xpd, on);
+}
+
 static const struct xops	fxs_xops = {
 	.card_new	= FXS_card_new,
 	.card_init	= FXS_card_init,
@@ -1413,8 +1418,7 @@ static const struct phoneops	fxs_phoneops = {
 	.card_open	= FXS_card_open,
 	.card_close	= FXS_card_close,
 	.card_ioctl	= FXS_card_ioctl,
-
-	.XPD_STATE	= XPROTO_CALLER(FXS, XPD_STATE),
+	.card_state	= FXS_card_state,
 };
 
 static xproto_table_t PROTO_TABLE(FXS) = {
diff --git a/drivers/dahdi/xpp/card_global.c b/drivers/dahdi/xpp/card_global.c
index ecb79fd..ba66b9e 100644
--- a/drivers/dahdi/xpp/card_global.c
+++ b/drivers/dahdi/xpp/card_global.c
@@ -685,7 +685,11 @@ HANDLER_DEF(GLOBAL, REGISTER_REPLY)
 		dump_reg_cmd("REG_REPLY", 0, xbus, xpd->addr.unit, reg->portnum, reg);
 		dump_packet("REG_REPLY", pack, 1);
 	}
-	return CALL_XMETHOD(card_register_reply, xbus, xpd, reg);
+	if (! XMETHOD(card_register_reply, xpd)) {
+		XPD_ERR(xpd, "REGISTER_REPLY: without card_register_reply() method\n");
+		return -EINVAL;
+	}
+	return CALL_XMETHOD(card_register_reply, xpd, reg);
 }
 
 HANDLER_DEF(GLOBAL, SYNC_REPLY)
diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c
index 7e91d2d..3d152c7 100644
--- a/drivers/dahdi/xpp/card_pri.c
+++ b/drivers/dahdi/xpp/card_pri.c
@@ -552,7 +552,7 @@ static bool valid_pri_modes(const xpd_t *xpd)
 	return 1;
 }
 
-static void PRI_card_pcm_recompute(xbus_t *xbus, xpd_t *xpd,
+static void PRI_card_pcm_recompute(xpd_t *xpd,
 		xpp_line_t pcm_mask)
 {
 	struct PRI_priv_data	*priv;
@@ -652,7 +652,7 @@ static int set_pri_proto(xpd_t *xpd, enum pri_protocol set_proto)
 	priv->is_cas = -1;
 	PHONEDEV(xpd).channels = pri_num_channels(set_proto);
 	PHONEDEV(xpd).offhook_state = BITMASK(PHONEDEV(xpd).channels);
-	PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	priv->deflaw = deflaw;
 	priv->dchan_num = dchan_num;
 	priv->local_loopback = 0;
@@ -1037,7 +1037,7 @@ static int pri_lineconfig(xpd_t *xpd, int lineconfig)
 		force_cas = 1;
 		set_mode_cas(xpd, 1);
 	}
-	PHONE_METHOD(xpd, card_pcm_recompute)(xpd->xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_pcm_recompute, xpd, 0);
 	/*
 	 * E1's can enable CRC checking
 	 * CRC4 is legal only for E1, and it is checked by pri_linecompat()
@@ -1545,7 +1545,7 @@ static int pri_startup(struct dahdi_span *span)
 	}
 	XPD_DBG(GENERAL, xpd, "STARTUP\n");
 	// Turn on all channels
-	PHONE_METHOD(xpd, XPD_STATE)(xpd->xbus, xpd, 1);
+	CALL_PHONE_METHOD(card_state, xpd, 1);
 	set_rbslines(xpd, 0);
 	write_subunit(xpd, REG_XPM2, 0x00);
 	return 0;
@@ -1569,7 +1569,7 @@ static int pri_shutdown(struct dahdi_span *span)
 	}
 	XPD_DBG(GENERAL, xpd, "SHUTDOWN\n");
 	// Turn off all channels
-	PHONE_METHOD(xpd, XPD_STATE)(xpd->xbus, xpd, 0);
+	CALL_PHONE_METHOD(card_state, xpd, 0);
 	return 0;
 }
 
@@ -1728,7 +1728,7 @@ static int pri_rbsbits(struct dahdi_chan *chan, int bits)
  * send 31 channels to the device, but they should be called 1-31 rather
  * than 0-30 .
  */
-static void PRI_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
+static void PRI_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack)
 {
 	struct PRI_priv_data	*priv;
 	byte			*pcm;
@@ -1738,7 +1738,6 @@ static void PRI_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
 	int			physical_chan;
 	int			physical_mask = 0;
 
-	BUG_ON(!xbus);
 	BUG_ON(!xpd);
 	BUG_ON(!pack);
 	priv = xpd->priv;
@@ -1802,7 +1801,7 @@ static void PRI_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
  *
  * \see PRI_card_pcm_fromspan
  */
-static void PRI_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
+static void PRI_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
 {
 	struct PRI_priv_data	*priv;
 	byte			*pcm;
@@ -1855,7 +1854,7 @@ static void PRI_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
 	spin_unlock_irqrestore(&xpd->lock, flags);
 }
 
-int PRI_timing_priority(xbus_t *xbus, xpd_t *xpd)
+int PRI_timing_priority(xpd_t *xpd)
 {
 	struct PRI_priv_data	*priv;
 
@@ -2169,6 +2168,11 @@ end:
 	return 0;
 }
 
+static int PRI_card_state(xpd_t *xpd, bool on)
+{
+	return CALL_PROTO(PRI, XPD_STATE, xpd->xbus, xpd, on);
+}
+
 static const struct xops	pri_xops = {
 	.card_new	= PRI_card_new,
 	.card_init	= PRI_card_init,
@@ -2186,8 +2190,7 @@ static const struct phoneops	pri_phoneops = {
 	.card_timing_priority	= PRI_timing_priority,
 	.card_ioctl	= PRI_card_ioctl,
 	.card_close	= PRI_card_close,
-
-	.XPD_STATE	= XPROTO_CALLER(PRI, XPD_STATE),
+	.card_state	= PRI_card_state,
 };
 
 static xproto_table_t PROTO_TABLE(PRI) = {
diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c
index 55c00f6..9feaeaa 100644
--- a/drivers/dahdi/xpp/xbus-core.c
+++ b/drivers/dahdi/xpp/xbus-core.c
@@ -900,14 +900,13 @@ static int xpd_initialize(xpd_t *xpd)
 {
 	int	ret = -ENODEV;
 
-	if(CALL_XMETHOD(card_init, xpd->xbus, xpd) < 0) {
+	if(CALL_XMETHOD(card_init, xpd) < 0) {
 		XPD_ERR(xpd, "Card Initialization failed\n");
 		goto out;
 	}
-	//CALL_XMETHOD(XPD_STATE, xpd->xbus, xpd, 0);	/* Turn off all channels */
 	xpd->card_present = 1;
 	if (IS_PHONEDEV(xpd)) {
-		PHONE_METHOD(xpd, XPD_STATE)(xpd->xbus, xpd, 1);	/* Turn on all channels */
+		CALL_PHONE_METHOD(card_state, xpd, 1);	/* Turn on all channels */
 	}
 	if(!xpd_setstate(xpd, XPD_STATE_READY)) {
 		goto out;
diff --git a/drivers/dahdi/xpp/xbus-pcm.c b/drivers/dahdi/xpp/xbus-pcm.c
index 843a411..65cf9c0 100644
--- a/drivers/dahdi/xpp/xbus-pcm.c
+++ b/drivers/dahdi/xpp/xbus-pcm.c
@@ -630,7 +630,7 @@ void elect_syncer(const char *msg)
 
 				if(!xpd || !xpd->card_present || !IS_PHONEDEV(xpd))
 					continue;
-				prio = PHONE_METHOD(xpd, card_timing_priority)(xbus, xpd);
+				prio = CALL_PHONE_METHOD(card_timing_priority, xpd);
 				if (prio < 0) {
 					DBG(SYNC, "%s/%s: skip sync\n",
 						xbus->busname, xpd->xpdname);
@@ -679,7 +679,7 @@ void update_wanted_pcm_mask(xpd_t *xpd, xpp_line_t new_mask, uint new_pcm_len)
  * channels which should be *added* to the automatic calculation.
  * Normally, this argument is 0.
  */
-void generic_card_pcm_recompute(xbus_t *xbus, xpd_t *xpd, xpp_line_t pcm_mask)
+void generic_card_pcm_recompute(xpd_t *xpd, xpp_line_t pcm_mask)
 {
 	int		i;
 	int		line_count = 0;
@@ -854,14 +854,13 @@ dropit:
  * Generic implementations of card_pcmfromspan()/card_pcmtospan()
  * For FXS/FXO
  */
-void generic_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
+void generic_card_pcm_fromspan(xpd_t *xpd, xpacket_t *pack)
 {
 	byte		*pcm;
 	unsigned long	flags;
 	xpp_line_t	wanted_lines;
 	int		i;
 
-	BUG_ON(!xbus);
 	BUG_ON(!xpd);
 	BUG_ON(!pack);
 	wanted_lines = PHONEDEV(xpd).wanted_pcm_mask;
@@ -890,7 +889,7 @@ void generic_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
 	spin_unlock_irqrestore(&xpd->lock, flags);
 }
 
-void generic_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack)
+void generic_card_pcm_tospan(xpd_t *xpd, xpacket_t *pack)
 {
 	byte		*pcm;
 	xpp_line_t	pcm_mask;
@@ -993,7 +992,7 @@ static int copy_pcm_tospan(xbus_t *xbus, xframe_t *xframe)
 			goto out;
 		if(SPAN_REGISTERED(xpd)) {
 			XBUS_COUNTER(xbus, RX_PACK_PCM)++;
-			PHONE_METHOD(xpd, card_pcm_tospan)(xbus, xpd, pack);
+			CALL_PHONE_METHOD(card_pcm_tospan, xpd, pack);
 		}
 	} while(p < xframe_end);
 	ret = 0;	/* all good */
@@ -1003,7 +1002,7 @@ out:
 	return ret;
 }
 
-int generic_timing_priority(xbus_t *xbus, xpd_t *xpd)
+int generic_timing_priority(xpd_t *xpd)
 {
 	return PHONEDEV(xpd).timing_priority;
 }
@@ -1080,7 +1079,7 @@ static void xbus_tick(xbus_t *xbus)
 					XPACKET_ADDR_SYNC(pack) = 1;
 					sent_sync_bit = 1;
 				}
-				PHONE_METHOD(xpd, card_pcm_fromspan)(xbus, xpd, pack);
+				CALL_PHONE_METHOD(card_pcm_fromspan, xpd, pack);
 				XBUS_COUNTER(xbus, TX_PACK_PCM)++;
 			}
 		}
@@ -1131,7 +1130,7 @@ static void xbus_tick(xbus_t *xbus)
 		 * Must be called *after* tx/rx so
 		 * D-Chan counters may be cleared
 		 */
-		CALL_XMETHOD(card_tick, xbus, xpd);
+		CALL_XMETHOD(card_tick, xpd);
 	}
 }
 
diff --git a/drivers/dahdi/xpp/xbus-pcm.h b/drivers/dahdi/xpp/xbus-pcm.h
index de2a829..f050541 100644
--- a/drivers/dahdi/xpp/xbus-pcm.h
... 475801 lines suppressed ...


-- 
team/sruffell/dahdi-linux.git



More information about the asterisk-scf-commits mailing list