[ALSA] Fix races in irq handler and ioremap
authorTakashi Iwai <tiwai@suse.de>
Tue, 6 Jun 2006 13:44:34 +0000 (15:44 +0200)
committerJaroslav Kysela <perex@suse.cz>
Thu, 22 Jun 2006 19:34:13 +0000 (21:34 +0200)
Call ioremap before request_irq for avoiding possible races
in the irq handler.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/cs4281.c
sound/pci/rme32.c
sound/pci/rme96.c

index 8c150eab45b673f27f9643449d0f5b8a10951a07..e77a4ce314b7a5f34ffab7d2828c82ee47a80ff4 100644 (file)
@@ -1379,6 +1379,13 @@ static int __devinit snd_cs4281_create(struct snd_card *card,
        chip->ba0_addr = pci_resource_start(pci, 0);
        chip->ba1_addr = pci_resource_start(pci, 1);
 
+       chip->ba0 = ioremap_nocache(chip->ba0_addr, pci_resource_len(pci, 0));
+       chip->ba1 = ioremap_nocache(chip->ba1_addr, pci_resource_len(pci, 1));
+       if (!chip->ba0 || !chip->ba1) {
+               snd_cs4281_free(chip);
+               return -ENOMEM;
+       }
+       
        if (request_irq(pci->irq, snd_cs4281_interrupt, SA_INTERRUPT|SA_SHIRQ,
                        "CS4281", chip)) {
                snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
@@ -1387,13 +1394,6 @@ static int __devinit snd_cs4281_create(struct snd_card *card,
        }
        chip->irq = pci->irq;
 
-       chip->ba0 = ioremap_nocache(chip->ba0_addr, pci_resource_len(pci, 0));
-       chip->ba1 = ioremap_nocache(chip->ba1_addr, pci_resource_len(pci, 1));
-       if (!chip->ba0 || !chip->ba1) {
-               snd_cs4281_free(chip);
-               return -ENOMEM;
-       }
-       
        tmp = snd_cs4281_chip_init(chip);
        if (tmp) {
                snd_cs4281_free(chip);
index 4dd53bfe0308142432737fa6deeea07052203b88..2cb9fe98db2f51f43ba2bbe1ba51c929f9d1c667 100644 (file)
@@ -1368,18 +1368,18 @@ static int __devinit snd_rme32_create(struct rme32 * rme32)
                return err;
        rme32->port = pci_resource_start(rme32->pci, 0);
 
-       if (request_irq(pci->irq, snd_rme32_interrupt, SA_INTERRUPT | SA_SHIRQ, "RME32", (void *) rme32)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
-               return -EBUSY;
-       }
-       rme32->irq = pci->irq;
-
        if ((rme32->iobase = ioremap_nocache(rme32->port, RME32_IO_SIZE)) == 0) {
                snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n",
                           rme32->port, rme32->port + RME32_IO_SIZE - 1);
                return -ENOMEM;
        }
 
+       if (request_irq(pci->irq, snd_rme32_interrupt, SA_INTERRUPT | SA_SHIRQ, "RME32", (void *) rme32)) {
+               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               return -EBUSY;
+       }
+       rme32->irq = pci->irq;
+
        /* read the card's revision number */
        pci_read_config_byte(pci, 8, &rme32->rev);
 
index 65611a7d366d557b323d23d777c028756046bcd2..991cb18c14f3d14ce19ced4d319bdf89b38c96e1 100644 (file)
@@ -1583,17 +1583,17 @@ snd_rme96_create(struct rme96 *rme96)
                return err;
        rme96->port = pci_resource_start(rme96->pci, 0);
 
+       if ((rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE)) == 0) {
+               snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1);
+               return -ENOMEM;
+       }
+
        if (request_irq(pci->irq, snd_rme96_interrupt, SA_INTERRUPT|SA_SHIRQ, "RME96", (void *)rme96)) {
                snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
                return -EBUSY;
        }
        rme96->irq = pci->irq;
 
-       if ((rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE)) == 0) {
-               snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1);
-               return -ENOMEM;
-       }
-
        /* read the card's revision number */
        pci_read_config_byte(pci, 8, &rme96->rev);