Skip to content

Commit ff6defa

Browse files
elfringtiwai
authored andcommitted
ALSA: Deletion of checks before the function call "iounmap"
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 <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent b76c0e9 commit ff6defa

File tree

26 files changed

+43
-90
lines changed

26 files changed

+43
-90
lines changed

sound/aoa/soundbus/i2sbus/core.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ static void i2sbus_release_dev(struct device *dev)
7474
int i;
7575

7676
i2sdev = container_of(dev, struct i2sbus_dev, sound.ofdev.dev);
77-
78-
if (i2sdev->intfregs) iounmap(i2sdev->intfregs);
79-
if (i2sdev->out.dbdma) iounmap(i2sdev->out.dbdma);
80-
if (i2sdev->in.dbdma) iounmap(i2sdev->in.dbdma);
77+
iounmap(i2sdev->intfregs);
78+
iounmap(i2sdev->out.dbdma);
79+
iounmap(i2sdev->in.dbdma);
8180
for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++)
8281
release_and_free_resource(i2sdev->allocated_resource[i]);
8382
free_dbdma_descriptor_ring(i2sdev, &i2sdev->out.dbdma_ring);
@@ -318,9 +317,9 @@ static int i2sbus_add_dev(struct macio_dev *macio,
318317
free_irq(dev->interrupts[i], dev);
319318
free_dbdma_descriptor_ring(dev, &dev->out.dbdma_ring);
320319
free_dbdma_descriptor_ring(dev, &dev->in.dbdma_ring);
321-
if (dev->intfregs) iounmap(dev->intfregs);
322-
if (dev->out.dbdma) iounmap(dev->out.dbdma);
323-
if (dev->in.dbdma) iounmap(dev->in.dbdma);
320+
iounmap(dev->intfregs);
321+
iounmap(dev->out.dbdma);
322+
iounmap(dev->in.dbdma);
324323
for (i=0;i<3;i++)
325324
release_and_free_resource(dev->allocated_resource[i]);
326325
mutex_destroy(&dev->lock);

sound/arm/aaci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,8 @@ static int aaci_probe_ac97(struct aaci *aaci)
889889
static void aaci_free_card(struct snd_card *card)
890890
{
891891
struct aaci *aaci = card->private_data;
892-
if (aaci->base)
893-
iounmap(aaci->base);
892+
893+
iounmap(aaci->base);
894894
}
895895

896896
static struct aaci *aaci_init_card(struct amba_device *dev)

sound/drivers/ml403-ac97cr.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,8 +1094,7 @@ static int snd_ml403_ac97cr_free(struct snd_ml403_ac97cr *ml403_ac97cr)
10941094
if (ml403_ac97cr->capture_irq >= 0)
10951095
free_irq(ml403_ac97cr->capture_irq, ml403_ac97cr);
10961096
/* give back "port" */
1097-
if (ml403_ac97cr->port != NULL)
1098-
iounmap(ml403_ac97cr->port);
1097+
iounmap(ml403_ac97cr->port);
10991098
kfree(ml403_ac97cr);
11001099
PDEBUG(INIT_INFO, "free(): (done)\n");
11011100
return 0;

sound/isa/msnd/msnd_pinnacle.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,7 @@ static int snd_msnd_attach(struct snd_card *card)
627627
return 0;
628628

629629
err_release_region:
630-
if (chip->mappedbase)
631-
iounmap(chip->mappedbase);
630+
iounmap(chip->mappedbase);
632631
release_mem_region(chip->base, BUFFSIZE);
633632
release_region(chip->io, DSP_NUMIO);
634633
free_irq(chip->irq, chip);

sound/parisc/harmony.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,9 +893,7 @@ snd_harmony_free(struct snd_harmony *h)
893893
if (h->irq >= 0)
894894
free_irq(h->irq, h);
895895

896-
if (h->iobase)
897-
iounmap(h->iobase);
898-
896+
iounmap(h->iobase);
899897
kfree(h);
900898
return 0;
901899
}

