]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[ALSA] Fix synchronize_irq() bugs, redundancies
authorJeff Garzik <jgarzik@redhat.com>
Tue, 22 Apr 2008 11:50:34 +0000 (13:50 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 24 Apr 2008 10:00:40 +0000 (12:00 +0200)
free_irq() calls synchronize_irq() for you, so there is no need for
drivers to manually do the same thing (again).  Thus, calls where
sync-irq immediately precedes free-irq can be simplified.

However, during this audit several bugs were noticed, where free-irq is
preceded by a "irq >= 0" check... but the sync-irq call is not covered
by the same check.

So, where sync-irq could not be eliminated completely, the missing check
was added.

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
22 files changed:
drivers/media/video/cx88/cx88-alsa.c
drivers/media/video/saa7134/saa7134-alsa.c
sound/pci/ad1889.c
sound/pci/ali5451/ali5451.c
sound/pci/atiixp.c
sound/pci/atiixp_modem.c
sound/pci/au88x0/au88x0.c
sound/pci/azt3328.c
sound/pci/cmipci.c
sound/pci/ens1370.c
sound/pci/es1938.c
sound/pci/es1968.c
sound/pci/hda/hda_intel.c
sound/pci/ice1712/ice1712.c
sound/pci/ice1712/ice1724.c
sound/pci/intel8x0.c
sound/pci/intel8x0m.c
sound/pci/maestro3.c
sound/pci/oxygen/oxygen_lib.c
sound/pci/sis7019.c
sound/pci/via82xx.c
sound/pci/via82xx_modem.c

index 316b106c3511b2a15981e692c6e4c7cd9884c6cd..03feb5b49e1b270428cdcb38ae938893324eb0d9 100644 (file)
@@ -690,10 +690,8 @@ MODULE_DEVICE_TABLE(pci, cx88_audio_pci_tbl);
 static int snd_cx88_free(snd_cx88_card_t *chip)
 {
 
-       if (chip->irq >= 0){
-               synchronize_irq(chip->irq);
+       if (chip->irq >= 0)
                free_irq(chip->irq, chip);
-       }
 
        cx88_core_put(chip->core,chip->pci);
 
index 047add8f3010efae75fd7128e2d293b75206e1e4..ec6bdb9680a3b2289975e3c8f5b1554e7b0f4ff7 100644 (file)
@@ -954,10 +954,8 @@ static void snd_saa7134_free(struct snd_card * card)
        if (chip->dev->dmasound.priv_data == NULL)
                return;
 
-       if (chip->irq >= 0) {
-               synchronize_irq(chip->irq);
+       if (chip->irq >= 0)
                free_irq(chip->irq, &chip->dev->dmasound);
-       }
 
        chip->dev->dmasound.priv_data = NULL;
 
index 1edb6448946d23ccfb6847a69cb8c0f511cfc732..39ec55b57b1e808ffef72e96cbea23bc9095cabd 100644 (file)
@@ -854,8 +854,6 @@ snd_ad1889_free(struct snd_ad1889 *chip)
 
        spin_unlock_irq(&chip->lock);
 
-       synchronize_irq(chip->irq);
-       
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
 
index fc04d3da1af5ec5146a0eacc1e0a10424d79bee7..1a0fd65ec2809478d71f037f310f6a3f36a1823b 100644 (file)
@@ -2047,10 +2047,8 @@ static int snd_ali_free(struct snd_ali * codec)
 {
        if (codec->hw_initialized)
                snd_ali_disable_address_interrupt(codec);
-       if (codec->irq >= 0) {
-               synchronize_irq(codec->irq);
+       if (codec->irq >= 0)
                free_irq(codec->irq, codec);
-       }
        if (codec->port)
                pci_release_regions(codec->pci);
        pci_disable_device(codec->pci);
index 4594186b83ee7bfb4b157b6eff9e2aba79aa0916..457228fb22aad76dee9fafb9950d85c80acfd73c 100644 (file)
@@ -1553,7 +1553,7 @@ static int snd_atiixp_free(struct atiixp *chip)
        if (chip->irq < 0)
                goto __hw_end;
        snd_atiixp_chip_stop(chip);
-       synchronize_irq(chip->irq);
+
       __hw_end:
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
index a67a869180d4f572739be0de81063c45fe31948c..d457a32a7939fffb7987af0709a3bb353ce647c3 100644 (file)
@@ -1197,7 +1197,7 @@ static int snd_atiixp_free(struct atiixp_modem *chip)
        if (chip->irq < 0)
                goto __hw_end;
        snd_atiixp_chip_stop(chip);
-       synchronize_irq(chip->irq);
+
       __hw_end:
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
index 26819e2f5761810eeb3346c1224f740c4d00b276..68368e490074c21b6a0bd312d8c2a3b2e089f65d 100644 (file)
@@ -126,7 +126,6 @@ static int snd_vortex_dev_free(struct snd_device *device)
        vortex_gameport_unregister(vortex);
        vortex_core_shutdown(vortex);
        // Take down PCI interface.
-       synchronize_irq(vortex->irq);
        free_irq(vortex->irq, vortex);
        iounmap(vortex->mmio);
        pci_release_regions(vortex->pci_dev);
@@ -220,7 +219,6 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)
        return 0;
 
       alloc_out:
-       synchronize_irq(chip->irq);
        free_irq(chip->irq, chip);
       irq_out:
        vortex_core_shutdown(chip);
index be87d3113ee406720163abc9b249252e59b4776d..5f63af6b88a29d35c1c906b6e1e34d88f07780a8 100644 (file)
@@ -1514,7 +1514,8 @@ snd_azf3328_free(struct snd_azf3328 *chip)
        /* well, at least we know how to disable the timer IRQ */
        snd_azf3328_codec_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x00);
 
-        synchronize_irq(chip->irq);
+       if (chip->irq >= 0)
+               synchronize_irq(chip->irq);
 __end_hw:
        snd_azf3328_free_joystick(chip);
         if (chip->irq >= 0)
index 4074584a7d90bb39296720db17d93ba88aa5982d..9971b5b7735b5620599fb83df460b973355cbb89 100644 (file)
@@ -2933,8 +2933,6 @@ static int snd_cmipci_free(struct cmipci *cm)
                /* reset mixer */
                snd_cmipci_mixer_write(cm, 0, 0);
 
-               synchronize_irq(cm->irq);
-
                free_irq(cm->irq, cm);
        }
 
