[svn-commits] tzafrir: linux/trunk r10685 - in /linux/trunk: drivers/dahdi/ include/dahdi/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed May 23 07:36:46 CDT 2012
Author: tzafrir
Date: Wed May 23 07:36:42 2012
New Revision: 10685
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10685
Log:
sysfs: refactor lineconfig string representation
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=10685&r1=10684&r2=10685
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Wed May 23 07:36:42 2012
@@ -773,6 +773,48 @@
return table[lineconfig_bit];
}
EXPORT_SYMBOL(dahdi_lineconfig_bit_name);
+
+ssize_t lineconfig_str(int lineconfig, char buf[], size_t size)
+{
+ int framing_bit = 0;
+ int coding_bit = 0;
+ int crc4_bit = 0;
+ int len = 0;
+ int bit;
+
+ for (bit = 4; bit <= 12; bit++) {
+ int mask = (1 << bit);
+ if (!(lineconfig & mask))
+ continue;
+ if (!framing_bit) {
+ switch (mask) {
+ case DAHDI_CONFIG_B8ZS:
+ case DAHDI_CONFIG_AMI:
+ case DAHDI_CONFIG_HDB3:
+ framing_bit = bit;
+ len += snprintf(buf + len, size, "%s/",
+ dahdi_lineconfig_bit_name(bit));
+ }
+ }
+ if (!coding_bit) {
+ switch (mask) {
+ case DAHDI_CONFIG_ESF:
+ case DAHDI_CONFIG_D4:
+ case DAHDI_CONFIG_CCS:
+ coding_bit = bit;
+ len += snprintf(buf + len, size, "%s",
+ dahdi_lineconfig_bit_name(bit));
+ }
+ }
+ if (!crc4_bit && mask == DAHDI_CONFIG_CRC4) {
+ crc4_bit = bit;
+ len += snprintf(buf + len, size, "/%s",
+ dahdi_lineconfig_bit_name(bit));
+ }
+ }
+ return len;
+}
+EXPORT_SYMBOL(lineconfig_str);
#ifdef CONFIG_PROC_FS
static const char *sigstr(int sig)
@@ -873,23 +915,9 @@
seq_printf(sfile, " (MASTER)");
if (s->lineconfig) {
- /* framing first */
- if (s->lineconfig & DAHDI_CONFIG_B8ZS)
- seq_printf(sfile, " B8ZS/");
- else if (s->lineconfig & DAHDI_CONFIG_AMI)
- seq_printf(sfile, " AMI/");
- else if (s->lineconfig & DAHDI_CONFIG_HDB3)
- seq_printf(sfile, " HDB3/");
- /* then coding */
- if (s->lineconfig & DAHDI_CONFIG_ESF)
- seq_printf(sfile, "ESF");
- else if (s->lineconfig & DAHDI_CONFIG_D4)
- seq_printf(sfile, "D4");
- else if (s->lineconfig & DAHDI_CONFIG_CCS)
- seq_printf(sfile, "CCS");
- /* E1's can enable CRC checking */
- if (s->lineconfig & DAHDI_CONFIG_CRC4)
- seq_printf(sfile, "/CRC4");
+ char tmpbuf[20];
+ lineconfig_str(s->lineconfig, tmpbuf, sizeof(tmpbuf));
+ seq_printf(sfile, " %s", tmpbuf);
}
seq_printf(sfile, " ");
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=10685&r1=10684&r2=10685
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-sysfs.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-sysfs.c Wed May 23 07:36:42 2012
@@ -179,25 +179,7 @@
int len = 0;
span = dev_to_span(dev);
- if (span->lineconfig) {
- /* framing first */
- if (span->lineconfig & DAHDI_CONFIG_B8ZS)
- len += sprintf(buf + len, "B8ZS/");
- else if (span->lineconfig & DAHDI_CONFIG_AMI)
- len += sprintf(buf + len, "AMI/");
- else if (span->lineconfig & DAHDI_CONFIG_HDB3)
- len += sprintf(buf + len, "HDB3/");
- /* then coding */
- if (span->lineconfig & DAHDI_CONFIG_ESF)
- len += sprintf(buf + len, "ESF");
- else if (span->lineconfig & DAHDI_CONFIG_D4)
- len += sprintf(buf + len, "D4");
- else if (span->lineconfig & DAHDI_CONFIG_CCS)
- len += sprintf(buf + len, "CCS");
- /* E1's can enable CRC checking */
- if (span->lineconfig & DAHDI_CONFIG_CRC4)
- len += sprintf(buf + len, "/CRC4");
- }
+ len += lineconfig_str(span->lineconfig, buf, 20);
len += sprintf(buf + len, "\n");
return len;
}
Modified: linux/trunk/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/include/dahdi/kernel.h?view=diff&rev=10685&r1=10684&r2=10685
==============================================================================
--- linux/trunk/include/dahdi/kernel.h (original)
+++ linux/trunk/include/dahdi/kernel.h Wed May 23 07:36:42 2012
@@ -807,6 +807,7 @@
const char *dahdi_spantype2str(enum spantypes st);
enum spantypes dahdi_str2spantype(const char *name);
const char *dahdi_lineconfig_bit_name(int lineconfig_bit);
+ssize_t lineconfig_str(int lineconfig, char buf[], size_t size);
struct file;
More information about the svn-commits
mailing list