dahdi: Cleanup in the dahdi_chan_poll function.

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

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9550 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
Shaun Ruffell 2010-12-21 16:09:31 +00:00
parent 9496527004
commit e26a4d25c8

View File

@ -8189,32 +8189,22 @@ static unsigned int dahdi_timer_poll(struct file *file, struct poll_table_struct
static unsigned int static unsigned int
dahdi_chan_poll(struct file *file, struct poll_table_struct *wait_table) dahdi_chan_poll(struct file *file, struct poll_table_struct *wait_table)
{ {
struct dahdi_chan *const c = file->private_data;
struct dahdi_chan *const chan = file->private_data; int ret = 0;
int ret;
unsigned long flags; unsigned long flags;
/* do the poll wait */ if (unlikely(!c))
if (chan) { return -EINVAL;
poll_wait(file, &chan->waitq, wait_table);
ret = 0; /* start with nothing to return */ poll_wait(file, &c->waitq, wait_table);
spin_lock_irqsave(&chan->lock, flags);
/* if at least 1 write buffer avail */ spin_lock_irqsave(&c->lock, flags);
if (chan->inwritebuf > -1) { ret |= (c->inwritebuf > -1) ? POLLOUT|POLLWRNORM : 0;
ret |= POLLOUT | POLLWRNORM; ret |= ((c->outreadbuf > -1) && !c->rxdisable) ? POLLIN|POLLRDNORM : 0;
} ret |= (c->eventoutidx != c->eventinidx) ? POLLPRI : 0;
if ((chan->outreadbuf > -1) && !chan->rxdisable) { spin_unlock_irqrestore(&c->lock, flags);
ret |= POLLIN | POLLRDNORM;
} return ret;
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 */
} }
static unsigned int dahdi_poll(struct file *file, struct poll_table_struct *wait_table) static unsigned int dahdi_poll(struct file *file, struct poll_table_struct *wait_table)