[PATCH V4 10/17] linux/io.h: iounmap/ioport_unmap cleanup.h support

David E. Box
2023-10-18T23:17:09Z

Add auto-release cleanups for ioumap and ioport_unmap.

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
---
V4 - New patch

include/linux/io.h | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/include/linux/io.h b/include/linux/io.h
index 7304f2a69960..1488832c4ad2 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -6,6 +6,7 @@
#ifndef _LINUX_IO_H
#define _LINUX_IO_H

+#include <linux/cleanup.h>
#include <linux/types.h>
#include <linux/init.h>
#include <linux/bug.h>
@@ -20,6 +21,9 @@ __visible void __iowrite32_copy(void __iomem *to, const void *from, size_t count
void __ioread32_copy(void *to, const void __iomem *from, size_t count);
void __iowrite64_copy(void __iomem *to, const void *from, size_t count);

+DEFINE_FREE(iounmap, void __iomem *, iounmap(_T));
+DEFINE_FREE(ioport_unmap, void __iomem *, ioport_unmap(_T));
+
#ifdef CONFIG_MMU
int ioremap_page_range(unsigned long addr, unsigned long end,
phys_addr_t phys_addr, pgprot_t prot);
--
2.34.1