summaryrefslogtreecommitdiff
path: root/drivers/dahdi
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2010-11-04 16:40:40 +0000
committerShaun Ruffell <sruffell@digium.com>2010-11-04 16:40:40 +0000
commit0b997fcebb6654b61eaca5acf4541f7a9797f487 (patch)
treed1487025beaccaec83c61e10b36ae0a62d34bf48 /drivers/dahdi
parentc7bab8ede97873481b5b0989ff562560b5e61827 (diff)
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@digium.com> Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9466 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi')
-rw-r--r--drivers/dahdi/dahdi-base.c118
1 files changed, 67 insertions, 51 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index 163d804..4886671 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -4938,6 +4938,72 @@ static int dahdi_ioctl_getconf(struct file *file, unsigned long data)
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 @@ dahdi_chanandpseudo_ioctl(struct file *file, unsigned int cmd,
} stack;
unsigned long flags;
int i, j, rv;
- int ret;
void __user * const user_data = (void __user *)data;
if (!chan)
@@ -5066,57 +5131,8 @@ dahdi_chanandpseudo_ioctl(struct file *file, unsigned int cmd,
}
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 */
- }
+ return dahdi_ioctl_iomux(file, data);
- interruptible_sleep_on(&chan->eventbufq);
- if (signal_pending(current))
- return -ERESTARTSYS;
- }
- /* clear IO MUX mask */
- chan->iomask = 0;
- break;
case DAHDI_GETEVENT: /* Get event on queue */
/* set up for no event */
j = DAHDI_EVENT_NONE;