[PATCH] sound: pci: asihpi: use pcim_iomap for managed PCI memory mapping
Rosen Penev <[email protected]>
| Newsgroups | gmane.linux.sound,gmane.linux.kernel |
|---|---|
| Message-ID | <[email protected]> |
Replace manual ioremap() calls with pcim_iomap() which uses devres for automatic cleanup. This eliminates the need for manual iounmap() in both the error path of asihpi_adapter_probe() and the asihpi_adapter_remove() function. The pcim_iomap() helper is cleaner and less error-prone since it handles unmapping automatically when the PCI device is released. Assisted-by: opencode/big-pickle Signed-off-by: Rosen Penev <[email protected]> --- sound/pci/asihpi/hpioctl.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c index 9de9ae7032b8..ec2da792e1c8 100644 --- a/sound/pci/asihpi/hpioctl.c +++ b/sound/pci/asihpi/hpioctl.c @@ -385,8 +385,7 @@ int asihpi_adapter_probe(struct pci_dev *pci_dev, if (pci_resource_flags(pci_dev, idx) & IORESOURCE_MEM) { memlen = pci_resource_len(pci_dev, idx); pci.ap_mem_base[idx] = - ioremap(pci_resource_start(pci_dev, idx), - memlen); + pcim_iomap(pci_dev, idx, memlen); if (!pci.ap_mem_base[idx]) { HPI_DEBUG_LOG(ERROR, "ioremap failed, aborting\n"); @@ -509,13 +508,6 @@ int asihpi_adapter_probe(struct pci_dev *pci_dev, return 0; err: - while (--idx >= 0) { - if (pci.ap_mem_base[idx]) { - iounmap(pci.ap_mem_base[idx]); - pci.ap_mem_base[idx] = NULL; - } - } - if (adapter.p_buffer) { adapter.buffer_size = 0; vfree(adapter.p_buffer); @@ -527,14 +519,11 @@ int asihpi_adapter_probe(struct pci_dev *pci_dev, void asihpi_adapter_remove(struct pci_dev *pci_dev) { - int idx; struct hpi_message hm; struct hpi_response hr; struct hpi_adapter *pa; - struct hpi_pci pci; pa = pci_get_drvdata(pci_dev); - pci = pa->adapter->pci; /* Disable IRQ generation on DSP side */ hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, @@ -550,10 +539,6 @@ void asihpi_adapter_remove(struct pci_dev *pci_dev) hm.adapter_index = pa->adapter->index; 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) - iounmap(pci.ap_mem_base[idx]); - if (pa->irq) free_irq(pa->irq, pa); -- 2.55.0