diff options
author | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2011-10-26 18:58:14 +0000 |
---|---|---|
committer | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2011-10-26 18:58:14 +0000 |
commit | 003582d221276735233c1155d5d64e3ee7eec4ac (patch) | |
tree | 66494feaba4f8cec822069d61c1ff46f136764ca /drivers/dahdi/wcte11xp.c | |
parent | 2ee9529e22a0c0ba57f01afebe86cdf2e6c72566 (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/wcte11xp.c')
-rw-r--r-- | drivers/dahdi/wcte11xp.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/dahdi/wcte11xp.c b/drivers/dahdi/wcte11xp.c index c8067c7..b2eab8d 100644 --- a/drivers/dahdi/wcte11xp.c +++ b/drivers/dahdi/wcte11xp.c @@ -174,6 +174,7 @@ struct t1 { unsigned char ec_chunk1[32][DAHDI_CHUNKSIZE]; unsigned char ec_chunk2[32][DAHDI_CHUNKSIZE]; unsigned char tempo[33]; + struct dahdi_device *ddev; struct dahdi_span span; /* Span */ struct dahdi_chan *chans[32]; /* Channels */ }; @@ -340,10 +341,12 @@ static void t1xxp_release(struct t1 *wc) { unsigned int x; - dahdi_unregister(&wc->span); + dahdi_unregister_device(wc->ddev); for (x = 0; x < (wc->spantype == TYPE_E1 ? 31 : 24); x++) { kfree(wc->chans[x]); } + kfree(wc->ddev->location); + dahdi_free_device(wc->ddev); kfree(wc); printk(KERN_INFO "Freed a Wildcard\n"); } @@ -976,14 +979,21 @@ static int t1xxp_software_init(struct t1 *wc) } if (x >= WC_MAX_CARDS) return -1; + + wc->ddev = dahdi_create_device(); + t4_serial_setup(wc); wc->num = x; sprintf(wc->span.name, "WCT1/%d", wc->num); snprintf(wc->span.desc, sizeof(wc->span.desc) - 1, "%s Card %d", wc->variety, wc->num); - wc->span.manufacturer = "Digium"; - strlcpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype)); - 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->ddev->manufacturer = "Digium"; + wc->ddev->devicetype = wc->variety; + 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->span.irq = wc->dev->irq; if (wc->spantype == TYPE_E1) { if (unchannelized) @@ -1011,7 +1021,8 @@ static int t1xxp_software_init(struct t1 *wc) wc->chans[x]->chanpos = x + 1; } wc->span.ops = &t1xxp_span_ops; - if (dahdi_register(&wc->span, 0)) { + 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; } |