From 42aa1a87b5c1f122557d2cf57bb3774515f151ff Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Tue, 29 Nov 2011 23:38:30 +0000 Subject: 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 git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10347 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/xpp/card_pri.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) 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) { -- cgit v1.2.3