Commit 7de8cf94 authored by Ricardo Ribalda's avatar Ricardo Ribalda Committed by Hans Verkuil
Browse files

media: pci/ivtv: Replace ioremap with devm_ variants



With Managed Device Resources the error handling is simpler.

The following smatch warning is silenced:
drivers/media/pci/ivtv/ivtv-driver.c: drivers/media/pci/ivtv/ivtv-driver.c:1296 ivtv_probe() warn: 'itv->dec_mem' from ioremap() not released on lines: 1296.
drivers/media/pci/ivtv/ivtv-driver.c: drivers/media/pci/ivtv/ivtv-driver.c:1296 ivtv_probe() warn: 'itv->enc_mem' from ioremap() not released on lines: 1296.

Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 364ae464
Loading
Loading
Loading
Loading
+12 −39
Original line number Diff line number Diff line
@@ -371,33 +371,6 @@ int ivtv_msleep_timeout(unsigned int msecs, int intr)
	return 0;
}

/* Release ioremapped memory */
static void ivtv_iounmap(struct ivtv *itv)
{
	if (itv == NULL)
		return;

	/* Release registers memory */
	if (itv->reg_mem != NULL) {
		IVTV_DEBUG_INFO("releasing reg_mem\n");
		iounmap(itv->reg_mem);
		itv->reg_mem = NULL;
	}
	/* Release io memory */
	if (itv->has_cx23415 && itv->dec_mem != NULL) {
		IVTV_DEBUG_INFO("releasing dec_mem\n");
		iounmap(itv->dec_mem);
	}
	itv->dec_mem = NULL;

	/* Release io memory */
	if (itv->enc_mem != NULL) {
		IVTV_DEBUG_INFO("releasing enc_mem\n");
		iounmap(itv->enc_mem);
		itv->enc_mem = NULL;
	}
}

/* Hauppauge card? get values from tveeprom */
void ivtv_read_eeprom(struct ivtv *itv, struct tveeprom *tv)
{
@@ -1041,7 +1014,8 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
	/* map io memory */
	IVTV_DEBUG_INFO("attempting ioremap at 0x%llx len 0x%08x\n",
		   (u64)itv->base_addr + IVTV_ENCODER_OFFSET, IVTV_ENCODER_SIZE);
	itv->enc_mem = ioremap(itv->base_addr + IVTV_ENCODER_OFFSET,
	itv->enc_mem = devm_ioremap(&pdev->dev,
				    itv->base_addr + IVTV_ENCODER_OFFSET,
				    IVTV_ENCODER_SIZE);
	if (!itv->enc_mem) {
		IVTV_ERR("ioremap failed. Can't get a window into CX23415/6 encoder memory\n");
@@ -1055,7 +1029,8 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
	if (itv->has_cx23415) {
		IVTV_DEBUG_INFO("attempting ioremap at 0x%llx len 0x%08x\n",
				(u64)itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE);
		itv->dec_mem = ioremap(itv->base_addr + IVTV_DECODER_OFFSET,
		itv->dec_mem = devm_ioremap(&pdev->dev,
					    itv->base_addr + IVTV_DECODER_OFFSET,
					    IVTV_DECODER_SIZE);
		if (!itv->dec_mem) {
			IVTV_ERR("ioremap failed. Can't get a window into CX23415 decoder memory\n");
@@ -1073,26 +1048,27 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
	/* map registers memory */
	IVTV_DEBUG_INFO("attempting ioremap at 0x%llx len 0x%08x\n",
		   (u64)itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
	itv->reg_mem =
	    ioremap(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
	itv->reg_mem = devm_ioremap(&pdev->dev,
				    itv->base_addr + IVTV_REG_OFFSET,
				    IVTV_REG_SIZE);
	if (!itv->reg_mem) {
		IVTV_ERR("ioremap failed. Can't get a window into CX23415/6 register space\n");
		IVTV_ERR("Each capture card with a CX23415/6 needs 64 kB of vmalloc address space for this window\n");
		IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\n");
		IVTV_ERR("Use the vmalloc= kernel command line option to set VmallocTotal to a larger value\n");
		retval = -ENOMEM;
		goto free_io;
		goto free_mem;
	}

	retval = ivtv_gpio_init(itv);
	if (retval)
		goto free_io;
		goto free_mem;

	/* active i2c  */
	IVTV_DEBUG_INFO("activating i2c...\n");
	if (init_ivtv_i2c(itv)) {
		IVTV_ERR("Could not initialize i2c\n");
		goto free_io;
		goto free_mem;
	}

	if (itv->card->hw_all & IVTV_HW_TVEEPROM) {
@@ -1277,8 +1253,6 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
free_i2c:
	v4l2_ctrl_handler_free(&itv->cxhdl.hdl);
	exit_ivtv_i2c(itv);
free_io:
	ivtv_iounmap(itv);
free_mem:
	release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
	release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
@@ -1439,7 +1413,6 @@ static void ivtv_remove(struct pci_dev *pdev)
	exit_ivtv_i2c(itv);

	free_irq(itv->pdev->irq, (void *)itv);
	ivtv_iounmap(itv);

	release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
	release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);