* [PATCH] sound: pci: asihpi: use pcim_iomap for managed PCI memory mapping
@ 2026-08-11 4:21 Rosen Penev
2026-08-11 6:20 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-08-11 4:21 UTC (permalink / raw)
To: linux-sound; +Cc: Jaroslav Kysela, Takashi Iwai, open list
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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] sound: pci: asihpi: use pcim_iomap for managed PCI memory mapping
2026-08-11 4:21 [PATCH] sound: pci: asihpi: use pcim_iomap for managed PCI memory mapping Rosen Penev
@ 2026-08-11 6:20 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-08-11 6:20 UTC (permalink / raw)
To: Rosen Penev; +Cc: linux-sound, Jaroslav Kysela, Takashi Iwai, open list
On Tue, 11 Aug 2026 06:21:22 +0200,
Rosen Penev wrote:
>
> 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>
Applied to for-next branch. Thanks.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-11 6:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11 4:21 [PATCH] sound: pci: asihpi: use pcim_iomap for managed PCI memory mapping Rosen Penev
2026-08-11 6:20 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox