[svn-commits] sruffell: linux/trunk r9967 - /linux/trunk/drivers/dahdi/wctdm24xxp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 2 15:03:47 CDT 2011


Author: sruffell
Date: Thu Jun  2 15:03:43 2011
New Revision: 9967

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9967
Log:
wctdm24xxp: reglock can be used to protect the txhookstate.

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

Modified:
    linux/trunk/drivers/dahdi/wctdm24xxp/base.c
    linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h

Modified: linux/trunk/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=9967&r1=9966&r2=9967
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/base.c Thu Jun  2 15:03:43 2011
@@ -1339,17 +1339,16 @@
 wctdm_proslic_check_oppending(struct wctdm *wc, struct wctdm_module *const mod)
 {
 	struct fxs *const fxs = &mod->mod.fxs;
-	unsigned long flags;
 	int res;
 
 	if (!(fxs->lasttxhook & SLIC_LF_OPPENDING))
 		return;
 
 	/* Monitor the Pending LF state change, for the next 100ms */
-	spin_lock_irqsave(&fxs->lasttxhooklock, flags);
+	spin_lock(&wc->reglock);
 
 	if (!(fxs->lasttxhook & SLIC_LF_OPPENDING)) {
-		spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
+		spin_unlock(&wc->reglock);
 		return;
 	}
 
@@ -1374,7 +1373,7 @@
 	} else { /* Start 100ms Timeout */
 		fxs->oppending_ms = 100;
 	}
-	spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
+	spin_unlock(&wc->reglock);
 }
 
 /* 256ms interrupt */
@@ -1383,7 +1382,6 @@
 {
 	struct fxs *const fxs = &mod->mod.fxs;
 	int res;
-	unsigned long flags;
 #ifdef PAQ_DEBUG
 	res = mod->isrshadow[1];
 	res &= ~0x3;
@@ -1401,7 +1399,7 @@
 		}
 	}
 #else
-	spin_lock_irqsave(&fxs->lasttxhooklock, flags);
+	spin_lock(&wc->reglock);
 	res = mod->isrshadow[1];
 
 #if 0
@@ -1429,7 +1427,6 @@
 	res = !res &&    /* reg 64 has to be zero at last isr read */
 		!(fxs->lasttxhook & SLIC_LF_OPPENDING) && /* not a transition */
 		fxs->lasttxhook; /* not an intended zero */
-	spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
 	
 	if (res) {
 		fxs->palarms++;
@@ -1437,7 +1434,6 @@
 			dev_notice(&wc->vb.pdev->dev,
 				   "Power alarm on module %d, resetting!\n",
 				   mod->card + 1);
-			spin_lock_irqsave(&fxs->lasttxhooklock, flags);
 			if (fxs->lasttxhook == SLIC_LF_RINGING) {
 				fxs->lasttxhook = POLARITY_XOR(fxs) ?
 							SLIC_LF_ACTIVE_REV :
@@ -1445,7 +1441,6 @@
 			}
 			fxs->lasttxhook |= SLIC_LF_OPPENDING;
 			mod->sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
-			spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
 
 			/* Update shadow register to avoid extra power alarms until next read */
 			mod->isrshadow[1] = fxs->lasttxhook;
@@ -1457,6 +1452,7 @@
 			}
 		}
 	}
+	spin_unlock(&wc->reglock);
 #endif
 }
 
@@ -1828,7 +1824,7 @@
 	unsigned long flags;
 	struct fxs *const fxs = &mod->mod.fxs;
 
-	spin_lock_irqsave(&fxs->lasttxhooklock, flags);
+	spin_lock_irqsave(&wc->reglock, flags);
 	switch (txsig) {
 	case DAHDI_TXSIG_ONHOOK:
 		switch (get_dahdi_chan(wc, mod)->sig) {
@@ -1868,7 +1864,7 @@
 		x = SLIC_LF_OPEN;
 		break;
 	default:
-		spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
+		spin_unlock_irqrestore(&wc->reglock, flags);
 		dev_notice(&wc->vb.pdev->dev,
 			"wctdm24xxp: Can't set tx state to %d\n", txsig);
 		return;
@@ -1877,7 +1873,7 @@
 	if (x != fxs->lasttxhook) {
 		fxs->lasttxhook = x | SLIC_LF_OPPENDING;
 		mod->sethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
-		spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
+		spin_unlock_irqrestore(&wc->reglock, flags);
 
 		if (debug & DEBUG_CARD) {
 			dev_info(&wc->vb.pdev->dev, "Setting FXS hook state "
@@ -1885,7 +1881,7 @@
 				 wc->intcount);
 		}
 	} else {
-		spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
+		spin_unlock_irqrestore(&wc->reglock, flags);
 	}
 }
 
@@ -2027,7 +2023,6 @@
 static void wctdm_isr_misc_fxs(struct wctdm *wc, struct wctdm_module *const mod)
 {
 	struct fxs *const fxs = &mod->mod.fxs;
-	unsigned long flags;
 
 	if (!(wc->intcount % 10000)) {
 		/* Accept an alarm once per 10 seconds */
@@ -2056,7 +2051,7 @@
 			/* Switch to active */
 			fxs->idletxhookstate = POLARITY_XOR(fxs) ? SLIC_LF_ACTIVE_REV :
 								    SLIC_LF_ACTIVE_FWD;
-			spin_lock_irqsave(&fxs->lasttxhooklock, flags);
+			spin_lock(&wc->reglock);
 			if (SLIC_LF_OHTRAN_FWD == fxs->lasttxhook) {
 				/* Apply the change if appropriate */
 				fxs->lasttxhook = SLIC_LF_OPPENDING | SLIC_LF_ACTIVE_FWD;
@@ -2078,7 +2073,7 @@
 						 "stop\n", mod->card);
 				}
 			}
-			spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
+			spin_unlock(&wc->reglock);
 		} else {
 			fxs->ohttimer = 0;
 			/* Switch to active */
@@ -2558,23 +2553,24 @@
 	return 0;
 }
 
