[dahdi-commits] sruffell: branch linux/sruffell/dahdi-linux-cmdqueue r6035 - /linux/team/sruf...

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Tue Feb 24 15:30:12 CST 2009


Author: sruffell
Date: Tue Feb 24 15:30:12 2009
New Revision: 6035

URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=6035
Log:
Use atomic operations for more of the span flags and remove all the inisr /
inatomic code in the register read / write routines.

Modified:
    linux/team/sruffell/dahdi-linux-cmdqueue/drivers/dahdi/wcte12xp/base.c
    linux/team/sruffell/dahdi-linux-cmdqueue/drivers/dahdi/wcte12xp/wcte12xp.h

Modified: linux/team/sruffell/dahdi-linux-cmdqueue/drivers/dahdi/wcte12xp/base.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/sruffell/dahdi-linux-cmdqueue/drivers/dahdi/wcte12xp/base.c?view=diff&rev=6035&r1=6034&r2=6035
==============================================================================
--- linux/team/sruffell/dahdi-linux-cmdqueue/drivers/dahdi/wcte12xp/base.c (original)
+++ linux/team/sruffell/dahdi-linux-cmdqueue/drivers/dahdi/wcte12xp/base.c Tue Feb 24 15:30:12 2009
@@ -229,28 +229,20 @@
 
 static inline int t1_setreg_full(struct t1 *wc, int addr, int val, int vpm_num)
 {
-	const int inatomic = in_atomic() ? 1 : 0;
 	struct command *cmd;
-	do {
-		cmd = get_free_cmd(wc);
-		if (cmd) {
-			cmd->address = addr;
-			cmd->data = val;
-			cmd->flags |= __CMD_WR;
-			if (vpm_num >= 0) {
-				cmd->flags |= __CMD_VPM;
-				cmd->vpm_num = vpm_num;
-			}
-			submit_cmd(wc, cmd);
-			return 0;
-		}
-		if (!inatomic) 
-			msleep(1);
-		else
-			return -1;
-	} while (1);
-	/* should never get here. */
-	return -1;
+	might_sleep();
+	while (!(cmd = get_free_cmd(wc))) {
+		msleep(1);
+	}
+	cmd->address = addr;
+	cmd->data = val;
+	cmd->flags |= __CMD_WR;
+	if (vpm_num >= 0) {
+		cmd->flags |= __CMD_VPM;
+		cmd->vpm_num = vpm_num;
+	}
+	submit_cmd(wc, cmd);
+	return 0;
 }
 
 static inline int t1_setreg(struct t1 *wc, int addr, int val)
@@ -261,33 +253,21 @@
 static inline int t1_getreg_full(struct t1 *wc, int addr, int vpm_num)
 {
 	struct command *cmd =  NULL;
-	int ret = 0;
-	int inisr = in_atomic() ? 1 : 0;
-retry:
-	cmd = get_free_cmd(wc);
-	if (cmd) {
-		cmd->address = addr;
-		cmd->data = 0x00;
-		cmd->flags = __CMD_RD;
-		if (inisr) {
-			cmd->flags |= __CMD_ISR;
-		}
-		if (vpm_num > -1) {
-			cmd->flags |= __CMD_VPM;
-			cmd->vpm_num = vpm_num;
-		}
-		submit_cmd(wc, cmd);
-	} else if (!inisr) {
-		msleep(500);
-		goto retry;
-	} else {
-		/* We're in atomic context...we need to just exit. */
-		return -1;
-	}
-
-	if (inisr)
-		return 0;
-
+	int ret;
+
+	might_sleep();
+
+	while (!(cmd = get_free_cmd(wc)))
+		msleep(1);
+
+	cmd->address = addr;
+	cmd->data = 0x00;
+	cmd->flags = __CMD_RD;
+	if (vpm_num > -1) {
+		cmd->flags |= __CMD_VPM;
+		cmd->vpm_num = vpm_num;
+	}
+	submit_cmd(wc, cmd);
 	wait_for_completion(&cmd->complete);
 	ret = cmd->data;
 	free_cmd(wc, cmd);
@@ -604,23 +584,18 @@
 static int t1xxp_shutdown(struct dahdi_span *span)
 {
 	struct t1 *wc = span->pvt;
-	unsigned long flags;
-
 	t1_setreg(wc, 0x46, 0x41);	/* GCR: Interrupt on Activation/Deactivation of AIX, LOS */
-	spin_lock_irqsave(&wc->reglock, flags);
-	span->flags &= ~DAHDI_FLAG_RUNNING;
-	spin_unlock_irqrestore(&wc->reglock, flags);
+	clear_bit(DAHDI_FLAGBIT_RUNNING, &span->flags);
 	return 0;
 }
 
 static int t1xxp_chanconfig(struct dahdi_chan *chan, int sigtype)
 {
 	struct t1 *wc = chan->pvt;
-	int alreadyrunning = chan->span->flags & DAHDI_FLAG_RUNNING;
-
-	if (alreadyrunning && (wc->spantype != TYPE_E1))
+	if (test_bit(DAHDI_FLAGBIT_RUNNING, &chan->span->flags) && 
+		(wc->spantype != TYPE_E1)) {
 		__t1xxp_set_clear(wc, chan->channo);
-
+	}
 	return 0;
 }
 
@@ -636,7 +611,7 @@
 		wc->ctlreg &= ~0x80;
 
 	/* If already running, apply changes immediately */
-	if (span->flags & DAHDI_FLAG_RUNNING)
+	if (test_bit(DAHDI_FLAGBIT_RUNNING, &span->flags))
 		return t1xxp_startup(span);
 
 	return 0;

Modified: linux/team/sruffell/dahdi-linux-cmdqueue/drivers/dahdi/wcte12xp/wcte12xp.h
URL: http://svn.digium.com/svn-view/dahdi/linux/team/sruffell/dahdi-linux-cmdqueue/drivers/dahdi/wcte12xp/wcte12xp.h?view=diff&rev=6035&r1=6034&r2=6035
==============================================================================
--- linux/team/sruffell/dahdi-linux-cmdqueue/drivers/dahdi/wcte12xp/wcte12xp.h (original)
+++ linux/team/sruffell/dahdi-linux-cmdqueue/drivers/dahdi/wcte12xp/wcte12xp.h Tue Feb 24 15:30:12 2009
@@ -51,7 +51,7 @@
 
 #define PCI_WINDOW_SIZE ((2 * 2 * 2 * SFRAME_SIZE) + (2 * ERING_SIZE * 4))
 
-#define MAX_COMMANDS 7*7*2*2 /* 42 bytes /3 (cntl,addr,data) /2 (cs) */
+#define MAX_COMMANDS 16
 
 #define NUM_EC 4
 




More information about the dahdi-commits mailing list