summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-05-23 12:35:56 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-05-23 12:35:56 +0000
commit3359e84a8d937b96153af9b1d608b68f9c0a949b (patch)
tree94e4abf9a2d2c868310066800fc5fca1ad60f867
parentfa1d3ba9465064f7a1551fe7369525d8b355861d (diff)
sysfs: add a linecompat span attribute
This way, dahdi_genconf may gather needed information without issuing ioctl()'s Signed-off-by: Shaun Ruffell <sruffell@digium.com> Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10684 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--drivers/dahdi/dahdi-base.c25
-rw-r--r--drivers/dahdi/dahdi-sysfs.c23
-rw-r--r--include/dahdi/kernel.h1
3 files changed, 49 insertions, 0 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index eddd137..367b951 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -749,6 +749,31 @@ const char *dahdi_spantype2str(enum spantypes st)
}
EXPORT_SYMBOL(dahdi_spantype2str);
+
+const char *dahdi_lineconfig_bit_name(int lineconfig_bit)
+{
+ static const char * const table[] = {
+ /* These apply to T1 */
+ [4] = "D4",
+ [5] = "ESF",
+ [6] = "AMI",
+ [7] = "B8ZS",
+ /* These apply to E1 */
+ [8] = "CCS",
+ [9] = "HDB3",
+ [10] = "CRC4",
+ /* These apply to BRI */
+ [11] = "NTTE",
+ [12] = "TERM",
+ /* Finish */
+ [16] = "NOTOPEN",
+ };
+ if (lineconfig_bit < 0 || lineconfig_bit >= ARRAY_SIZE(table))
+ return NULL;
+ return table[lineconfig_bit];
+}
+EXPORT_SYMBOL(dahdi_lineconfig_bit_name);
+
#ifdef CONFIG_PROC_FS
static const char *sigstr(int sig)
{
diff --git a/drivers/dahdi/dahdi-sysfs.c b/drivers/dahdi/dahdi-sysfs.c
index 8bfbb9a..d7bf608 100644
--- a/drivers/dahdi/dahdi-sysfs.c
+++ b/drivers/dahdi/dahdi-sysfs.c
@@ -26,6 +26,7 @@
#include <dahdi/kernel.h>
#include <linux/device.h>
#include <linux/slab.h>
+#include <linux/ctype.h>
#include "dahdi.h"
#include "dahdi-sysfs.h"
@@ -201,6 +202,27 @@ static BUS_ATTR_READER(lineconfig_show, dev, buf)
return len;
}
+static BUS_ATTR_READER(linecompat_show, dev, buf)
+{
+ struct dahdi_span *span;
+ int bit;
+ int len = 0;
+
+ span = dev_to_span(dev);
+ for (bit = 4; bit <= 12; bit++) {
+ if (span->linecompat & (1 << bit)) {
+ const char *name = dahdi_lineconfig_bit_name(bit);
+ if (name)
+ len += sprintf(buf + len, "%s ", name);
+ }
+ }
+ /* chomp */
+ while (len > 0 && isspace(buf[len - 1]))
+ buf[--len] = '\0';
+ len += sprintf(buf + len, "\n");
+ return len;
+}
+
static struct device_attribute span_dev_attrs[] = {
__ATTR_RO(name),
__ATTR_RO(desc),
@@ -214,6 +236,7 @@ static struct device_attribute span_dev_attrs[] = {
__ATTR_RO(basechan),
__ATTR_RO(channels),
__ATTR_RO(lineconfig),
+ __ATTR_RO(linecompat),
__ATTR_NULL,
};
diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h
index d1f8631..08c1c41 100644
--- a/include/dahdi/kernel.h
+++ b/include/dahdi/kernel.h
@@ -806,6 +806,7 @@ enum spantypes {
};
const char *dahdi_spantype2str(enum spantypes st);
enum spantypes dahdi_str2spantype(const char *name);
+const char *dahdi_lineconfig_bit_name(int lineconfig_bit);
struct file;