summaryrefslogtreecommitdiff
path: root/drivers/dahdi/wct4xxp
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2011-07-01 15:45:14 +0000
committerShaun Ruffell <sruffell@digium.com>2011-07-01 15:45:14 +0000
commit45ac17696e044a6ece9bf6633b9f0d1177ae4d50 (patch)
tree1a555785f7d45b9453a6617e9681f9db97f2efdb /drivers/dahdi/wct4xxp
parentc0152d150a3a9768b26e2962be932b9017886b1c (diff)
wct4xxp: Add module parameter to ignore rotary switch settings.
The dual and quad span cards have a rotary switch onboard which controls the order that cards serviced by this driver are registered with the core of DAHDI. This commit adds a module parameter 'ignore_rotary' which, when set to 1, causes the driver to ignore the position of the rotary switch and only consider the physical slot when registering with DAHDI. Ignoring the rotary switch settings also permits the PCI device to be bound and unbound from the driver at runtime since registration with DAHDI no longer only happens when the module is first initialized. By default, the rotary switch will still be used to determine registration order. This commit does not change the default behavior. Signed-off-by: Shaun Ruffell <sruffell@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10016 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/wct4xxp')
-rw-r--r--drivers/dahdi/wct4xxp/base.c94
1 files changed, 61 insertions, 33 deletions
diff --git a/drivers/dahdi/wct4xxp/base.c b/drivers/dahdi/wct4xxp/base.c
index 2dbb00f..d7f135a 100644
--- a/drivers/dahdi/wct4xxp/base.c
+++ b/drivers/dahdi/wct4xxp/base.c
@@ -213,6 +213,7 @@ static int hardhdlcmode = 0xff;
static int latency = 1;
static int ms_per_irq = 1;
+static int ignore_rotary;
#ifdef FANCY_ALARM
static int altab[] = {
@@ -2119,7 +2120,7 @@ static void init_spans(struct t4 *wc)
snprintf(ts->span.desc, sizeof(ts->span.desc) - 1,
"T%dXXP (PCI) Card %d Span %d", wc->numspans, wc->num, x+1);
ts->span.manufacturer = "Digium";
- if (order_index[wc->order] == 1)
+ if (!ignore_rotary && (1 == order_index[wc->order]))
snprintf(ts->span.location, sizeof(ts->span.location) - 1, "Board ID Switch %d", wc->order);
else
snprintf(ts->span.location, sizeof(ts->span.location) - 1,
@@ -4641,8 +4642,36 @@ static void free_wc(struct t4 *wc)
kfree(wc);
}
+/**
+ * wct4xxp_sort_cards - Sort the cards in card array by rotary switch settings.
+ *
+ */
+static void wct4xxp_sort_cards(void)
+{
+ int x;
+
+ /* get the current number of probed cards and run a slice of a tail
+ * insertion sort */
+ for (x = 0; x < MAX_T4_CARDS; x++) {
+ if (!cards[x+1])
+ break;
+ }
+ for ( ; x > 0; x--) {
+ if (cards[x]->order < cards[x-1]->order) {
+ struct t4 *tmp = cards[x];
+ cards[x] = cards[x-1];
+ cards[x-1] = tmp;
+ } else {
+ /* if we're not moving it, we won't move any more
+ * since all cards are sorted on addition */
+ break;
+ }
+ }
+}
+
static int __devinit t4_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
+ int res;
struct t4 *wc;
struct devtype *dt;
unsigned int x, f;
@@ -4806,23 +4835,9 @@ static int __devinit t4_init_one(struct pci_dev *pdev, const struct pci_device_i
}
init_spans(wc);
- /* get the current number of probed cards and run a slice of a tail
- * insertion sort */
- for (x = 0; x < MAX_T4_CARDS; x++) {
- if (!cards[x+1])
- break;
- }
- for ( ; x > 0; x--) {
- if (cards[x]->order < cards[x-1]->order) {
- struct t4 *tmp = cards[x];
- cards[x] = cards[x-1];
- cards[x-1] = tmp;
- } else {
- /* if we're not moving it, we won't move any more
- * since all cards are sorted on addition */
- break;
- }
- }
+
+ if (!ignore_rotary)
+ wct4xxp_sort_cards();
dev_info(&wc->dev->dev, "Found a Wildcard: %s\n", wc->variety);
wc->gpio = 0x00000000;
@@ -4858,7 +4873,11 @@ static int __devinit t4_init_one(struct pci_dev *pdev, const struct pci_device_i
}
#endif
- return 0;
+ res = 0;
+ if (ignore_rotary)
+ res = t4_launch(wc);
+
+ return res;
}
static int t4_hardware_stop(struct t4 *wc)
@@ -5015,20 +5034,25 @@ static int __init t4_init(void)
printk(KERN_NOTICE "wct4xxp: Ident of first card is not zero (%d)\n",
cards[0]->order);
}
- for (i = 0; cards[i]; i++) {
- /* warn the user of duplicate ident values it is probably
- * unintended */
- if (debug && res < 15 && cards[i+1] &&
- cards[res]->order == cards[i+1]->order) {
- printk(KERN_NOTICE "wct4xxp: Duplicate ident value found (%d)\n",
- cards[i]->order);
- }
- res = t4_launch(cards[i]);
- if (res) {
- int j;
- for (j = 0; j < i; ++j)
- _t4_remove_one(cards[j]);
- break;
+
+ /* If we're ignoring the rotary switch settings, then we've already
+ * registered in the context of .probe */
+ if (!ignore_rotary) {
+ for (i = 0; cards[i]; i++) {
+ /* warn the user of duplicate ident values it is
+ * probably unintended */
+ if (debug && res < 15 && cards[i+1] &&
+ cards[res]->order == cards[i+1]->order) {
+ printk(KERN_NOTICE "wct4xxp: Duplicate ident "
+ "value found (%d)\n", cards[i]->order);
+ }
+ res = t4_launch(cards[i]);
+ if (res) {
+ int j;
+ for (j = 0; j < i; ++j)
+ _t4_remove_one(cards[j]);
+ break;
+ }
}
}
return res;
@@ -5059,6 +5083,10 @@ module_param(j1mode, int, 0600);
module_param(sigmode, int, 0600);
module_param(latency, int, 0600);
module_param(ms_per_irq, int, 0600);
+module_param(ignore_rotary, int, 0400);
+MODULE_PARM_DESC(ignore_rotary, "Set to > 0 to ignore the rotary switch when " \
+ "registering with DAHDI.");
+
#ifdef VPM_SUPPORT
module_param(vpmsupport, int, 0600);
module_param(vpmdtmfsupport, int, 0600);