Skip to contentSkip to conversation

linux/io.h: Add cleanup defination for iounmap() and memunmap()

PATCH New Frank Li 1 participant 1 message Aug 2, 2024 Arm i.MX and Layerscape

lore
Share & tools
lore

Frank Li

author maintainer
#0 lore raw

PATCH v2 1/1 linux/io.h: Add cleanup defination for iounmap() and memunmap()

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

---
Change from v1 to v2
- Remove IS_ERR_OR_NULL() and just simple use !(_T)

---
 include/linux/io.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/io.h +3 -0
index 59ec5eea696c4..4cce787d52805 100644
@@ -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 (!(_T)) iounmap(_T))
+DEFINE_FREE(memunmap, void *, if (!(_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
Signature · 1 line
2.34.1