[svn-commits] tzafrir: branch linux/tzafrir/sysfs r8702 - in /linux/team/tzafrir/sysfs: dri...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu May 27 08:02:04 CDT 2010


Author: tzafrir
Date: Thu May 27 08:02:02 2010
New Revision: 8702

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8702
Log:
DAHDI-linux-sysfs: Change span readiness criteria:

* Don't wait for dahdi_cfg ioctl()
* Instead create a read/write 'user_ready' span attribute:
  - Writing to it from UDEV symlink_span (online)
  - Reading it blocks until writing
  - Used by dahdi_waitfor_spans to verify spans are ready
* Don't need to use udevsettle in dahdi_waitfor_spans.
* Also add a 'configured_channels' readonly attributes that shows
  the same info as 'user_ready' without blocking.

Modified:
    linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c
    linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c
    linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.h
    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=8702&r1=8701&r2=8702
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c Thu May 27 08:02:02 2010
@@ -4096,7 +4096,6 @@
 
 			ret = spans[lc.span]->spanconfig(spans[lc.span], &lc);
 		}
-		wake_up_interruptible(&spans[lc.span]->configured);
 		return ret;
 	}
 	case DAHDI_STARTUP:
@@ -4354,7 +4353,6 @@
 		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;
 	}
@@ -5916,7 +5914,7 @@
 	span->spanno = x;
 
 	spin_lock_init(&span->lock);
-	init_waitqueue_head(&span->configured);
+	init_waitqueue_head(&span->wait_user);
 
 	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=8702&r1=8701&r2=8702
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c Thu May 27 08:02:02 2010
@@ -175,7 +175,7 @@
 	return sprintf(buf, "%d\n", dahdi_is_sync_master(span));
 }
 
-static int ready_channels(struct dahdi_span *span)
+static int configured_channels(struct dahdi_span *span)
 {
 	unsigned long flags;
 	int ready = 0;
@@ -195,26 +195,53 @@
 	return ready;
 }
 
+static BUS_ATTR_READER(configured_channels_show, dev, buf)
+{
+	struct dahdi_span *span;
+
+	span = dev_to_span(dev);
+	return sprintf(buf, "%03d\t%d/%d\t%s\n",
+		span->spanno,
+		configured_channels(span),
+		span->channels,
+		span->name);
+}
+
+static BUS_ATTR_WRITER(user_ready_store, dev, buf, count)
+{
+	struct dahdi_span *span;
+
+	span = dev_to_span(dev);
+	span->user_ready++;
+	span_dbg(DEVICES, span, "Got user_ready(%s)\n", buf);
+	wake_up_interruptible(&span->wait_user);
+	return count;
+}
+
 #define	SPAN_WAIT_TIMEOUT	(20*HZ)
 
-static BUS_ATTR_READER(wait_for_channels_show, dev, buf)
+static BUS_ATTR_READER(user_ready_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,
+		span->wait_user,
+		span->user_ready,
 		SPAN_WAIT_TIMEOUT);
 	if(ret == 0) {
-		span_dbg(DEVICES, span, "Span wait configuration timeout\n");
+		span_dbg(DEVICES, span, "Span wait user timeout\n");
 		return -ETIMEDOUT;
 	} else if(ret < 0) {
-		span_dbg(DEVICES, span, "Span wait configuration interrupted\n");
+		span_dbg(DEVICES, span, "Span wait user interrupted\n");
 		return -ERESTARTSYS;
 	}
-	return sprintf(buf, "%d/%d\n", ready_channels(span), span->channels);
+	return sprintf(buf, "%03d\t%d/%d\t%s\n",
+		span->spanno,
+		configured_channels(span),
+		span->channels,
+		span->name);
 }
 
 static struct device_attribute span_dev_attrs[] = {
@@ -233,7 +260,9 @@
 	__ATTR_RO(syncsrc),
 	__ATTR_RO(is_digital),
 	__ATTR_RO(is_sync_master),
-	__ATTR_RO(wait_for_channels),
+	__ATTR_RO(configured_channels),
+	__ATTR(user_ready, S_IRUGO | S_IWUSR, user_ready_show,
+			user_ready_store),
 	__ATTR_NULL,
 };
 

Modified: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.h?view=diff&rev=8702&r1=8701&r2=8702
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.h (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.h Thu May 27 08:02:02 2010
@@ -17,6 +17,9 @@
 				const char *buf, size_t count)
 #define BUS_ATTR_READER(name, dev, buf) \
    ssize_t name(struct device *dev, struct device_attribute *attr, char *buf)
+#define BUS_ATTR_WRITER(name, dev, buf, count) \
+   ssize_t name(struct device *dev, struct device_attribute *attr, \
+		   const char *buf, size_t count)
 #else
 #define	DEVICE_ATTR_READER(name, dev, buf)	\
 		ssize_t name(struct device *dev, char *buf)
@@ -24,6 +27,8 @@
 		ssize_t name(struct device *dev, const char *buf, size_t count)
 #define BUS_ATTR_READER(name, dev, buf) \
    ssize_t name(struct device *dev, char *buf)
+#define BUS_ATTR_WRITER(name, dev, buf, count) \
+   ssize_t name(struct device *dev, const char *buf, size_t count)
 #endif
 
 #define	DRIVER_ATTR_READER(name, drv, buf)	\

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=8702&r1=8701&r2=8702
==============================================================================
--- linux/team/tzafrir/sysfs/include/dahdi/kernel.h (original)
+++ linux/team/tzafrir/sysfs/include/dahdi/kernel.h Thu May 27 08:02:02 2010
@@ -765,7 +765,8 @@
 	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 user_ready;			/*!< Got confirmation from user-space */
+	wait_queue_head_t wait_user;	/*!< wait until span->user_ready == 1 */
 	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