summaryrefslogtreecommitdiff
path: root/drivers/dahdi/xpp/xbus-core.c
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2010-07-13 17:25:06 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2010-07-13 17:25:06 +0000
commitdfa545814b61b3e1d527e842dd883b153277c4b4 (patch)
tree1d44d19b37b1337e0bda53255c5c3a7f363d42f1 /drivers/dahdi/xpp/xbus-core.c
parent624e11908da4c775717011a31bad086d2c268d2d (diff)
prevent handling of duplicate Astribanks
Don't let AB which are unplugged/replugged create duplicate XBUS's (if asterisk don't close the original channels). git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@8905 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/xpp/xbus-core.c')
-rw-r--r--drivers/dahdi/xpp/xbus-core.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c
index 2d2ecb4..3acf2d9 100644
--- a/drivers/dahdi/xpp/xbus-core.c
+++ b/drivers/dahdi/xpp/xbus-core.c
@@ -87,6 +87,42 @@ static struct xbus_desc {
xbus_t *xbus;
} xbuses_array[MAX_BUSES];
+static xbus_t *xbus_byhwid(const char *hwid)
+{
+ int i;
+ xbus_t *xbus;
+
+ for (i = 0; i < ARRAY_SIZE(xbuses_array); i++) {
+ xbus = xbuses_array[i].xbus;
+ if (xbus && strcmp(hwid, xbus->label) == 0)
+ return xbus;
+ }
+ return NULL;
+}
+
+int xbus_check_unique(xbus_t *xbus)
+{
+ if (!xbus)
+ return -ENOENT;
+ if (xbus->label) {
+ xbus_t *xbus_old;
+
+ XBUS_DBG(DEVICES, xbus, "Checking LABEL='%s'\n", xbus->label);
+ xbus_old = xbus_byhwid(xbus->label);
+ if (xbus_old && xbus_old != xbus) {
+ XBUS_NOTICE(xbus_old,
+ "Duplicate LABEL='%s'. Leave %s unused. refcount_xbus=%d\n",
+ xbus_old->label,
+ xbus->busname,
+ refcount_xbus(xbus_old));
+ return -EBUSY;
+ }
+ } else {
+ XBUS_NOTICE(xbus, "MISSING BOARD LABEL!!!\n");
+ }
+ return 0;
+}
+
const char *xbus_statename(enum xbus_state st)
{
switch(st) {