ALSA: Deletion of checks before the function call "iounmap"
authorMarkus Elfring <elfring@users.sourceforge.net>
Sat, 3 Jan 2015 21:55:54 +0000 (22:55 +0100)
committerTakashi Iwai <tiwai@suse.de>
Sun, 4 Jan 2015 14:13:45 +0000 (15:13 +0100)
The iounmap() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
26 files changed:
sound/aoa/soundbus/i2sbus/core.c
sound/arm/aaci.c
sound/drivers/ml403-ac97cr.c
sound/isa/msnd/msnd_pinnacle.c
sound/parisc/harmony.c
sound/pci/ad1889.c
sound/pci/asihpi/hpioctl.c
sound/pci/atiixp.c
sound/pci/atiixp_modem.c
sound/pci/aw2/aw2-alsa.c
sound/pci/bt87x.c
sound/pci/cs4281.c
sound/pci/cs46xx/cs46xx_lib.c
sound/pci/ctxfi/cthw20k1.c
sound/pci/ctxfi/cthw20k2.c
sound/pci/echoaudio/echoaudio.c
sound/pci/hda/hda_intel.c
sound/pci/lola/lola.c
sound/pci/mixart/mixart.c
sound/pci/nm256/nm256.c
sound/pci/rme9652/hdsp.c
sound/pci/rme9652/hdspm.c
sound/pci/rme9652/rme9652.c
sound/pci/sis7019.c
sound/pci/ymfpci/ymfpci_main.c
sound/ppc/pmac.c

index 837ba99a7524bc47ae0e4ab2e711195b3e6d59b0..b9737fae656a89ba6121eddf4804312f2843dc7f 100644 (file)
@@ -74,10 +74,9 @@ static void i2sbus_release_dev(struct device *dev)
        int i;
 
        i2sdev = container_of(dev, struct i2sbus_dev, sound.ofdev.dev);
-
-       if (i2sdev->intfregs) iounmap(i2sdev->intfregs);
-       if (i2sdev->out.dbdma) iounmap(i2sdev->out.dbdma);
-       if (i2sdev->in.dbdma) iounmap(i2sdev->in.dbdma);
+       iounmap(i2sdev->intfregs);
+       iounmap(i2sdev->out.dbdma);
+       iounmap(i2sdev->in.dbdma);
        for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++)
                release_and_free_resource(i2sdev->allocated_resource[i]);
        free_dbdma_descriptor_ring(i2sdev, &i2sdev->out.dbdma_ring);
@@ -318,9 +317,9 @@ static int i2sbus_add_dev(struct macio_dev *macio,
                        free_irq(dev->interrupts[i], dev);
        free_dbdma_descriptor_ring(dev, &dev->out.dbdma_ring);
        free_dbdma_descriptor_ring(dev, &dev->in.dbdma_ring);
-       if (dev->intfregs) iounmap(dev->intfregs);
-       if (dev->out.dbdma) iounmap(dev->out.dbdma);
-       if (dev->in.dbdma) iounmap(dev->in.dbdma);
+       iounmap(dev->intfregs);
+       iounmap(dev->out.dbdma);
+       iounmap(dev->in.dbdma);
        for (i=0;i<3;i++)
                release_and_free_resource(dev->allocated_resource[i]);
        mutex_destroy(&dev->lock);
index 0e83a73efb16e18dc4a5dc5982e86976dc9e2f2c..4140b1b950544bce0fc0360402d67f7fc5a031d4 100644 (file)
@@ -889,8 +889,8 @@ static int aaci_probe_ac97(struct aaci *aaci)
 static void aaci_free_card(struct snd_card *card)
 {
        struct aaci *aaci = card->private_data;
-       if (aaci->base)
-               iounmap(aaci->base);
+
+       iounmap(aaci->base);
 }
 
 static struct aaci *aaci_init_card(struct amba_device *dev)
index ec01de1cb23b3c4fefa325f3186ea7bae7d532c9..bdcb5721393b1b326497e7a9e4fa43c60a2c3ee5 100644 (file)
@@ -1094,8 +1094,7 @@ static int snd_ml403_ac97cr_free(struct snd_ml403_ac97cr *ml403_ac97cr)
        if (ml403_ac97cr->capture_irq >= 0)
                free_irq(ml403_ac97cr->capture_irq, ml403_ac97cr);
        /* give back "port" */
-       if (ml403_ac97cr->port != NULL)
-               iounmap(ml403_ac97cr->port);
+       iounmap(ml403_ac97cr->port);
        kfree(ml403_ac97cr);
        PDEBUG(INIT_INFO, "free(): (done)\n");
        return 0;
index 65b36825d194a63d366f79eea5ed0adc5f517c04..4c072666115dbd1d2559974fb5701592e7b8ba2a 100644 (file)
@@ -627,8 +627,7 @@ static int snd_msnd_attach(struct snd_card *card)
        return 0;
 
 err_release_region:
-       if (chip->mappedbase)
-               iounmap(chip->mappedbase);
+       iounmap(chip->mappedbase);
        release_mem_region(chip->base, BUFFSIZE);
        release_region(chip->io, DSP_NUMIO);
        free_irq(chip->irq, chip);
index 29604a239c4447b82d14541c5337a62dc10e6f21..f2350c1d6ee89f7978a3ef00a7cdfa6c682a3795 100644 (file)
@@ -893,9 +893,7 @@ snd_harmony_free(struct snd_harmony *h)
        if (h->irq >= 0)
                free_irq(h->irq, h);
 
-       if (h->iobase)
-               iounmap(h->iobase);
-
+       iounmap(h->iobase);
        kfree(h);
        return 0;
 }
index 547ee30540a07974686219610be6f7e90164cbee..0de31290411c97ee6b2da4c57416c181b2611f01 100644 (file)
@@ -853,12 +853,9 @@ snd_ad1889_free(struct snd_ad1889 *chip)
                free_irq(chip->irq, chip);
 
 skip_hw:
-       if (chip->iobase)
-               iounmap(chip->iobase);
-
+       iounmap(chip->iobase);
        pci_release_regions(chip->pci);
        pci_disable_device(chip->pci);
-
        kfree(chip);
        return 0;
 }
index 72af66bdf7149ecaef5a30dd3b4a9736463102e9..67d113356971d04f855362ad6a35c0aa64b2d6dd 100644 (file)
@@ -541,10 +541,8 @@ void asihpi_adapter_remove(struct pci_dev *pci_dev)
        hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL);
 
        /* unmap PCI memory space, mapped during device init. */
-       for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) {
-               if (pci.ap_mem_base[idx])
-                       iounmap(pci.ap_mem_base[idx]);
-       }
+       for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; ++idx)
+               iounmap(pci.ap_mem_base[idx]);
 
        if (pa->irq)
                free_irq(pa->irq, pa);
index 9c1c4452a8ee416c4ea343780a9dfee89a84b94b..d24188fea4b6453f3cdc566f9731cadf23cc9a03 100644 (file)
@@ -1585,8 +1585,7 @@ static int snd_atiixp_free(struct atiixp *chip)
       __hw_end:
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
-       if (chip->remap_addr)
-               iounmap(chip->remap_addr);
+       iounmap(chip->remap_addr);
        pci_release_regions(chip->pci);
        pci_disable_device(chip->pci);
        kfree(chip);
index b2f63e0727de36345d5fc5915d13f72c65e14f3b..c321a97b43445233b750c03af46bffeddf94da0c 100644 (file)
@@ -1211,8 +1211,7 @@ static int snd_atiixp_free(struct atiixp_modem *chip)
       __hw_end:
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
-       if (chip->remap_addr)
-               iounmap(chip->remap_addr);
+       iounmap(chip->remap_addr);
        pci_release_regions(chip->pci);
        pci_disable_device(chip->pci);
        kfree(chip);
index e1cf01949fda7a2959388e1d64c2309566496394..8d2fee7b33bd75edcb634602788ae70b6946418a 100644 (file)
@@ -229,9 +229,7 @@ static int snd_aw2_dev_free(struct snd_device *device)
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *)chip);
        /* release the i/o ports & memory */
-       if (chip->iobase_virt)
-               iounmap(chip->iobase_virt);
-
+       iounmap(chip->iobase_virt);
        pci_release_regions(chip->pci);
        /* disable the PCI entry */
        pci_disable_device(chip->pci);
index 058b9973c09c487ad6b4ffa5ccbd7ceb1fe19a8e..e82ceacbe64fbdd6a54489ddc5f34d83af43187e 100644 (file)
@@ -690,8 +690,7 @@ static int snd_bt87x_free(struct snd_bt87x *chip)
                snd_bt87x_stop(chip);
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
-       if (chip->mmio)
-               iounmap(chip->mmio);
+       iounmap(chip->mmio);
        pci_release_regions(chip->pci);
        pci_disable_device(chip->pci);
        kfree(chip);
