mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zijun Hu <zijun_hu@icloud.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Zijun Hu <zijun_hu@icloud.com>,
	linux-kernel@vger.kernel.org,  Zijun Hu <quic_zijuhu@quicinc.com>
Subject: [PATCH 1/2] lib: devres: Simplify API devm_iounmap() implementation
Date: Wed, 18 Sep 2024 22:48:13 +0800	[thread overview]
Message-ID: <20240918-fix_lib_devres-v1-1-e696ab5486e6@quicinc.com> (raw)
In-Reply-To: <20240918-fix_lib_devres-v1-0-e696ab5486e6@quicinc.com>

From: Zijun Hu <quic_zijuhu@quicinc.com>

Simplify devm_iounmap() implementation by dedicated API devres_release()
compared with current solution, namely, devres_destroy() + iounmap()
devres_release() has the following advantages:

- it is simpler if devm_iounmap()'s parameter @addr is valid, namely
  @addr was ever returned by one of devm_ioremap() variants.

- it can avoid unnecessary iounmap(@addr) if @addr is not valid.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 lib/devres.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/devres.c b/lib/devres.c
index 4fc152de6d8b..68ffcd5d9358 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -115,9 +115,8 @@ EXPORT_SYMBOL(devm_ioremap_wc);
  */
 void devm_iounmap(struct device *dev, void __iomem *addr)
 {
-	WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
+	WARN_ON(devres_release(dev, devm_ioremap_release, devm_ioremap_match,
 			       (__force void *)addr));
-	iounmap(addr);
 }
 EXPORT_SYMBOL(devm_iounmap);
 

-- 
2.34.1


  reply	other threads:[~2024-09-18 14:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-18 14:48 [PATCH 0/2] lib: devres: Simplify both API devm_iounmap() and devm_ioport_unmap() implementation Zijun Hu
2024-09-18 14:48 ` Zijun Hu [this message]
2024-09-18 14:48 ` [PATCH 2/2] lib: devres: Simplify API " Zijun Hu

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=20240918-fix_lib_devres-v1-1-e696ab5486e6@quicinc.com \
    --to=zijun_hu@icloud.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_zijuhu@quicinc.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome