mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] linux/io.h: Add cleanup defination for iounmap() and memunmap()
@ 2024-07-31 23:31 Frank Li
  2024-08-01  7:27 ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Frank Li @ 2024-07-31 23:31 UTC (permalink / raw)
  To: Arnd Bergmann, Jason Gunthorpe, Niklas Schnelle, Andrew Morton,
	Alexei Starovoitov, Kent Overstreet, open list
  Cc: imx

Add DEFINE_FREE for iounmap() and memunmap() to support scope based
cleanup.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 include/linux/io.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/io.h b/include/linux/io.h
index 59ec5eea696c4..7695d7973c8ff 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -163,6 +163,9 @@ enum {
 void *memremap(resource_size_t offset, size_t size, unsigned long flags);
 void memunmap(void *addr);
 
+DEFINE_FREE(iounmap, void __iomem *, if (!IS_ERR_OR_NULL(_T)) iounmap(_T))
+DEFINE_FREE(memunmap, void *, if (!IS_ERR_OR_NULL(_T)) memunmap(_T))
+
 /*
  * On x86 PAT systems we have memory tracking that keeps track of
  * the allowed mappings on memory ranges. This tracking works for
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-02  8:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-31 23:31 [PATCH 1/1] linux/io.h: Add cleanup defination for iounmap() and memunmap() Frank Li
2024-08-01  7:27 ` Arnd Bergmann
2024-08-01 15:15   ` Frank Li
2024-08-02  8:07     ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®