index 05a4337f811633cbba82ecca87ffb799bbc1586a..ea339111c59f74f14443e3de0068cb108251a63b 100644 (file)
@@ -1316,10 +1316,8 @@ static int snd_cs4281_free(struct cs4281 *chip)
 
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
-       if (chip->ba0)
-               iounmap(chip->ba0);
-       if (chip->ba1)
-               iounmap(chip->ba1);
+       iounmap(chip->ba0);
+       iounmap(chip->ba1);
        pci_release_regions(chip->pci);
        pci_disable_device(chip->pci);
 
index dfec84e1a575ebe73badcbf5d20c02f4a674df9a..128bbfe80aa76810e82edd427a53e647314c237a 100644 (file)
@@ -2949,8 +2949,8 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip)
 
        for (idx = 0; idx < 5; idx++) {
                struct snd_cs46xx_region *region = &chip->region.idx[idx];
-               if (region->remap_addr)
-                       iounmap(region->remap_addr);
+
+               iounmap(region->remap_addr);
                release_and_free_resource(region->resource);
        }
 
index b425aa8ee57858fb11c43f5c1b56bfa6adc8bbca..b8b0d8ef931919b31b6607c0b1d152a9e08dfb1e 100644 (file)
@@ -1985,10 +1985,7 @@ static int hw_card_shutdown(struct hw *hw)
                free_irq(hw->irq, hw);
 
        hw->irq = -1;
-
-       if (hw->mem_base)
-               iounmap(hw->mem_base);
-
+       iounmap(hw->mem_base);
        hw->mem_base = NULL;
 
        if (hw->io_base)
index 253899d1379096ea3108c5588aa012b3e4bd9a80..4e16b4d05eedc7fa66bcd5e5729c494a77fd21af 100644 (file)
@@ -2110,10 +2110,7 @@ static int hw_card_shutdown(struct hw *hw)
                free_irq(hw->irq, hw);
 
        hw->irq = -1;
-
-       if (hw->mem_base)
-               iounmap(hw->mem_base);
-
+       iounmap(hw->mem_base);
        hw->mem_base = NULL;
 
        if (hw->io_base)
index 21228adaa70cb104b58580ec6392f129a9011708..98d4f35cff2e0e6d8f062a714f78ce1c3ba321c6 100644 (file)
@@ -1872,12 +1872,8 @@ static int snd_echo_free(struct echoaudio *chip)
        if (chip->comm_page)
                snd_dma_free_pages(&chip->commpage_dma_buf);
 
-       if (chip->dsp_registers)
-               iounmap(chip->dsp_registers);
-
+       iounmap(chip->dsp_registers);
        release_and_free_resource(chip->iores);
-
-
        pci_disable_device(chip->pci);
 
        /* release chip data */
index d426a0bd6a5f7e86adf482c83ad86e3203a8a3ad..a9714251b1594d7f30890101b74a9c1853feef27 100644 (file)
@@ -1138,8 +1138,7 @@ static int azx_free(struct azx *chip)
                free_irq(chip->irq, (void*)chip);
        if (chip->msi)
                pci_disable_msi(chip->pci);
-       if (chip->remap_addr)
-               iounmap(chip->remap_addr);
+       iounmap(chip->remap_addr);
 
        azx_free_stream_pages(chip);
        if (chip->region_requested)
index 4cf4be5ef82a3b0377b853af6aef59beafa9d38a..9ff6000849732cdb66a80fc8aaad81eb38a77327 100644 (file)
@@ -551,10 +551,8 @@ static void lola_free(struct lola *chip)
        lola_free_mixer(chip);
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *)chip);
-       if (chip->bar[0].remap_addr)
-               iounmap(chip->bar[0].remap_addr);
-       if (chip->bar[1].remap_addr)
-               iounmap(chip->bar[1].remap_addr);
+       iounmap(chip->bar[0].remap_addr);
+       iounmap(chip->bar[1].remap_addr);
        if (chip->rb.area)
                snd_dma_free_pages(&chip->rb);
        pci_release_regions(chip->pci);
index 1faf47e81570f889c5800165402a6c4cbea745d4..c3a9f39f8d61a822921e647b2bea5e147c10c7ae 100644 (file)
@@ -1114,10 +1114,9 @@ static int snd_mixart_free(struct mixart_mgr *mgr)
        }
 
        /* release the i/o ports */
-       for (i = 0; i < 2; i++) {
-               if (mgr->mem[i].virt)
-                       iounmap(mgr->mem[i].virt);
-       }
+       for (i = 0; i < 2; ++i)
+               iounmap(mgr->mem[i].virt);
+
        pci_release_regions(mgr->pci);
 
        /* free flowarray */
