[zaptel-commits] tzafrir: trunk r1390 - in /trunk/xpp: card_fxs.c xpp_zap.c

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Mon Sep 4 15:51:20 MST 2006


Author: tzafrir
Date: Mon Sep  4 17:51:19 2006
New Revision: 1390

URL: http://svn.digium.com/view/zaptel?rev=1390&view=rev
Log:
Move all zt_hooksig(...{OFF,ON}HOOK) calls into update_line_status() 
in xpp_zap.c

Modified:
    trunk/xpp/card_fxs.c
    trunk/xpp/xpp_zap.c

Modified: trunk/xpp/card_fxs.c
URL: http://svn.digium.com/view/zaptel/trunk/xpp/card_fxs.c?rev=1390&r1=1389&r2=1390&view=diff
==============================================================================
--- trunk/xpp/card_fxs.c (original)
+++ trunk/xpp/card_fxs.c Mon Sep  4 17:51:19 2006
@@ -768,21 +768,17 @@
 		if(IS_SET(xpd->digital_outputs, i) || IS_SET(xpd->digital_inputs, i))
 			continue;
 		if(IS_SET(sig_toggles, i)) {
-			struct zt_chan *chan = &xpd->span.chans[i];
-
 			xpd->ringing[i] = 0;		// No more ringing...
 			do_chan_power(xpd->xbus, xpd, BIT(i), 0);	// When not ringing, VBAT is always Low
 			MARK_BLINK(priv,i,LED_GREEN,0);
 			if(IS_SET(sig_status, i)) {
-				DBG("%s/%s/%d: OFFHOOK\n", xbus->busname, xpd->xpdname, chan->channo);
+				DBG("%s/%s/%d: OFFHOOK\n", xbus->busname, xpd->xpdname, i);
 				MARK_LED(priv,i,LED_GREEN,LED_ON);
-				BIT_SET(xpd->hookstate, i);
-				zt_hooksig(chan, ZT_RXSIG_OFFHOOK);
+				update_line_status(xpd, i, 1);
 			} else {
-				DBG("%s/%s/%d: ONHOOK\n", xbus->busname, xpd->xpdname, chan->channo);
+				DBG("%s/%s/%d: ONHOOK\n", xbus->busname, xpd->xpdname, i);
 				MARK_LED(priv,i,LED_GREEN,LED_OFF);
-				BIT_CLR(xpd->hookstate, i);
-				zt_hooksig(chan, ZT_RXSIG_ONHOOK);
+				update_line_status(xpd, i, 0);
 			}
 		}
 	}
@@ -819,22 +815,18 @@
 		for(i = 0; i < ARRAY_SIZE(input_channels); i++) {
 			int		channo = input_channels[i];
 			int		newchanno;
-			struct zt_chan	*chan;
 
 			if(IS_SET(lines, channo)) {
 				newchanno = LINES_REGULAR + LINES_DIGI_OUT + i;
 				BIT_CLR(lines, channo);
 				BIT_SET(lines, newchanno);
-				chan = &xpd->span.chans[newchanno];
 				xpd->ringing[newchanno] = 0;			// Stop ringing. No leds for digital inputs.
 				if(offhook && !IS_SET(xpd->hookstate, newchanno)) {		// OFFHOOK
-					DBG("OFFHOOK: channo=%d\n", chan->channo);
-					BIT_SET(xpd->hookstate, newchanno);
-					zt_hooksig(chan, ZT_RXSIG_OFFHOOK);
+					DBG("%s/%s/%d: OFFHOOK\n", xbus->busname, xpd->xpdname, newchanno);
+					update_line_status(xpd, newchanno, 1);
 				} else if(!offhook && IS_SET(xpd->hookstate, newchanno)) {	// ONHOOK
-					DBG("ONHOOK channo=%d\n", chan->channo);
-					BIT_CLR(xpd->hookstate, newchanno);
-					zt_hooksig(chan, ZT_RXSIG_ONHOOK);
+					DBG("%s/%s/%d: ONHOOK\n", xbus->busname, xpd->xpdname, newchanno);
+					update_line_status(xpd, newchanno, 0);
 				}
 			}
 		}

Modified: trunk/xpp/xpp_zap.c
URL: http://svn.digium.com/view/zaptel/trunk/xpp/xpp_zap.c?rev=1390&r1=1389&r2=1390&view=diff
==============================================================================
--- trunk/xpp/xpp_zap.c (original)
+++ trunk/xpp/xpp_zap.c Mon Sep  4 17:51:19 2006
@@ -619,7 +619,7 @@
 	DBG("Update XPD alarms: %s -> %02X\n", xpd->span.name, alarm_flag);
 }
 
-void update_line_status(xpd_t *xpd, int pos, bool good)
+void update_line_status(xpd_t *xpd, int pos, bool to_offhook)
 {
 	struct zt_chan	*chan;
 
@@ -627,13 +627,19 @@
 	if(!SPAN_REGISTERED(xpd))
 		return;
 	chan = &xpd->chans[pos];
-	if(good)
+	/*
+	 * We should not spinlock before calling zt_hooksig() as
+	 * it may call back into our xpp_hooksig() and cause
+	 * a nested spinlock scenario
+	 */
+	if(to_offhook) {
+		BIT_SET(xpd->hookstate, pos);
 		zt_hooksig(chan, ZT_RXSIG_OFFHOOK);
-	else
+	} else {
+		BIT_CLR(xpd->hookstate, pos);
 		zt_hooksig(chan, ZT_RXSIG_ONHOOK);
-}
-
-#define	RING_TIME	15	/* in ticks */
+	}
+}
 
 void update_zap_ring(xpd_t *xpd, int pos, bool on)
 {
@@ -643,6 +649,11 @@
 	if(!SPAN_REGISTERED(xpd))
 		return;
 	chan = &xpd->chans[pos];
+	/*
+	 * We should not spinlock before calling zt_hooksig() as
+	 * it may call back into our xpp_hooksig() and cause
+	 * a nested spinlock scenario
+	 */
 	if(on)
 		zt_hooksig(chan, ZT_RXSIG_RING);
 	else



More information about the zaptel-commits mailing list