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

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


Author: sruffell
Date: Tue Dec 21 10:09:31 2010
New Revision: 9550

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9550
Log:
dahdi: Cleanup in the dahdi_chan_poll function.

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

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=9550&r1=9549&r2=9550
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Tue Dec 21 10:09:31 2010
@@ -8189,32 +8189,22 @@
 static unsigned int
 dahdi_chan_poll(struct file *file, struct poll_table_struct *wait_table)
 {
-
-	struct dahdi_chan *const chan = file->private_data;
-	int	ret;
+	struct dahdi_chan *const c = file->private_data;
+	int ret = 0;
 	unsigned long flags;
 
-	  /* do the poll wait */
-	if (chan) {
-		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 */
-		if (chan->inwritebuf > -1) {
-			ret |= POLLOUT | POLLWRNORM;
-		}
-		if ((chan->outreadbuf > -1) && !chan->rxdisable) {
-			ret |= POLLIN | POLLRDNORM;
-		}
-		if (chan->eventoutidx != chan->eventinidx)
-		   {
-			/* Indicate an exception */
-			ret |= POLLPRI;
-		   }
-		spin_unlock_irqrestore(&chan->lock, flags);
-	} else
-		ret = -EINVAL;
-	return(ret);  /* return what we found */
+	if (unlikely(!c))
+		return -EINVAL;
+
+	poll_wait(file, &c->waitq, wait_table);
+
+	spin_lock_irqsave(&c->lock, flags);
+	ret |= (c->inwritebuf > -1) ? POLLOUT|POLLWRNORM : 0;
+	ret |= ((c->outreadbuf > -1) && !c->rxdisable) ?  POLLIN|POLLRDNORM : 0;
+	ret |= (c->eventoutidx != c->eventinidx) ? POLLPRI : 0;
+	spin_unlock_irqrestore(&c->lock, flags);
+
+	return ret;
 }
 
 static unsigned int dahdi_poll(struct file *file, struct poll_table_struct *wait_table)




More information about the svn-commits mailing list