summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-11-29 23:38:30 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-11-29 23:38:30 +0000
commit42aa1a87b5c1f122557d2cf57bb3774515f151ff (patch)
tree7a449af61bd3e0f2cc29fce618a58e6480723234
parent4b9f62a79ff751696fa55b661f2cbf219d60d606 (diff)
xpp: PRI: restore pri_protocol to R/W:
Restores the pri_protocol attribute of the XPD node in SysFS to be writable. Fixes a minor regression from the pinned-spans fix, similar to r10334. * This attribute was made R/O in digium r10280 as part of the pinned-spans changes: - The E1/T1 settings were changed via new set_spantype() method which was called from dahdi when the 'spantype' dahdi attribute was written to. - This fails our init_card_4_* trying to write E1/T1 into our private attribute. * Restored our old code (with minor modifications) so we can set E1/T1 the old way (writing to our 'pri_protocol' attribute) as well as the new way (when it will be used eventually). Signed-off-by: Oron Peled <oron.peled@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10347 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--drivers/dahdi/xpp/card_pri.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c
index 358e3bc..677bd6b 100644
--- a/drivers/dahdi/xpp/card_pri.c
+++ b/drivers/dahdi/xpp/card_pri.c
@@ -2261,7 +2261,43 @@ static DEVICE_ATTR_READER(pri_protocol_show, dev, buf)
return len;
}
-static DEVICE_ATTR(pri_protocol, S_IRUGO, pri_protocol_show, NULL);
+static DEVICE_ATTR_WRITER(pri_protocol_store, dev, buf, count)
+{
+ xpd_t *xpd;
+ enum pri_protocol new_protocol = PRI_PROTO_0;
+ int i;
+ int ret;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ XPD_DBG(GENERAL, xpd, "%s\n", buf);
+ if (!xpd)
+ return -ENODEV;
+ i = strcspn(buf, " \r\n");
+ if (i != 2) {
+ XPD_NOTICE(xpd,
+ "Protocol name '%s' has %d characters (should be 2). Ignored.\n",
+ buf, i);
+ return -EINVAL;
+ }
+ if (strnicmp(buf, "E1", 2) == 0)
+ new_protocol = PRI_PROTO_E1;
+ else if (strnicmp(buf, "T1", 2) == 0)
+ new_protocol = PRI_PROTO_T1;
+ else if (strnicmp(buf, "J1", 2) == 0)
+ new_protocol = PRI_PROTO_J1;
+ else {
+ XPD_NOTICE(xpd,
+ "Unknown PRI protocol '%s' (should be E1|T1|J1). Ignored.\n",
+ buf);
+ return -EINVAL;
+ }
+ ret = set_pri_proto(xpd, new_protocol);
+ return (ret < 0) ? ret : count;
+}
+
+static DEVICE_ATTR(pri_protocol, S_IRUGO | S_IWUSR, pri_protocol_show,
+ pri_protocol_store);
static DEVICE_ATTR_READER(pri_localloop_show, dev, buf)
{