index 4e41a4e29a1e4dd48fb11ec4981b0da8a90c0b56..3f52a44143a5f33c5d89b8997575fd3cc873b089 100644 (file)
@@ -1460,10 +1460,8 @@ static int snd_nm256_free(struct nm256 *chip)
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
 
-       if (chip->cport)
-               iounmap(chip->cport);
-       if (chip->buffer)
-               iounmap(chip->buffer);
+       iounmap(chip->cport);
+       iounmap(chip->buffer);
        release_and_free_resource(chip->res_cport);
        release_and_free_resource(chip->res_buffer);
 
index cf5a6c8b9a63a36aee58b438e58190be9f6231df..fe66bcb21475b29c39b75a1545ec4748db74b08d 100644 (file)
@@ -5309,9 +5309,7 @@ static int snd_hdsp_free(struct hdsp *hdsp)
 
        release_firmware(hdsp->firmware);
        vfree(hdsp->fw_uploaded);
-
-       if (hdsp->iobase)
-               iounmap(hdsp->iobase);
+       iounmap(hdsp->iobase);
 
        if (hdsp->port)
                pci_release_regions(hdsp->pci);
index 3342705a571506c66358840d74a579499b866d1c..8109b8e5f6efa6a7a2d255ff727e0cf7dde7ad64 100644 (file)
@@ -6965,9 +6965,7 @@ static int snd_hdspm_free(struct hdspm * hdspm)
                free_irq(hdspm->irq, (void *) hdspm);
 
        kfree(hdspm->mixer);
-
-       if (hdspm->iobase)
-               iounmap(hdspm->iobase);
+       iounmap(hdspm->iobase);
 
        if (hdspm->port)
                pci_release_regions(hdspm->pci);
index 6521521853b8ca74881dab96d8845d7e1770912c..648911c1a226eecd5da2e2728e3cd590fc1f3087 100644 (file)
@@ -1756,8 +1756,7 @@ static int snd_rme9652_free(struct snd_rme9652 *rme9652)
 
        if (rme9652->irq >= 0)
                free_irq(rme9652->irq, (void *)rme9652);
-       if (rme9652->iobase)
-               iounmap(rme9652->iobase);
+       iounmap(rme9652->iobase);
        if (rme9652->port)
                pci_release_regions(rme9652->pci);
 
index 7f6a0a0d115a9a65dbbcfaec7ad01842a95829e0..5e9437ba6eec5d7b830a583ebe7a8e55f59a75ad 100644 (file)
@@ -1064,12 +1064,9 @@ static int sis_chip_free(struct sis7019 *sis)
        if (sis->irq >= 0)
                free_irq(sis->irq, sis);
 
-       if (sis->ioaddr)
-               iounmap(sis->ioaddr);
-
+       iounmap(sis->ioaddr);
        pci_release_regions(sis->pci);
        pci_disable_device(sis->pci);
-
        sis_free_suspend(sis);
        return 0;
 }
index f5581a97d3913b37b45ba4266bdd8d7c96688292..de7f06fb3f920a47e363ab8d6e5ca5784ee5c395 100644 (file)
@@ -2246,8 +2246,7 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)
        release_and_free_resource(chip->mpu_res);
        release_and_free_resource(chip->fm_res);
        snd_ymfpci_free_gameport(chip);
-       if (chip->reg_area_virt)
-               iounmap(chip->reg_area_virt);
+       iounmap(chip->reg_area_virt);
        if (chip->work_ptr.area)
                snd_dma_free_pages(&chip->work_ptr);
        
index 5a13b22748b217b08571cdd90d3f8a8078ac8223..d399df473896f3a30de6cd9d25649e9af1461e6e 100644 (file)
@@ -867,16 +867,11 @@ static int snd_pmac_free(struct snd_pmac *chip)
        snd_pmac_dbdma_free(chip, &chip->capture.cmd);
        snd_pmac_dbdma_free(chip, &chip->extra_dma);
        snd_pmac_dbdma_free(chip, &emergency_dbdma);
-       if (chip->macio_base)
-               iounmap(chip->macio_base);
-       if (chip->latch_base)
-               iounmap(chip->latch_base);
-       if (chip->awacs)
-               iounmap(chip->awacs);
-       if (chip->playback.dma)
-               iounmap(chip->playback.dma);
-       if (chip->capture.dma)
-               iounmap(chip->capture.dma);
+       iounmap(chip->macio_base);
+       iounmap(chip->latch_base);
+       iounmap(chip->awacs);
+       iounmap(chip->playback.dma);
+       iounmap(chip->capture.dma);
 
        if (chip->node) {
                int i;