Re: [PATCH 01/62] highmem: mark k[un]map_atomic() with two argumentsas deprecated

From: Cesar Eduardo Barros
Date: Sun Nov 27 2011 - 07:34:18 EST


Em 27-11-2011 03:26, Cong Wang escreveu:
/*
* Prevent people trying to call kunmap_atomic() as if it were kunmap()
* kunmap_atomic() should get the return value of kmap_atomic, not the page.
*/
-#define kunmap_atomic(addr, args...) \
-do { \
- BUILD_BUG_ON(__same_type((addr), struct page *)); \
- __kunmap_atomic(addr); \
-} while (0)
+static inline void kunmap_atomic(void *addr)
+{
+ BUILD_BUG_ON(__same_type((addr), struct page *));
+ __kunmap_atomic(addr);
+}
+
+static inline void __deprecated kunmap_atomic_deprecated(void *addr,
+ enum km_type km)
+{
+ BUILD_BUG_ON(__same_type((addr), struct page *));
+ __kunmap_atomic(addr);
+}

This will break the misuse detection of kunmap_atomic (see commit 597781f3e51f48ef8e67be772196d9e9673752c4).

kunmap_atomic() _must_ be a macro, so the __same_type can see the type the caller used. If you use an inline function, all it will see is a void *, even if the caller confused it with kunmap() and passed a struct page *.

--
Cesar Eduardo Barros
cesarb@xxxxxxxxxx
cesar.barros@xxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/