sound/pci/ad1889.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -853,12 +853,9 @@ snd_ad1889_free(struct snd_ad1889 *chip)
853853
free_irq(chip->irq, chip);
854854

855855
skip_hw:
856-
if (chip->iobase)
857-
iounmap(chip->iobase);
858-
856+
iounmap(chip->iobase);
859857
pci_release_regions(chip->pci);
860858
pci_disable_device(chip->pci);
861-
862859
kfree(chip);
863860
return 0;
864861
}

sound/pci/asihpi/hpioctl.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,8 @@ void asihpi_adapter_remove(struct pci_dev *pci_dev)
541541
hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL);
542542

543543
/* unmap PCI memory space, mapped during device init. */
544-
for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; idx++) {
545-
if (pci.ap_mem_base[idx])
546-
iounmap(pci.ap_mem_base[idx]);
547-
}
544+
for (idx = 0; idx < HPI_MAX_ADAPTER_MEM_SPACES; ++idx)
545+
iounmap(pci.ap_mem_base[idx]);
548546

549547
if (pa->irq)
550548
free_irq(pa->irq, pa);

sound/pci/atiixp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,8 +1585,7 @@ static int snd_atiixp_free(struct atiixp *chip)
15851585
__hw_end:
15861586
if (chip->irq >= 0)
15871587
free_irq(chip->irq, chip);
1588-
if (chip->remap_addr)
1589-
iounmap(chip->remap_addr);
1588+
iounmap(chip->remap_addr);
15901589
pci_release_regions(chip->pci);
15911590
pci_disable_device(chip->pci);
15921591
kfree(chip);

sound/pci/atiixp_modem.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,8 +1211,7 @@ static int snd_atiixp_free(struct atiixp_modem *chip)
12111211
__hw_end:
12121212
if (chip->irq >= 0)
12131213
free_irq(chip->irq, chip);
1214-
if (chip->remap_addr)
1215-
iounmap(chip->remap_addr);
1214+
iounmap(chip->remap_addr);
12161215
pci_release_regions(chip->pci);
12171216
pci_disable_device(chip->pci);
12181217
kfree(chip);

sound/pci/aw2/aw2-alsa.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,7 @@ static int snd_aw2_dev_free(struct snd_device *device)
229229
if (chip->irq >= 0)
230230
free_irq(chip->irq, (void *)chip);
231231
/* release the i/o ports & memory */
232-
if (chip->iobase_virt)
233-
iounmap(chip->iobase_virt);
234-
232+
iounmap(chip->iobase_virt);
235233
pci_release_regions(chip->pci);
236234
/* disable the PCI entry */
237235
pci_disable_device(chip->pci);

sound/pci/bt87x.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,7 @@ static int snd_bt87x_free(struct snd_bt87x *chip)
690690
snd_bt87x_stop(chip);
691691
if (chip->irq >= 0)
692692
free_irq(chip->irq, chip);
693-
if (chip->mmio)
694-
iounmap(chip->mmio);
693+
iounmap(chip->mmio);
695694
pci_release_regions(chip->pci);
696695
pci_disable_device(chip->pci);
697696
kfree(chip);

sound/pci/cs4281.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,10 +1316,8 @@ static int snd_cs4281_free(struct cs4281 *chip)
13161316

13171317
if (chip->irq >= 0)
13181318
free_irq(chip->irq, chip);
1319-
if (chip->ba0)
1320-
iounmap(chip->ba0);
1321-
if (chip->ba1)
1322-
iounmap(chip->ba1);
1319+
iounmap(chip->ba0);
1320+
iounmap(chip->ba1);
13231321
pci_release_regions(chip->pci);
13241322
pci_disable_device(chip->pci);
13251323

sound/pci/cs46xx/cs46xx_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,8 +2949,8 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip)
29492949

