Messages in this thread | | | Date | Sun, 27 Nov 2011 10:34:06 -0200 | From | Cesar Eduardo Barros <> | Subject | Re: [PATCH 01/62] highmem: mark k[un]map_atomic() with two arguments as deprecated |
| |
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@cesarb.net cesar.barros@gmail.com
| |