From: Rosen Penev <rosenp@gmail.com>
To: linux-sound@vger.kernel.org
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] sound: pci: asihpi: use pcim_iomap for managed PCI memory mapping
Date: Mon, 10 Aug 2026 21:21:22 -0700 [thread overview]
Message-ID: <20260811042122.44923-1-rosenp@gmail.com> (raw)
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
next reply other threads:[~2026-08-11 4:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 4:21 Rosen Penev [this message]
2026-08-11 6:20 ` [PATCH] sound: pci: asihpi: use pcim_iomap for managed PCI memory mapping Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260811042122.44923-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.