Commit 1c11a4cf authored by Ricardo Ribalda's avatar Ricardo Ribalda Committed by Hans Verkuil

media: pci/ivtv: Replace request_mem_region with devm_ variant

The managed device resource version of the function greatly
simplifies the error handling.
Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 7de8cf94
...@@ -814,24 +814,24 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *pdev, ...@@ -814,24 +814,24 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *pdev,
IVTV_ERR("No suitable DMA available.\n"); IVTV_ERR("No suitable DMA available.\n");
return -EIO; return -EIO;
} }
if (!request_mem_region(itv->base_addr, IVTV_ENCODER_SIZE, "ivtv encoder")) { if (!devm_request_mem_region(&pdev->dev, itv->base_addr,
IVTV_ENCODER_SIZE, "ivtv encoder")) {
IVTV_ERR("Cannot request encoder memory region.\n"); IVTV_ERR("Cannot request encoder memory region.\n");
return -EIO; return -EIO;
} }
if (!request_mem_region(itv->base_addr + IVTV_REG_OFFSET, if (!devm_request_mem_region(&pdev->dev,
IVTV_REG_SIZE, "ivtv registers")) { itv->base_addr + IVTV_REG_OFFSET,
IVTV_REG_SIZE, "ivtv registers")) {
IVTV_ERR("Cannot request register memory region.\n"); IVTV_ERR("Cannot request register memory region.\n");
release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
return -EIO; return -EIO;
} }
if (itv->has_cx23415 && if (itv->has_cx23415 &&
!request_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, !devm_request_mem_region(&pdev->dev,
IVTV_DECODER_SIZE, "ivtv decoder")) { itv->base_addr + IVTV_DECODER_OFFSET,
IVTV_DECODER_SIZE, "ivtv decoder")) {
IVTV_ERR("Cannot request decoder memory region.\n"); IVTV_ERR("Cannot request decoder memory region.\n");
release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
return -EIO; return -EIO;
} }
...@@ -843,11 +843,6 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *pdev, ...@@ -843,11 +843,6 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *pdev,
pci_read_config_word(pdev, PCI_COMMAND, &cmd); pci_read_config_word(pdev, PCI_COMMAND, &cmd);
if (!(cmd & PCI_COMMAND_MASTER)) { if (!(cmd & PCI_COMMAND_MASTER)) {
IVTV_ERR("Bus Mastering is not enabled\n"); IVTV_ERR("Bus Mastering is not enabled\n");
if (itv->has_cx23415)
release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET,
IVTV_DECODER_SIZE);
release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
return -ENXIO; return -ENXIO;
} }
} }
...@@ -1006,10 +1001,8 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) ...@@ -1006,10 +1001,8 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
/* PCI Device Setup */ /* PCI Device Setup */
retval = ivtv_setup_pci(itv, pdev, pci_id); retval = ivtv_setup_pci(itv, pdev, pci_id);
if (retval == -EIO) if (retval == -EIO || retval == -ENXIO)
goto free_worker; goto free_worker;
if (retval == -ENXIO)
goto free_mem;
/* map io memory */ /* map io memory */
IVTV_DEBUG_INFO("attempting ioremap at 0x%llx len 0x%08x\n", IVTV_DEBUG_INFO("attempting ioremap at 0x%llx len 0x%08x\n",
...@@ -1023,7 +1016,7 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) ...@@ -1023,7 +1016,7 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\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"); IVTV_ERR("Use the vmalloc= kernel command line option to set VmallocTotal to a larger value\n");
retval = -ENOMEM; retval = -ENOMEM;
goto free_mem; goto free_worker;
} }
if (itv->has_cx23415) { if (itv->has_cx23415) {
...@@ -1038,7 +1031,7 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) ...@@ -1038,7 +1031,7 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\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"); IVTV_ERR("Use the vmalloc= kernel command line option to set VmallocTotal to a larger value\n");
retval = -ENOMEM; retval = -ENOMEM;
goto free_mem; goto free_worker;
} }
} }
else { else {
...@@ -1057,18 +1050,18 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) ...@@ -1057,18 +1050,18 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\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"); IVTV_ERR("Use the vmalloc= kernel command line option to set VmallocTotal to a larger value\n");
retval = -ENOMEM; retval = -ENOMEM;
goto free_mem; goto free_worker;
} }
retval = ivtv_gpio_init(itv); retval = ivtv_gpio_init(itv);
if (retval) if (retval)
goto free_mem; goto free_worker;
/* active i2c */ /* active i2c */
IVTV_DEBUG_INFO("activating i2c...\n"); IVTV_DEBUG_INFO("activating i2c...\n");
if (init_ivtv_i2c(itv)) { if (init_ivtv_i2c(itv)) {
IVTV_ERR("Could not initialize i2c\n"); IVTV_ERR("Could not initialize i2c\n");
goto free_mem; goto free_worker;
} }
if (itv->card->hw_all & IVTV_HW_TVEEPROM) { if (itv->card->hw_all & IVTV_HW_TVEEPROM) {
...@@ -1253,11 +1246,6 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) ...@@ -1253,11 +1246,6 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
free_i2c: free_i2c:
v4l2_ctrl_handler_free(&itv->cxhdl.hdl); v4l2_ctrl_handler_free(&itv->cxhdl.hdl);
exit_ivtv_i2c(itv); exit_ivtv_i2c(itv);
free_mem:
release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
if (itv->has_cx23415)
release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE);
free_worker: free_worker:
kthread_stop(itv->irq_worker_task); kthread_stop(itv->irq_worker_task);
err: err:
...@@ -1414,11 +1402,6 @@ static void ivtv_remove(struct pci_dev *pdev) ...@@ -1414,11 +1402,6 @@ static void ivtv_remove(struct pci_dev *pdev)
free_irq(itv->pdev->irq, (void *)itv); free_irq(itv->pdev->irq, (void *)itv);
release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE);
release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
if (itv->has_cx23415)
release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE);
pci_disable_device(itv->pdev); pci_disable_device(itv->pdev);
for (i = 0; i < IVTV_VBI_FRAMES; i++) for (i = 0; i < IVTV_VBI_FRAMES; i++)
kfree(itv->vbi.sliced_mpeg_data[i]); kfree(itv->vbi.sliced_mpeg_data[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment