[svn-commits] tzafrir: linux/trunk r10334 - /linux/trunk/drivers/dahdi/xpp/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Nov 10 10:56:33 CST 2011
Author: tzafrir
Date: Thu Nov 10 10:56:29 2011
New Revision: 10334
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10334
Log:
xpp: restore backward compat dahdi_registration
This restores a somewhat limited functionality of the "span"
write interface in the SysFS node of the span, broken by the
pinned-spans code.
* PROBLEM: dahdi-linux pinned-spans should work with existing dahdi-tools
specifically the dahdi_registration tool.
* As a result, we should still be able to control dahdi registration
order. However, registration is now in complete devices and not spans
* Restored dahdi_autoreg=[0/1] xpp module parameter:
- It now refers to complete astribanks and not individual spans
* The xpp module sysfs "span" attribute:
- Implemented write method (for dahdi_registration tool)
- The first write of [1/0] to this attribute, registers/unregisters
the complete astribank
- Further writes are ignored (with DBG messages)
* Also, implemented new xbus_is_registered() function
* Once the new dahdi-tools are merged, we should turn deprecation
messages from DBG() to NOTICE()
Signed-off-by: Oron Peled <oron.peled at xorcom.com>
Acked-by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Modified:
linux/trunk/drivers/dahdi/xpp/xbus-core.c
linux/trunk/drivers/dahdi/xpp/xbus-core.h
linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c
Modified: linux/trunk/drivers/dahdi/xpp/xbus-core.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-core.c?view=diff&rev=10334&r1=10333&r2=10334
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-core.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-core.c Thu Nov 10 10:56:29 2011
@@ -61,6 +61,8 @@
static DEF_PARM(uint, command_queue_length, 1000, 0444, "Maximal command queue length");
static DEF_PARM(uint, poll_timeout, 1000, 0644, "Timeout (in jiffies) waiting for units to reply");
static DEF_PARM_BOOL(rx_tasklet, 0, 0644, "Use receive tasklets");
+static DEF_PARM_BOOL(dahdi_autoreg, 0, 0644,
+ "Register devices automatically (1) or not (0)");
#ifdef CONFIG_PROC_FS
static int xbus_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data);
@@ -870,12 +872,22 @@
goto out;
}
-static int xbus_register_dahdi_device(xbus_t *xbus)
+int xbus_is_registered(xbus_t *xbus)
+{
+ return xbus->ddev && xbus->ddev->dev.parent;
+}
+
+int xbus_register_dahdi_device(xbus_t *xbus)
{
int i;
int offset = 0;
XBUS_DBG(DEVICES, xbus, "Entering %s\n", __func__);
+ if (xbus_is_registered(xbus)) {
+ XBUS_ERR(xbus, "Already registered to DAHDI\n");
+ WARN_ON(1);
+ return -EINVAL;
+ }
xbus->ddev = dahdi_create_device();
/*
* This actually describe the dahdi_spaninfo version 3
@@ -929,7 +941,7 @@
return 0;
}
-static void xbus_unregister_dahdi_device(xbus_t *xbus)
+void xbus_unregister_dahdi_device(xbus_t *xbus)
{
int i;
@@ -1017,7 +1029,8 @@
*/
xbus_request_sync(xbus, SYNC_MODE_PLL);
elect_syncer("xbus_populate(end)"); /* FIXME: try to do it later */
- xbus_register_dahdi_device(xbus);
+ if (dahdi_autoreg)
+ xbus_register_dahdi_device(xbus);
out:
XBUS_DBG(DEVICES, xbus, "Leaving\n");
wake_up_interruptible_all(&worker->wait_for_xpd_initialization);
Modified: linux/trunk/drivers/dahdi/xpp/xbus-core.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-core.h?view=diff&rev=10334&r1=10333&r2=10334
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-core.h (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-core.h Thu Nov 10 10:56:29 2011
@@ -343,6 +343,10 @@
void xpd_device_unregister(xpd_t *xpd);
int echocancel_xpd(xpd_t *xpd, int on);
+int xbus_is_registered(xbus_t *xbus);
+int xbus_register_dahdi_device(xbus_t *xbus);
+void xbus_unregister_dahdi_device(xbus_t *xbus);
+
int xpp_driver_init(void);
void xpp_driver_exit(void);
int xbus_sysfs_transport_create(xbus_t *xbus);
Modified: linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c?view=diff&rev=10334&r1=10333&r2=10334
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c Thu Nov 10 10:56:29 2011
@@ -613,6 +613,48 @@
return len;
}
+/*
+ * For backward compatibility with old dahdi-tools
+ * Remove after dahdi_registration is upgraded
+ */
+static DEVICE_ATTR_WRITER(span_store, dev, buf, count)
+{
+ xpd_t *xpd;
+ int dahdi_reg;
+ int ret;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ if (!xpd)
+ return -ENODEV;
+ ret = sscanf(buf, "%d", &dahdi_reg);
+ if (ret != 1)
+ return -EINVAL;
+ if (!XBUS_IS(xpd->xbus, READY))
+ return -ENODEV;
+ XPD_DBG(DEVICES, xpd,
+ "%s -- deprecated (should use pinned-spans)\n",
+ (dahdi_reg) ? "register" : "unregister");
+ if (xbus_is_registered(xpd->xbus)) {
+ if (dahdi_reg) {
+ XPD_DBG(DEVICES, xpd,
+ "already registered %s. Ignored.\n",
+ xpd->xbus->busname);
+ } else {
+ xbus_unregister_dahdi_device(xpd->xbus);
+ }
+ } else {
+ if (!dahdi_reg) {
+ XPD_DBG(DEVICES, xpd,
+ "already unregistered %s. Ignored.\n",
+ xpd->xbus->busname);
+ } else {
+ xbus_register_dahdi_device(xpd->xbus);
+ }
+ }
+ return count;
+}
+
static DEVICE_ATTR_READER(type_show, dev, buf)
{
xpd_t *xpd;
@@ -695,7 +737,7 @@
static struct device_attribute xpd_dev_attrs[] = {
__ATTR(chipregs, S_IRUGO | S_IWUSR, chipregs_show, chipregs_store),
__ATTR(blink, S_IRUGO | S_IWUSR, blink_show, blink_store),
- __ATTR_RO(span),
+ __ATTR(span, S_IRUGO | S_IWUSR, span_show, span_store),
__ATTR_RO(type),
__ATTR_RO(offhook),
__ATTR_RO(timing_priority),
More information about the svn-commits
mailing list