index 52fae4a7cfddcaf8354deaf95a50eab5822ba7a8..fbf1124f7c79d1609f594fdb786e0ec0e0b676ac 100644 (file)
@@ -1910,7 +1910,8 @@ static int snd_ensoniq_free(struct ensoniq *ensoniq)
        outl(0, ES_REG(ensoniq, CONTROL));      /* switch everything off */
        outl(0, ES_REG(ensoniq, SERIAL));       /* clear serial interface */
 #endif
-       synchronize_irq(ensoniq->irq);
+       if (ensoniq->irq >= 0)
+               synchronize_irq(ensoniq->irq);
        pci_set_power_state(ensoniq->pci, 3);
       __hw_end:
 #ifdef CHIP1370
index 1a314fa99c45889148c07b3d95609496b2e19c76..84fac1fbf10399bf9a3c0008945e78e9ad8c1d0f 100644 (file)
@@ -1488,7 +1488,6 @@ static int es1938_suspend(struct pci_dev *pci, pm_message_t state)
 
        outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */
        if (chip->irq >= 0) {
-               synchronize_irq(chip->irq);
                free_irq(chip->irq, chip);
                chip->irq = -1;
        }
@@ -1578,10 +1577,8 @@ static int snd_es1938_free(struct es1938 *chip)
 
        snd_es1938_free_gameport(chip);
 
-       if (chip->irq >= 0) {
-               synchronize_irq(chip->irq);
+       if (chip->irq >= 0)
                free_irq(chip->irq, chip);
-       }
        pci_release_regions(chip->pci);
        pci_disable_device(chip->pci);
        kfree(chip);
index 13837989606136af7e52cbe79d18c40e86f64e30..1bf298d214b90462cfe7b5253c7d4d0f6c097fd1 100644 (file)
@@ -2475,7 +2475,8 @@ static inline void snd_es1968_free_gameport(struct es1968 *chip) { }
 static int snd_es1968_free(struct es1968 *chip)
 {
        if (chip->io_port) {
-               synchronize_irq(chip->irq);
+               if (chip->irq >= 0)
+                       synchronize_irq(chip->irq);
                outw(1, chip->io_port + 0x04); /* clear WP interrupts */
                outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */
        }
index bc3867e1945c2adcfa0a17c51670f0f7f5cff042..b3a618eb42cdf5b4a45bc861312b974b7ce00581 100644 (file)
@@ -1682,7 +1682,6 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state)
                snd_hda_suspend(chip->bus, state);
        azx_stop_chip(chip);
        if (chip->irq >= 0) {
-               synchronize_irq(chip->irq);
                free_irq(chip->irq, chip);
                chip->irq = -1;
        }
@@ -1738,10 +1737,8 @@ static int azx_free(struct azx *chip)
                azx_stop_chip(chip);
        }
 
-       if (chip->irq >= 0) {
-               synchronize_irq(chip->irq);
+       if (chip->irq >= 0)
                free_irq(chip->irq, (void*)chip);
-       }
        if (chip->msi)
                pci_disable_msi(chip->pci);
        if (chip->remap_addr)
index 38e93ca12e2735f96f5052672f72fd2721d25f2d..29d449d73c9864132d15ea0e4cd3313634870231 100644 (file)
@@ -2490,10 +2490,9 @@ static int snd_ice1712_free(struct snd_ice1712 *ice)
        outb(0xff, ICEREG(ice, IRQMASK));
        /* --- */
       __hw_end:
