diff options
author | Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk> | 2004-11-19 22:15:30 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-11-19 22:15:30 -0800 |
commit | c083a79aa29da886988a0d6f3900c71c89dfa205 (patch) | |
tree | 5e529e641601130c83137d2afef39e40310704e0 /sound | |
parent | 28b3389a3166340c4d5a67dc55e4a6fd9bc9c6e5 (diff) | |
download | history-c083a79aa29da886988a0d6f3900c71c89dfa205.tar.gz |
[PATCH] ad1889 annotations and fixes
fixed leaks on failure exits in ->probe()
Diffstat (limited to 'sound')
-rw-r--r-- | sound/oss/ad1889.c | 45 | ||||
-rw-r--r-- | sound/oss/ad1889.h | 2 |
2 files changed, 30 insertions, 17 deletions
diff --git a/sound/oss/ad1889.c b/sound/oss/ad1889.c index 25477365397d6f..607a07a5930fb0 100644 --- a/sound/oss/ad1889.c +++ b/sound/oss/ad1889.c @@ -1011,36 +1011,45 @@ static int __devinit ad1889_probe(struct pci_dev *pcidev, const struct pci_devic if (!(pci_resource_flags(pcidev, 0) & IORESOURCE_MEM)) { printk(KERN_ERR DEVNAME ": memory region not assigned\n"); - goto err_free_mem; + goto out1; + } + + if (pci_request_region(pcidev, 0, DEVNAME)) { + printk(KERN_ERR DEVNAME ": unable to request memory region\n"); + goto out1; + } + + dev->regbase = ioremap_nocache(bar, AD_DSIOMEMSIZE); + if (!dev->regbase) { + printk(KERN_ERR DEVNAME ": unable to remap iomem\n"); + goto out2; } if (request_irq(pcidev->irq, ad1889_interrupt, SA_SHIRQ, DEVNAME, dev) != 0) { printk(KERN_ERR DEVNAME ": unable to request interrupt\n"); - goto err_free_mem; + goto out3; } - request_mem_region(bar, AD_DSIOMEMSIZE, DEVNAME); - dev->regbase = (unsigned long)ioremap_nocache(bar, AD_DSIOMEMSIZE); - - printk(KERN_INFO DEVNAME ": %s at 0x%lx IRQ %d\n", + printk(KERN_INFO DEVNAME ": %s at %p IRQ %d\n", (char *)ent->driver_data, dev->regbase, pcidev->irq); if (ad1889_aclink_reset(pcidev) != 0) - goto err_free_mem; + goto out4; /* register /dev/dsp */ if ((dev->dev_audio = register_sound_dsp(&ad1889_fops, -1)) < 0) { printk(KERN_ERR DEVNAME ": cannot register /dev/dsp\n"); - goto err_free_irq; + goto out4; } if ((err = ad1889_ac97_init(dev, 0)) != 0) - goto err_free_dsp; + goto out5; + /* XXX: cleanups */ if (((proc_root = proc_mkdir("driver/ad1889", NULL)) == NULL) || create_proc_read_entry("ac97", S_IFREG|S_IRUGO, proc_root, ac97_read_proc, dev->ac97_codec) == NULL || create_proc_read_entry("info", S_IFREG|S_IRUGO, proc_root, ad1889_read_proc, dev) == NULL) - goto err_free_dsp; + goto out5; ad1889_initcfg(dev); @@ -1050,13 +1059,15 @@ static int __devinit ad1889_probe(struct pci_dev *pcidev, const struct pci_devic return 0; -err_free_dsp: +out5: unregister_sound_dsp(dev->dev_audio); - -err_free_irq: +out4: free_irq(pcidev->irq, dev); - -err_free_mem: +out3: + iounmap(dev->regbase); +out2: + pci_release_region(pcidev, 0); +out1: ad1889_free_dev(dev); pci_set_drvdata(pcidev, NULL); @@ -1072,10 +1083,12 @@ static void __devexit ad1889_remove(struct pci_dev *pcidev) unregister_sound_mixer(dev->ac97_codec->dev_mixer); unregister_sound_dsp(dev->dev_audio); free_irq(pcidev->irq, dev); - release_mem_region(dev->regbase, AD_DSIOMEMSIZE); + iounmap(dev->regbase); + pci_release_region(pcidev, 0); /* any hw programming needed? */ ad1889_free_dev(dev); + pci_set_drvdata(pcidev, NULL); } MODULE_AUTHOR("Randolph Chung"); diff --git a/sound/oss/ad1889.h b/sound/oss/ad1889.h index 964a6b4d5716aa..e04affce1dd15c 100644 --- a/sound/oss/ad1889.h +++ b/sound/oss/ad1889.h @@ -104,7 +104,7 @@ typedef struct ad1889_state { } ad1889_state_t; typedef struct ad1889_dev { - unsigned long regbase; + void __iomem *regbase; struct pci_dev *pci; spinlock_t lock; |