From 303755f3582114b1e357ed8d6929a916f745cfeb Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 19 Jun 2013 10:07:03 +1000 Subject: [PATCH] include/linux/mmzone.h: cleanups - implement zone_idx() in C to fix its references-args-twice macro bug - use zone_idx() in is_highmem() to remove large amounts of silly fluff. Cc: Lin Feng Cc: Mel Gorman Signed-off-by: Andrew Morton --- include/linux/mmzone.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index af4a3b77a8de..d5e2bc5ad626 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -841,7 +841,10 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long); /* * zone_idx() returns 0 for the ZONE_DMA zone, 1 for the ZONE_NORMAL zone, etc. */ -#define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones) +static inline enum zone_type zone_idx(struct zone *zone) +{ + return zone - zone->zone_pgdat->node_zones; +} static inline int populated_zone(struct zone *zone) { @@ -878,10 +881,10 @@ static inline int is_highmem_idx(enum zone_type idx) static inline int is_highmem(struct zone *zone) { #ifdef CONFIG_HIGHMEM - int zone_off = (char *)zone - (char *)zone->zone_pgdat->node_zones; - return zone_off == ZONE_HIGHMEM * sizeof(*zone) || - (zone_off == ZONE_MOVABLE * sizeof(*zone) && - zone_movable_is_highmem()); + enum zone_type idx = zone_idx(zone); + + return idx == ZONE_HIGHMEM || + (idx == ZONE_MOVABLE && zone_movable_is_highmem()); #else return 0; #endif -- 2.39.5