summaryrefslogtreecommitdiff
path: root/drivers/dahdi/wcb4xxp
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-10-26 18:58:14 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2011-10-26 18:58:14 +0000
commit003582d221276735233c1155d5d64e3ee7eec4ac (patch)
tree66494feaba4f8cec822069d61c1ff46f136764ca /drivers/dahdi/wcb4xxp
parent2ee9529e22a0c0ba57f01afebe86cdf2e6c72566 (diff)
dahdi: Register devices instead of 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 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. This generalizes similar concepts that were previously xpp specific. The conversion of the xpp code was almost entirely done by Oron and Tzafrir. Signed-off-by: Shaun Ruffell <sruffell@digium.com> Signed-off-by: Oron Peled <oron.peled@xorcom.com> Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10273 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/wcb4xxp')
-rw-r--r--drivers/dahdi/wcb4xxp/base.c44
-rw-r--r--drivers/dahdi/wcb4xxp/wcb4xxp.h1
2 files changed, 26 insertions, 19 deletions
diff --git a/drivers/dahdi/wcb4xxp/base.c b/drivers/dahdi/wcb4xxp/base.c
index 3fb5647..72744f8 100644
--- a/drivers/dahdi/wcb4xxp/base.c
+++ b/drivers/dahdi/wcb4xxp/base.c
@@ -2494,11 +2494,6 @@ static void init_spans(struct b4xxp *b4)
sprintf(bspan->span.name, "B4/%d/%d", b4->cardno, i+1);
sprintf(bspan->span.desc, "B4XXP (PCI) Card %d Span %d", b4->cardno, i+1);
- bspan->span.manufacturer = "Digium";
- strlcpy(bspan->span.devicetype, b4->variety,
- sizeof(bspan->span.devicetype));
- sprintf(bspan->span.location, "PCI Bus %02d Slot %02d",
- b4->pdev->bus->number, PCI_SLOT(b4->pdev->devfn) + 1);
bspan->span.ops = &b4xxp_span_ops;
/* HDLC stuff */
@@ -2930,14 +2925,27 @@ static int __devinit b4xx_probe(struct pci_dev *pdev, const struct pci_device_id
hfc_init_all_st(b4);
/* initialize the DAHDI structures, and let DAHDI know it has some new hardware to play with */
+ b4->ddev = dahdi_create_device();
init_spans(b4);
+
for (x=0; x < b4->numspans; x++) {
- if (dahdi_register(&b4->spans[x].span, 0)) {
- dev_err(&b4->pdev->dev,
- "Unable to register span %s\n",
- b4->spans[x].span.name);
- goto err_out_unreg_spans;
- }
+ struct dahdi_span *const s = &b4->spans[x].span;
+ list_add_tail(&s->device_node, &b4->ddev->spans);
+ }
+
+ b4->ddev->manufacturer = "Digium";
+ b4->ddev->devicetype = b4->variety;
+ b4->ddev->location = kasprintf(GFP_KERNEL, "PCI Bus %02d Slot %02d",
+ b4->pdev->bus->number,
+ PCI_SLOT(b4->pdev->devfn) + 1);
+ if (!b4->ddev->location) {
+ ret = -ENOMEM;
+ goto err_out_del_from_card_array;
+ }
+
+ if (dahdi_register_device(b4->ddev, &b4->pdev->dev)) {
+ dev_err(&b4->pdev->dev, "Unable to register device.\n");
+ goto err_out_unreg_spans;
}
@@ -2973,10 +2981,7 @@ static int __devinit b4xx_probe(struct pci_dev *pdev, const struct pci_device_id
/* 'x' will have the failing span #. (0-3). We need to unregister everything before it. */
err_out_unreg_spans:
- while (x) {
- dahdi_unregister(&b4->spans[x].span);
- x--;
- };
+ dahdi_unregister_device(b4->ddev);
b4xxp_init_stage1(b4); /* full reset, re-init to "no-irq" state */
free_irq(pdev->irq, b4);
@@ -2997,6 +3002,8 @@ err_out_free_mem:
pci_set_drvdata(pdev, NULL);
pci_iounmap(pdev, b4->ioaddr);
pci_iounmap(pdev, b4->addr);
+ kfree(b4->ddev->location);
+ dahdi_free_device(b4->ddev);
kfree(b4);
err_out_release_regions:
@@ -3011,14 +3018,11 @@ err_out_disable_pdev:
static void __devexit b4xxp_remove(struct pci_dev *pdev)
{
struct b4xxp *b4 = pci_get_drvdata(pdev);
- int i;
if (b4) {
b4->shutdown = 1;
- for (i=b4->numspans - 1; i >= 0; i--) {
- dahdi_unregister(&b4->spans[i].span);
- }
+ dahdi_unregister_device(b4->ddev);
b4xxp_init_stage1(b4);
remove_sysfs_files(b4);
@@ -3033,6 +3037,8 @@ static void __devexit b4xxp_remove(struct pci_dev *pdev)
tasklet_kill(&b4->b4xxp_tlet);
+ kfree(b4->ddev->location);
+ dahdi_free_device(b4->ddev);
kfree(b4);
}
diff --git a/drivers/dahdi/wcb4xxp/wcb4xxp.h b/drivers/dahdi/wcb4xxp/wcb4xxp.h
index 56dc93b..80a28fe 100644
--- a/drivers/dahdi/wcb4xxp/wcb4xxp.h
+++ b/drivers/dahdi/wcb4xxp/wcb4xxp.h
@@ -474,6 +474,7 @@ struct b4xxp {
/* Flags for our bottom half */
unsigned int shutdown; /* 1=bottom half doesn't process anything, just returns */
struct tasklet_struct b4xxp_tlet;
+ struct dahdi_device *ddev;
};
/* CPLD access bits */