29502950
for (idx = 0; idx < 5; idx++) {
29512951
struct snd_cs46xx_region *region = &chip->region.idx[idx];
2952-
if (region->remap_addr)
2953-
iounmap(region->remap_addr);
2952+
2953+
iounmap(region->remap_addr);
29542954
release_and_free_resource(region->resource);
29552955
}
29562956

sound/pci/ctxfi/cthw20k1.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,10 +1985,7 @@ static int hw_card_shutdown(struct hw *hw)
19851985
free_irq(hw->irq, hw);
19861986

19871987
hw->irq = -1;
1988-
1989-
if (hw->mem_base)
1990-
iounmap(hw->mem_base);
1991-
1988+
iounmap(hw->mem_base);
19921989
hw->mem_base = NULL;
19931990

19941991
if (hw->io_base)

sound/pci/ctxfi/cthw20k2.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,10 +2110,7 @@ static int hw_card_shutdown(struct hw *hw)
21102110
free_irq(hw->irq, hw);
21112111

21122112
hw->irq = -1;
2113-
2114-
if (hw->mem_base)
2115-
iounmap(hw->mem_base);
2116-
2113+
iounmap(hw->mem_base);
21172114
hw->mem_base = NULL;
21182115

21192116
if (hw->io_base)

sound/pci/echoaudio/echoaudio.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,12 +1872,8 @@ static int snd_echo_free(struct echoaudio *chip)
18721872
if (chip->comm_page)
18731873
snd_dma_free_pages(&chip->commpage_dma_buf);
18741874

1875-
if (chip->dsp_registers)
1876-
iounmap(chip->dsp_registers);
1877-
1875+
iounmap(chip->dsp_registers);
18781876
release_and_free_resource(chip->iores);
1879-
1880-
18811877
pci_disable_device(chip->pci);
18821878

18831879
/* release chip data */

sound/pci/hda/hda_intel.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,8 +1138,7 @@ static int azx_free(struct azx *chip)
11381138
free_irq(chip->irq, (void*)chip);
11391139
if (chip->msi)
11401140
pci_disable_msi(chip->pci);
1141-
if (chip->remap_addr)
1142-
iounmap(chip->remap_addr);
1141+
iounmap(chip->remap_addr);
11431142

11441143
azx_free_stream_pages(chip);
11451144
if (chip->region_requested)

sound/pci/lola/lola.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,8 @@ static void lola_free(struct lola *chip)
551551
lola_free_mixer(chip);
552552
if (chip->irq >= 0)
553553
free_irq(chip->irq, (void *)chip);
554-
if (chip->bar[0].remap_addr)
555-
iounmap(chip->bar[0].remap_addr);
556-
if (chip->bar[1].remap_addr)
557-
iounmap(chip->bar[1].remap_addr);
554+
iounmap(chip->bar[0].remap_addr);
555+
iounmap(chip->bar[1].remap_addr);
558556
if (chip->rb.area)
559557
snd_dma_free_pages(&chip->rb);
560558
pci_release_regions(chip->pci);

sound/pci/mixart/mixart.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,10 +1114,9 @@ static int snd_mixart_free(struct mixart_mgr *mgr)
11141114
}
11151115

11161116
/* release the i/o ports */
1117-
for (i = 0; i < 2; i++) {
1118-
if (mgr->mem[i].virt)
1119-
iounmap(mgr->mem[i].virt);
1120-
}
1117+
for (i = 0; i < 2; ++i)
1118+
iounmap(mgr->mem[i].virt);
1119+
11211120
pci_release_regions(mgr->pci);
11221121

11231122
/* free flowarray */

sound/pci/nm256/nm256.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,10 +1460,8 @@ static int snd_nm256_free(struct nm256 *chip)
14601460
if (chip->irq >= 0)
14611461
free_irq(chip->irq, chip);
14621462

