[svn-commits] sruffell: linux/trunk r9548 - in /linux/trunk: drivers/dahdi/ include/dahdi/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 21 16:09:26 UTC 2010


Author: sruffell
Date: Tue Dec 21 10:09:22 2010
New Revision: 9548

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9548
Log:
dahdi: Use a single wait_queue_t for dahdi channels.

Since we've now switched to wait_event_interruptible calls, we have a
condition that we can check when we're awoken.  This allows us to
combine the separate wait queues into a single queue.

Signed-off-by: Shaun Ruffell <sruffell at digium.com>
Acked-by: Russ Meyerreicks <rmeyerreicks at digium.com>

Modified:
    linux/trunk/drivers/dahdi/dahdi-base.c
    linux/trunk/include/dahdi/kernel.h

Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=9548&r1=9547&r2=9548
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Tue Dec 21 10:09:22 2010
@@ -945,12 +945,7 @@
 		chan->eventinidx = 0;
 
 	/* wake em all up */
-	if (chan->iomask & DAHDI_IOMUX_SIGEVENT)
-		wake_up_interruptible(&chan->eventbufq);
-
-	wake_up_interruptible(&chan->readbufq);
-	wake_up_interruptible(&chan->writebufq);
-	wake_up_interruptible(&chan->sel);
+	wake_up_interruptible(&chan->waitq);
 
 	return;
 }
@@ -1293,11 +1288,7 @@
 	chan->pulsecount = 0;
 	chan->pulsetimer = 0;
 	chan->ringdebtimer = 0;
-	init_waitqueue_head(&chan->sel);
-	init_waitqueue_head(&chan->readbufq);
-	init_waitqueue_head(&chan->writebufq);
-	init_waitqueue_head(&chan->eventbufq);
-	init_waitqueue_head(&chan->txstateq);
+	init_waitqueue_head(&chan->waitq);
 	chan->txdialbuf[0] = '\0';
 	chan->digitmode = DIGIT_MODE_DTMF;
 	chan->dialing = 0;
@@ -2063,7 +2054,7 @@
 			break;
 		if (file->f_flags & O_NONBLOCK)
 			return -EAGAIN;
-		rv = wait_event_interruptible(chan->readbufq,
+		rv = wait_event_interruptible(chan->waitq,
 				(chan->outreadbuf > -1));
 		if (rv)
 			return rv;
@@ -2191,7 +2182,7 @@
 			return -EAGAIN;
 		}
 		/* Wait for something to be available */
-		rv = wait_event_interruptible(chan->writebufq,
+		rv = wait_event_interruptible(chan->waitq,
 					      (chan->inwritebuf >= 0));
 		if (rv)
 			return rv;
@@ -2605,11 +2596,7 @@
 	chan->itimerset = chan->itimer = chan->otimer = 0;
 	chan->ringdebtimer = 0;
 
-	init_waitqueue_head(&chan->sel);
-	init_waitqueue_head(&chan->readbufq);
-	init_waitqueue_head(&chan->writebufq);
-	init_waitqueue_head(&chan->eventbufq);
-	init_waitqueue_head(&chan->txstateq);
+	init_waitqueue_head(&chan->waitq);
 
 	/* Reset conferences */
 	reset_conf(chan);
@@ -4980,7 +4967,7 @@
 		unsigned int wait_result;
 
 		wait_result = 0;
-		prepare_to_wait(&chan->eventbufq, &wait, TASK_INTERRUPTIBLE);
+		prepare_to_wait(&chan->waitq, &wait, TASK_INTERRUPTIBLE);
 
 		spin_lock_irqsave(&chan->lock, flags);
 		chan->iomask = iomask;
@@ -5011,14 +4998,14 @@
 		}
 
 		if (signal_pending(current)) {
-			finish_wait(&chan->eventbufq, &wait);
+			finish_wait(&chan->waitq, &wait);
 			return -ERESTARTSYS;
 		}
 
 		schedule();
 	}
 
-	finish_wait(&chan->eventbufq, &wait);
+	finish_wait(&chan->waitq, &wait);
 	spin_lock_irqsave(&chan->lock, flags);
 	chan->iomask = 0;
 	spin_unlock_irqrestore(&chan->lock, flags);
@@ -5206,8 +5193,7 @@
 				chan->readn[j] = 0;
 				chan->readidx[j] = 0;
 			}
