summaryrefslogtreecommitdiff
path: root/drivers/dahdi/wctdm24xxp/base.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/dahdi/wctdm24xxp/base.c')
-rw-r--r--drivers/dahdi/wctdm24xxp/base.c89
1 files changed, 65 insertions, 24 deletions
diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c
index a50f67a..e4587eb 100644
--- a/drivers/dahdi/wctdm24xxp/base.c
+++ b/drivers/dahdi/wctdm24xxp/base.c
@@ -4147,6 +4147,30 @@ static int wctdm_dacs(struct dahdi_chan *dst, struct dahdi_chan *src)
return 0;
}
+/**
+ * TODO: Add comment about this function.
+ *
+ */
+static void wctdm24xxp_registered(struct dahdi_span *span)
+{
+ struct dahdi_span *s;
+ struct dahdi_device *ddev = span->parent;
+ struct wctdm *wc = NULL;
+
+ list_for_each_entry(s, &ddev->spans, device_node) {
+ wc = (container_of(s, struct wctdm_span, span))->wc;
+ if (!test_bit(DAHDI_FLAGBIT_REGISTERED, &s->flags)) {
+ dev_err(&wc->vb.pdev->dev, "HERE: %d\n", __LINE__);
+ return;
+ }
+ }
+
+ if (wc)
+ wc->initialized = 1;
+
+ dev_err(&wc->vb.pdev->dev, "HERE: %s %d\n", wc->board_name, __LINE__);
+}
+
static const struct dahdi_span_ops wctdm24xxp_analog_span_ops = {
.owner = THIS_MODULE,
.hooksig = wctdm_hooksig,
@@ -4155,6 +4179,7 @@ static const struct dahdi_span_ops wctdm24xxp_analog_span_ops = {
.ioctl = wctdm_ioctl,
.watchdog = wctdm_watchdog,
.dacs = wctdm_dacs,
+ .registered = wctdm24xxp_registered,
#ifdef VPM_SUPPORT
.echocan_create = wctdm_echocan_create,
.echocan_name = wctdm_echocan_name,
@@ -4171,6 +4196,7 @@ static const struct dahdi_span_ops wctdm24xxp_digital_span_ops = {
.spanconfig = b400m_spanconfig,
.chanconfig = b400m_chanconfig,
.dacs = wctdm_dacs,
+ .registered = wctdm24xxp_registered,
#ifdef VPM_SUPPORT
.echocan_create = wctdm_echocan_create,
.echocan_name = wctdm_echocan_name,
@@ -4255,12 +4281,6 @@ wctdm_init_span(struct wctdm *wc, int spanno, int chanoffset, int chancount,
snprintf(s->span.desc, sizeof(s->span.desc) - 1, "%s Board %d",
wc->desc->name, card_position + 1);
- snprintf(s->span.location, sizeof(s->span.location) - 1,
- "PCI%s Bus %02d Slot %02d",
- (wc->desc->flags & FLAG_EXPRESS) ? " Express" : "",
- pdev->bus->number, PCI_SLOT(pdev->devfn) + 1);
- s->span.manufacturer = "Digium";
- strncpy(s->span.devicetype, wc->desc->name, sizeof(s->span.devicetype) - 1);
if (wc->companding == DAHDI_LAW_DEFAULT) {
if (wc->digi_mods || digital_span)
@@ -4370,8 +4390,6 @@ static void wctdm_fixup_analog_span(struct wctdm *wc, int spanno)
for (x = 0; x < MAX_SPANS; x++) {
if (!wc->spans[x])
continue;
- if (wc->vpmadt032)
- strncat(wc->spans[x]->span.devicetype, " (VPMADT032)", sizeof(wc->spans[x]->span.devicetype) - 1);
}
}
@@ -4692,9 +4710,10 @@ static void wctdm_back_out_gracefully(struct wctdm *wc)
kfree(frame);
}
-
-
kfree(wc->board_name);
+ kfree(wc->ddev->devicetype);
+ kfree(wc->ddev->location);
+ dahdi_free_device(wc->ddev);
kfree(wc);
}
@@ -5476,21 +5495,48 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
#ifdef USE_ASYNC_INIT
async_synchronize_cookie(cookie);
#endif
+ wc->ddev = dahdi_create_device();
+ wc->ddev->manufacturer = "Digium";
+ wc->ddev->location = kasprintf(GFP_KERNEL, "PCI%s Bus %02d Slot %02d",
+ (wc->desc->flags & FLAG_EXPRESS) ?
+ " Express" : "",
+ pdev->bus->number,
+ PCI_SLOT(pdev->devfn) + 1);
+ if (!wc->ddev->location) {
+ wctdm_back_out_gracefully(wc);
+ return -ENOMEM;
+ }
+
+ if (wc->vpmadt032) {
+ wc->ddev->devicetype = kasprintf(GFP_KERNEL, "%s (VPMADT032)",
+ wc->desc->name);
+ } else {
+ wc->ddev->devicetype = kasprintf(GFP_KERNEL, "%s",
+ wc->desc->name);
+ }
+
+ if (!wc->ddev->devicetype) {
+ wctdm_back_out_gracefully(wc);
+ return -ENOMEM;
+ }
+
/* We should be ready for DAHDI to come in now. */
for (i = 0; i < MAX_SPANS; ++i) {
+ struct dahdi_span *span;
+
if (!wc->spans[i])
continue;
- if (dahdi_register(&wc->spans[i]->span, 0)) {
- dev_notice(&wc->vb.pdev->dev, "Unable to register span %d with DAHDI\n", i);
- while (i)
- dahdi_unregister(&wc->spans[i--]->span);
- wctdm_back_out_gracefully(wc);
- return -1;
- }
+ span = &wc->spans[i]->span;
+
+ list_add_tail(&span->device_node, &wc->ddev->spans);
}
- wc->initialized = 1;
+ if (dahdi_register_device(wc->ddev, &wc->vb.pdev->dev)) {
+ dev_notice(&wc->vb.pdev->dev, "Unable to register device with DAHDI\n");
+ wctdm_back_out_gracefully(wc);
+ return -1;
+ }
dev_info(&wc->vb.pdev->dev,
"Found a %s: %s (%d BRI spans, %d analog %s)\n",
@@ -5542,12 +5588,7 @@ static void wctdm_release(struct wctdm *wc)
{
int i;
- if (wc->initialized) {
- for (i = 0; i < MAX_SPANS; i++) {
- if (wc->spans[i])
- dahdi_unregister(&wc->spans[i]->span);
- }
- }
+ dahdi_unregister_device(wc->ddev);
down(&ifacelock);
for (i = 0; i < WC_MAX_IFACES; i++)