[zaptel-commits] tzafrir: branch 1.4 r3669 - /branches/1.4/wcfxo.c
SVN commits to the Zaptel project
zaptel-commits at lists.digium.com
Fri Jan 11 16:07:45 CST 2008
Author: tzafrir
Date: Fri Jan 11 16:07:44 2008
New Revision: 3669
URL: http://svn.digium.com/view/zaptel?view=rev&rev=3669
Log:
* Reduce indentation in wcfxo.c .
* Also improve an error message there.
Modified:
branches/1.4/wcfxo.c
Modified: branches/1.4/wcfxo.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wcfxo.c?view=diff&rev=3669&r1=3668&r2=3669
==============================================================================
--- branches/1.4/wcfxo.c (original)
+++ branches/1.4/wcfxo.c Fri Jan 11 16:07:44 2008
@@ -845,7 +845,6 @@
static int __devinit wcfxo_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
- int res;
struct wcfxo *wc;
struct wcfxo_desc *d = (struct wcfxo_desc *)ent->driver_data;
int x;
@@ -853,93 +852,95 @@
for (x=0;x<WC_MAX_IFACES;x++)
if (!ifaces[x]) break;
if (x >= WC_MAX_IFACES) {
- printk("Too many interfaces\n");
+ printk(KERN_ERR "Too many interfaces: Found %d, can only handle %d.\n",
+ x, WC_MAX_IFACES - 1);
return -EIO;
}
- if (pci_enable_device(pdev)) {
- res = -EIO;
- } else {
- wc = kmalloc(sizeof(struct wcfxo), GFP_KERNEL);
- if (wc) {
- ifaces[x] = wc;
- memset(wc, 0, sizeof(struct wcfxo));
- wc->ioaddr = pci_resource_start(pdev, 0);
- wc->dev = pdev;
- wc->pos = x;
- wc->variety = d->name;
- wc->flags = d->flags;
- /* Keep track of whether we need to free the region */
- if (request_region(wc->ioaddr, 0xff, "wcfxo"))
- wc->freeregion = 1;
-
- /* Allocate enough memory for two zt chunks, receive and transmit. Each sample uses
- 32 bits. Allocate an extra set just for control too */
- wc->writechunk = (int *)pci_alloc_consistent(pdev, ZT_MAX_CHUNKSIZE * 2 * 2 * 2 * 4, &wc->writedma);
- if (!wc->writechunk) {
- printk("wcfxo: Unable to allocate DMA-able memory\n");
- if (wc->freeregion)
- release_region(wc->ioaddr, 0xff);
- return -ENOMEM;
- }
-
- wc->readchunk = wc->writechunk + ZT_MAX_CHUNKSIZE * 4; /* in doublewords */
- wc->readdma = wc->writedma + ZT_MAX_CHUNKSIZE * 16; /* in bytes */
-
- if (wcfxo_initialize(wc)) {
- printk("wcfxo: Unable to intialize modem\n");
- if (wc->freeregion)
- release_region(wc->ioaddr, 0xff);
- kfree(wc);
- return -EIO;
- }
-
- /* Enable bus mastering */
- pci_set_master(pdev);
-
- /* Keep track of which device we are */
- pci_set_drvdata(pdev, wc);
-
- if (request_irq(pdev->irq, wcfxo_interrupt, ZAP_IRQ_SHARED, "wcfxo", wc)) {
- printk("wcfxo: Unable to request IRQ %d\n", pdev->irq);
- if (wc->freeregion)
- release_region(wc->ioaddr, 0xff);
- kfree(wc);
- return -EIO;
- }
-
-
- wcfxo_hardware_init(wc);
- /* Enable interrupts */
- wcfxo_enable_interrupts(wc);
- /* Initialize Write/Buffers to all blank data */
- memset((void *)wc->writechunk,0,ZT_MAX_CHUNKSIZE * 2 * 2 * 2 * 4);
- /* Start DMA */
- wcfxo_start_dma(wc);
-
- /* Initialize DAA (after it's started) */
- if (wcfxo_init_daa(wc)) {
- printk("Failed to initailize DAA, giving up...\n");
- wcfxo_stop_dma(wc);
- wcfxo_disable_interrupts(wc);
- zt_unregister(&wc->span);
- free_irq(pdev->irq, wc);
-
- /* Reset PCI chip and registers */
- outb(0x0e, wc->ioaddr + WC_CNTL);
-
- if (wc->freeregion)
- release_region(wc->ioaddr, 0xff);
- kfree(wc);
- return -EIO;
- }
- wcfxo_set_daa_mode(wc);
- printk("Found a Wildcard FXO: %s\n", wc->variety);
- res = 0;
- } else
- res = -ENOMEM;
- }
- return res;
+ if (pci_enable_device(pdev))
+ return -EIO;
+
+ wc = kmalloc(sizeof(struct wcfxo), GFP_KERNEL);
+ if (!wc) {
+ printk(KERN_ERR "wcfxo: Failed initializinf card. Not enough memory.");
+ return -ENOMEM;
+ }
+
+ ifaces[x] = wc;
+ memset(wc, 0, sizeof(struct wcfxo));
+ wc->ioaddr = pci_resource_start(pdev, 0);
+ wc->dev = pdev;
+ wc->pos = x;
+ wc->variety = d->name;
+ wc->flags = d->flags;
+ /* Keep track of whether we need to free the region */
+ if (request_region(wc->ioaddr, 0xff, "wcfxo"))
+ wc->freeregion = 1;
+
+ /* Allocate enough memory for two zt chunks, receive and transmit. Each sample uses
+ 32 bits. Allocate an extra set just for control too */
+ wc->writechunk = (int *)pci_alloc_consistent(pdev, ZT_MAX_CHUNKSIZE * 2 * 2 * 2 * 4, &wc->writedma);
+ if (!wc->writechunk) {
+ printk("wcfxo: Unable to allocate DMA-able memory\n");
+ if (wc->freeregion)
+ release_region(wc->ioaddr, 0xff);
+ return -ENOMEM;
+ }
+
+ wc->readchunk = wc->writechunk + ZT_MAX_CHUNKSIZE * 4; /* in doublewords */
+ wc->readdma = wc->writedma + ZT_MAX_CHUNKSIZE * 16; /* in bytes */
+
+ if (wcfxo_initialize(wc)) {
+ printk("wcfxo: Unable to intialize modem\n");
+ if (wc->freeregion)
+ release_region(wc->ioaddr, 0xff);
+ kfree(wc);
+ return -EIO;
+ }
+
+ /* Enable bus mastering */
+ pci_set_master(pdev);
+
+ /* Keep track of which device we are */
+ pci_set_drvdata(pdev, wc);
+
+ if (request_irq(pdev->irq, wcfxo_interrupt, ZAP_IRQ_SHARED, "wcfxo", wc)) {
+ printk("wcfxo: Unable to request IRQ %d\n", pdev->irq);
+ if (wc->freeregion)
+ release_region(wc->ioaddr, 0xff);
+ kfree(wc);
+ return -EIO;
+ }
+
+
+ wcfxo_hardware_init(wc);
+ /* Enable interrupts */
+ wcfxo_enable_interrupts(wc);
+ /* Initialize Write/Buffers to all blank data */
+ memset((void *)wc->writechunk,0,ZT_MAX_CHUNKSIZE * 2 * 2 * 2 * 4);
+ /* Start DMA */
+ wcfxo_start_dma(wc);
+
+ /* Initialize DAA (after it's started) */
+ if (wcfxo_init_daa(wc)) {
+ printk("Failed to initailize DAA, giving up...\n");
+ wcfxo_stop_dma(wc);
+ wcfxo_disable_interrupts(wc);
+ zt_unregister(&wc->span);
+ free_irq(pdev->irq, wc);
+
+ /* Reset PCI chip and registers */
+ outb(0x0e, wc->ioaddr + WC_CNTL);
+
+ if (wc->freeregion)
+ release_region(wc->ioaddr, 0xff);
+ kfree(wc);
+ return -EIO;
+ }
+ wcfxo_set_daa_mode(wc);
+ printk("Found a Wildcard FXO: %s\n", wc->variety);
+
+ return 0;
}
static void wcfxo_release(struct wcfxo *wc)
More information about the zaptel-commits
mailing list