From 9a7db0943b5402a92069ac8857fd1a3b1a0d6979 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Thu, 9 May 2013 15:10:11 -0500 Subject: [PATCH] wcte12xp: Look for multiple loopup codes before setting looping up the framer. This brings the wcte12xp driver in line with the wct4xxp driver. It also eliminates the chance that the local side will errouneously go into loopup when switched from E1 to T1 mode via the spantype sysfs attribute. Internal-Issue-ID: DAHDI-1038 Signed-off-by: Shaun Ruffell Signed-off-by: Russ Meyerriecks --- drivers/dahdi/wcte12xp/base.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index 18f1129..22bd450 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -2206,27 +2206,32 @@ static void t1_check_alarms(struct t1 *wc) /* Detect loopup code if we're not sending one */ if ((!wc->span.mainttimer) && (d & 0x08)) { /* Loop-up code detected */ - if ((wc->span.maintstat != DAHDI_MAINT_REMOTELOOP)) { + if ((++wc->loopupcnt > 80) && + (wc->span.maintstat != DAHDI_MAINT_REMOTELOOP)) { t1_notice(wc, "Loopup detected,"\ " enabling remote loop\n"); t1_setreg(wc, 0x36, 0x08); /* LIM0: Disable any local loop */ t1_setreg(wc, 0x37, 0xf6); /* LIM1: Enable remote loop */ wc->span.maintstat = DAHDI_MAINT_REMOTELOOP; } - } else + } else { wc->loopupcnt = 0; + } + /* Same for loopdown code */ if ((!wc->span.mainttimer) && (d & 0x10)) { /* Loop-down code detected */ - if ((wc->span.maintstat == DAHDI_MAINT_REMOTELOOP)) { + if ((++wc->loopdowncnt > 80) && + (wc->span.maintstat == DAHDI_MAINT_REMOTELOOP)) { t1_notice(wc, "Loopdown detected,"\ " disabling remote loop\n"); t1_setreg(wc, 0x36, 0x08); /* LIM0: Disable any local loop */ t1_setreg(wc, 0x37, 0xf0); /* LIM1: Disable remote loop */ wc->span.maintstat = DAHDI_MAINT_NONE; } - } else + } else { wc->loopdowncnt = 0; + } } if (wc->span.lineconfig & DAHDI_CONFIG_NOTOPEN) {