summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-11-10 16:56:29 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-11-10 16:56:29 +0000
commit2fbf6c1646c2b7fef3c608c303f76f6053b29f49 (patch)
tree9eebd9929c13004202e65aa67d08d8415e6eadb8
parentadbe8be83cb1e8833383260ad9cc2fae6c638871 (diff)
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@xorcom.com> Acked-by Tzafrir Cohen <tzafrir.cohen@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10334 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--drivers/dahdi/xpp/xbus-core.c19
-rw-r--r--drivers/dahdi/xpp/xbus-core.h4
-rw-r--r--drivers/dahdi/xpp/xbus-sysfs.c44
3 files changed, 63 insertions, 4 deletions
diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c
index b5c7c31..51efc47 100644
--- a/drivers/dahdi/xpp/xbus-core.c
+++ b/drivers/dahdi/xpp/xbus-core.c
@@ -61,6 +61,8 @@ extern int debug;
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 @@ err:
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 @@ static int xbus_register_dahdi_device(xbus_t *xbus)
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 @@ void xbus_populate(void *data)
*/
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);
diff --git a/drivers/dahdi/xpp/xbus-core.h b/drivers/dahdi/xpp/xbus-core.h
index 67da031..270330e 100644
--- a/drivers/dahdi/xpp/xbus-core.h
+++ b/drivers/dahdi/xpp/xbus-core.h
@@ -343,6 +343,10 @@ int xpd_device_register(xbus_t *xbus, xpd_t *xpd);
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);
diff --git a/drivers/dahdi/xpp/xbus-sysfs.c b/drivers/dahdi/xpp/xbus-sysfs.c
index ccc1a01..31835bb 100644
--- a/drivers/dahdi/xpp/xbus-sysfs.c
+++ b/drivers/dahdi/xpp/xbus-sysfs.c
@@ -613,6 +613,48 @@ static DEVICE_ATTR_READER(span_show, dev, buf)
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 int xpd_match(struct device *dev, struct device_driver *driver)
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),