-			wake_up_interruptible(&chan->readbufq);  /* wake_up_interruptible waiting on read */
-			wake_up_interruptible(&chan->sel); /* wake_up_interruptible waiting on select */
+			wake_up_interruptible(&chan->waitq);  /* wake_up_interruptible waiting on read */
 		   }
 		if (i & DAHDI_FLUSH_WRITE) /* if for write (output) */
 		   {
@@ -5219,12 +5205,7 @@
 				chan->writen[j] = 0;
 				chan->writeidx[j] = 0;
 			}
-			wake_up_interruptible(&chan->writebufq); /* wake_up_interruptible waiting on write */
-			wake_up_interruptible(&chan->sel);  /* wake_up_interruptible waiting on select */
-			   /* if IO MUX wait on write empty, well, this
-				certainly *did* empty the write */
-			if (chan->iomask & DAHDI_IOMUX_WRITEEMPTY)
-				wake_up_interruptible(&chan->eventbufq); /* wake_up_interruptible waiting on IOMUX */
+			wake_up_interruptible(&chan->waitq); /* wake_up_interruptible waiting on write */
 		   }
 		if (i & DAHDI_FLUSH_EVENT) /* if for events */
 		   {
@@ -5242,7 +5223,7 @@
 			spin_unlock_irqrestore(&chan->lock, flags);
 			if (!i)
 				break; /* skip if none */
-			rv = wait_event_interruptible(chan->writebufq,
+			rv = wait_event_interruptible(chan->waitq,
 						      (chan->outwritebuf > -1));
 			if (rv)
 				return rv;
@@ -5917,7 +5898,7 @@
 				spin_unlock_irqrestore(&chan->lock, flags);
 				if (file->f_flags & O_NONBLOCK)
 					return -EINPROGRESS;
-				wait_event_interruptible(chan->txstateq,
+				wait_event_interruptible(chan->waitq,
 					is_txstate(chan, DAHDI_TXSIG_ONHOOK));
 				if (signal_pending(current))
 					return -ERESTARTSYS;
@@ -5932,7 +5913,7 @@
 				spin_unlock_irqrestore(&chan->lock, flags);
 				if (file->f_flags & O_NONBLOCK)
 					return -EINPROGRESS;
-				wait_event_interruptible(chan->txstateq,
+				wait_event_interruptible(chan->waitq,
 					is_txstate(chan, DAHDI_TXSIG_OFFHOOK));
 				if (signal_pending(current))
 					return -ERESTARTSYS;
@@ -6725,7 +6706,7 @@
 						there is something to write */
 						ms->outwritebuf = -1;
 						if (ms->iomask & (DAHDI_IOMUX_WRITE | DAHDI_IOMUX_WRITEEMPTY))
-							wake_up_interruptible(&ms->eventbufq);
+							wake_up_interruptible(&ms->waitq);
 						/* If we're only supposed to start when full, disable the transmitter */
 						if ((ms->txbufpolicy == DAHDI_POLICY_WHEN_FULL) ||
 							(ms->txbufpolicy == DAHDI_POLICY_HALF_FULL))
@@ -6735,7 +6716,7 @@
 					if (ms->outwritebuf == ms->inwritebuf) {
 						ms->outwritebuf = oldbuf;
 						if (ms->iomask & (DAHDI_IOMUX_WRITE | DAHDI_IOMUX_WRITEEMPTY))
-							wake_up_interruptible(&ms->eventbufq);
+							wake_up_interruptible(&ms->waitq);
 						/* If we're only supposed to start when full, disable the transmitter */
 						if ((ms->txbufpolicy == DAHDI_POLICY_WHEN_FULL) ||
 							(ms->txbufpolicy == DAHDI_POLICY_HALF_FULL))
@@ -6759,10 +6740,7 @@
 out in the later versions, and is put back now. */
 				if (!(ms->flags & DAHDI_FLAG_PPP) ||
 				    !dahdi_have_netdev(ms)) {
-					wake_up_interruptible(&ms->writebufq);
-					wake_up_interruptible(&ms->sel);
-					if (ms->iomask & DAHDI_IOMUX_WRITE)
-						wake_up_interruptible(&ms->eventbufq);
+					wake_up_interruptible(&ms->waitq);
 				}
 				/* Transmit a flag if this is an HDLC channel */
 				if (ms->flags & DAHDI_FLAG_HDLC)
@@ -6922,7 +6900,7 @@
 	case DAHDI_TXSTATE_START:
 		/* If we were starting, go off hook now ready to debounce */
 		dahdi_rbs_sethook(chan, DAHDI_TXSIG_OFFHOOK, DAHDI_TXSTATE_AFTERSTART, DAHDI_AFTERSTART_TIME);
-		wake_up_interruptible(&chan->txstateq);
+		wake_up_interruptible(&chan->waitq);
 		break;
 
 	case DAHDI_TXSTATE_PREWINK:
@@ -6935,7 +6913,7 @@
 		dahdi_rbs_sethook(chan, DAHDI_TXSIG_ONHOOK, DAHDI_TXSTATE_ONHOOK, 0);
 		if (chan->file && (chan->file->f_flags & O_NONBLOCK))
 			__qevent(chan, DAHDI_EVENT_HOOKCOMPLETE);
-		wake_up_interruptible(&chan->txstateq);
+		wake_up_interruptible(&chan->waitq);
 		break;
 
 	case DAHDI_TXSTATE_PREFLASH:
@@ -6947,7 +6925,7 @@
 		dahdi_rbs_sethook(chan, DAHDI_TXSIG_OFFHOOK, DAHDI_TXSTATE_OFFHOOK, 0);
 		if (chan->file && (chan->file->f_flags & O_NONBLOCK))
 			__qevent(chan, DAHDI_EVENT_HOOKCOMPLETE);
-		wake_up_interruptible(&chan->txstateq);
+		wake_up_interruptible(&chan->waitq);
 		break;
 
 	case DAHDI_TXSTATE_DEBOUNCE:
@@ -6955,21 +6933,21 @@
 		/* See if we've gone back on hook */
 		if ((chan->rxhooksig == DAHDI_RXSIG_ONHOOK) && (chan->rxflashtime > 2))
 			chan->itimerset = chan->itimer = chan->rxflashtime * DAHDI_CHUNKSIZE;
-		wake_up_interruptible(&chan->txstateq);
+		wake_up_interruptible(&chan->waitq);
 		break;
 
 	case DAHDI_TXSTATE_AFTERSTART:
 		dahdi_rbs_sethook(chan, DAHDI_TXSIG_OFFHOOK, DAHDI_TXSTATE_OFFHOOK, 0);
 		if (chan->file && (chan->file->f_flags & O_NONBLOCK))
 			__qevent(chan, DAHDI_EVENT_HOOKCOMPLETE);
-		wake_up_interruptible(&chan->txstateq);
+		wake_up_interruptible(&chan->waitq);
 		break;
 
 	case DAHDI_TXSTATE_KEWL:
 		dahdi_rbs_sethook(chan, DAHDI_TXSIG_ONHOOK, DAHDI_TXSTATE_AFTERKEWL, DAHDI_AFTERKEWLTIME);
 		if (chan->file && (chan->file->f_flags & O_NONBLOCK))
 			__qevent(chan, DAHDI_EVENT_HOOKCOMPLETE);
-		wake_up_interruptible(&chan->txstateq);
+		wake_up_interruptible(&chan->waitq);
 		break;
 
 	case DAHDI_TXSTATE_AFTERKEWL:
@@ -6983,7 +6961,7 @@
 	case DAHDI_TXSTATE_PULSEBREAK:
 		dahdi_rbs_sethook(chan, DAHDI_TXSIG_OFFHOOK, DAHDI_TXSTATE_PULSEMAKE,
 			chan->pulsemaketime);
-		wake_up_interruptible(&chan->txstateq);
+		wake_up_interruptible(&chan->waitq);
 		break;
 
 	case DAHDI_TXSTATE_PULSEMAKE:
@@ -6997,13 +6975,13 @@
 		}
 		chan->txstate = DAHDI_TXSTATE_PULSEAFTER;
 		chan->otimer = chan->pulseaftertime * DAHDI_CHUNKSIZE;
-		wake_up_interruptible(&chan->txstateq);
+		wake_up_interruptible(&chan->waitq);
 		break;
 
 	case DAHDI_TXSTATE_PULSEAFTER:
 		chan->txstate = DAHDI_TXSTATE_OFFHOOK;
 		__do_dtmf(chan);
-		wake_up_interruptible(&chan->txstateq);
+		wake_up_interruptible(&chan->waitq);
 		break;
 
 	default:
@@ -7913,7 +7891,7 @@
 							/* if there are processes waiting in poll() on this channel,
 							   wake them up */
 							if (!ms->rxdisable) {
-								wake_up_interruptible(&ms->sel);
+								wake_up_interruptible(&ms->waitq);
 							}
 						}
 /* In the very orignal driver, it was quite well known to me (Jim) that there
@@ -7935,9 +7913,7 @@
 #ifdef CONFIG_DAHDI_DEBUG
 							module_printk(KERN_NOTICE, "Notifying reader data in block %d\n", oldbuf);
 #endif
-							wake_up_interruptible(&ms->readbufq);
-							if (ms->iomask & DAHDI_IOMUX_READ)
-								wake_up_interruptible(&ms->eventbufq);
+							wake_up_interruptible(&ms->waitq);
 						}
 					}
 				}
@@ -8111,12 +8087,8 @@
 		ss->outreadbuf = oldreadbuf;
 	}
 
-	if (!ss->rxdisable) {
-		wake_up_interruptible(&ss->readbufq);
-		wake_up_interruptible(&ss->sel);
-		if (ss->iomask & DAHDI_IOMUX_READ)
-			wake_up_interruptible(&ss->eventbufq);
-	}
+	if (!ss->rxdisable)
+		wake_up_interruptible(&ss->waitq);
 	spin_unlock_irqrestore(&ss->lock, flags);
 }
 
@@ -8153,7 +8125,7 @@
 			if (ss->outwritebuf == ss->inwritebuf) {
 				ss->outwritebuf = -1;
 				if (ss->iomask & (DAHDI_IOMUX_WRITE | DAHDI_IOMUX_WRITEEMPTY))
-					wake_up_interruptible(&ss->eventbufq);
+					wake_up_interruptible(&ss->waitq);
 				/* If we're only supposed to start when full, disable the transmitter */
 				if ((ss->txbufpolicy == DAHDI_POLICY_WHEN_FULL) || (ss->txbufpolicy == DAHDI_POLICY_HALF_FULL))
 					ss->txdisable = 1;
@@ -8165,10 +8137,7 @@
 
 			if (!(ss->flags & DAHDI_FLAG_PPP) ||
 			    !dahdi_have_netdev(ss)) {
-				wake_up_interruptible(&ss->writebufq);
-				wake_up_interruptible(&ss->sel);
-				if ((ss->iomask & DAHDI_IOMUX_WRITE) && (res >= 0))
-					wake_up_interruptible(&ss->eventbufq);
+				wake_up_interruptible(&ss->waitq);
 			}
 		}
 	} else {
@@ -8229,7 +8198,7 @@
 
 	  /* do the poll wait */
 	if (chan) {
-		poll_wait(file, &chan->sel, wait_table);
+		poll_wait(file, &chan->waitq, wait_table);
 		ret = 0; /* start with nothing to return */
 		spin_lock_irqsave(&chan->lock, flags);
 		   /* if at least 1 write buffer avail */

Modified: linux/trunk/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/include/dahdi/kernel.h?view=diff&rev=9548&r1=9547&r2=9548
==============================================================================
--- linux/trunk/include/dahdi/kernel.h (original)
+++ linux/trunk/include/dahdi/kernel.h Tue Dec 21 10:09:22 2010
@@ -451,26 +451,23 @@
 	int		sigcap;			/*!< Capability for signalling */
 	__u32		chan_alarms;		/*!< alarms status */
 
+	wait_queue_head_t waitq;
+
 	/* Used only by DAHDI -- NO DRIVER SERVICEABLE PARTS BELOW */
 	/* Buffer declarations */
 	u_char		*readbuf[DAHDI_MAX_NUM_BUFS];	/*!< read buffer */
 	int		inreadbuf;
 	int		outreadbuf;
-	wait_queue_head_t readbufq; /*!< read wait queue */
 
 	u_char		*writebuf[DAHDI_MAX_NUM_BUFS]; /*!< write buffers */
 	int		inwritebuf;
 	int		outwritebuf;
-	wait_queue_head_t writebufq; /*!< write wait queue */
 	
 	int		blocksize;	/*!< Block size */
 
 	int		eventinidx;  /*!< out index in event buf (circular) */
 	int		eventoutidx;  /*!< in index in event buf (circular) */
 	unsigned int	eventbuf[DAHDI_MAX_EVENTSIZE];  /*!< event circ. buffer */
-	wait_queue_head_t eventbufq; /*!< event wait queue */
-	
-	wait_queue_head_t txstateq;	/*!< waiting on the tx state to change */
 	
 	int		readn[DAHDI_MAX_NUM_BUFS];  /*!< # of bytes ready in read buf */
 	int		readidx[DAHDI_MAX_NUM_BUFS];  /*!< current read pointer */
@@ -507,7 +504,6 @@
 
 	/* I/O Mask */	
 	unsigned int iomask;  /*! I/O Mux signal mask */
-	wait_queue_head_t sel;	/*! thingy for select stuff */
 	
 	/* HDLC state machines */
 	struct fasthdlc_state txhdlc;




More information about the svn-commits mailing list