summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/highmem.h52
1 files changed, 46 insertions, 6 deletions
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 3a93f73a8acc..11617a835cf2 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -109,20 +109,60 @@ static inline void kmap_atomic_idx_pop(void)
109#endif 109#endif
110 110
111/* 111/*
112 * Make both: kmap_atomic(page, idx) and kmap_atomic(page) work. 112 * NOTE:
113 * kmap_atomic() and kunmap_atomic() with two arguments are deprecated.
114 * We only keep them for backward compatibility, any usage of them
115 * are now warned.
113 */ 116 */
114#define kmap_atomic(page, args...) __kmap_atomic(page) 117
118#define PASTE(a, b) a ## b
119#define PASTE2(a, b) PASTE(a, b)
120
121#define NARG_(_2, _1, n, ...) n
122#define NARG(...) NARG_(__VA_ARGS__, 2, 1, :)
123
124static inline void *kmap_atomic(struct page *page)
125{
126 return __kmap_atomic(page);
127}
128
129static inline void __deprecated *kmap_atomic_deprecated(struct page *page,
130 enum km_type km)
131{
132 return __kmap_atomic(page);
133}
134
135#define kmap_atomic1(...) kmap_atomic(__VA_ARGS__)
136#define kmap_atomic2(...) kmap_atomic_deprecated(__VA_ARGS__)
137#define kmap_atomic(...) PASTE2(kmap_atomic, NARG(__VA_ARGS__)(__VA_ARGS__))
138
139static inline void __deprecated __kunmap_atomic_deprecated(void *addr,
140 enum km_type km)
141{
142 __kunmap_atomic(addr);
143}
115 144
116/* 145/*
117 * Prevent people trying to call kunmap_atomic() as if it were kunmap() 146 * Prevent people trying to call kunmap_atomic() as if it were kunmap()
118 * kunmap_atomic() should get the return value of kmap_atomic, not the page. 147 * kunmap_atomic() should get the return value of kmap_atomic, not the page.
119 */ 148 */
120#define kunmap_atomic(addr, args...) \ 149#define kunmap_atomic_deprecated(addr, km) \
121do { \ 150do { \
122 BUILD_BUG_ON(__same_type((addr), struct page *)); \ 151 BUILD_BUG_ON(__same_type((addr), struct page *)); \
123 __kunmap_atomic(addr); \ 152 __kunmap_atomic_deprecated(addr, km); \
124} while (0) 153} while (0)
125 154
155#define kunmap_atomic_withcheck(addr) \
156do { \
157 BUILD_BUG_ON(__same_type((addr), struct page *)); \
158 __kunmap_atomic(addr); \
159} while (0)
160
161#define kunmap_atomic1(...) kunmap_atomic_withcheck(__VA_ARGS__)
162#define kunmap_atomic2(...) kunmap_atomic_deprecated(__VA_ARGS__)
163#define kunmap_atomic(...) PASTE2(kunmap_atomic, NARG(__VA_ARGS__)(__VA_ARGS__))
164/**** End of C pre-processor tricks for deprecated macros ****/
165
126/* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */ 166/* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */
127#ifndef clear_user_highpage 167#ifndef clear_user_highpage
128static inline void clear_user_highpage(struct page *page, unsigned long vaddr) 168static inline void clear_user_highpage(struct page *page, unsigned long vaddr)