* [PATCH 11/13] ALSA: Deletion of checks before the function call "iounmap"
[not found] ` <54A9355F.4050102@users.sourceforge.net>
@ 2015-01-04 13:36 ` SF Markus Elfring
2015-01-05 13:58 ` Dan Carpenter
2016-10-26 12:26 ` Dan Carpenter
0 siblings, 2 replies; 7+ messages in thread
From: SF Markus Elfring @ 2015-01-04 13:36 UTC (permalink / raw)
To: Jaroslav Kysela, Johannes Berg, Clemens Ladisch, Russell King,
Takashi Iwai, Thibaut Varene, alsa-devel, linuxppc-dev,
linux-parisc
Cc: Julia Lawall, kernel-janitors, LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Jan 2015 22:55:54 +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>
---
sound/aoa/soundbus/i2sbus/core.c | 13 ++++++-------
sound/arm/aaci.c | 4 ++--
sound/drivers/ml403-ac97cr.c | 3 +--
sound/isa/msnd/msnd_pinnacle.c | 3 +--
sound/parisc/harmony.c | 4 +---
sound/pci/ad1889.c | 5 +----
sound/pci/asihpi/hpioctl.c | 6 ++----
sound/pci/atiixp.c | 3 +--
sound/pci/atiixp_modem.c | 3 +--
sound/pci/aw2/aw2-alsa.c | 4 +---
sound/pci/bt87x.c | 3 +--
sound/pci/cs4281.c | 6 ++----
sound/pci/cs46xx/cs46xx_lib.c | 4 ++--
sound/pci/ctxfi/cthw20k1.c | 5 +----
sound/pci/ctxfi/cthw20k2.c | 5 +----
sound/pci/echoaudio/echoaudio.c | 6 +-----
sound/pci/hda/hda_intel.c | 3 +--
sound/pci/lola/lola.c | 6 ++----
sound/pci/mixart/mixart.c | 7 +++----
sound/pci/nm256/nm256.c | 6 ++----
sound/pci/rme9652/hdsp.c | 4 +---
sound/pci/rme9652/hdspm.c | 4 +---
sound/pci/rme9652/rme9652.c | 3 +--
sound/pci/sis7019.c | 5 +----
sound/pci/ymfpci/ymfpci_main.c | 3 +--
sound/ppc/pmac.c | 15 +++++----------
26 files changed, 43 insertions(+), 90 deletions(-)
diff --git a/sound/aoa/soundbus/i2sbus/core.c b/sound/aoa/soundbus/i2sbus/core.c
index 4e2b4fb..7835045 100644
--- a/sound/aoa/soundbus/i2sbus/core.c
+++ b/sound/aoa/soundbus/i2sbus/core.c
@@ -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);
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index 0e83a73..4140b1b 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -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)
diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c
index ec01de1..bdcb572 100644
--- a/sound/drivers/ml403-ac97cr.c
+++ b/sound/drivers/ml403-ac97cr.c
@@ -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;
diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c
index 65b3682..4c07266 100644
--- a/sound/isa/msnd/msnd_pinnacle.c
+++ b/sound/isa/msnd/msnd_pinnacle.c
@@ -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);
diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c
index 29604a2..f2350c1 100644
--- a/sound/parisc/harmony.c
+++ b/sound/parisc/harmony.c
@@ -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;
}
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index 547ee30..0de3129 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -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;
}
diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
index 72af66b..67d1133 100644
--- a/sound/pci/asihpi/hpioctl.c
+++ b/sound/pci/asihpi/hpioctl.c
@@ -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);
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 9c1c445..d24188f 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -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);
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index b2f63e0..c321a97 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -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);
diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c
index e1cf019..8d2fee7 100644
--- a/sound/pci/aw2/aw2-alsa.c
+++ b/sound/pci/aw2/aw2-alsa.c
@@ -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);
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index 058b997..e82ceac 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -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);
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index 05a4337..ea33911 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -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);
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index dfec84e..128bbfe 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -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);
}
diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c
index b425aa8..b8b0d8e 100644
--- a/sound/pci/ctxfi/cthw20k1.c
+++ b/sound/pci/ctxfi/cthw20k1.c
@@ -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)
diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c
index 253899d..4e16b4d 100644
--- a/sound/pci/ctxfi/cthw20k2.c
+++ b/sound/pci/ctxfi/cthw20k2.c
@@ -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)
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 21228ad..98d4f35 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -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 */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index d426a0b..a971425 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -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)
diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c
index 4cf4be5..9ff60008 100644
--- a/sound/pci/lola/lola.c
+++ b/sound/pci/lola/lola.c
@@ -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);
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 1faf47e..c3a9f39 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -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 */
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 4e41a4e..3f52a44 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -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);
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index cf5a6c8..fe66bcb 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -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);
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 3342705..8109b8e 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -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);
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index 6521521..648911c 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -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);
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index 7f6a0a0..5e9437b 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -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;
}
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index f5581a9..de7f06f 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -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);
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 5a13b22..d399df4 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -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;
--
2.2.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 11/13] ALSA: Deletion of checks before the function call "iounmap"
2015-01-04 13:36 ` [PATCH 11/13] ALSA: Deletion of checks before the function call "iounmap" SF Markus Elfring
@ 2015-01-05 13:58 ` Dan Carpenter
2016-10-26 12:26 ` Dan Carpenter
1 sibling, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2015-01-05 13:58 UTC (permalink / raw)
To: SF Markus Elfring
Cc: alsa-devel, Russell King, linux-parisc, Takashi Iwai,
kernel-janitors, Clemens Ladisch, LKML, Julia Lawall,
Thibaut Varene, Johannes Berg, linuxppc-dev
On Sun, Jan 04, 2015 at 02:36:01PM +0100, SF Markus Elfring wrote:
> /* 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]);
>
Don't do the gratuitous idx++ to ++idx changes. You do it a couple
other places as well. It belongs in a separate patch if you really feel
it is worth doing. (It is not a clean up and it is not worth doing).
regards,
dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 0/9] video: fbdev: Deletion of some unnecessary checks
[not found] ` <5317A59D.4@users.sourceforge.net>
[not found] ` <54A9355F.4050102@users.sourceforge.net>
@ 2015-01-19 17:54 ` SF Markus Elfring
2015-01-19 18:00 ` [PATCH 1/9] video: Deletion of checks before the function call "iounmap" SF Markus Elfring
1 sibling, 1 reply; 7+ messages in thread
From: SF Markus Elfring @ 2015-01-19 17:54 UTC (permalink / raw)
To: Antonino Daplas, Ferenc Bakonyi, Hans de Goede, Helge Deller,
James E. J. Bottomley, Jean-Christophe Plagniol-Villard,
Kristoffer Ericson, Peter Jones, Tomi Valkeinen, linux-fbdev,
linux-nvidia, linux-parisc
Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Jan 2015 17:57:25 +0100
Further update suggestions were taken into account after a patch was applied
from static source code analysis.
Markus Elfring (9):
fbdev: Deletion of checks before the function call "iounmap"
One function call less in tdfxfb_probe() after error detection
One function call less in vesafb_probe() after error detection
Add check for return value of ioremap() in cirrusfb_pci_register()
Less function calls in trident_pci_probe() after error detection
One function call less in pvr2fb_common_init() after error detection
One function call less in tgafb_register() after error detection
Less function calls in valkyriefb_init() after error detection
Less function calls in w100fb_probe() after error detection
drivers/video/fbdev/aty/atyfb_base.c | 15 +++++--------
drivers/video/fbdev/cirrusfb.c | 10 ++++++---
drivers/video/fbdev/controlfb.c | 6 ++---
drivers/video/fbdev/efifb.c | 3 +--
drivers/video/fbdev/hgafb.c | 3 +--
drivers/video/fbdev/hpfb.c | 3 +--
drivers/video/fbdev/i810/i810_main.c | 6 ++---
drivers/video/fbdev/macfb.c | 15 +++++--------
drivers/video/fbdev/offb.c | 3 +--
drivers/video/fbdev/pvr2fb.c | 15 ++++++-------
drivers/video/fbdev/s1d13xxxfb.c | 3 +--
drivers/video/fbdev/s3fb.c | 6 ++---
drivers/video/fbdev/sh_mobile_hdmi.c | 6 ++---
drivers/video/fbdev/sh_mobile_lcdcfb.c | 3 +--
drivers/video/fbdev/simplefb.c | 3 +--
drivers/video/fbdev/stifb.c | 3 +--
drivers/video/fbdev/tdfxfb.c | 22 +++++++++----------
drivers/video/fbdev/tgafb.c | 20 ++++++++---------
drivers/video/fbdev/tridentfb.c | 15 +++++++------
drivers/video/fbdev/valkyriefb.c | 37 ++++++++++++++++++-------------
drivers/video/fbdev/vesafb.c | 11 +++++-----
drivers/video/fbdev/w100fb.c | 40 +++++++++++++++++-----------------
22 files changed, 116 insertions(+), 132 deletions(-)
--
2.2.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/9] video: Deletion of checks before the function call "iounmap"
2015-01-19 17:54 ` [PATCH 0/9] video: fbdev: Deletion of some unnecessary checks SF Markus Elfring
@ 2015-01-19 18:00 ` SF Markus Elfring
0 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2015-01-19 18:00 UTC (permalink / raw)
To: Antonino Daplas, Ferenc Bakonyi, Hans de Goede, Helge Deller,
James E. J. Bottomley, Jean-Christophe Plagniol-Villard,
Kristoffer Ericson, Peter Jones, Tomi Valkeinen, linux-fbdev,
linux-nvidia, linux-parisc
Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Jan 2015 22:45:39 +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>
---
drivers/video/fbdev/aty/atyfb_base.c | 15 +++++----------
drivers/video/fbdev/cirrusfb.c | 3 +--
drivers/video/fbdev/controlfb.c | 6 ++----
drivers/video/fbdev/efifb.c | 3 +--
drivers/video/fbdev/hgafb.c | 3 +--
drivers/video/fbdev/hpfb.c | 3 +--
drivers/video/fbdev/i810/i810_main.c | 6 ++----
drivers/video/fbdev/macfb.c | 15 +++++----------
drivers/video/fbdev/offb.c | 3 +--
drivers/video/fbdev/pvr2fb.c | 3 +--
drivers/video/fbdev/s1d13xxxfb.c | 3 +--
drivers/video/fbdev/s3fb.c | 6 ++----
drivers/video/fbdev/sh_mobile_hdmi.c | 6 ++----
drivers/video/fbdev/sh_mobile_lcdcfb.c | 3 +--
drivers/video/fbdev/simplefb.c | 3 +--
drivers/video/fbdev/stifb.c | 3 +--
drivers/video/fbdev/tdfxfb.c | 6 ++----
drivers/video/fbdev/tgafb.c | 3 +--
drivers/video/fbdev/tridentfb.c | 6 ++----
drivers/video/fbdev/valkyriefb.c | 9 +++------
drivers/video/fbdev/vesafb.c | 6 ++----
drivers/video/fbdev/w100fb.c | 9 +++------
22 files changed, 41 insertions(+), 82 deletions(-)
diff --git a/drivers/video/fbdev/aty/atyfb_base.c b/drivers/video/fbdev/aty/atyfb_base.c
index 37ec09b..0f4b147 100644
--- a/drivers/video/fbdev/aty/atyfb_base.c
+++ b/drivers/video/fbdev/aty/atyfb_base.c
@@ -3605,10 +3605,8 @@ err_release_io:
#ifdef __sparc__
kfree(par->mmap_map);
#else
- if (par->ati_regbase)
- iounmap(par->ati_regbase);
- if (info->screen_base)
- iounmap(info->screen_base);
+ iounmap(par->ati_regbase);
+ iounmap(info->screen_base);
#endif
err_release_mem:
if (par->aux_start)
@@ -3733,13 +3731,10 @@ static void atyfb_remove(struct fb_info *info)
}
#endif
#ifndef __sparc__
- if (par->ati_regbase)
- iounmap(par->ati_regbase);
- if (info->screen_base)
- iounmap(info->screen_base);
+ iounmap(par->ati_regbase);
+ iounmap(info->screen_base);
#ifdef __BIG_ENDIAN
- if (info->sprite.addr)
- iounmap(info->sprite.addr);
+ iounmap(info->sprite.addr);
#endif
#endif
#ifdef __sparc__
diff --git a/drivers/video/fbdev/cirrusfb.c b/drivers/video/fbdev/cirrusfb.c
index d992aa5..d8b3359 100644
--- a/drivers/video/fbdev/cirrusfb.c
+++ b/drivers/video/fbdev/cirrusfb.c
@@ -2164,8 +2164,7 @@ err_release_regions:
#endif
pci_release_regions(pdev);
err_release_fb:
- if (cinfo->laguna_mmio != NULL)
- iounmap(cinfo->laguna_mmio);
+ iounmap(cinfo->laguna_mmio);
framebuffer_release(info);
err_out:
return ret;
diff --git a/drivers/video/fbdev/controlfb.c b/drivers/video/fbdev/controlfb.c
index 080fdd2..d386fed 100644
--- a/drivers/video/fbdev/controlfb.c
+++ b/drivers/video/fbdev/controlfb.c
@@ -1068,10 +1068,8 @@ static void control_cleanup(void)
if (!p)
return;
- if (p->cmap_regs)
- iounmap(p->cmap_regs);
- if (p->control_regs)
- iounmap(p->control_regs);
+ iounmap(p->cmap_regs);
+ iounmap(p->control_regs);
if (p->frame_buffer) {
if (p->control_use_bank2)
p->frame_buffer -= 0x600000;
diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
index 4bfff34..a6d08f0 100644
--- a/drivers/video/fbdev/efifb.c
+++ b/drivers/video/fbdev/efifb.c
@@ -65,8 +65,7 @@ static int efifb_setcolreg(unsigned regno, unsigned red, unsigned green,
static void efifb_destroy(struct fb_info *info)
{
- if (info->screen_base)
- iounmap(info->screen_base);
+ iounmap(info->screen_base);
if (request_mem_succeeded)
release_mem_region(info->apertures->ranges[0].base,
info->apertures->ranges[0].size);
diff --git a/drivers/video/fbdev/hgafb.c b/drivers/video/fbdev/hgafb.c
index 5ff9fe2..76b231e 100644
--- a/drivers/video/fbdev/hgafb.c
+++ b/drivers/video/fbdev/hgafb.c
@@ -552,8 +552,7 @@ static int hgafb_probe(struct platform_device *pdev)
if (! hga_card_detect()) {
printk(KERN_INFO "hgafb: HGA card not detected.\n");
- if (hga_vram)
- iounmap(hga_vram);
+ iounmap(hga_vram);
return -EINVAL;
}
diff --git a/drivers/video/fbdev/hpfb.c b/drivers/video/fbdev/hpfb.c
index a1b7e5f..9b47102 100644
--- a/drivers/video/fbdev/hpfb.c
+++ b/drivers/video/fbdev/hpfb.c
@@ -355,8 +355,7 @@ static void hpfb_remove_one(struct dio_dev *d)
iounmap((void *)fb_regs);
release_mem_region(d->resource.start, resource_size(&d->resource));
fb_dealloc_cmap(&fb_info.cmap);
- if (fb_info.screen_base)
- iounmap(fb_info.screen_base);
+ iounmap(fb_info.screen_base);
}
static struct dio_device_id hpfb_dio_tbl[] = {
diff --git a/drivers/video/fbdev/i810/i810_main.c b/drivers/video/fbdev/i810/i810_main.c
index bb674e4..ce3a585 100644
--- a/drivers/video/fbdev/i810/i810_main.c
+++ b/drivers/video/fbdev/i810/i810_main.c
@@ -2105,10 +2105,8 @@ static void i810fb_release_resource(struct fb_info *info,
if (par->i810_gtt.i810_fb_memory)
agp_free_memory(gtt->i810_fb_memory);
- if (par->mmio_start_virtual)
- iounmap(par->mmio_start_virtual);
- if (par->aperture.virtual)
- iounmap(par->aperture.virtual);
+ iounmap(par->mmio_start_virtual);
+ iounmap(par->aperture.virtual);
kfree(par->edid);
if (par->res_flags & FRAMEBUFFER_REQ)
release_mem_region(par->aperture.physical,
diff --git a/drivers/video/fbdev/macfb.c b/drivers/video/fbdev/macfb.c
index cda7587..dde0520 100644
--- a/drivers/video/fbdev/macfb.c
+++ b/drivers/video/fbdev/macfb.c
@@ -541,16 +541,11 @@ static void __init macfb_setup(char *options)
static void __init iounmap_macfb(void)
{
- if (dafb_cmap_regs)
- iounmap(dafb_cmap_regs);
- if (v8_brazil_cmap_regs)
- iounmap(v8_brazil_cmap_regs);
- if (rbv_cmap_regs)
- iounmap(rbv_cmap_regs);
- if (civic_cmap_regs)
- iounmap(civic_cmap_regs);
- if (csc_cmap_regs)
- iounmap(csc_cmap_regs);
+ iounmap(dafb_cmap_regs);
+ iounmap(v8_brazil_cmap_regs);
+ iounmap(rbv_cmap_regs);
+ iounmap(civic_cmap_regs);
+ iounmap(csc_cmap_regs);
}
static int __init macfb_init(void)
diff --git a/drivers/video/fbdev/offb.c b/drivers/video/fbdev/offb.c
index 43a0a52..5efce99 100644
--- a/drivers/video/fbdev/offb.c
+++ b/drivers/video/fbdev/offb.c
@@ -281,8 +281,7 @@ static int offb_set_par(struct fb_info *info)
static void offb_destroy(struct fb_info *info)
{
- if (info->screen_base)
- iounmap(info->screen_base);
+ iounmap(info->screen_base);
release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size);
framebuffer_release(info);
}
diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c
index 7c74f58..7aa4ef1 100644
--- a/drivers/video/fbdev/pvr2fb.c
+++ b/drivers/video/fbdev/pvr2fb.c
@@ -841,8 +841,7 @@ static int pvr2fb_common_init(void)
return 0;
out_err:
- if (fb_info->screen_base)
- iounmap(fb_info->screen_base);
+ iounmap(fb_info->screen_base);
if (par->mmio_base)
iounmap((void *)par->mmio_base);
diff --git a/drivers/video/fbdev/s1d13xxxfb.c b/drivers/video/fbdev/s1d13xxxfb.c
index 83433cb..dff38b7 100644
--- a/drivers/video/fbdev/s1d13xxxfb.c
+++ b/drivers/video/fbdev/s1d13xxxfb.c
@@ -750,8 +750,7 @@ s1d13xxxfb_remove(struct platform_device *pdev)
fb_dealloc_cmap(&info->cmap);
- if (info->screen_base)
- iounmap(info->screen_base);
+ iounmap(info->screen_base);
framebuffer_release(info);
}
diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c
index f0ae61a..3d9d45f 100644
--- a/drivers/video/fbdev/s3fb.c
+++ b/drivers/video/fbdev/s3fb.c
@@ -1382,8 +1382,7 @@ err_find_mode:
#ifdef CONFIG_FB_S3_DDC
if (par->ddc_registered)
i2c_del_adapter(&par->ddc_adapter);
- if (par->mmio)
- iounmap(par->mmio);
+ iounmap(par->mmio);
#endif
pci_iounmap(dev, info->screen_base);
err_iomap:
@@ -1419,8 +1418,7 @@ static void s3_pci_remove(struct pci_dev *dev)
#ifdef CONFIG_FB_S3_DDC
if (par->ddc_registered)
i2c_del_adapter(&par->ddc_adapter);
- if (par->mmio)
- iounmap(par->mmio);
+ iounmap(par->mmio);
#endif
pci_iounmap(dev, info->screen_base);
diff --git a/drivers/video/fbdev/sh_mobile_hdmi.c b/drivers/video/fbdev/sh_mobile_hdmi.c
index 7c72a3f..2a7187d 100644
--- a/drivers/video/fbdev/sh_mobile_hdmi.c
+++ b/drivers/video/fbdev/sh_mobile_hdmi.c
@@ -1397,8 +1397,7 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
ecodec:
free_irq(irq, hdmi);
ereqirq:
- if (hdmi->htop1)
- iounmap(hdmi->htop1);
+ iounmap(hdmi->htop1);
emap_htop1:
pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev);
@@ -1428,8 +1427,7 @@ static int __exit sh_hdmi_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
clk_disable_unprepare(hdmi->hdmi_clk);
clk_put(hdmi->hdmi_clk);
- if (hdmi->htop1)
- iounmap(hdmi->htop1);
+ iounmap(hdmi->htop1);
iounmap(hdmi->base);
release_mem_region(res->start, resource_size(res));
diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
index d3013cd..4f9a25b 100644
--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
@@ -2489,8 +2489,7 @@ static int sh_mobile_lcdc_remove(struct platform_device *pdev)
clk_put(priv->dot_clk);
}
- if (priv->base)
- iounmap(priv->base);
+ iounmap(priv->base);
if (priv->irq)
free_irq(priv->irq, priv);
diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c
index 92cac80..40e6b33 100644
--- a/drivers/video/fbdev/simplefb.c
+++ b/drivers/video/fbdev/simplefb.c
@@ -72,8 +72,7 @@ static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
static void simplefb_destroy(struct fb_info *info)
{
- if (info->screen_base)
- iounmap(info->screen_base);
+ iounmap(info->screen_base);
}
static struct fb_ops simplefb_ops = {
diff --git a/drivers/video/fbdev/stifb.c b/drivers/video/fbdev/stifb.c
index 86621fa..ea12305 100644
--- a/drivers/video/fbdev/stifb.c
+++ b/drivers/video/fbdev/stifb.c
@@ -1374,8 +1374,7 @@ stifb_cleanup(void)
unregister_framebuffer(sti->info);
release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
release_mem_region(info->fix.smem_start, info->fix.smem_len);
- if (info->screen_base)
- iounmap(info->screen_base);
+ iounmap(info->screen_base);
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
}
diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c
index f761fe3..69d4062 100644
--- a/drivers/video/fbdev/tdfxfb.c
+++ b/drivers/video/fbdev/tdfxfb.c
@@ -1572,15 +1572,13 @@ out_err_iobase:
release_region(pci_resource_start(pdev, 2),
pci_resource_len(pdev, 2));
out_err_screenbase:
- if (info->screen_base)
- iounmap(info->screen_base);
+ iounmap(info->screen_base);
release_mem_region(info->fix.smem_start, pci_resource_len(pdev, 1));
out_err_regbase:
/*
* Cleanup after anything that was remapped/allocated.
*/
- if (default_par->regbase_virt)
- iounmap(default_par->regbase_virt);
+ iounmap(default_par->regbase_virt);
release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
out_err:
framebuffer_release(info);
diff --git a/drivers/video/fbdev/tgafb.c b/drivers/video/fbdev/tgafb.c
index 65ba992..b6fb7e8 100644
--- a/drivers/video/fbdev/tgafb.c
+++ b/drivers/video/fbdev/tgafb.c
@@ -1520,8 +1520,7 @@ static int tgafb_register(struct device *dev)
err2:
fb_dealloc_cmap(&info->cmap);
err1:
- if (mem_base)
- iounmap(mem_base);
+ iounmap(mem_base);
release_mem_region(bar0_start, bar0_len);
err0:
framebuffer_release(info);
diff --git a/drivers/video/fbdev/tridentfb.c b/drivers/video/fbdev/tridentfb.c
index 7ed9a22..71567401 100644
--- a/drivers/video/fbdev/tridentfb.c
+++ b/drivers/video/fbdev/tridentfb.c
@@ -1531,13 +1531,11 @@ static int trident_pci_probe(struct pci_dev *dev,
out_unmap2:
kfree(info->pixmap.addr);
- if (info->screen_base)
- iounmap(info->screen_base);
+ iounmap(info->screen_base);
release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len);
disable_mmio(info->par);
out_unmap1:
- if (default_par->io_virt)
- iounmap(default_par->io_virt);
+ iounmap(default_par->io_virt);
release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len);
framebuffer_release(info);
return err;
diff --git a/drivers/video/fbdev/valkyriefb.c b/drivers/video/fbdev/valkyriefb.c
index 275fb98..2a9213b 100644
--- a/drivers/video/fbdev/valkyriefb.c
+++ b/drivers/video/fbdev/valkyriefb.c
@@ -400,12 +400,9 @@ int __init valkyriefb_init(void)
out_cmap_free:
fb_dealloc_cmap(&p->info.cmap);
out_free:
- if (p->frame_buffer)
- iounmap(p->frame_buffer);
- if (p->cmap_regs)
- iounmap(p->cmap_regs);
- if (p->valkyrie_regs)
- iounmap(p->valkyrie_regs);
+ iounmap(p->frame_buffer);
+ iounmap(p->cmap_regs);
+ iounmap(p->valkyrie_regs);
kfree(p);
return err;
}
diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c
index d79a0ac..693d18e 100644
--- a/drivers/video/fbdev/vesafb.c
+++ b/drivers/video/fbdev/vesafb.c
@@ -176,8 +176,7 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
static void vesafb_destroy(struct fb_info *info)
{
fb_dealloc_cmap(&info->cmap);
- if (info->screen_base)
- iounmap(info->screen_base);
+ iounmap(info->screen_base);
release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size);
}
@@ -492,8 +491,7 @@ static int vesafb_probe(struct platform_device *dev)
fb_info(info, "%s frame buffer device\n", info->fix.id);
return 0;
err:
- if (info->screen_base)
- iounmap(info->screen_base);
+ iounmap(info->screen_base);
framebuffer_release(info);
release_mem_region(vesafb_fix.smem_start, size_total);
return err;
diff --git a/drivers/video/fbdev/w100fb.c b/drivers/video/fbdev/w100fb.c
index 10951c8..aeb53eb 100644
--- a/drivers/video/fbdev/w100fb.c
+++ b/drivers/video/fbdev/w100fb.c
@@ -770,12 +770,9 @@ out:
fb_dealloc_cmap(&info->cmap);
kfree(info->pseudo_palette);
}
- if (remapped_fbuf != NULL)
- iounmap(remapped_fbuf);
- if (remapped_regs != NULL)
- iounmap(remapped_regs);
- if (remapped_base != NULL)
- iounmap(remapped_base);
+ iounmap(remapped_fbuf);
+ iounmap(remapped_regs);
+ iounmap(remapped_base);
if (info)
framebuffer_release(info);
return err;
--
2.2.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 11/13] ALSA: Deletion of checks before the function call "iounmap"
2015-01-04 13:36 ` [PATCH 11/13] ALSA: Deletion of checks before the function call "iounmap" SF Markus Elfring
2015-01-05 13:58 ` Dan Carpenter
@ 2016-10-26 12:26 ` Dan Carpenter
2016-10-26 12:28 ` Johannes Berg
1 sibling, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2016-10-26 12:26 UTC (permalink / raw)
To: SF Markus Elfring
Cc: alsa-devel, Russell King, linux-parisc, Takashi Iwai,
kernel-janitors, Clemens Ladisch, LKML, Jaroslav Kysela,
Julia Lawall, Thibaut Varene, Johannes Berg, linuxppc-dev
Someone was just mentioning in another thread that removing the check
from iounmap() is not portable to other arches and then I remembered
that Markus removed a bunch of these.
We should consider reverting this, perhaps?
regards,
dan carpenter
On Sun, Jan 04, 2015 at 02:36:01PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 3 Jan 2015 22:55:54 +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>
> ---
> sound/aoa/soundbus/i2sbus/core.c | 13 ++++++-------
> sound/arm/aaci.c | 4 ++--
> sound/drivers/ml403-ac97cr.c | 3 +--
> sound/isa/msnd/msnd_pinnacle.c | 3 +--
> sound/parisc/harmony.c | 4 +---
> sound/pci/ad1889.c | 5 +----
> sound/pci/asihpi/hpioctl.c | 6 ++----
> sound/pci/atiixp.c | 3 +--
> sound/pci/atiixp_modem.c | 3 +--
> sound/pci/aw2/aw2-alsa.c | 4 +---
> sound/pci/bt87x.c | 3 +--
> sound/pci/cs4281.c | 6 ++----
> sound/pci/cs46xx/cs46xx_lib.c | 4 ++--
> sound/pci/ctxfi/cthw20k1.c | 5 +----
> sound/pci/ctxfi/cthw20k2.c | 5 +----
> sound/pci/echoaudio/echoaudio.c | 6 +-----
> sound/pci/hda/hda_intel.c | 3 +--
> sound/pci/lola/lola.c | 6 ++----
> sound/pci/mixart/mixart.c | 7 +++----
> sound/pci/nm256/nm256.c | 6 ++----
> sound/pci/rme9652/hdsp.c | 4 +---
> sound/pci/rme9652/hdspm.c | 4 +---
> sound/pci/rme9652/rme9652.c | 3 +--
> sound/pci/sis7019.c | 5 +----
> sound/pci/ymfpci/ymfpci_main.c | 3 +--
> sound/ppc/pmac.c | 15 +++++----------
> 26 files changed, 43 insertions(+), 90 deletions(-)
>
> diff --git a/sound/aoa/soundbus/i2sbus/core.c b/sound/aoa/soundbus/i2sbus/core.c
> index 4e2b4fb..7835045 100644
> --- a/sound/aoa/soundbus/i2sbus/core.c
> +++ b/sound/aoa/soundbus/i2sbus/core.c
> @@ -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);
> diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
> index 0e83a73..4140b1b 100644
> --- a/sound/arm/aaci.c
> +++ b/sound/arm/aaci.c
> @@ -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)
> diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c
> index ec01de1..bdcb572 100644
> --- a/sound/drivers/ml403-ac97cr.c
> +++ b/sound/drivers/ml403-ac97cr.c
> @@ -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;
> diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c
> index 65b3682..4c07266 100644
> --- a/sound/isa/msnd/msnd_pinnacle.c
> +++ b/sound/isa/msnd/msnd_pinnacle.c
> @@ -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);
> diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c
> index 29604a2..f2350c1 100644
> --- a/sound/parisc/harmony.c
> +++ b/sound/parisc/harmony.c
> @@ -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;
> }
> diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
> index 547ee30..0de3129 100644
> --- a/sound/pci/ad1889.c
> +++ b/sound/pci/ad1889.c
> @@ -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;
> }
> diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c
> index 72af66b..67d1133 100644
> --- a/sound/pci/asihpi/hpioctl.c
> +++ b/sound/pci/asihpi/hpioctl.c
> @@ -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);
> diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
> index 9c1c445..d24188f 100644
> --- a/sound/pci/atiixp.c
> +++ b/sound/pci/atiixp.c
> @@ -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);
> diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
> index b2f63e0..c321a97 100644
> --- a/sound/pci/atiixp_modem.c
> +++ b/sound/pci/atiixp_modem.c
> @@ -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);
> diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c
> index e1cf019..8d2fee7 100644
> --- a/sound/pci/aw2/aw2-alsa.c
> +++ b/sound/pci/aw2/aw2-alsa.c
> @@ -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);
> diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
> index 058b997..e82ceac 100644
> --- a/sound/pci/bt87x.c
> +++ b/sound/pci/bt87x.c
> @@ -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);
> diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
> index 05a4337..ea33911 100644
> --- a/sound/pci/cs4281.c
> +++ b/sound/pci/cs4281.c
> @@ -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);
>
> diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
> index dfec84e..128bbfe 100644
> --- a/sound/pci/cs46xx/cs46xx_lib.c
> +++ b/sound/pci/cs46xx/cs46xx_lib.c
> @@ -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);
> }
>
> diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c
> index b425aa8..b8b0d8e 100644
> --- a/sound/pci/ctxfi/cthw20k1.c
> +++ b/sound/pci/ctxfi/cthw20k1.c
> @@ -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)
> diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c
> index 253899d..4e16b4d 100644
> --- a/sound/pci/ctxfi/cthw20k2.c
> +++ b/sound/pci/ctxfi/cthw20k2.c
> @@ -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)
> diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
> index 21228ad..98d4f35 100644
> --- a/sound/pci/echoaudio/echoaudio.c
> +++ b/sound/pci/echoaudio/echoaudio.c
> @@ -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 */
> diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
> index d426a0b..a971425 100644
> --- a/sound/pci/hda/hda_intel.c
> +++ b/sound/pci/hda/hda_intel.c
> @@ -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)
> diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c
> index 4cf4be5..9ff60008 100644
> --- a/sound/pci/lola/lola.c
> +++ b/sound/pci/lola/lola.c
> @@ -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);
> diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
> index 1faf47e..c3a9f39 100644
> --- a/sound/pci/mixart/mixart.c
> +++ b/sound/pci/mixart/mixart.c
> @@ -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 */
> diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
> index 4e41a4e..3f52a44 100644
> --- a/sound/pci/nm256/nm256.c
> +++ b/sound/pci/nm256/nm256.c
> @@ -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);
>
> diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
> index cf5a6c8..fe66bcb 100644
> --- a/sound/pci/rme9652/hdsp.c
> +++ b/sound/pci/rme9652/hdsp.c
> @@ -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);
> diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
> index 3342705..8109b8e 100644
> --- a/sound/pci/rme9652/hdspm.c
> +++ b/sound/pci/rme9652/hdspm.c
> @@ -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);
> diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
> index 6521521..648911c 100644
> --- a/sound/pci/rme9652/rme9652.c
> +++ b/sound/pci/rme9652/rme9652.c
> @@ -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);
>
> diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
> index 7f6a0a0..5e9437b 100644
> --- a/sound/pci/sis7019.c
> +++ b/sound/pci/sis7019.c
> @@ -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;
> }
> diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
> index f5581a9..de7f06f 100644
> --- a/sound/pci/ymfpci/ymfpci_main.c
> +++ b/sound/pci/ymfpci/ymfpci_main.c
> @@ -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);
>
> diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
> index 5a13b22..d399df4 100644
> --- a/sound/ppc/pmac.c
> +++ b/sound/ppc/pmac.c
> @@ -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;
> --
> 2.2.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 11/13] ALSA: Deletion of checks before the function call "iounmap"
2016-10-26 12:26 ` Dan Carpenter
@ 2016-10-26 12:28 ` Johannes Berg
2016-10-26 12:42 ` Dan Carpenter
0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2016-10-26 12:28 UTC (permalink / raw)
To: Dan Carpenter, SF Markus Elfring
Cc: alsa-devel, Russell King, linux-parisc, Takashi Iwai,
kernel-janitors, Clemens Ladisch, LKML, Jaroslav Kysela,
Julia Lawall, Thibaut Varene, linuxppc-dev
On Wed, 2016-10-26 at 15:26 +0300, Dan Carpenter wrote:
> Someone was just mentioning in another thread that removing the check
> from iounmap() is not portable to other arches and then I remembered
> that Markus removed a bunch of these.
>
> We should consider reverting this, perhaps?
Can't we teach all architectures? Not that reverting it would be a
problem.
johannes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 11/13] ALSA: Deletion of checks before the function call "iounmap"
2016-10-26 12:28 ` Johannes Berg
@ 2016-10-26 12:42 ` Dan Carpenter
0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2016-10-26 12:42 UTC (permalink / raw)
To: Johannes Berg
Cc: SF Markus Elfring, Jaroslav Kysela, Clemens Ladisch, Russell King,
Takashi Iwai, Thibaut Varene, alsa-devel, linuxppc-dev,
linux-parisc, LKML, kernel-janitors, Julia Lawall
On Wed, Oct 26, 2016 at 02:28:59PM +0200, Johannes Berg wrote:
> On Wed, 2016-10-26 at 15:26 +0300, Dan Carpenter wrote:
> > Someone was just mentioning in another thread that removing the check
> > from iounmap() is not portable to other arches and then I remembered
> > that Markus removed a bunch of these.
> >
> > We should consider reverting this, perhaps?
>
> Can't we teach all architectures? Not that reverting it would be a
> problem.
We probably should. I just didn't want to suggest it, in case it sounds
like volunteering... I'm not going to be able to do it because I'm on
the road for a bit.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-10-26 12:42 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <5307CAA2.8060406@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402212321410.2043@localhost6.localdomain6>
[not found] ` <530A086E.8010901@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402231635510.1985@localhost6.localdomain6>
[not found] ` <530A72AA.3000601@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402240658210.2090@localhost6.localdomain6>
[not found] ` <530B5FB6.6010207@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1402241710370.2074@hadrien>
[not found] ` <530C5E18.1020800@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1402251014170.2080@hadrien>
[not found] ` <530CD2C4.4050903@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1402251840450.7035@hadrien>
[not found] ` <530CF8FF.8080600@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402252117150.2047@localhost6.localdomain6>
[not found] ` <530DD06F.4090703@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402262129250.2221@localhost6.localdomain6>
[not found] ` <5317A59D.4@users.sourceforge.net>
[not found] ` <54A9355F.4050102@users.sourceforge.net>
2015-01-04 13:36 ` [PATCH 11/13] ALSA: Deletion of checks before the function call "iounmap" SF Markus Elfring
2015-01-05 13:58 ` Dan Carpenter
2016-10-26 12:26 ` Dan Carpenter
2016-10-26 12:28 ` Johannes Berg
2016-10-26 12:42 ` Dan Carpenter
2015-01-19 17:54 ` [PATCH 0/9] video: fbdev: Deletion of some unnecessary checks SF Markus Elfring
2015-01-19 18:00 ` [PATCH 1/9] video: Deletion of checks before the function call "iounmap" SF Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).