[svn-commits] tzafrir: branch linux/tzafrir/sysfs r8651 - in /linux/team/tzafrir/sysfs: dri...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon May 17 15:30:27 CDT 2010
Author: tzafrir
Date: Mon May 17 15:30:24 2010
New Revision: 8651
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8651
Log:
add span attribute wait_for_channels
/sys/bus/dahdi_spans/devices/*/wait_for_channels
Blocks the calling process (max 2000 jiffies) until span is ready for Asterisk:
- All channels are configured
- Digital spans are configured
Modified:
linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c
linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c
linux/team/tzafrir/sysfs/include/dahdi/kernel.h
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c?view=diff&rev=8651&r1=8650&r2=8651
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c Mon May 17 15:30:24 2010
@@ -4080,6 +4080,7 @@
case DAHDI_SPANCONFIG:
{
struct dahdi_lineconfig lc;
+ int ret = 0;
if (copy_from_user(&lc, user_data, sizeof(lc)))
return -EFAULT;
@@ -4093,9 +4094,10 @@
spans[lc.span]->txlevel = lc.lbo;
spans[lc.span]->rxlevel = 0;
- return spans[lc.span]->spanconfig(spans[lc.span], &lc);
- }
- return 0;
+ ret = spans[lc.span]->spanconfig(spans[lc.span], &lc);
+ }
+ wake_up_interruptible(&spans[lc.span]->configured);
+ return ret;
}
case DAHDI_STARTUP:
CHECK_VALID_SPAN(j);
@@ -4352,6 +4354,7 @@
module_printk(KERN_NOTICE, "Configured channel %s, flags %04lx, sig %04x\n", chans[ch.chan]->name, chans[ch.chan]->flags, chans[ch.chan]->sig);
#endif
spin_unlock_irqrestore(&chans[ch.chan]->lock, flags);
+ wake_up_interruptible(&chans[ch.chan]->span->configured);
return res;
}
@@ -5913,6 +5916,7 @@
span->spanno = x;
spin_lock_init(&span->lock);
+ init_waitqueue_head(&span->configured);
if (!span->deflaw) {
module_printk(KERN_NOTICE, "Span %s didn't specify default law. "
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c?view=diff&rev=8651&r1=8650&r2=8651
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c Mon May 17 15:30:24 2010
@@ -33,6 +33,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/errno.h>
+#include <linux/sched.h>
#include <linux/workqueue.h>
#include <linux/delay.h> /* for msleep() to debug */
#include <dahdi/kernel.h>
@@ -172,6 +173,46 @@
span = dev_to_span(dev);
return sprintf(buf, "%d\n", dahdi_is_sync_master(span));
+}
+
+static int ready_channels(struct dahdi_span *span)
+{
+ unsigned long flags;
+ int ready = 0;
+ int i;
+
+ spin_lock_irqsave(&span->lock, flags);
+ for (i = 0; i < span->channels; i++) {
+ struct dahdi_chan *chan = span->chans[i];
+
+ if(chan->sig == DAHDI_SIG_NONE)
+ continue;
+ if(chan->sig == __DAHDI_SIG_DACS && span->lineconfig == 0)
+ continue;
+ ready++;
+ }
+ spin_unlock_irqrestore(&span->lock, flags);
+ return ready;
+}
+
+static BUS_ATTR_READER(wait_for_channels_show, dev, buf)
+{
+ struct dahdi_span *span;
+ int ret;
+
+ span = dev_to_span(dev);
+ ret = wait_event_interruptible_timeout(
+ span->configured,
+ ready_channels(span) >= span->channels,
+ 2000);
+ if(ret == 0) {
+ span_dbg(DEVICES, span, "Span wait configuration timeout\n");
+ return -ETIMEDOUT;
+ } else if(ret < 0) {
+ span_dbg(DEVICES, span, "Span wait configuration interrupted\n");
+ return -ERESTARTSYS;
+ }
+ return sprintf(buf, "%d/%d\n", ready_channels(span), span->channels);
}
static struct device_attribute span_dev_attrs[] = {
@@ -190,6 +231,7 @@
__ATTR_RO(syncsrc),
__ATTR_RO(is_digital),
__ATTR_RO(is_sync_master),
+ __ATTR_RO(wait_for_channels),
__ATTR_NULL,
};
Modified: linux/team/tzafrir/sysfs/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/include/dahdi/kernel.h?view=diff&rev=8651&r1=8650&r2=8651
==============================================================================
--- linux/team/tzafrir/sysfs/include/dahdi/kernel.h (original)
+++ linux/team/tzafrir/sysfs/include/dahdi/kernel.h Mon May 17 15:30:24 2010
@@ -765,6 +765,7 @@
char location[40]; /*!< span device's location in system */
char hardware_id[40]; /*!< span device's unique id (serial) */
int span_id; /*!< span unique number on its device */
+ wait_queue_head_t configured; /*!< waiting until span is fully configured */
int deflaw; /*!< Default law (DAHDI_MULAW or DAHDI_ALAW) */
int alarms; /*!< Pending alarms on span */
unsigned long flags;
More information about the svn-commits
mailing list