diff options
Diffstat (limited to 'drivers/dahdi/wcte12xp/base.c')
-rw-r--r-- | drivers/dahdi/wcte12xp/base.c | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index a65b279..037fc9d 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -705,6 +705,9 @@ static void free_wc(struct t1 *wc) } #endif + kfree(wc->ddev->location); + kfree(wc->ddev->devicetype); + dahdi_free_device(wc->ddev); kfree(wc); } @@ -919,14 +922,23 @@ static void t1xxp_framer_start(struct t1 *wc, struct dahdi_span *span) static void set_span_devicetype(struct t1 *wc) { - strncpy(wc->span.devicetype, wc->variety, - sizeof(wc->span.devicetype) - 1); - + const char *olddevicetype; #if defined(VPM_SUPPORT) - if (wc->vpmadt032) - strncat(wc->span.devicetype, " (VPMADT032)", - sizeof(wc->span.devicetype) - 1); + bool have_vpm = (wc->vpmadt032) ? true : false; +#else + bool have_vpm = false; #endif + olddevicetype = wc->ddev->devicetype; + + wc->ddev->devicetype = kasprintf(GFP_KERNEL, + (have_vpm) ? "%s (VPMADT032)" : "%s", + wc->variety); + + /* On the off chance that we were able to allocate it previously. */ + if (!wc->ddev->devicetype) + wc->ddev->devicetype = olddevicetype; + else + kfree(olddevicetype); } static int t1xxp_startup(struct dahdi_span *span) @@ -1529,6 +1541,7 @@ static const struct dahdi_span_ops t1_span_ops = { static int t1_software_init(struct t1 *wc) { int x; + int res; int num; struct pci_dev *pdev = wc->vb.pdev; @@ -1548,12 +1561,15 @@ static int t1_software_init(struct t1 *wc) num = x; sprintf(wc->span.name, "WCT1/%d", num); snprintf(wc->span.desc, sizeof(wc->span.desc) - 1, "%s Card %d", wc->variety, num); - wc->span.manufacturer = "Digium"; + wc->ddev->manufacturer = "Digium"; set_span_devicetype(wc); - snprintf(wc->span.location, sizeof(wc->span.location) - 1, - "PCI Bus %02d Slot %02d", pdev->bus->number, - PCI_SLOT(pdev->devfn) + 1); + wc->ddev->location = kasprintf(GFP_KERNEL, "PCI Bus %02d Slot %02d", + pdev->bus->number, + PCI_SLOT(pdev->devfn) + 1); + + if (!wc->ddev->location) + return -ENOMEM; wc->span.irq = pdev->irq; @@ -1579,9 +1595,11 @@ static int t1_software_init(struct t1 *wc) wc->chans[x]->chanpos = x + 1; } wc->span.ops = &t1_span_ops; - if (dahdi_register(&wc->span, 0)) { - t1_info(wc, "Unable to register span with DAHDI\n"); - return -1; + list_add_tail(&wc->span.device_node, &wc->ddev->spans); + res = dahdi_register_device(wc->ddev, &wc->vb.pdev->dev); + if (res) { + t1_info(wc, "Unable to register with DAHDI\n"); + return res; } set_bit(INITIALIZED, &wc->bit_flags); @@ -2256,13 +2274,13 @@ static int __devinit te12xp_init_one(struct pci_dev *pdev, const struct pci_devi return -EIO; } - if (!(wc = kmalloc(sizeof(*wc), GFP_KERNEL))) { + wc = kzalloc(sizeof(*wc), GFP_KERNEL); + if (!wc) return -ENOMEM; - } ifaces[index] = wc; - memset(wc, 0, sizeof(*wc)); wc->ledstate = -1; + wc->ddev = dahdi_create_device(); spin_lock_init(&wc->reglock); INIT_LIST_HEAD(&wc->active_cmds); INIT_LIST_HEAD(&wc->pending_cmds); @@ -2375,7 +2393,7 @@ static void __devexit te12xp_remove_one(struct pci_dev *pdev) if (!wc) return; - dahdi_unregister(&wc->span); + dahdi_unregister_device(wc->ddev); remove_sysfs_files(wc); |