1463-
if (chip->cport)
1464-
iounmap(chip->cport);
1465-
if (chip->buffer)
1466-
iounmap(chip->buffer);
1463+
iounmap(chip->cport);
1464+
iounmap(chip->buffer);
14671465
release_and_free_resource(chip->res_cport);
14681466
release_and_free_resource(chip->res_buffer);
14691467

sound/pci/rme9652/hdsp.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5309,9 +5309,7 @@ static int snd_hdsp_free(struct hdsp *hdsp)
53095309

53105310
release_firmware(hdsp->firmware);
53115311
vfree(hdsp->fw_uploaded);
5312-
5313-
if (hdsp->iobase)
5314-
iounmap(hdsp->iobase);
5312+
iounmap(hdsp->iobase);
53155313

53165314
if (hdsp->port)
53175315
pci_release_regions(hdsp->pci);

sound/pci/rme9652/hdspm.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6965,9 +6965,7 @@ static int snd_hdspm_free(struct hdspm * hdspm)
69656965
free_irq(hdspm->irq, (void *) hdspm);
69666966

69676967
kfree(hdspm->mixer);
6968-
6969-
if (hdspm->iobase)
6970-
iounmap(hdspm->iobase);
6968+
iounmap(hdspm->iobase);
69716969

69726970
if (hdspm->port)
69736971
pci_release_regions(hdspm->pci);

sound/pci/rme9652/rme9652.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,8 +1756,7 @@ static int snd_rme9652_free(struct snd_rme9652 *rme9652)
17561756

17571757
if (rme9652->irq >= 0)
17581758
free_irq(rme9652->irq, (void *)rme9652);
1759-
if (rme9652->iobase)
1760-
iounmap(rme9652->iobase);
1759+
iounmap(rme9652->iobase);
17611760
if (rme9652->port)
17621761
pci_release_regions(rme9652->pci);
17631762

sound/pci/sis7019.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,12 +1064,9 @@ static int sis_chip_free(struct sis7019 *sis)
10641064
if (sis->irq >= 0)
10651065
free_irq(sis->irq, sis);
10661066

1067-
if (sis->ioaddr)
1068-
iounmap(sis->ioaddr);
1069-
1067+
iounmap(sis->ioaddr);
10701068
pci_release_regions(sis->pci);
10711069
pci_disable_device(sis->pci);
1072-
10731070
sis_free_suspend(sis);
10741071
return 0;
10751072
}

sound/pci/ymfpci/ymfpci_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,8 +2246,7 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)
22462246
release_and_free_resource(chip->mpu_res);
22472247
release_and_free_resource(chip->fm_res);
22482248
snd_ymfpci_free_gameport(chip);
2249-
if (chip->reg_area_virt)
2250-
iounmap(chip->reg_area_virt);
2249+
iounmap(chip->reg_area_virt);
22512250
if (chip->work_ptr.area)
22522251
snd_dma_free_pages(&chip->work_ptr);
22532252

sound/ppc/pmac.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -867,16 +867,11 @@ static int snd_pmac_free(struct snd_pmac *chip)
867867
snd_pmac_dbdma_free(chip, &chip->capture.cmd);
868868
snd_pmac_dbdma_free(chip, &chip->extra_dma);
869869
snd_pmac_dbdma_free(chip, &emergency_dbdma);
870-
if (chip->macio_base)
871-
iounmap(chip->macio_base);
872-
if (chip->latch_base)
873-
iounmap(chip->latch_base);
874-
if (chip->awacs)
875-
iounmap(chip->awacs);
876-
if (chip->playback.dma)
877-
iounmap(chip->playback.dma);
878-
if (chip->capture.dma)
879-
iounmap(chip->capture.dma);
870+
iounmap(chip->macio_base);
871+
iounmap(chip->latch_base);
872+
iounmap(chip->awacs);
873+
iounmap(chip->playback.dma);
874+
iounmap(chip->capture.dma);
880875

881876
if (chip->node) {
882877
int i;

0 commit comments

Comments
 (0)