]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
include/linux/mmzone.h: cleanups
authorAndrew Morton <akpm@linux-foundation.org>
Tue, 26 Mar 2013 23:24:47 +0000 (10:24 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 2 Apr 2013 07:29:13 +0000 (18:29 +1100)
- 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 <linfeng@cn.fujitsu.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/mmzone.h

index 5c76737d836b1edc218bfba700fb26c09e62408a..280cb6cf3ffa357dc6961185219e8181dbc16c0a 100644 (file)
@@ -815,7 +815,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)
 {
@@ -857,10 +860,10 @@ static inline int is_normal_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