[alsa-devel] [PATCH] port pcxhr driver do devres

Rolf Eike Beer eike-kernel at sf-tec.de
Sun Sep 21 17:31:39 CEST 2008


Signed-off-by: Rolf Eike Beer <eike-kernel at sf-tec.de>

---
I was a bit bored and ported the pcxhr driver to use devres to manage it's
IRQ and PCI resources. This is completely untested as I don't have such a
card but you might find it useful nevertheless.

commit e7df0303a1517bdd0d2f0af5fbdf91acc0b7f426
tree 45fbf9c75c8ea51ae89f0409ed02138380b71624
parent 9824b8f11373b0df806c135a342da9319ef1d893
author Rolf Eike Beer <eike-kernel at sf-tec.de> Sun, 21 Sep 2008 17:26:28 +0200
committer Rolf Eike Beer <eike-kernel at sf-tec.de> Sun, 21 Sep 2008 17:26:28 +0200

 sound/pci/pcxhr/pcxhr.c |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index 2c7e253..676389e 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -1171,12 +1171,6 @@ static int pcxhr_free(struct pcxhr_mgr *mgr)
 		snd_printdd("reset pcxhr !\n");
 	}
 
-	/* release irq  */
-	if (mgr->irq >= 0)
-		free_irq(mgr->irq, mgr);
-
-	pci_release_regions(mgr->pci);
-
 	/* free hostport purgebuffer */
 	if (mgr->hostport.area) {
 		snd_dma_free_pages(&mgr->hostport);
@@ -1185,7 +1179,6 @@ static int pcxhr_free(struct pcxhr_mgr *mgr)
 
 	kfree(mgr->prmh);
 
-	pci_disable_device(mgr->pci);
 	kfree(mgr);
 	return 0;
 }
@@ -1210,21 +1203,19 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id
 	}
 
 	/* enable PCI device */
-	if ((err = pci_enable_device(pci)) < 0)
+	if ((err = pcim_enable_device(pci)) < 0)
 		return err;
 	pci_set_master(pci);
 
 	/* check if we can restrict PCI DMA transfers to 32 bits */
 	if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0) {
 		snd_printk(KERN_ERR "architecture does not support 32bit PCI busmaster DMA\n");
-		pci_disable_device(pci);
 		return -ENXIO;
 	}
 
 	/* alloc card manager */
 	mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
 	if (! mgr) {
-		pci_disable_device(pci);
 		return -ENOMEM;
 	}
 
@@ -1238,7 +1229,6 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id
 	/* resource assignment */
 	if ((err = pci_request_regions(pci, card_name)) < 0) {
 		kfree(mgr);
-		pci_disable_device(pci);
 		return err;
 	}
 	for (i = 0; i < 3; i++)
@@ -1247,7 +1237,7 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id
 	mgr->pci = pci;
 	mgr->irq = -1;
 
-	if (request_irq(pci->irq, pcxhr_interrupt, IRQF_SHARED,
+	if (devm_request_irq(&pci->dev, pci->irq, pcxhr_interrupt, IRQF_SHARED,
 			card_name, mgr)) {
 		snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
 		pcxhr_free(mgr);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20080921/89f92f49/attachment.sig 


More information about the Alsa-devel mailing list