From b3c86b81ae638d90ee27a821e962e297ab85cbe4 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Wed, 17 Nov 2010 12:09:10 -0600 Subject: 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 --- drivers/dahdi/wctdm.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'drivers/dahdi/wctdm.c') diff --git a/drivers/dahdi/wctdm.c b/drivers/dahdi/wctdm.c index 9c56865..143af0a 100644 --- a/drivers/dahdi/wctdm.c +++ b/drivers/dahdi/wctdm.c @@ -205,6 +205,7 @@ struct wctdm { struct pci_dev *dev; char *variety; struct dahdi_span span; + struct dahdi_device *ddev; unsigned char ios; int usecount; unsigned int intcount; @@ -2367,10 +2368,16 @@ static int wctdm_initialize(struct wctdm *wc) /* DAHDI stuff */ sprintf(wc->span.name, "WCTDM/%d", wc->pos); snprintf(wc->span.desc, sizeof(wc->span.desc) - 1, "%s Board %d", wc->variety, wc->pos + 1); - snprintf(wc->span.location, sizeof(wc->span.location) - 1, - "PCI Bus %02d Slot %02d", wc->dev->bus->number, PCI_SLOT(wc->dev->devfn) + 1); - wc->span.manufacturer = "Digium"; - strlcpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype)); + wc->ddev->location = kasprintf(GFP_KERNEL, + "PCI Bus %02d Slot %02d", + wc->dev->bus->number, + PCI_SLOT(wc->dev->devfn) + 1); + if (!wc->ddev->location) + return -ENOMEM; + + wc->ddev->manufacturer = "Digium"; + wc->ddev->devicetype = wc->variety; + if (alawoverride) { printk(KERN_INFO "ALAW override parameter detected. Device will be operating in ALAW\n"); wc->span.deflaw = DAHDI_LAW_ALAW; @@ -2390,7 +2397,9 @@ static int wctdm_initialize(struct wctdm *wc) wc->span.flags = DAHDI_FLAG_RBS; wc->span.ops = &wctdm_span_ops; - if (dahdi_register(&wc->span, 0)) { + wc->ddev = dahdi_create_device(); + list_add_tail(&wc->span.device_node, &wc->ddev->spans); + if (dahdi_register_device(wc->ddev, &wc->dev->dev)) { printk(KERN_NOTICE "Unable to register span with DAHDI\n"); return -1; } @@ -2679,7 +2688,9 @@ static int __devinit wctdm_init_one(struct pci_dev *pdev, const struct pci_devic release_region(wc->ioaddr, 0xff); pci_free_consistent(pdev, DAHDI_MAX_CHUNKSIZE * 2 * 2 * 2 * 4, (void *)wc->writechunk, wc->writedma); pci_set_drvdata(pdev, NULL); - dahdi_unregister(&wc->span); + dahdi_unregister_device(wc->ddev); + kfree(wc->ddev->location); + dahdi_free_device(wc->ddev); kfree(wc); return -EIO; @@ -2710,10 +2721,14 @@ static int __devinit wctdm_init_one(struct pci_dev *pdev, const struct pci_devic static void wctdm_release(struct wctdm *wc) { - dahdi_unregister(&wc->span); + dahdi_unregister_device(wc->ddev); if (wc->freeregion) release_region(wc->ioaddr, 0xff); + + kfree(wc->ddev->location); + dahdi_free_device(wc->ddev); kfree(wc); + printk(KERN_INFO "Freed a Wildcard\n"); } -- cgit v1.2.3