summaryrefslogtreecommitdiff
path: root/drivers/dahdi/xpp
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-05-23 12:20:23 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-05-23 12:20:23 +0000
commitfa1d3ba9465064f7a1551fe7369525d8b355861d (patch)
treee69ab4124842248fc84b8534dd05ebe90a091cfb /drivers/dahdi/xpp
parent45a4b3459991f23fc17240886d1435d67ff2e89c (diff)
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
Diffstat (limited to 'drivers/dahdi/xpp')
-rw-r--r--drivers/dahdi/xpp/card_bri.c5
-rw-r--r--drivers/dahdi/xpp/card_fxo.c2
-rw-r--r--drivers/dahdi/xpp/card_fxs.c2
-rw-r--r--drivers/dahdi/xpp/card_pri.c42
4 files changed, 34 insertions, 17 deletions
diff --git a/drivers/dahdi/xpp/card_bri.c b/drivers/dahdi/xpp/card_bri.c
index 92dd213..3ef9ddb 100644
--- a/drivers/dahdi/xpp/card_bri.c
+++ b/drivers/dahdi/xpp/card_bri.c
@@ -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 */
diff --git a/drivers/dahdi/xpp/card_fxo.c b/drivers/dahdi/xpp/card_fxo.c
index 5e83761..b578ad3 100644
--- a/drivers/dahdi/xpp/card_fxo.c
+++ b/drivers/dahdi/xpp/card_fxo.c
@@ -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);
diff --git a/drivers/dahdi/xpp/card_fxs.c b/drivers/dahdi/xpp/card_fxs.c
index e92c775..48fb27a 100644
--- a/drivers/dahdi/xpp/card_fxs.c
+++ b/drivers/dahdi/xpp/card_fxs.c
@@ -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);
diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c
index 0dbdecb..3630565 100644
--- a/drivers/dahdi/xpp/card_pri.c
+++ b/drivers/dahdi/xpp/card_pri.c
@@ -101,20 +101,20 @@ static const char *protocol_names[] = {
[PRI_PROTO_J1] = "J1"
};
-static const char *pri_protocol_name(enum pri_protocol pri_protocol)
+static enum spantypes pri_protocol2spantype(enum pri_protocol pri_protocol)
{
- return protocol_names[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 enum pri_protocol pri_protocol_bystr(const char *spantype)
+static const char *pri_protocol_name(enum pri_protocol pri_protocol)
{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(protocol_names); i++) {
- if (strcasecmp(protocol_names[i], spantype) == 0)
- return i;
- }
- return PRI_PROTO_0;
+ return protocol_names[pri_protocol];
}
static int pri_num_channels(enum pri_protocol pri_protocol)
@@ -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;