From: Bhumika Goyal Date: Fri, 11 Mar 2016 14:03:05 +0000 (+0530) Subject: Staging: android: ashmem.c: Convert macros page_range_{subsumes/subsumed_by/in}_range... X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=c0ece6c383f84e0c408347cdb59456017a2f9e27;p=linux-beck.git Staging: android: ashmem.c: Convert macros page_range_{subsumes/subsumed_by/in}_range to static inline function Convert macros page_range_{subsumes/subsumed_by/in}_range to static inline function as static inline functions are preferred over macros. The change can be done as the arguments at all call sites have the same type. Also, all three macro have same type of arguments and return values so they can converted using a common semantic patch. @r@ identifier f; expression e; @@ #define f(...) e @r2@ identifier r.f; identifier range,start,end; expression r.e; @@ - #define f(range,start,end) e + static inline int f(struct ashmem_range *range, size_t start, size_t end) +{ + return e; +} Signed-off-by: Bhumika Goyal Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 6b14efd28cd2..8a8078f954d5 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -106,20 +106,29 @@ static struct kmem_cache *ashmem_range_cachep __read_mostly; #define range_on_lru(range) \ ((range)->purged == ASHMEM_NOT_PURGED) -#define page_range_subsumes_range(range, start, end) \ - (((range)->pgstart >= (start)) && ((range)->pgend <= (end))) +static inline int page_range_subsumes_range(struct ashmem_range *range, + size_t start, size_t end) +{ + return (((range)->pgstart >= (start)) && ((range)->pgend <= (end))); +} -#define page_range_subsumed_by_range(range, start, end) \ - (((range)->pgstart <= (start)) && ((range)->pgend >= (end))) +static inline int page_range_subsumed_by_range(struct ashmem_range *range, + size_t start, size_t end) +{ + return (((range)->pgstart <= (start)) && ((range)->pgend >= (end))); +} static inline int page_in_range(struct ashmem_range *range, size_t page) { return (((range)->pgstart <= (page)) && ((range)->pgend >= (page))); } -#define page_range_in_range(range, start, end) \ - (page_in_range(range, start) || page_in_range(range, end) || \ - page_range_subsumes_range(range, start, end)) +static inline int page_range_in_range(struct ashmem_range *range, + size_t start, size_t end) +{ + return (page_in_range(range, start) || page_in_range(range, end) || + page_range_subsumes_range(range, start, end)); +} static inline int range_before_page(struct ashmem_range *range, size_t page) {