Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: move is_ioremap_addr() into new header file

Now is_ioremap_addr() is only used in kernel/iomem.c and gonna be used in
mm/ioremap.c. Move it into its own new header file linux/ioremap.h.

Link: https://lkml.kernel.org/r/20230706154520.11257-17-bhe@redhat.com
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Baoquan He <bhe@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Brian Cain <bcain@quicinc.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Chris Zankel <chris@zankel.net>
Cc: David Laight <David.Laight@ACULAB.COM>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Mike Rapoport (IBM) <rppt@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Niklas Schnelle <schnelle@linux.ibm.com>
Cc: Rich Felker <dalias@libc.org>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Baoquan He and committed by
Andrew Morton
016fec91 ab1cd020

+32 -24
-10
arch/powerpc/include/asm/pgtable.h
··· 157 157 return (pgtable_t)pmd_page_vaddr(pmd); 158 158 } 159 159 160 - #ifdef CONFIG_PPC64 161 - #define is_ioremap_addr is_ioremap_addr 162 - static inline bool is_ioremap_addr(const void *x) 163 - { 164 - unsigned long addr = (unsigned long)x; 165 - 166 - return addr >= IOREMAP_BASE && addr < IOREMAP_END; 167 - } 168 - #endif /* CONFIG_PPC64 */ 169 - 170 160 #endif /* __ASSEMBLY__ */ 171 161 172 162 #endif /* _ASM_POWERPC_PGTABLE_H */
+30
include/linux/ioremap.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_IOREMAP_H 3 + #define _LINUX_IOREMAP_H 4 + 5 + #include <linux/kasan.h> 6 + #include <asm/pgtable.h> 7 + 8 + #if defined(CONFIG_HAS_IOMEM) || defined(CONFIG_GENERIC_IOREMAP) 9 + /* 10 + * Ioremap often, but not always uses the generic vmalloc area. E.g on 11 + * Power ARCH, it could have different ioremap space. 12 + */ 13 + #ifndef IOREMAP_START 14 + #define IOREMAP_START VMALLOC_START 15 + #define IOREMAP_END VMALLOC_END 16 + #endif 17 + static inline bool is_ioremap_addr(const void *x) 18 + { 19 + unsigned long addr = (unsigned long)kasan_reset_tag(x); 20 + 21 + return addr >= IOREMAP_START && addr < IOREMAP_END; 22 + } 23 + #else 24 + static inline bool is_ioremap_addr(const void *x) 25 + { 26 + return false; 27 + } 28 + #endif 29 + 30 + #endif /* _LINUX_IOREMAP_H */
-5
include/linux/mm.h
··· 1055 1055 * On nommu, vmalloc/vfree wrap through kmalloc/kfree directly, so there 1056 1056 * is no special casing required. 1057 1057 */ 1058 - 1059 - #ifndef is_ioremap_addr 1060 - #define is_ioremap_addr(x) is_vmalloc_addr(x) 1061 - #endif 1062 - 1063 1058 #ifdef CONFIG_MMU 1064 1059 extern bool is_vmalloc_addr(const void *x); 1065 1060 extern int is_vmalloc_or_module_addr(const void *x);
+1
kernel/iomem.c
··· 3 3 #include <linux/types.h> 4 4 #include <linux/io.h> 5 5 #include <linux/mm.h> 6 + #include <linux/ioremap.h> 6 7 7 8 #ifndef ioremap_cache 8 9 /* temporary while we convert existing ioremap_cache users to memremap */
+1 -9
mm/ioremap.c
··· 10 10 #include <linux/mm.h> 11 11 #include <linux/io.h> 12 12 #include <linux/export.h> 13 - 14 - /* 15 - * Ioremap often, but not always uses the generic vmalloc area. E.g on 16 - * Power ARCH, it could have different ioremap space. 17 - */ 18 - #ifndef IOREMAP_START 19 - #define IOREMAP_START VMALLOC_START 20 - #define IOREMAP_END VMALLOC_END 21 - #endif 13 + #include <linux/ioremap.h> 22 14 23 15 void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, 24 16 pgprot_t prot)