summaryrefslogtreecommitdiff
path: root/drivers/dahdi/xpp/card_pri.c
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/card_pri.c
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/card_pri.c')
-rw-r--r--drivers/dahdi/xpp/card_pri.c42
1 files changed, 28 insertions, 14 deletions
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;