-static int set_lasttxhook_interruptible(struct fxs *fxs, unsigned newval, int * psethook)
+static int set_lasttxhook_interruptible(struct wctdm *wc, struct fxs *fxs,
+					unsigned newval, int *psethook)
 {
 	int res = 0;
 	unsigned long flags;
 	int timeout = 0;
 
 	do {
-		spin_lock_irqsave(&fxs->lasttxhooklock, flags);
+		spin_lock_irqsave(&wc->reglock, flags);
 		if (SLIC_LF_OPPENDING & fxs->lasttxhook) {
-			spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
+			spin_unlock_irqrestore(&wc->reglock, flags);
 			if (timeout++ > 100)
 				return -1;
 			msleep(1);
 		} else {
 			fxs->lasttxhook = (newval & SLIC_LF_SETMASK) | SLIC_LF_OPPENDING;
 			*psethook = CMD_WR(LINE_STATE, fxs->lasttxhook);
-			spin_unlock_irqrestore(&fxs->lasttxhooklock, flags);
+			spin_unlock_irqrestore(&wc->reglock, flags);
 			break;
 		}
 	} while (1);
@@ -2603,7 +2599,7 @@
 		    ((fxs->lasttxhook & SLIC_LF_SETMASK) != SLIC_LF_OPEN)) {
 			x = fxs->lasttxhook;
 			x |= SLIC_LF_REVMASK;
-			set_lasttxhook_interruptible(fxs, x, &mod->sethook);
+			set_lasttxhook_interruptible(wc, fxs, x, &mod->sethook);
 		}
 	} else {
 		fxs->idletxhookstate &= ~SLIC_LF_REVMASK;
@@ -2612,7 +2608,7 @@
 		    ((fxs->lasttxhook & SLIC_LF_SETMASK) != SLIC_LF_OPEN)) {
 			x = fxs->lasttxhook;
 			x &= ~SLIC_LF_REVMASK;
-			set_lasttxhook_interruptible(fxs, x, &mod->sethook);
+			set_lasttxhook_interruptible(wc, fxs, x, &mod->sethook);
 		}
 	}
 	if (debug) {
@@ -2852,8 +2848,6 @@
 	}
 
 	if (!fast) {
-		spin_lock_init(&fxs->lasttxhooklock);
-
 		/* Check for power leaks */
 		if (wctdm_proslic_powerleak_test(wc, mod)) {
 			dev_notice(&wc->vb.pdev->dev,
@@ -3301,7 +3295,7 @@
 		if (((fxs->lasttxhook & SLIC_LF_SETMASK) == SLIC_LF_ACTIVE_FWD) ||
 		    ((fxs->lasttxhook & SLIC_LF_SETMASK) == SLIC_LF_ACTIVE_REV)) {
 
-			x = set_lasttxhook_interruptible(fxs,
+			x = set_lasttxhook_interruptible(wc, fxs,
 				(POLARITY_XOR(fxs) ?
 				SLIC_LF_OHTRAN_REV : SLIC_LF_OHTRAN_FWD),
 				&mod->sethook);
@@ -3458,7 +3452,7 @@
 			x = fxs->lasttxhook & SLIC_LF_SETMASK;
 			x |= SLIC_LF_REVMASK;
 			if (x != fxs->lasttxhook) { 
-				x = set_lasttxhook_interruptible(fxs, x,
+				x = set_lasttxhook_interruptible(wc, fxs, x,
 								 &mod->sethook);
 				if ((debug & DEBUG_CARD) && x) {
 					dev_info(&wc->vb.pdev->dev,
@@ -3475,7 +3469,7 @@
 			x = fxs->lasttxhook & SLIC_LF_SETMASK;
 			x &= ~SLIC_LF_REVMASK;
 			if (x != fxs->lasttxhook) { 
-				x = set_lasttxhook_interruptible(fxs, x,
+				x = set_lasttxhook_interruptible(wc, fxs, x,
 								 &mod->sethook);
 				if ((debug & DEBUG_CARD) & x) {
 					dev_info(&wc->vb.pdev->dev,

Modified: linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h?view=diff&rev=9967&r1=9966&r2=9967
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h Thu Jun  2 15:03:43 2011
@@ -178,7 +178,6 @@
 */
 	int lasttxhook;
 	int oppending_ms;
-	spinlock_t lasttxhooklock;
 	int palarms;
 	struct dahdi_vmwi_info vmwisetting;
 	int vmwi_active_messages;




More information about the svn-commits mailing list