[dahdi-commits] tzafrir: linux/trunk r10684 - in /linux/trunk: drivers/dahdi/ include/dahdi/
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Wed May 23 07:36:00 CDT 2012
Author: tzafrir
Date: Wed May 23 07:35:56 2012
New Revision: 10684
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10684
Log:
sysfs: add a linecompat span attribute
This way, dahdi_genconf may gather needed information without issuing
ioctl()'s
Signed-off-by: Shaun Ruffell <sruffell at digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Modified:
linux/trunk/drivers/dahdi/dahdi-base.c
linux/trunk/drivers/dahdi/dahdi-sysfs.c
linux/trunk/include/dahdi/kernel.h
Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=10684&r1=10683&r2=10684
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Wed May 23 07:35:56 2012
@@ -748,6 +748,31 @@
};
}
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)
Modified: linux/trunk/drivers/dahdi/dahdi-sysfs.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-sysfs.c?view=diff&rev=10684&r1=10683&r2=10684
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-sysfs.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-sysfs.c Wed May 23 07:35:56 2012
@@ -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 @@
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 @@
__ATTR_RO(basechan),
__ATTR_RO(channels),
__ATTR_RO(lineconfig),
+ __ATTR_RO(linecompat),
__ATTR_NULL,
};
Modified: linux/trunk/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/include/dahdi/kernel.h?view=diff&rev=10684&r1=10683&r2=10684
==============================================================================
--- linux/trunk/include/dahdi/kernel.h (original)
+++ linux/trunk/include/dahdi/kernel.h Wed May 23 07:35:56 2012
@@ -806,6 +806,7 @@
};
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;
More information about the dahdi-commits
mailing list