summaryrefslogtreecommitdiff
path: root/drivers/dahdi/xpp/xbus-sysfs.c
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 /drivers/dahdi/xpp/xbus-sysfs.c
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
Diffstat (limited to 'drivers/dahdi/xpp/xbus-sysfs.c')
-rw-r--r--drivers/dahdi/xpp/xbus-sysfs.c44
1 files changed, 43 insertions, 1 deletions
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),