ALSA: pci: asihpi: use pcim_iomap for managed PCI memory mapping

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 <rosenp@gmail.com>
Link: https://patch.msgid.link/20260811042122.44923-1-rosenp@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Rosen Penev 2026-08-10 21:21:22 -07:00 committed by Takashi Iwai
parent 9508f9f122
commit a9ac75b664

View File

@ -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);