-       if (ice->irq >= 0) {
-               synchronize_irq(ice->irq);
+       if (ice->irq >= 0)
                free_irq(ice->irq, ice);
-       }
+
        if (ice->port)
                pci_release_regions(ice->pci);
        snd_ice1712_akm4xxx_free(ice);
index 6b15e1cbfe4f5e3f8498f798ab95b571ad10b734..13ea94f317cb816a817bfe4e80e2ea11a1026762 100644 (file)
@@ -2153,10 +2153,8 @@ static int snd_vt1724_free(struct snd_ice1712 *ice)
        outb(0xff, ICEREG1724(ice, IRQMASK));
        /* --- */
       __hw_end:
-       if (ice->irq >= 0) {
-               synchronize_irq(ice->irq);
+       if (ice->irq >= 0)
                free_irq(ice->irq, ice);
-       }
        pci_release_regions(ice->pci);
        snd_ice1712_akm4xxx_free(ice);
        pci_disable_device(ice->pci);
index 47485afcab5f11f00eb99c14275c33454f5b4d7b..048d99e25ab0f0010ea1f4c7a7a06b553e1449d6 100644 (file)
@@ -2468,7 +2468,7 @@ static int snd_intel8x0_free(struct intel8x0 *chip)
                pci_write_config_dword(chip->pci, 0x4c, val);
        }
        /* --- */
-       synchronize_irq(chip->irq);
+
       __hw_end:
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
@@ -2517,7 +2517,6 @@ static int intel8x0_suspend(struct pci_dev *pci, pm_message_t state)
                chip->sdm_saved = igetbyte(chip, ICHREG(SDM));
 
        if (chip->irq >= 0) {
-               synchronize_irq(chip->irq);
                free_irq(chip->irq, chip);
                chip->irq = -1;
        }
index cadda8d6b70f8a00a01748c633c7116329868a6c..15db810d5893423927a9188fe67a9f75b0628612 100644 (file)
@@ -986,7 +986,8 @@ static int snd_intel8x0_free(struct intel8x0m *chip)
        for (i = 0; i < chip->bdbars_count; i++)
                iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS);
        /* --- */
-       synchronize_irq(chip->irq);
+       if (chip->irq >= 0)
+               synchronize_irq(chip->irq);
       __hw_end:
        if (chip->bdbars.area)
                snd_dma_free_pages(&chip->bdbars);
index a753dae65ab6494e77e7397bb4e148065d472ca3..a536c59fbea1e4faed5155ce579ac0ac800e572b 100644 (file)
@@ -2542,10 +2542,8 @@ static int snd_m3_free(struct snd_m3 *chip)
        vfree(chip->suspend_mem);
 #endif
 
-       if (chip->irq >= 0) {
-               synchronize_irq(chip->irq);
+       if (chip->irq >= 0)
                free_irq(chip->irq, chip);
-       }
 
        if (chip->iobase)
                pci_release_regions(chip->pci);
index f84f6a128ee9c4c88bde15c260f20a5e7b140cc6..897697d43506d2354b2ffc954f58232d97b3c556 100644 (file)
@@ -410,10 +410,8 @@ static void oxygen_card_free(struct snd_card *card)
        oxygen_write16(chip, OXYGEN_DMA_STATUS, 0);
        oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
        spin_unlock_irq(&chip->reg_lock);
-       if (chip->irq >= 0) {
+       if (chip->irq >= 0)
                free_irq(chip->irq, chip);
-               synchronize_irq(chip->irq);
-       }
        flush_scheduled_work();
        chip->model->cleanup(chip);
        mutex_destroy(&chip->mutex);
index 742f1180c39e44ccdc65bb3214c0d7ebf8c2c4ec..df2007e3be7cbf63bb18f68c3ee144b6b5a1520b 100644 (file)
@@ -1194,7 +1194,6 @@ static int sis_suspend(struct pci_dev *pci, pm_message_t state)
        /* snd_pcm_suspend_all() stopped all channels, so we're quiescent.
         */
        if (sis->irq >= 0) {
-               synchronize_irq(sis->irq);
                free_irq(sis->irq, sis);
                sis->irq = -1;
        }
index a756be661f9aa94e1e1d4af3c77a666f02a25355..b585cc3e4c472eea6434e89d9ed463038f6a61c9 100644 (file)
@@ -2236,7 +2236,7 @@ static int snd_via82xx_free(struct via82xx *chip)
        /* disable interrupts */
        for (i = 0; i < chip->num_devs; i++)
                snd_via82xx_channel_reset(chip, &chip->devs[i]);
-       synchronize_irq(chip->irq);
+
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
  __end_hw:
index f5df1c79bee166594ade22aba607664e22a15f99..31f64ee398820c62ffb8c9b51318a2c4e122e9b0 100644 (file)
@@ -1075,7 +1075,7 @@ static int snd_via82xx_free(struct via82xx_modem *chip)
        /* disable interrupts */
        for (i = 0; i < chip->num_devs; i++)
                snd_via82xx_channel_reset(chip, &chip->devs[i]);
-       synchronize_irq(chip->irq);
+
       __end_hw:
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);