convert span->spantype to enumerated type
* This is a minimal convertion -- everything compiles and looks OK. * We print a warning for spans registering without a spantype. * Low-level drivers may later want (but not required) to fold their internal representations to this canonical representation -- it will save code and make it more readable. 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@10683 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
parent
b7081c2b45
commit
579132bb89
|
@ -706,6 +706,49 @@ static int dahdi_q_sig(struct dahdi_chan *chan)
|
|||
return -1; /* not found -- error */
|
||||
}
|
||||
|
||||
enum spantypes dahdi_str2spantype(const char *name)
|
||||
{
|
||||
if (strcasecmp("FXS", name) == 0)
|
||||
return SPANTYPE_ANALOG_FXS;
|
||||
else if (strcasecmp("FXO", name) == 0)
|
||||
return SPANTYPE_ANALOG_FXO;
|
||||
else if (strcasecmp("ANALOG_MIXED", name) == 0)
|
||||
return SPANTYPE_ANALOG_MIXED;
|
||||
else if (strcasecmp("E1", name) == 0)
|
||||
return SPANTYPE_DIGITAL_E1;
|
||||
else if (strcasecmp("T1", name) == 0)
|
||||
return SPANTYPE_DIGITAL_T1;
|
||||
else if (strcasecmp("J1", name) == 0)
|
||||
return SPANTYPE_DIGITAL_J1;
|
||||
else if (strcasecmp("BRI_NT", name) == 0)
|
||||
return SPANTYPE_DIGITAL_BRI_NT;
|
||||
else if (strcasecmp("BRI_TE", name) == 0)
|
||||
return SPANTYPE_DIGITAL_BRI_TE;
|
||||
else if (strcasecmp("BRI_SOFT", name) == 0)
|
||||
return SPANTYPE_DIGITAL_BRI_SOFT;
|
||||
else
|
||||
return SPANTYPE_INVALID;
|
||||
}
|
||||
EXPORT_SYMBOL(dahdi_str2spantype);
|
||||
|
||||
const char *dahdi_spantype2str(enum spantypes st)
|
||||
{
|
||||
switch (st) {
|
||||
case SPANTYPE_ANALOG_FXS: return "FXS";
|
||||
case SPANTYPE_ANALOG_FXO: return "FXO";
|
||||
case SPANTYPE_ANALOG_MIXED: return "ANALOG_MIXED";
|
||||
case SPANTYPE_DIGITAL_E1: return "E1";
|
||||
case SPANTYPE_DIGITAL_T1: return "T1";
|
||||
case SPANTYPE_DIGITAL_J1: return "J1";
|
||||
case SPANTYPE_DIGITAL_BRI_NT: return "BRI_NT";
|
||||
case SPANTYPE_DIGITAL_BRI_TE: return "BRI_TE";
|
||||
case SPANTYPE_DIGITAL_BRI_SOFT: return "BRI_SOFT";
|
||||
default:
|
||||
case SPANTYPE_INVALID: return "INVALID";
|
||||
};
|
||||
}
|
||||
EXPORT_SYMBOL(dahdi_spantype2str);
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
static const char *sigstr(int sig)
|
||||
{
|
||||
|
@ -4265,7 +4308,7 @@ static int dahdi_ioctl_spanstat(struct file *file, unsigned long data)
|
|||
sizeof(spaninfo.location));
|
||||
}
|
||||
if (s->spantype) {
|
||||
strlcpy(spaninfo.spantype, s->spantype,
|
||||
strlcpy(spaninfo.spantype, dahdi_spantype2str(s->spantype),
|
||||
sizeof(spaninfo.spantype));
|
||||
}
|
||||
|
||||
|
@ -4356,7 +4399,7 @@ static int dahdi_ioctl_spanstat_v1(struct file *file, unsigned long data)
|
|||
|
||||
if (s->spantype) {
|
||||
strlcpy(spaninfo_v1.spantype,
|
||||
s->spantype,
|
||||
dahdi_spantype2str(s->spantype),
|
||||
sizeof(spaninfo_v1.spantype));
|
||||
}
|
||||
|
||||
|
@ -6829,6 +6872,11 @@ static void __dahdi_init_span(struct dahdi_span *span)
|
|||
span->name);
|
||||
span->deflaw = DAHDI_LAW_MULAW;
|
||||
}
|
||||
if (span->spantype == SPANTYPE_INVALID) {
|
||||
module_printk(KERN_NOTICE,
|
||||
"Warning: Span %s didn't specify a spantype. "
|
||||
"Please fix driver!\n", span->name);
|
||||
}
|
||||
|
||||
for (x = 0; x < span->channels; ++x) {
|
||||
span->chans[x]->span = span;
|
||||
|
|
|
@ -118,11 +118,18 @@ static BUS_ATTR_READER(field##_show, dev, buf) \
|
|||
|
||||
span_attr(name, "%s\n");
|
||||
span_attr(desc, "%s\n");
|
||||
span_attr(spantype, "%s\n");
|
||||
span_attr(alarms, "0x%x\n");
|
||||
span_attr(lbo, "%d\n");
|
||||
span_attr(syncsrc, "%d\n");
|
||||
|
||||
static BUS_ATTR_READER(spantype_show, dev, buf)
|
||||
{
|
||||
struct dahdi_span *span;
|
||||
|
||||
span = dev_to_span(dev);
|
||||
return sprintf(buf, "%s\n", dahdi_spantype2str(span->spantype));
|
||||
}
|
||||
|
||||
static BUS_ATTR_READER(local_spanno_show, dev, buf)
|
||||
{
|
||||
struct dahdi_span *span;
|
||||
|
@ -474,7 +481,7 @@ dahdi_spantype_show(struct device *dev,
|
|||
/* TODO: Make sure this doesn't overflow the page. */
|
||||
list_for_each_entry(span, &ddev->spans, device_node) {
|
||||
count = sprintf(buf, "%d:%s\n",
|
||||
local_spanno(span), span->spantype);
|
||||
local_spanno(span), dahdi_spantype2str(span->spantype));
|
||||
buf += count;
|
||||
total += count;
|
||||
}
|
||||
|
@ -490,11 +497,19 @@ dahdi_spantype_store(struct device *dev, struct device_attribute *attr,
|
|||
int ret;
|
||||
struct dahdi_span *span;
|
||||
unsigned int local_span_number;
|
||||
char desired_spantype[80];
|
||||
char spantype_name[80];
|
||||
enum spantypes spantype;
|
||||
|
||||
ret = sscanf(buf, "%u:%70s", &local_span_number, desired_spantype);
|
||||
if (ret != 2)
|
||||
ret = sscanf(buf, "%u:%70s", &local_span_number, spantype_name);
|
||||
if (ret != 2) {
|
||||
dev_err(&ddev->dev, "Wrong input format: '%s'\n", buf);
|
||||
return -EINVAL;
|
||||
}
|
||||
spantype = dahdi_str2spantype(spantype_name);
|
||||
if (spantype == SPANTYPE_INVALID) {
|
||||
dev_err(&ddev->dev, "Invalid spantype: '%s'\n", buf);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
list_for_each_entry(span, &ddev->spans, device_node) {
|
||||
if (local_spanno(span) == local_span_number)
|
||||
|
@ -520,7 +535,7 @@ dahdi_spantype_store(struct device *dev, struct device_attribute *attr,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = span->ops->set_spantype(span, &desired_spantype[0]);
|
||||
ret = span->ops->set_spantype(span, spantype);
|
||||
return (ret < 0) ? ret : count;
|
||||
}
|
||||
|
||||
|
|
|
@ -290,12 +290,12 @@ static void init_spans(struct tor2 *tor)
|
|||
s->channels = 24;
|
||||
s->deflaw = DAHDI_LAW_MULAW;
|
||||
s->linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_B8ZS | DAHDI_CONFIG_D4 | DAHDI_CONFIG_ESF;
|
||||
s->spantype = "T1";
|
||||
s->spantype = SPANTYPE_DIGITAL_T1;
|
||||
} else {
|
||||
s->channels = 31;
|
||||
s->deflaw = DAHDI_LAW_ALAW;
|
||||
s->linecompat = DAHDI_CONFIG_HDB3 | DAHDI_CONFIG_CCS | DAHDI_CONFIG_CRC4;
|
||||
s->spantype = "E1";
|
||||
s->spantype = SPANTYPE_DIGITAL_E1;
|
||||
}
|
||||
s->chans = tor->chans[x];
|
||||
s->flags = DAHDI_FLAG_RBS;
|
||||
|
|
|
@ -2505,7 +2505,9 @@ static void init_spans(struct b4xxp *b4)
|
|||
bspan = &b4->spans[i];
|
||||
bspan->parent = b4;
|
||||
|
||||
bspan->span.spantype = (bspan->te_mode) ? "TE" : "NT";
|
||||
bspan->span.spantype = (bspan->te_mode)
|
||||
? SPANTYPE_DIGITAL_BRI_TE
|
||||
: SPANTYPE_DIGITAL_BRI_NT;
|
||||
bspan->span.offset = i;
|
||||
bspan->span.channels = WCB4XXP_CHANNELS_PER_SPAN;
|
||||
bspan->span.flags = 0;
|
||||
|
|
|
@ -792,12 +792,12 @@ static int t1xxp_software_init(struct t1xxp *wc)
|
|||
wc->span.channels = 31;
|
||||
wc->span.deflaw = DAHDI_LAW_ALAW;
|
||||
wc->span.linecompat = DAHDI_CONFIG_HDB3 | DAHDI_CONFIG_CCS | DAHDI_CONFIG_CRC4;
|
||||
wc->span.spantype = "E1";
|
||||
wc->span.spantype = SPANTYPE_DIGITAL_E1;
|
||||
} else {
|
||||
wc->span.channels = 24;
|
||||
wc->span.deflaw = DAHDI_LAW_MULAW;
|
||||
wc->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_B8ZS | DAHDI_CONFIG_D4 | DAHDI_CONFIG_ESF;
|
||||
wc->span.spantype = "T1";
|
||||
wc->span.spantype = SPANTYPE_DIGITAL_T1;
|
||||
}
|
||||
for (x=0;x<wc->span.channels;x++) {
|
||||
sprintf(wc->chans[x]->name, "WCT1/%d/%d", wc->num, x + 1);
|
||||
|
|
|
@ -2130,13 +2130,13 @@ static void t4_init_one_span(struct t4 *wc, struct t4_span *ts)
|
|||
|
||||
switch (ts->linemode) {
|
||||
case T1:
|
||||
ts->span.spantype = "T1";
|
||||
ts->span.spantype = SPANTYPE_DIGITAL_T1;
|
||||
break;
|
||||
case E1:
|
||||
ts->span.spantype = "E1";
|
||||
ts->span.spantype = SPANTYPE_DIGITAL_E1;
|
||||
break;
|
||||
case J1:
|
||||
ts->span.spantype = "J1";
|
||||
ts->span.spantype = SPANTYPE_DIGITAL_J1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2185,40 +2185,47 @@ static void t4_init_one_span(struct t4 *wc, struct t4_span *ts)
|
|||
/**
|
||||
* t4_set_linemode - Allows user space to change the linemode before spans are assigned.
|
||||
* @span: span on which to change the linemode.
|
||||
* @linemode: Textual description of the new linemode.
|
||||
* @linemode: A value from enumerated spantypes
|
||||
*
|
||||
* This callback is used to override the E1/T1 mode jumper settings and set
|
||||
* the linemode on for each span. Called when the "spantype" attribute
|
||||
* is written in sysfs under the dahdi_device.
|
||||
*
|
||||
*/
|
||||
static int t4_set_linemode(struct dahdi_span *span, const char *linemode)
|
||||
static int t4_set_linemode(struct dahdi_span *span, enum spantypes linemode)
|
||||
{
|
||||
struct t4_span *ts = container_of(span, struct t4_span, span);
|
||||
struct t4 *wc = ts->owner;
|
||||
int res = 0;
|
||||
enum linemode mode;
|
||||
const char *old_name;
|
||||
|
||||
dev_dbg(&wc->dev->dev, "Setting '%s' to '%s'\n", span->name, linemode);
|
||||
dev_dbg(&wc->dev->dev, "Setting '%s' to '%s'\n", span->name,
|
||||
dahdi_spantype2str(linemode));
|
||||
|
||||
if (!strcasecmp(span->spantype, linemode))
|
||||
if (span->spantype == linemode)
|
||||
return 0;
|
||||
|
||||
if (!strcasecmp(linemode, "t1")) {
|
||||
old_name = dahdi_spantype2str(span->spantype);
|
||||
switch (linemode) {
|
||||
case SPANTYPE_DIGITAL_T1:
|
||||
dev_info(&wc->dev->dev,
|
||||
"Changing from %s to T1 line mode.\n", span->spantype);
|
||||
"Changing from %s to T1 line mode.\n", old_name);
|
||||
mode = T1;
|
||||
} else if (!strcasecmp(linemode, "e1")) {
|
||||
break;
|
||||
case SPANTYPE_DIGITAL_E1:
|
||||
dev_info(&wc->dev->dev,
|
||||
"Changing from %s to E1 line mode.\n", span->spantype);
|
||||
"Changing from %s to E1 line mode.\n", old_name);
|
||||
mode = E1;
|
||||
} else if (!strcasecmp(linemode, "j1")) {
|
||||
break;
|
||||
case SPANTYPE_DIGITAL_J1:
|
||||
dev_info(&wc->dev->dev,
|
||||
"Changing from %s to J1 line mode.\n", span->spantype);
|
||||
"Changing from %s to J1 line mode.\n", old_name);
|
||||
mode = J1;
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
dev_err(&wc->dev->dev,
|
||||
"'%s' is an unknown linemode.\n", linemode);
|
||||
"Got invalid linemode %d from dahdi\n", linemode);
|
||||
res = -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -2295,13 +2302,13 @@ static void init_spans(struct t4 *wc)
|
|||
"T%dXXP (PCI) Card %d Span %d", wc->numspans, wc->num, x+1);
|
||||
switch (ts->linemode) {
|
||||
case T1:
|
||||
ts->span.spantype = "T1";
|
||||
ts->span.spantype = SPANTYPE_DIGITAL_T1;
|
||||
break;
|
||||
case E1:
|
||||
ts->span.spantype = "E1";
|
||||
ts->span.spantype = SPANTYPE_DIGITAL_E1;
|
||||
break;
|
||||
case J1:
|
||||
ts->span.spantype = "J1";
|
||||
ts->span.spantype = SPANTYPE_DIGITAL_J1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -4520,7 +4520,7 @@ wctdm_init_span(struct wctdm *wc, int spanno, int chanoffset, int chancount,
|
|||
s->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_B8ZS | DAHDI_CONFIG_D4;
|
||||
s->span.linecompat |= DAHDI_CONFIG_ESF | DAHDI_CONFIG_HDB3 | DAHDI_CONFIG_CCS | DAHDI_CONFIG_CRC4;
|
||||
s->span.linecompat |= DAHDI_CONFIG_NTTE | DAHDI_CONFIG_TERM;
|
||||
s->span.spantype = "TE";
|
||||
s->span.spantype = SPANTYPE_DIGITAL_BRI_TE;
|
||||
} else {
|
||||
s->span.ops = &wctdm24xxp_analog_span_ops;
|
||||
s->span.flags = DAHDI_FLAG_RBS;
|
||||
|
|
|
@ -2150,7 +2150,9 @@ static int b400m_set_ntte(struct b400m_span *bspan, int te_mode, int term_on)
|
|||
int all_modes = 0, all_terms = 0;
|
||||
int i;
|
||||
|
||||
bspan->wspan->span.spantype = (te_mode > 0) ? "TE" : "NT";
|
||||
bspan->wspan->span.spantype = (te_mode > 0)
|
||||
? SPANTYPE_DIGITAL_BRI_TE
|
||||
: SPANTYPE_DIGITAL_BRI_NT;
|
||||
|
||||
bspan->te_mode = te_mode;
|
||||
bspan->term_on = term_on;
|
||||
|
|
|
@ -1000,12 +1000,12 @@ static int t1xxp_software_init(struct t1 *wc)
|
|||
else
|
||||
wc->span.channels = 31;
|
||||
wc->span.deflaw = DAHDI_LAW_ALAW;
|
||||
wc->span.spantype = "E1";
|
||||
wc->span.spantype = SPANTYPE_DIGITAL_E1;
|
||||
wc->span.linecompat = DAHDI_CONFIG_HDB3 | DAHDI_CONFIG_CCS | DAHDI_CONFIG_CRC4;
|
||||
} else {
|
||||
wc->span.channels = 24;
|
||||
wc->span.deflaw = DAHDI_LAW_MULAW;
|
||||
wc->span.spantype = "T1";
|
||||
wc->span.spantype = SPANTYPE_DIGITAL_T1;
|
||||
wc->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_B8ZS | DAHDI_CONFIG_D4 | DAHDI_CONFIG_ESF;
|
||||
}
|
||||
wc->span.chans = wc->chans;
|
||||
|
|
|
@ -1848,13 +1848,13 @@ static int t1_software_init(struct t1 *wc, enum linemode type)
|
|||
|
||||
if (type == E1) {
|
||||
wc->span.channels = 31;
|
||||
wc->span.spantype = "E1";
|
||||
wc->span.spantype = SPANTYPE_DIGITAL_E1;
|
||||
wc->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_HDB3 |
|
||||
DAHDI_CONFIG_CCS | DAHDI_CONFIG_CRC4;
|
||||
wc->span.deflaw = DAHDI_LAW_ALAW;
|
||||
} else {
|
||||
wc->span.channels = 24;
|
||||
wc->span.spantype = "T1";
|
||||
wc->span.spantype = SPANTYPE_DIGITAL_T1;
|
||||
wc->span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_B8ZS |
|
||||
DAHDI_CONFIG_D4 | DAHDI_CONFIG_ESF;
|
||||
wc->span.deflaw = DAHDI_LAW_MULAW;
|
||||
|
@ -1900,13 +1900,13 @@ error_exit:
|
|||
* DAHDI).
|
||||
*
|
||||
*/
|
||||
static int t1xxp_set_linemode(struct dahdi_span *span, const char *linemode)
|
||||
static int t1xxp_set_linemode(struct dahdi_span *span, enum spantypes linemode)
|
||||
{
|
||||
int res;
|
||||
struct t1 *wc = container_of(span, struct t1, span);
|
||||
|
||||
/* We may already be set to the requested type. */
|
||||
if (!strcasecmp(span->spantype, linemode))
|
||||
if (span->spantype == linemode)
|
||||
return 0;
|
||||
|
||||
res = t1_wait_for_ready(wc);
|
||||
|
@ -1920,17 +1920,20 @@ static int t1xxp_set_linemode(struct dahdi_span *span, const char *linemode)
|
|||
del_timer_sync(&wc->timer);
|
||||
flush_workqueue(wc->wq);
|
||||
|
||||
if (!strcasecmp(linemode, "t1")) {
|
||||
switch (linemode) {
|
||||
case SPANTYPE_DIGITAL_T1:
|
||||
dev_info(&wc->vb.pdev->dev,
|
||||
"Changing from E1 to T1 line mode.\n");
|
||||
res = t1_software_init(wc, T1);
|
||||
} else if (!strcasecmp(linemode, "e1")) {
|
||||
break;
|
||||
case SPANTYPE_DIGITAL_E1:
|
||||
dev_info(&wc->vb.pdev->dev,
|
||||
"Changing from T1 to E1 line mode.\n");
|
||||
res = t1_software_init(wc, E1);
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
dev_err(&wc->vb.pdev->dev,
|
||||
"'%s' is an unknown linemode.\n", linemode);
|
||||
"Got invalid linemode %d from dahdi\n", linemode);
|
||||
res = -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -793,7 +793,10 @@ static int BRI_card_dahdi_preregistration(xpd_t *xpd, bool on)
|
|||
/* Nothing to do yet */
|
||||
return 0;
|
||||
}
|
||||
PHONEDEV(xpd).span.spantype = "BRI";
|
||||
PHONEDEV(xpd).span.spantype =
|
||||
(PHONEDEV(xpd).direction == TO_PHONE)
|
||||
? SPANTYPE_DIGITAL_BRI_NT
|
||||
: SPANTYPE_DIGITAL_BRI_TE;
|
||||
PHONEDEV(xpd).span.linecompat = DAHDI_CONFIG_AMI | DAHDI_CONFIG_CCS;
|
||||
PHONEDEV(xpd).span.deflaw = DAHDI_LAW_ALAW;
|
||||
BIT_SET(PHONEDEV(xpd).digital_signalling, 2); /* D-Channel */
|
||||
|
|
|
@ -554,7 +554,7 @@ static int FXO_card_dahdi_preregistration(xpd_t *xpd, bool on)
|
|||
BUG_ON(!priv);
|
||||
timer_count = xpd->timer_count;
|
||||
XPD_DBG(GENERAL, xpd, "%s\n", (on) ? "ON" : "OFF");
|
||||
PHONEDEV(xpd).span.spantype = "FXO";
|
||||
PHONEDEV(xpd).span.spantype = SPANTYPE_ANALOG_FXO;
|
||||
for_each_line(xpd, i) {
|
||||
struct dahdi_chan *cur_chan = XPD_CHAN(xpd, i);
|
||||
|
||||
|
|
|
@ -586,7 +586,7 @@ static int FXS_card_dahdi_preregistration(xpd_t *xpd, bool on)
|
|||
priv = xpd->priv;
|
||||
BUG_ON(!priv);
|
||||
XPD_DBG(GENERAL, xpd, "%s\n", (on) ? "on" : "off");
|
||||
PHONEDEV(xpd).span.spantype = "FXS";
|
||||
PHONEDEV(xpd).span.spantype = SPANTYPE_ANALOG_FXS;
|
||||
for_each_line(xpd, i) {
|
||||
struct dahdi_chan *cur_chan = XPD_CHAN(xpd, i);
|
||||
|
||||
|
|
|
@ -101,22 +101,22 @@ static const char *protocol_names[] = {
|
|||
[PRI_PROTO_J1] = "J1"
|
||||
};
|
||||
|
||||
static enum spantypes pri_protocol2spantype(enum pri_protocol pri_protocol)
|
||||
{
|
||||
switch (pri_protocol) {
|
||||
case PRI_PROTO_E1: return SPANTYPE_DIGITAL_E1;
|
||||
case PRI_PROTO_T1: return SPANTYPE_DIGITAL_T1;
|
||||
case PRI_PROTO_J1: return SPANTYPE_DIGITAL_J1;
|
||||
default:
|
||||
return SPANTYPE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
static const char *pri_protocol_name(enum pri_protocol pri_protocol)
|
||||
{
|
||||
return protocol_names[pri_protocol];
|
||||
}
|
||||
|
||||
static enum pri_protocol pri_protocol_bystr(const char *spantype)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(protocol_names); i++) {
|
||||
if (strcasecmp(protocol_names[i], spantype) == 0)
|
||||
return i;
|
||||
}
|
||||
return PRI_PROTO_0;
|
||||
}
|
||||
|
||||
static int pri_num_channels(enum pri_protocol pri_protocol)
|
||||
{
|
||||
static int num_channels[] = {
|
||||
|
@ -1077,14 +1077,28 @@ bad_lineconfig:
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int pri_set_spantype(struct dahdi_span *span, const char *spantype)
|
||||
static int pri_set_spantype(struct dahdi_span *span, enum spantypes spantype)
|
||||
{
|
||||
struct phonedev *phonedev = container_of(span, struct phonedev, span);
|
||||
xpd_t *xpd = container_of(phonedev, struct xpd, phonedev);
|
||||
enum pri_protocol set_proto = PRI_PROTO_0;
|
||||
|
||||
XPD_INFO(xpd, "%s: %s\n", __func__, spantype);
|
||||
set_proto = pri_protocol_bystr(spantype);
|
||||
XPD_INFO(xpd, "%s: %s\n", __func__, dahdi_spantype2str(spantype));
|
||||
switch (spantype) {
|
||||
case SPANTYPE_DIGITAL_E1:
|
||||
set_proto = PRI_PROTO_E1;
|
||||
break;
|
||||
case SPANTYPE_DIGITAL_T1:
|
||||
set_proto = PRI_PROTO_T1;
|
||||
break;
|
||||
case SPANTYPE_DIGITAL_J1:
|
||||
set_proto = PRI_PROTO_J1;
|
||||
break;
|
||||
default:
|
||||
XPD_NOTICE(xpd, "%s: bad spantype '%s'\n",
|
||||
__func__, dahdi_spantype2str(spantype));
|
||||
return -EINVAL;
|
||||
}
|
||||
return set_pri_proto(xpd, set_proto);
|
||||
}
|
||||
|
||||
|
@ -1361,7 +1375,7 @@ static int apply_pri_protocol(xpd_t *xpd)
|
|||
priv = xpd->priv;
|
||||
BUG_ON(!xbus);
|
||||
XPD_DBG(GENERAL, xpd, "\n");
|
||||
PHONEDEV(xpd).span.spantype = pri_protocol_name(priv->pri_protocol);
|
||||
PHONEDEV(xpd).span.spantype = pri_protocol2spantype(priv->pri_protocol);
|
||||
PHONEDEV(xpd).span.linecompat = pri_linecompat(priv->pri_protocol);
|
||||
PHONEDEV(xpd).span.deflaw = priv->deflaw;
|
||||
PHONEDEV(xpd).span.alarms = DAHDI_ALARM_NONE;
|
||||
|
|
|
@ -792,6 +792,21 @@ struct dahdi_count {
|
|||
#define DAHDI_FLAG_TXUNDERRUN DAHDI_FLAG(TXUNDERRUN)
|
||||
#define DAHDI_FLAG_RXOVERRUN DAHDI_FLAG(RXOVERRUN)
|
||||
|
||||
enum spantypes {
|
||||
SPANTYPE_INVALID = 0,
|
||||
SPANTYPE_ANALOG_FXS,
|
||||
SPANTYPE_ANALOG_FXO,
|
||||
SPANTYPE_ANALOG_MIXED,
|
||||
SPANTYPE_DIGITAL_E1,
|
||||
SPANTYPE_DIGITAL_T1,
|
||||
SPANTYPE_DIGITAL_J1,
|
||||
SPANTYPE_DIGITAL_BRI_NT,
|
||||
SPANTYPE_DIGITAL_BRI_TE,
|
||||
SPANTYPE_DIGITAL_BRI_SOFT,
|
||||
};
|
||||
const char *dahdi_spantype2str(enum spantypes st);
|
||||
enum spantypes dahdi_str2spantype(const char *name);
|
||||
|
||||
struct file;
|
||||
|
||||
struct dahdi_span_ops {
|
||||
|
@ -890,7 +905,7 @@ struct dahdi_span_ops {
|
|||
|
||||
/*! Called when the spantype / linemode is changed before the span is
|
||||
* assigned a number. */
|
||||
int (*set_spantype)(struct dahdi_span *span, const char *spantype);
|
||||
int (*set_spantype)(struct dahdi_span *span, enum spantypes st);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -921,7 +936,7 @@ struct dahdi_span {
|
|||
spinlock_t lock;
|
||||
char name[40]; /*!< Span name */
|
||||
char desc[80]; /*!< Span description */
|
||||
const char *spantype; /*!< span type in text form */
|
||||
enum spantypes spantype; /*!< span type */
|
||||
int deflaw; /*!< Default law (DAHDI_MULAW or DAHDI_ALAW) */
|
||||
int alarms; /*!< Pending alarms on span */
|
||||
unsigned long flags;
|
||||
|
|
Loading…
Reference in New Issue