[svn-commits] sruffell: linux/trunk r9466 - /linux/trunk/drivers/dahdi/dahdi-base.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Nov 4 11:40:44 CDT 2010


Author: sruffell
Date: Thu Nov  4 11:40:40 2010
New Revision: 9466

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9466
Log:
dahdi: Move the DAHDI_IOMUX ioctl handler into a separate function.

Just a cleanup patch that moves code into a standalone function.  Real
change to follow.

Signed-off-by: Shaun Ruffell <sruffell at digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

Modified:
    linux/trunk/drivers/dahdi/dahdi-base.c

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=9466&r1=9465&r2=9466
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Thu Nov  4 11:40:40 2010
@@ -4938,6 +4938,72 @@
 	return 0;
 }
 
+/**
+ * dahdi_ioctl_iomux() - Wait for *something* to happen.
+ *
+ */
+static int dahdi_ioctl_iomux(struct file *file, unsigned long data)
+{
+	struct dahdi_chan *const chan = chan_from_file(file);
+	unsigned long flags;
+	int ret;
+
+	if (!chan)
+		return -EINVAL;
+
+	get_user(chan->iomask, (int __user *)data);  /* save mask */
+	if (!chan->iomask)return(-EINVAL);  /* cant wait for nothing */
+	for(;;)  /* loop forever */
+	   {
+		  /* has to have SOME mask */
+		ret = 0;  /* start with empty return value */
+		spin_lock_irqsave(&chan->lock, flags);
+		  /* if looking for read */
+		if (chan->iomask & DAHDI_IOMUX_READ)
+		   {
+			/* if read available */
+			if ((chan->outreadbuf > -1)  && !chan->rxdisable)
+				ret |= DAHDI_IOMUX_READ;
+		   }
+		  /* if looking for write avail */
+		if (chan->iomask & DAHDI_IOMUX_WRITE)
+		   {
+			if (chan->inwritebuf > -1)
+				ret |= DAHDI_IOMUX_WRITE;
+		   }
+		  /* if looking for write empty */
+		if (chan->iomask & DAHDI_IOMUX_WRITEEMPTY)
+		   {
+			  /* if everything empty -- be sure the transmitter is enabled */
+			chan->txdisable = 0;
+			if (chan->outwritebuf < 0)
+				ret |= DAHDI_IOMUX_WRITEEMPTY;
+		   }
+		  /* if looking for signalling event */
+		if (chan->iomask & DAHDI_IOMUX_SIGEVENT)
+		   {
+			  /* if event */
+			if (chan->eventinidx != chan->eventoutidx)
+				ret |= DAHDI_IOMUX_SIGEVENT;
+		   }
+		spin_unlock_irqrestore(&chan->lock, flags);
+		  /* if something to return, or not to wait */
+		if (ret || (chan->iomask & DAHDI_IOMUX_NOWAIT))
+		   {
+			  /* set return value */
+			put_user(ret, (int __user *)data);
+			break; /* get out of loop */
+		   }
+
+		interruptible_sleep_on(&chan->eventbufq);
+		if (signal_pending(current))
+			return -ERESTARTSYS;
+	   }
+	  /* clear IO MUX mask */
+	chan->iomask = 0;
+	return 0;
+}
+
 static int
 dahdi_chanandpseudo_ioctl(struct file *file, unsigned int cmd,
 			  unsigned long data)
@@ -4949,7 +5015,6 @@
 	} stack;
 	unsigned long flags;
 	int i, j, rv;
-	int ret;
 	void __user * const user_data = (void __user *)data;
 
 	if (!chan)
@@ -5066,57 +5131,8 @@
 		   }
 		break;
 	case DAHDI_IOMUX: /* wait for something to happen */
-		get_user(chan->iomask, (int __user *)data);  /* save mask */
-		if (!chan->iomask) return(-EINVAL);  /* cant wait for nothing */
-		for(;;)  /* loop forever */
-		   {
-			  /* has to have SOME mask */
-			ret = 0;  /* start with empty return value */
-			spin_lock_irqsave(&chan->lock, flags);
-			  /* if looking for read */
-			if (chan->iomask & DAHDI_IOMUX_READ)
-			   {
-				/* if read available */
-				if ((chan->outreadbuf > -1)  && !chan->rxdisable)
-					ret |= DAHDI_IOMUX_READ;
-			   }
-			  /* if looking for write avail */
-			if (chan->iomask & DAHDI_IOMUX_WRITE)
-			   {
-				if (chan->inwritebuf > -1)
-					ret |= DAHDI_IOMUX_WRITE;
-			   }
-			  /* if looking for write empty */
-			if (chan->iomask & DAHDI_IOMUX_WRITEEMPTY)
-			   {
-				  /* if everything empty -- be sure the transmitter is enabled */
-				chan->txdisable = 0;
-				if (chan->outwritebuf < 0)
-					ret |= DAHDI_IOMUX_WRITEEMPTY;
-			   }
-			  /* if looking for signalling event */
-			if (chan->iomask & DAHDI_IOMUX_SIGEVENT)
-			   {
-				  /* if event */
-				if (chan->eventinidx != chan->eventoutidx)
-					ret |= DAHDI_IOMUX_SIGEVENT;
-			   }
-			spin_unlock_irqrestore(&chan->lock, flags);
-			  /* if something to return, or not to wait */
-			if (ret || (chan->iomask & DAHDI_IOMUX_NOWAIT))
-			   {
-				  /* set return value */
-				put_user(ret, (int __user *)data);
-				break; /* get out of loop */
-			   }
-
-			interruptible_sleep_on(&chan->eventbufq);
-			if (signal_pending(current))
-				return -ERESTARTSYS;
-		   }
-		  /* clear IO MUX mask */
-		chan->iomask = 0;
-		break;
+		return dahdi_ioctl_iomux(file, data);
+
 	case DAHDI_GETEVENT:  /* Get event on queue */
 		  /* set up for no event */
 		j = DAHDI_EVENT_NONE;




More information about the svn-commits mailing list