diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2008-01-11 22:07:44 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2008-01-11 22:07:44 +0000 |
commit | 1a9ee1d65893c18f4ff1c956135f14bca5ca7be3 (patch) | |
tree | ca7dc87a3b94adb9cbb377c0b63ce75b3ae29287 /wcfxo.c | |
parent | eecfbb328db7fca69f7a28f8bf1bf1e7b94e2194 (diff) |
* Reduce indentation in wcfxo.c .
* Also improve an error message there.
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@3669 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'wcfxo.c')
-rw-r--r-- | wcfxo.c | 155 |
1 files changed, 78 insertions, 77 deletions
@@ -845,7 +845,6 @@ static int wcfxo_init_daa(struct wcfxo *wc) 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 @@ static int __devinit wcfxo_init_one(struct pci_dev *pdev, const struct pci_devic 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; - } + if (pci_enable_device(pdev)) + return -EIO; - wc->readchunk = wc->writechunk + ZT_MAX_CHUNKSIZE * 4; /* in doublewords */ - wc->readdma = wc->writedma + ZT_MAX_CHUNKSIZE * 16; /* in bytes */ + wc = kmalloc(sizeof(struct wcfxo), GFP_KERNEL); + if (!wc) { + printk(KERN_ERR "wcfxo: Failed initializinf card. Not enough memory."); + return -ENOMEM; + } - if (wcfxo_initialize(wc)) { - printk("wcfxo: Unable to intialize modem\n"); - if (wc->freeregion) - release_region(wc->ioaddr, 0xff); - kfree(wc); - return -EIO; - } + 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; + } - /* Enable bus mastering */ - pci_set_master(pdev); + wc->readchunk = wc->writechunk + ZT_MAX_CHUNKSIZE * 4; /* in doublewords */ + wc->readdma = wc->writedma + ZT_MAX_CHUNKSIZE * 16; /* in bytes */ - /* Keep track of which device we are */ - pci_set_drvdata(pdev, wc); + if (wcfxo_initialize(wc)) { + printk("wcfxo: Unable to intialize modem\n"); + if (wc->freeregion) + release_region(wc->ioaddr, 0xff); + kfree(wc); + return -EIO; + } - 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; - } + /* Enable bus mastering */ + pci_set_master(pdev); + /* Keep track of which device we are */ + pci_set_drvdata(pdev, wc); - 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; + 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; } - return res; + + + 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) |