diff options
author | Shaun Ruffell <sruffell@digium.com> | 2010-11-17 12:09:10 -0600 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2011-04-15 14:21:13 -0500 |
commit | b3c86b81ae638d90ee27a821e962e297ab85cbe4 (patch) | |
tree | c70e2c6b0e74c5bc3a20e6c597df1f9fbc7ca891 /drivers/dahdi/tor2.c | |
parent | 9c8aa9db7eca1c91bd37bd5b55add0cee40d7cd9 (diff) |
dahdi: register/unregister devices as opposed to individual spans.
Increasingly, spans are implemented by devices that support more than a
single span. Introduce a 'struct dahdi_device' object which explicitly
contains multiple spans. This will also allow a cleaner representation
of spans and devices in sysfs since order of arrival will not determine
the layout of the devices. This also gives the core of dahdi a way to
know the relationship between spans.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Diffstat (limited to 'drivers/dahdi/tor2.c')
-rw-r--r-- | drivers/dahdi/tor2.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/dahdi/tor2.c b/drivers/dahdi/tor2.c index 1babb4f..32e8435 100644 --- a/drivers/dahdi/tor2.c +++ b/drivers/dahdi/tor2.c @@ -97,6 +97,7 @@ struct tor2 { unsigned long xilinx8_region; /* 8 bit Region allocated to Xilinx */ unsigned long xilinx8_len; /* Length of 8 bit Xilinx region */ __iomem volatile unsigned char *mem8; /* Virtual representation of 8 bit Xilinx memory area */ + struct dahdi_device *ddev; struct tor2_span tspans[SPANS_PER_CARD]; /* Span data */ struct dahdi_chan **chans[SPANS_PER_CARD]; /* Pointers to card channels */ struct tor2_chan tchans[32 * SPANS_PER_CARD]; /* Channel user data */ @@ -283,10 +284,6 @@ static void init_spans(struct tor2 *tor) snprintf(s->desc, sizeof(s->desc) - 1, "Tormenta 2 (PCI) Quad %s Card %d Span %d", (tor->cardtype == TYPE_T1) ? "T1" : "E1", tor->num, x + 1); - s->manufacturer = "Digium"; - strlcpy(s->devicetype, tor->type, sizeof(s->devicetype)); - snprintf(s->location, sizeof(s->location) - 1, - "PCI Bus %02d Slot %02d", tor->pci->bus->number, PCI_SLOT(tor->pci->devfn) + 1); if (tor->cardtype == TYPE_T1) { s->channels = 24; s->deflaw = DAHDI_LAW_MULAW; @@ -320,19 +317,31 @@ static void init_spans(struct tor2 *tor) static int __devinit tor2_launch(struct tor2 *tor) { + int res; struct dahdi_span *s; int i; if (test_bit(DAHDI_FLAGBIT_REGISTERED, &tor->tspans[0].dahdi_span.flags)) return 0; + tor->ddev = dahdi_create_device(); + tor->ddev->location = kasprintf(GFP_KERNEL, "PCI Bus %02d Slot %02d", + tor->pci->bus->number, + PCI_SLOT(tor->pci->devfn) + 1); + + if (!tor->ddev->location) + return -ENOMEM; + printk(KERN_INFO "Tor2: Launching card: %d\n", tor->order); for (i = 0; i < SPANS_PER_CARD; ++i) { s = &tor->tspans[i].dahdi_span; - if (dahdi_register(s, 0)) { - printk(KERN_ERR "Unable to register span %s\n", s->name); - goto error_exit; - } + list_add_tail(&s->device_node, &tor->ddev->spans); + } + + res = dahdi_register_device(tor->ddev, &tor->pci->dev); + if (res) { + dev_err(&tor->pci->dev, "Unable to register with DAHDI.\n"); + return res; } writew(PLX_INTENA, &tor->plx[INTCSR]); /* enable PLX interrupt */ @@ -340,14 +349,6 @@ static int __devinit tor2_launch(struct tor2 *tor) tasklet_init(&tor->tor2_tlet, tor2_tasklet, (unsigned long)tor); #endif return 0; - -error_exit: - for (i = 0; i < SPANS_PER_CARD; ++i) { - s = &tor->tspans[i].dahdi_span; - if (test_bit(DAHDI_FLAGBIT_REGISTERED, &s->flags)) - dahdi_unregister(s); - } - return -1; } static void free_tor(struct tor2 *tor) @@ -363,6 +364,8 @@ static void free_tor(struct tor2 *tor) if (tor->chans[x]) kfree(tor->chans[x]); } + kfree(tor->ddev->location); + dahdi_free_device(tor->ddev); kfree(tor); } @@ -629,7 +632,6 @@ static struct pci_driver tor2_driver; static void __devexit tor2_remove(struct pci_dev *pdev) { struct tor2 *tor; - int i; tor = pci_get_drvdata(pdev); if (!tor) @@ -639,11 +641,7 @@ static void __devexit tor2_remove(struct pci_dev *pdev) writeb(0, &tor->mem8[LEDREG]); writew(0, &tor->plx[INTCSR]); free_irq(tor->irq, tor); - for (i = 0; i < SPANS_PER_CARD; ++i) { - struct dahdi_span *s = &tor->tspans[i].dahdi_span; - if (test_bit(DAHDI_FLAGBIT_REGISTERED, &s->flags)) - dahdi_unregister(s); - } + dahdi_unregister_device(tor->ddev); release_mem_region(tor->plx_region, tor->plx_len); release_mem_region(tor->xilinx32_region, tor->xilinx32_len); release_mem_region(tor->xilinx8_region, tor->xilinx8_len); |